@kohost/api-client 3.0.0-beta.47 → 3.0.0-beta.50

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 (156) hide show
  1. package/dist/cjs/AMQPClient/index.js +290 -0
  2. package/dist/cjs/Commands/CheckInReservationCommand.js +19 -0
  3. package/dist/cjs/Commands/Command.js +34 -0
  4. package/dist/cjs/Commands/CreateImageUploadEndpointCommand.js +17 -0
  5. package/dist/cjs/Commands/CreateShortLinkCommand.js +20 -0
  6. package/dist/cjs/Commands/DiscoverReservationRoomTypeUpsellOptionsCommand.js +20 -0
  7. package/dist/cjs/Commands/DiscoverReservationsCommand.js +20 -0
  8. package/dist/cjs/Commands/DiscoverRoomTypesCommand.js +19 -0
  9. package/dist/cjs/Commands/DiscoverRoomsCommand.js +35 -0
  10. package/dist/cjs/Commands/DiscoverUsersCommand.js +19 -0
  11. package/dist/cjs/Commands/GetMobileKeyCommand.js +24 -0
  12. package/dist/cjs/Commands/GetProductsCommand.js +17 -0
  13. package/dist/cjs/Commands/OCRDocumentCommand.js +15 -0
  14. package/dist/cjs/Commands/SellProductsCommand.js +17 -0
  15. package/dist/cjs/Commands/SendEmailCommand.js +24 -0
  16. package/dist/cjs/Commands/SendSMSCommand.js +21 -0
  17. package/dist/cjs/Commands/SetAlarmCommand.js +17 -0
  18. package/dist/cjs/Commands/SetCourtesyCommand.js +17 -0
  19. package/dist/cjs/Commands/SetDimmerCommand.js +17 -0
  20. package/dist/cjs/Commands/SetLockCommand.js +17 -0
  21. package/dist/cjs/Commands/SetMediaCommand.js +17 -0
  22. package/dist/cjs/Commands/SetSceneCommand.js +17 -0
  23. package/dist/cjs/Commands/SetSwitchCommand.js +17 -0
  24. package/dist/cjs/Commands/SetThermostatCommand.js +17 -0
  25. package/dist/cjs/Commands/SetWindowCoveringCommand.js +17 -0
  26. package/dist/cjs/Commands/UpdateReservationCommand.js +19 -0
  27. package/dist/cjs/Commands/UpdateUserCommand.js +41 -0
  28. package/dist/cjs/Commands/UploadImageCommand.js +17 -0
  29. package/dist/cjs/Commands/index.js +55 -0
  30. package/dist/cjs/Errors/AppError.js +8 -0
  31. package/dist/cjs/Errors/AuthenticationError.js +9 -0
  32. package/dist/cjs/Errors/AuthorizationError.js +9 -0
  33. package/dist/cjs/Errors/DeviceCommError.js +9 -0
  34. package/dist/cjs/Errors/LoginError.js +9 -0
  35. package/dist/cjs/Errors/NotFoundError.js +9 -0
  36. package/dist/cjs/Errors/RequestError.js +9 -0
  37. package/dist/cjs/Errors/SystemCommError.js +9 -0
  38. package/dist/cjs/Errors/TokenExpiredError.js +9 -0
  39. package/dist/cjs/Errors/UnprocessableRequestError.js +9 -0
  40. package/dist/cjs/Errors/ValidationError.js +9 -0
  41. package/dist/cjs/Errors/index.js +15 -0
  42. package/dist/cjs/Events/ApplicationInUseEvent.js +17 -0
  43. package/dist/cjs/Events/ApplicationOutOfUseEvent.js +17 -0
  44. package/dist/cjs/Events/EmailEvent.js +18 -0
  45. package/dist/cjs/Events/Event.js +55 -0
  46. package/dist/cjs/Events/SMSEvent.js +18 -0
  47. package/dist/cjs/Events/SMSSentEvent.js +17 -0
  48. package/dist/cjs/Events/ShortLinkCreatedEvent.js +17 -0
  49. package/dist/cjs/Events/SystemCameraUpdatedEvent.js +17 -0
  50. package/dist/cjs/Events/SystemCourtesyUpdatedEvent.js +17 -0
  51. package/dist/cjs/Events/SystemDimmerUpdatedEvent.js +17 -0
  52. package/dist/cjs/Events/SystemGatewayUpdatedEvent.js +17 -0
  53. package/dist/cjs/Events/SystemLockUpdatedEvent.js +17 -0
  54. package/dist/cjs/Events/SystemMediaSourceUpdatedEvent.js +17 -0
  55. package/dist/cjs/Events/SystemMotionSensorUpdatedEvent.js +17 -0
  56. package/dist/cjs/Events/SystemProductUpdatedEvent.js +17 -0
  57. package/dist/cjs/Events/SystemReservationUpdatedEvent.js +17 -0
  58. package/dist/cjs/Events/SystemSceneControllerUpdatedEvent.js +17 -0
  59. package/dist/cjs/Events/SystemSpaceTypeUpdatedEvent.js +17 -0
  60. package/dist/cjs/Events/SystemSpaceUpdatedEvent.js +17 -0
  61. package/dist/cjs/Events/SystemSwitchUpdatedEvent.js +17 -0
  62. package/dist/cjs/Events/SystemThermostatUpdatedEvent.js +17 -0
  63. package/dist/cjs/Events/SystemUserUpdatedEvent.js +17 -0
  64. package/dist/cjs/Events/SystemWindowCoveringUpdatedEvent.js +17 -0
  65. package/dist/cjs/Events/index.js +50 -0
  66. package/dist/cjs/Models/Alarm.js +29 -0
  67. package/dist/cjs/Models/Camera.js +29 -0
  68. package/dist/cjs/Models/Courtesy.js +33 -0
  69. package/dist/cjs/Models/Credential.js +29 -0
  70. package/dist/cjs/Models/Dimmer.js +61 -0
  71. package/dist/cjs/Models/DiscoveredDevice.js +30 -0
  72. package/dist/cjs/Models/EmailMessage.js +29 -0
  73. package/dist/cjs/Models/EnergyReport.js +29 -0
  74. package/dist/cjs/Models/EnergyReportShard.js +29 -0
  75. package/dist/cjs/Models/Gateway.js +29 -0
  76. package/dist/cjs/Models/Identification.js +32 -0
  77. package/dist/cjs/Models/Kohost.js +96 -0
  78. package/dist/cjs/Models/Lock.js +33 -0
  79. package/dist/cjs/Models/MediaFile.js +41 -0
  80. package/dist/cjs/Models/MediaSource.js +29 -0
  81. package/dist/cjs/Models/MotionSensor.js +29 -0
  82. package/dist/cjs/Models/Organization.js +28 -0
  83. package/dist/cjs/Models/Product.js +29 -0
  84. package/dist/cjs/Models/Property.js +28 -0
  85. package/dist/cjs/Models/Reservation.js +98 -0
  86. package/dist/cjs/Models/Room.js +212 -0
  87. package/dist/cjs/Models/Scene.js +183 -0
  88. package/dist/cjs/Models/ShortLink.js +29 -0
  89. package/dist/cjs/Models/SmsMessage.js +29 -0
  90. package/dist/cjs/Models/Space.js +97 -0
  91. package/dist/cjs/Models/SpaceType.js +30 -0
  92. package/dist/cjs/Models/Switch.js +33 -0
  93. package/dist/cjs/Models/SystemUser.js +48 -0
  94. package/dist/cjs/Models/Thermostat.js +80 -0
  95. package/dist/cjs/Models/Ticket.js +105 -0
  96. package/dist/cjs/Models/User.js +73 -0
  97. package/dist/cjs/Models/WindowCovering.js +49 -0
  98. package/dist/cjs/Models/index.js +68 -0
  99. package/dist/cjs/{SocketIoClient.js → SocketIoClient/index.js} +19 -14
  100. package/dist/cjs/defs/deviceTypes.js +15 -0
  101. package/dist/cjs/defs/formalDeviceTypes.js +6 -0
  102. package/dist/cjs/defs/index.js +11 -0
  103. package/dist/cjs/index.js +23 -0
  104. package/dist/cjs/schemas/alarm.json +103 -0
  105. package/dist/cjs/schemas/camera.json +50 -0
  106. package/dist/cjs/schemas/courtesy.json +46 -0
  107. package/dist/cjs/schemas/credential.json +31 -0
  108. package/dist/cjs/schemas/definitions.json +191 -0
  109. package/dist/cjs/schemas/dimmer.json +43 -0
  110. package/dist/cjs/schemas/discoveredDevice.json +31 -0
  111. package/dist/cjs/schemas/emailMessage.json +71 -0
  112. package/dist/cjs/schemas/energyReport.json +86 -0
  113. package/dist/cjs/schemas/energyReportShard.json +75 -0
  114. package/dist/cjs/schemas/gateway.json +35 -0
  115. package/dist/cjs/schemas/identification.json +61 -0
  116. package/dist/cjs/schemas/lock.json +45 -0
  117. package/dist/cjs/schemas/mediaFile.json +67 -0
  118. package/dist/cjs/schemas/mediaSource.json +184 -0
  119. package/dist/cjs/schemas/motionSensor.json +32 -0
  120. package/dist/cjs/schemas/organization.json +36 -0
  121. package/dist/cjs/schemas/payment.json +47 -0
  122. package/dist/cjs/schemas/product.json +40 -0
  123. package/dist/cjs/schemas/property.json +246 -0
  124. package/dist/cjs/schemas/reservation.json +118 -0
  125. package/dist/cjs/schemas/room.json +98 -0
  126. package/dist/cjs/schemas/scene.json +121 -0
  127. package/dist/cjs/schemas/shortLink.json +30 -0
  128. package/dist/cjs/schemas/smsMessage.json +61 -0
  129. package/dist/cjs/schemas/space.json +120 -0
  130. package/dist/cjs/schemas/spaceType.json +30 -0
  131. package/dist/cjs/schemas/switch.json +42 -0
  132. package/dist/cjs/schemas/systemUser.json +95 -0
  133. package/dist/cjs/schemas/thermostat.json +153 -0
  134. package/dist/cjs/schemas/ticket.json +96 -0
  135. package/dist/cjs/schemas/user.json +152 -0
  136. package/dist/cjs/schemas/windowCovering.json +43 -0
  137. package/dist/cjs/utils/errorFactory.js +8 -0
  138. package/dist/cjs/utils/eventFactory.js +10 -0
  139. package/dist/cjs/utils/getDeviceTypes.js +7 -0
  140. package/dist/cjs/utils/getFormalDeviceType.js +5 -0
  141. package/dist/cjs/utils/index.js +11 -0
  142. package/dist/cjs/utils/schema.js +25 -0
  143. package/dist/esm/Models.js +451 -435
  144. package/dist/esm/Models.js.map +4 -4
  145. package/dist/esm/utils.js +7 -26
  146. package/dist/esm/utils.js.map +3 -3
  147. package/package.json +12 -7
  148. package/dist/cjs/AMQPClient.js +0 -462
  149. package/dist/cjs/Commands.js +0 -973
  150. package/dist/cjs/Errors.js +0 -209
  151. package/dist/cjs/Events.js +0 -578
  152. package/dist/cjs/Models.js +0 -4905
  153. package/dist/cjs/defs.js +0 -167
  154. package/dist/cjs/index.cjs.js +0 -6755
  155. package/dist/cjs/utils.js +0 -525
  156. /package/dist/cjs/{Client.js → Client/index.js} +0 -0
@@ -1,4905 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __commonJS = (cb, mod) => function __require() {
5
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
- };
7
-
8
- // src/schemas/definitions/common.json
9
- var require_common = __commonJS({
10
- "src/schemas/definitions/common.json"(exports2, module2) {
11
- module2.exports = {
12
- $schema: "http://json-schema.org/draft-07/schema",
13
- $id: "https://api.kohost.io/schemas/v3/definitions/common.json",
14
- definitions: {
15
- id: {
16
- type: "string",
17
- not: {
18
- enum: ["global", "system"]
19
- }
20
- },
21
- systemData: {
22
- type: "object",
23
- default: {}
24
- },
25
- metadata: {
26
- type: "object",
27
- default: {}
28
- },
29
- date: {
30
- type: ["string", "object"],
31
- format: "date-time"
32
- },
33
- createdAt: {
34
- type: ["string", "object"],
35
- format: "date-time"
36
- },
37
- updatedAt: {
38
- type: ["string", "object"],
39
- format: "date-time"
40
- },
41
- file: {
42
- type: "object",
43
- required: ["name", "type", "data"],
44
- properties: {
45
- name: {
46
- type: "string",
47
- description: "Name of the file."
48
- },
49
- type: {
50
- type: "string",
51
- description: "MIME type of the file (e.g. application/pdf)."
52
- },
53
- data: {
54
- type: "string",
55
- description: "Base64-encoded data of the file."
56
- }
57
- }
58
- },
59
- address: {
60
- type: "object",
61
- properties: {
62
- id: {
63
- type: "string"
64
- },
65
- line1: {
66
- type: "string"
67
- },
68
- line2: {
69
- type: "string"
70
- },
71
- line3: {
72
- type: "string"
73
- },
74
- city: {
75
- type: "string"
76
- },
77
- state: {
78
- type: "string"
79
- },
80
- postalCode: {
81
- type: "string"
82
- },
83
- countryCode: {
84
- type: "string",
85
- minLength: 2,
86
- maxLength: 2
87
- }
88
- }
89
- },
90
- driver: {
91
- type: "string",
92
- enum: [
93
- "aws-kinesis",
94
- "butler",
95
- "crestron",
96
- "ecobee",
97
- "igor",
98
- "inncom",
99
- "kohost-k7",
100
- "kohost-pms",
101
- "lg",
102
- "lirc",
103
- "mews",
104
- "paxton",
105
- "pelican-wireless",
106
- "rebrandly",
107
- "salto",
108
- "salto-irn",
109
- "se",
110
- "sendgrid",
111
- "stay-n-touch",
112
- "twilio",
113
- "cloudflare-images",
114
- "cloudflare-stream",
115
- "insperia-privacy"
116
- ]
117
- }
118
- }
119
- };
120
- }
121
- });
122
-
123
- // src/schemas/definitions/device.json
124
- var require_device = __commonJS({
125
- "src/schemas/definitions/device.json"(exports2, module2) {
126
- module2.exports = {
127
- $schema: "http://json-schema.org/draft-07/schema",
128
- $id: "https://api.kohost.io/schemas/v3/definitions/device.json",
129
- definitions: {
130
- id: {
131
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
132
- },
133
- systemData: {
134
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
135
- },
136
- type: {
137
- type: "string",
138
- enum: [
139
- "alarm",
140
- "dimmer",
141
- "switch",
142
- "motionSensor",
143
- "windowCovering",
144
- "camera",
145
- "mediaSource",
146
- "thermostat",
147
- "lock",
148
- "courtesy",
149
- "gateway",
150
- "tv",
151
- "dvr",
152
- "appleTv",
153
- "discPlayer",
154
- "mediaPlayer",
155
- "uncontrolledDevice"
156
- ]
157
- },
158
- name: {
159
- type: "string"
160
- },
161
- subType: {
162
- type: ["string", "null"]
163
- },
164
- supportedNotifications: {
165
- type: "array",
166
- uniqueItems: true,
167
- items: {
168
- enum: [
169
- "button 1",
170
- "button 2",
171
- "button 3",
172
- "button 4",
173
- "button 5",
174
- "idle",
175
- "powerHasBeedApplied",
176
- "acMainsDisconnected",
177
- "acMainsReconnected",
178
- "replaceBatterySoon",
179
- "replaceBatteryNow",
180
- "hardwareFailure",
181
- "softwareFailure",
182
- "hardwareFailureWithCode",
183
- "softwareFailureWithCode",
184
- "motionDetection",
185
- "airFilterNeedsCleaned",
186
- "smokeDetected",
187
- "outsideSafeTemperatureRange",
188
- "outsideSafeHumidityRange"
189
- ]
190
- }
191
- },
192
- notification: {
193
- type: ["object", "null"],
194
- properties: {
195
- name: {
196
- type: "string",
197
- $ref: "#/definitions/supportedNotifications/items"
198
- },
199
- timestamp: {
200
- type: "number",
201
- minimum: 1655907956593
202
- },
203
- description: {
204
- type: "string"
205
- }
206
- }
207
- },
208
- batteryLevel: {
209
- type: "number",
210
- minimum: 0,
211
- maximum: 100
212
- },
213
- watts: {
214
- type: "number",
215
- minimum: 0
216
- }
217
- }
218
- };
219
- }
220
- });
221
-
222
- // src/utils/schema.js
223
- var require_schema = __commonJS({
224
- "src/utils/schema.js"(exports2, module2) {
225
- var Ajv = require("ajv");
226
- var ajv = new Ajv({
227
- allErrors: true,
228
- useDefaults: true,
229
- strict: false,
230
- allowMatchingProperties: true,
231
- allowUnionTypes: true,
232
- strictRequired: false
233
- });
234
- var addFormats = require("ajv-formats");
235
- var commonDefs = require_common();
236
- var deviceDefs = require_device();
237
- addFormats(ajv);
238
- ajv.addSchema(commonDefs);
239
- ajv.addSchema(deviceDefs);
240
- module2.exports = {
241
- add: /* @__PURE__ */ __name(function add(schema) {
242
- ajv.addSchema(schema);
243
- }, "add"),
244
- compile: /* @__PURE__ */ __name(function compile(schema) {
245
- return ajv.compile(schema);
246
- }, "compile")
247
- };
248
- }
249
- });
250
-
251
- // src/schemas/reservation.json
252
- var require_reservation = __commonJS({
253
- "src/schemas/reservation.json"(exports2, module2) {
254
- module2.exports = {
255
- $schema: "http://json-schema.org/draft-07/schema",
256
- $id: "https://api.kohost.io/schemas/v3/reservation.json",
257
- title: "Reservation",
258
- type: "object",
259
- required: ["type", "status", "checkInDateTime", "checkOutDateTime"],
260
- properties: {
261
- id: {
262
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
263
- },
264
- driver: {
265
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
266
- },
267
- primaryGuest: {
268
- type: "string"
269
- },
270
- type: {
271
- type: "string"
272
- },
273
- sharedGuests: {
274
- type: "array",
275
- items: {
276
- type: "string"
277
- }
278
- },
279
- spaceType: {
280
- type: "string"
281
- },
282
- space: {
283
- type: "string"
284
- },
285
- status: {
286
- type: "string",
287
- enum: [
288
- "reserved",
289
- "checkedIn",
290
- "checkedOut",
291
- "cancelled",
292
- "noShow",
293
- "enquired",
294
- "requested",
295
- "optional"
296
- ],
297
- 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)"
298
- },
299
- mobileCheckInStatus: {
300
- type: "string",
301
- enum: [
302
- "ready",
303
- "blocked",
304
- "preArrivalStepsRequired",
305
- "spaceNotAssigned",
306
- "spaceNotReady",
307
- "checkInTimeNotStarted"
308
- ]
309
- },
310
- mobileCheckInStatusMessage: {
311
- type: "string"
312
- },
313
- confirmationNumber: {
314
- type: "string"
315
- },
316
- checkInDateTime: {
317
- type: ["string", "object"],
318
- format: "date-time"
319
- },
320
- checkOutDateTime: {
321
- type: ["string", "object"],
322
- format: "date-time"
323
- },
324
- adultCount: {
325
- type: "number",
326
- default: 1,
327
- minimum: 1
328
- },
329
- childCount: {
330
- type: "number",
331
- default: 0
332
- },
333
- revenue: {
334
- type: "array",
335
- items: {
336
- type: "object",
337
- properties: {
338
- date: {
339
- type: "string",
340
- format: "date-time"
341
- },
342
- amount: {
343
- type: "number"
344
- },
345
- type: {
346
- type: "string",
347
- enum: ["service", "product"]
348
- }
349
- }
350
- }
351
- },
352
- rateSuppressed: {
353
- type: "boolean"
354
- },
355
- payment: {
356
- type: "string"
357
- },
358
- company: {
359
- type: "string"
360
- },
361
- travelAgent: {
362
- type: "string"
363
- },
364
- systemData: {
365
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
366
- },
367
- metadata: {
368
- ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/metadata"
369
- }
370
- }
371
- };
372
- }
373
- });
374
-
375
- // src/Errors/AppError.js
376
- var require_AppError = __commonJS({
377
- "src/Errors/AppError.js"(exports2, module2) {
378
- module2.exports = class AppError extends Error {
379
- static {
380
- __name(this, "AppError");
381
- }
382
- constructor(message = "Internal Server Error", options) {
383
- super(message, options);
384
- this.type = this.constructor.name;
385
- this.statusCode = 500;
386
- Object.setPrototypeOf(this, AppError.prototype);
387
- }
388
- };
389
- }
390
- });
391
-
392
- // src/Errors/AuthenticationError.js
393
- var require_AuthenticationError = __commonJS({
394
- "src/Errors/AuthenticationError.js"(exports2, module2) {
395
- var AppError = require_AppError();
396
- module2.exports = class AuthenticationError extends AppError {
397
- static {
398
- __name(this, "AuthenticationError");
399
- }
400
- constructor(message = "Authentication Error", options = {}) {
401
- super(message, options);
402
- this.statusCode = 401;
403
- Object.setPrototypeOf(this, AuthenticationError.prototype);
404
- }
405
- };
406
- }
407
- });
408
-
409
- // src/Errors/AuthorizationError.js
410
- var require_AuthorizationError = __commonJS({
411
- "src/Errors/AuthorizationError.js"(exports2, module2) {
412
- var AppError = require_AppError();
413
- module2.exports = class AuthorizationError extends AppError {
414
- static {
415
- __name(this, "AuthorizationError");
416
- }
417
- constructor(message = "Authorization Error", options = {}) {
418
- super(message, options);
419
- this.statusCode = 403;
420
- Object.setPrototypeOf(this, AuthorizationError.prototype);
421
- }
422
- };
423
- }
424
- });
425
-
426
- // src/Errors/DeviceCommError.js
427
- var require_DeviceCommError = __commonJS({
428
- "src/Errors/DeviceCommError.js"(exports2, module2) {
429
- var AppError = require_AppError();
430
- module2.exports = class DeviceCommError extends AppError {
431
- static {
432
- __name(this, "DeviceCommError");
433
- }
434
- constructor(message = "Device Communication Error", options = {}) {
435
- super(message, options);
436
- this.statusCode = 503;
437
- Object.setPrototypeOf(this, DeviceCommError.prototype);
438
- }
439
- };
440
- }
441
- });
442
-
443
- // src/Errors/LoginError.js
444
- var require_LoginError = __commonJS({
445
- "src/Errors/LoginError.js"(exports2, module2) {
446
- var AppError = require_AppError();
447
- module2.exports = class LoginError extends AppError {
448
- static {
449
- __name(this, "LoginError");
450
- }
451
- constructor(message = "Invalid Login information provided", options = {}) {
452
- super(message, options);
453
- this.statusCode = 401;
454
- Object.setPrototypeOf(this, LoginError.prototype);
455
- }
456
- };
457
- }
458
- });
459
-
460
- // src/Errors/NotFoundError.js
461
- var require_NotFoundError = __commonJS({
462
- "src/Errors/NotFoundError.js"(exports2, module2) {
463
- var AppError = require_AppError();
464
- module2.exports = class NotFoundError extends AppError {
465
- static {
466
- __name(this, "NotFoundError");
467
- }
468
- constructor(message = "Resource Not Found", options = {}) {
469
- super(message, options);
470
- this.statusCode = 404;
471
- Object.setPrototypeOf(this, NotFoundError.prototype);
472
- }
473
- };
474
- }
475
- });
476
-
477
- // src/Errors/RequestError.js
478
- var require_RequestError = __commonJS({
479
- "src/Errors/RequestError.js"(exports2, module2) {
480
- var AppError = require_AppError();
481
- module2.exports = class RequestError extends AppError {
482
- static {
483
- __name(this, "RequestError");
484
- }
485
- constructor(message = "Bad Request", options = {}) {
486
- super(message, options);
487
- this.statusCode = 400;
488
- Object.setPrototypeOf(this, RequestError.prototype);
489
- }
490
- };
491
- }
492
- });
493
-
494
- // src/Errors/SystemCommError.js
495
- var require_SystemCommError = __commonJS({
496
- "src/Errors/SystemCommError.js"(exports2, module2) {
497
- var AppError = require_AppError();
498
- module2.exports = class SystemCommError extends AppError {
499
- static {
500
- __name(this, "SystemCommError");
501
- }
502
- constructor(message = "System Communication Error", options = {}) {
503
- super(message, options);
504
- this.statusCode = 503;
505
- Object.setPrototypeOf(this, SystemCommError.prototype);
506
- }
507
- };
508
- }
509
- });
510
-
511
- // src/Errors/TokenExpiredError.js
512
- var require_TokenExpiredError = __commonJS({
513
- "src/Errors/TokenExpiredError.js"(exports2, module2) {
514
- var AppError = require_AppError();
515
- module2.exports = class TokenExpiredError extends AppError {
516
- static {
517
- __name(this, "TokenExpiredError");
518
- }
519
- constructor(message = "Token Expired", options = {}) {
520
- super(message, options);
521
- this.statusCode = 401;
522
- Object.setPrototypeOf(this, TokenExpiredError.prototype);
523
- }
524
- };
525
- }
526
- });
527
-
528
- // src/Errors/UnprocessableRequestError.js
529
- var require_UnprocessableRequestError = __commonJS({
530
- "src/Errors/UnprocessableRequestError.js"(exports2, module2) {
531
- var AppError = require_AppError();
532
- module2.exports = class UnprocessableRequestError extends AppError {
533
- static {
534
- __name(this, "UnprocessableRequestError");
535
- }
536
- constructor(message = "Unprocessable Request Error", options = {}) {
537
- super(message, options);
538
- this.statusCode = 422;
539
- Object.setPrototypeOf(this, UnprocessableRequestError.prototype);
540
- }
541
- };
542
- }
543
- });
544
-
545
- // src/Errors/ValidationError.js
546
- var require_ValidationError = __commonJS({
547
- "src/Errors/ValidationError.js"(exports2, module2) {
548
- var AppError = require_AppError();
549
- module2.exports = class ValidationError extends AppError {
550
- static {
551
- __name(this, "ValidationError");
552
- }
553
- constructor(message = "Validation Error", options = {}) {
554
- super(message, options);
555
- this.statusCode = 400;
556
- Object.setPrototypeOf(this, ValidationError.prototype);
557
- }
558
- };
559
- }
560
- });
561
-
562
- // src/Errors/index.js
563
- var require_Errors = __commonJS({
564
- "src/Errors/index.js"(exports2, module2) {
565
- var Errors = {
566
- AppError: require_AppError(),
567
- AuthenticationError: require_AuthenticationError(),
568
- AuthorizationError: require_AuthorizationError(),
569
- DeviceCommError: require_DeviceCommError(),
570
- LoginError: require_LoginError(),
571
- NotFoundError: require_NotFoundError(),
572
- RequestError: require_RequestError(),
573
- SystemCommError: require_SystemCommError(),
574
- TokenExpiredError: require_TokenExpiredError(),
575
- UnprocessableRequestError: require_UnprocessableRequestError(),
576
- ValidationError: require_ValidationError()
577
- };
578
- module2.exports = Errors;
579
- }
580
- });
581
-
582
- // src/Models/kohost.js
583
- var require_kohost = __commonJS({
584
- "src/Models/kohost.js"(exports2, module2) {
585
- var { ValidationError } = require_Errors();
586
- var { customAlphabet: generate } = require("nanoid");
587
- var Kohost = class {
588
- static {
589
- __name(this, "Kohost");
590
- }
591
- constructor(data) {
592
- if (!this.schema) {
593
- throw new Error("Schema is not defined");
594
- }
595
- if (!this.validator) {
596
- throw new Error("Validator is not defined");
597
- }
598
- const isNew = data?.id ? false : true;
599
- this._setId(data);
600
- this._validate(data);
601
- this._setProperties(data);
602
- this._setTimestamps(isNew);
603
- }
604
- static get validProperties() {
605
- throw new Error("validProperties is not defined");
606
- }
607
- get schemaProperties() {
608
- return Object.keys(this.validator.schema.properties);
609
- }
610
- _setId(data) {
611
- if (data._id)
612
- data.id = data._id;
613
- if (!data.id) {
614
- data.id = this.constructor.generateId();
615
- }
616
- delete data._id;
617
- }
618
- _setProperties(data) {
619
- this.schemaProperties.forEach((key) => {
620
- if (data[key] !== void 0)
621
- this[key] = data[key];
622
- });
623
- }
624
- _setTimestamps(isNew) {
625
- const now = /* @__PURE__ */ new Date();
626
- if (isNew && this.schemaProperties.includes("createdAt") && !this.createdAt) {
627
- this.createdAt = now;
628
- }
629
- }
630
- _validate(data) {
631
- const valid = this.validator(data);
632
- if (!valid) {
633
- throw new ValidationError(`Invalid ${this.constructor.name}`, {
634
- cause: this.validator.errors
635
- });
636
- }
637
- }
638
- static generateId() {
639
- const length = 8;
640
- const characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
641
- const id = generate(characters, length)();
642
- return id;
643
- }
644
- static getActionDelta(old, _new) {
645
- const delta = {};
646
- for (const action in _new) {
647
- if (this.actionProperties?.includes(action)) {
648
- if (old[action] !== _new[action]) {
649
- delta[action] = 1;
650
- }
651
- }
652
- }
653
- return delta;
654
- }
655
- toObject() {
656
- const obj = { ...this };
657
- Object.keys(obj).forEach((key) => {
658
- if (!this.constructor.validProperties.includes(key)) {
659
- delete obj[key];
660
- }
661
- });
662
- return obj;
663
- }
664
- };
665
- module2.exports = Kohost;
666
- }
667
- });
668
-
669
- // src/Models/reservation.js
670
- var require_reservation2 = __commonJS({
671
- "src/Models/reservation.js"(exports2, module2) {
672
- var schemas = require_schema();
673
- var schema = require_reservation();
674
- var Kohost = require_kohost();
675
- schemas.add(schema);
676
- var validator = schemas.compile(schema);
677
- var Reservation2 = class extends Kohost {
678
- static {
679
- __name(this, "Reservation");
680
- }
681
- constructor(data) {
682
- super(data);
683
- }
684
- get peopleCount() {
685
- return this.adultCount + this.childCount;
686
- }
687
- get hasPayment() {
688
- return this.paymentId?.length > 0;
689
- }
690
- range(tz) {
691
- const start = new Date(this.checkInDateTime);
692
- const end = new Date(this.checkOutDateTime);
693
- if (start.getDate() === end.getDate() && start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
694
- return `${start.toLocaleString("default", {
695
- month: "short",
696
- timeZone: tz
697
- })} ${start.toLocaleString("default", {
698
- timeZone: tz,
699
- day: "numeric"
700
- })}`;
701
- }
702
- if (start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
703
- return `${start.toLocaleString("default", {
704
- month: "short",
705
- timeZone: tz
706
- })} ${start.toLocaleString("default", {
707
- timeZone: tz,
708
- day: "numeric"
709
- })}-${end.toLocaleString("default", {
710
- timeZone: tz,
711
- day: "numeric"
712
- })}`;
713
- }
714
- return `${start.toLocaleString("default", {
715
- month: "short",
716
- timeZone: tz
717
- })} ${start.getDate()} - ${end.toLocaleString("default", {
718
- month: "short",
719
- timeZone: tz
720
- })} ${end.getDate()}`;
721
- }
722
- checkInTime(tz) {
723
- return new Date(this.checkInDateTime).toLocaleString("default", {
724
- hour: "numeric",
725
- minute: "numeric",
726
- timeZone: tz
727
- });
728
- }
729
- checkOutTime(tz) {
730
- return new Date(this.checkOutDateTime).toLocaleString("default", {
731
- hour: "numeric",
732
- minute: "numeric",
733
- timeZone: tz
734
- });
735
- }
736
- };
737
- Object.defineProperty(Reservation2.prototype, "schema", {
738
- value: schema
739
- });
740
- Object.defineProperty(Reservation2.prototype, "validator", {
741
- get: function() {
742
- return validator;
743
- }
744
- });
745
- Object.defineProperty(Reservation2, "validProperties", {
746
- value: Object.keys(schema.properties)
747
- });
748
- module2.exports = Reservation2;
749
- }
750
- });
751
-
752
- // src/schemas/mediaFile.json
753
- var require_mediaFile = __commonJS({
754
- "src/schemas/mediaFile.json"(exports2, module2) {
755
- module2.exports = {
756
- $schema: "http://json-schema.org/draft-07/schema",
757
- $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
758
- title: "Media File",
759
- description: "Any media file",
760
- type: "object",
761
- properties: {
762
- id: {
763
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
764
- },
765
- type: {
766
- type: "string",
767
- default: "mediaFile"
768
- },
769
- fileHash: {
770
- type: "string"
771
- },
772
- mimeType: {
773
- type: "string",
774
- enum: [
775
- "image/*",
776
- "image/jpeg",
777
- "image/png",
778
- "image/gif",
779
- "image/webp",
780
- "image/avif",
781
- "image/svg+xml",
782
- "application/pdf"
783
- ]
784
- },
785
- data: {
786
- type: "string"
787
- },
788
- url: {
789
- type: "string",
790
- format: "uri"
791
- },
792
- width: {
793
- type: "integer",
794
- minimum: 0
795
- },
796
- height: {
797
- type: "integer",
798
- minimum: 0
799
- },
800
- size: {
801
- type: "integer",
802
- minimum: 0,
803
- description: "Size in bytes"
804
- },
805
- uploadUrl: {
806
- type: "string",
807
- format: "uri"
808
- },
809
- uploadUrlExpires: {
810
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
811
- },
812
- createdBy: {
813
- type: "string"
814
- },
815
- systemData: {
816
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
817
- }
818
- },
819
- additionalProperties: false,
820
- required: ["id", "type"]
821
- };
822
- }
823
- });
824
-
825
- // src/Models/mediaFile.js
826
- var require_mediaFile2 = __commonJS({
827
- "src/Models/mediaFile.js"(exports2, module2) {
828
- var schemas = require_schema();
829
- var schema = require_mediaFile();
830
- var Kohost = require_kohost();
831
- var { RequestError } = require_Errors();
832
- schemas.add(schema);
833
- var validator = schemas.compile(schema);
834
- var MediaFile2 = class extends Kohost {
835
- static {
836
- __name(this, "MediaFile");
837
- }
838
- constructor(data) {
839
- super(data);
840
- }
841
- createImageVariant(params) {
842
- if (this.mimeType != "image/*")
843
- throw new RequestError("Only dynamic images can have variants");
844
- const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
845
- return this.url.replace(/\/public$/, `/${query}`);
846
- }
847
- };
848
- Object.defineProperty(MediaFile2.prototype, "schema", {
849
- value: schema
850
- });
851
- Object.defineProperty(MediaFile2.prototype, "validator", {
852
- get: function() {
853
- return validator;
854
- }
855
- });
856
- Object.defineProperty(MediaFile2, "validProperties", {
857
- value: Object.keys(schema.properties)
858
- });
859
- module2.exports = MediaFile2;
860
- }
861
- });
862
-
863
- // src/schemas/switch.json
864
- var require_switch = __commonJS({
865
- "src/schemas/switch.json"(exports2, module2) {
866
- module2.exports = {
867
- $schema: "http://json-schema.org/draft-07/schema",
868
- $id: "https://api.kohost.io/schemas/v3/switch.json",
869
- title: "Switch",
870
- description: "Any smart switch",
871
- type: "object",
872
- properties: {
873
- id: {
874
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
875
- },
876
- name: {
877
- type: "string"
878
- },
879
- type: {
880
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
881
- },
882
- subType: {
883
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/subType"
884
- },
885
- supportedNotifications: {
886
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
887
- },
888
- notification: {
889
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
890
- },
891
- driver: {
892
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
893
- },
894
- state: {
895
- type: "string",
896
- enum: ["on", "off"]
897
- },
898
- systemData: {
899
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
900
- },
901
- watts: {
902
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
903
- }
904
- },
905
- additionalProperties: false,
906
- required: ["id", "type", "systemData", "state", "driver"]
907
- };
908
- }
909
- });
910
-
911
- // src/Models/switch.js
912
- var require_switch2 = __commonJS({
913
- "src/Models/switch.js"(exports2, module2) {
914
- var schemas = require_schema();
915
- var schema = require_switch();
916
- var Kohost = require_kohost();
917
- schemas.add(schema);
918
- var validator = schemas.compile(schema);
919
- var Switch2 = class extends Kohost {
920
- static {
921
- __name(this, "Switch");
922
- }
923
- constructor(data) {
924
- super(data);
925
- }
926
- };
927
- Object.defineProperty(Switch2.prototype, "schema", {
928
- value: schema
929
- });
930
- Object.defineProperty(Switch2.prototype, "validator", {
931
- get: function() {
932
- return validator;
933
- }
934
- });
935
- Object.defineProperty(Switch2, "validProperties", {
936
- value: Object.keys(schema.properties)
937
- });
938
- Object.defineProperty(Switch2, "actionProperties", {
939
- value: ["state"]
940
- });
941
- module2.exports = Switch2;
942
- }
943
- });
944
-
945
- // src/schemas/alarm.json
946
- var require_alarm = __commonJS({
947
- "src/schemas/alarm.json"(exports2, module2) {
948
- module2.exports = {
949
- $schema: "http://json-schema.org/draft-07/schema",
950
- $id: "https://api.kohost.io/schemas/v3/alarm.json",
951
- title: "Alarm",
952
- description: "Any smart alarm system",
953
- type: "object",
954
- properties: {
955
- id: {
956
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
957
- },
958
- name: {
959
- type: "string"
960
- },
961
- type: {
962
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
963
- },
964
- systemData: {
965
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
966
- },
967
- supportedNotifications: {
968
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
969
- },
970
- notification: {
971
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
972
- },
973
- driver: {
974
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
975
- },
976
- areas: {
977
- type: "array",
978
- items: {
979
- type: "object",
980
- properties: {
981
- number: {
982
- type: "number"
983
- },
984
- name: {
985
- type: "string"
986
- },
987
- securityMode: {
988
- type: "string",
989
- enum: ["arming", "disarming", "armed", "disarmed", "alarm"]
990
- },
991
- readyToArm: {
992
- type: "boolean"
993
- }
994
- },
995
- additionalProperties: false
996
- }
997
- },
998
- zones: {
999
- type: "array",
1000
- items: {
1001
- type: "object",
1002
- properties: {
1003
- number: {
1004
- type: "number",
1005
- minimum: 0
1006
- },
1007
- name: {
1008
- type: "string"
1009
- },
1010
- secure: {
1011
- type: "boolean"
1012
- },
1013
- bypassed: {
1014
- type: "boolean"
1015
- }
1016
- },
1017
- additionalProperties: false
1018
- }
1019
- },
1020
- supportedTroubles: {
1021
- type: "array",
1022
- uniqueItems: true,
1023
- items: {
1024
- type: "string",
1025
- enum: ["battery", "ac", "phone", "bell", "fire"]
1026
- }
1027
- },
1028
- troubles: {
1029
- type: "array",
1030
- uniqueItems: true,
1031
- items: {
1032
- $ref: "#/properties/supportedTroubles/items"
1033
- }
1034
- },
1035
- watts: {
1036
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
1037
- }
1038
- },
1039
- additionalProperties: false,
1040
- required: [
1041
- "id",
1042
- "type",
1043
- "systemData",
1044
- "areas",
1045
- "zones",
1046
- "supportedTroubles",
1047
- "troubles",
1048
- "driver"
1049
- ]
1050
- };
1051
- }
1052
- });
1053
-
1054
- // src/Models/alarm.js
1055
- var require_alarm2 = __commonJS({
1056
- "src/Models/alarm.js"(exports2, module2) {
1057
- var schemas = require_schema();
1058
- var schema = require_alarm();
1059
- var Kohost = require_kohost();
1060
- schemas.add(schema);
1061
- var validator = schemas.compile(schema);
1062
- var Alarm2 = class extends Kohost {
1063
- static {
1064
- __name(this, "Alarm");
1065
- }
1066
- constructor(data) {
1067
- super(data);
1068
- }
1069
- };
1070
- Object.defineProperty(Alarm2.prototype, "schema", {
1071
- value: schema
1072
- });
1073
- Object.defineProperty(Alarm2.prototype, "validator", {
1074
- get: function() {
1075
- return validator;
1076
- }
1077
- });
1078
- Object.defineProperty(Alarm2, "validProperties", {
1079
- value: Object.keys(schema.properties)
1080
- });
1081
- module2.exports = Alarm2;
1082
- }
1083
- });
1084
-
1085
- // src/schemas/dimmer.json
1086
- var require_dimmer = __commonJS({
1087
- "src/schemas/dimmer.json"(exports2, module2) {
1088
- module2.exports = {
1089
- $schema: "http://json-schema.org/draft-07/schema",
1090
- $id: "https://api.kohost.io/schemas/v3/dimmer.json",
1091
- title: "Dimmer",
1092
- description: "Any smart dimmer",
1093
- type: "object",
1094
- properties: {
1095
- id: {
1096
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
1097
- },
1098
- name: {
1099
- type: "string"
1100
- },
1101
- type: {
1102
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
1103
- },
1104
- subType: {
1105
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/subType"
1106
- },
1107
- supportedNotifications: {
1108
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1109
- },
1110
- notification: {
1111
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
1112
- },
1113
- driver: {
1114
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1115
- },
1116
- level: {
1117
- type: "number",
1118
- minimum: 0,
1119
- maximum: 100
1120
- },
1121
- systemData: {
1122
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
1123
- },
1124
- watts: {
1125
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
1126
- }
1127
- },
1128
- additionalProperties: false,
1129
- required: ["id", "type", "systemData", "level", "driver"]
1130
- };
1131
- }
1132
- });
1133
-
1134
- // src/Models/dimmer.js
1135
- var require_dimmer2 = __commonJS({
1136
- "src/Models/dimmer.js"(exports2, module2) {
1137
- var schemas = require_schema();
1138
- var schema = require_dimmer();
1139
- var Kohost = require_kohost();
1140
- schemas.add(schema);
1141
- var validator = schemas.compile(schema);
1142
- var Dimmer2 = class extends Kohost {
1143
- static {
1144
- __name(this, "Dimmer");
1145
- }
1146
- constructor(data) {
1147
- super(data);
1148
- }
1149
- static getActionDelta(old, _new) {
1150
- const delta = {};
1151
- for (const action in _new) {
1152
- if (this.actionProperties?.includes(action)) {
1153
- if (action === "level") {
1154
- const oldLevel = old[action];
1155
- const newLevel = _new[action];
1156
- delta[action] = newLevel - oldLevel / 100;
1157
- } else {
1158
- delta[action] = 1;
1159
- }
1160
- }
1161
- }
1162
- return delta;
1163
- }
1164
- };
1165
- Object.defineProperty(Dimmer2.prototype, "schema", {
1166
- value: schema
1167
- });
1168
- Object.defineProperty(Dimmer2.prototype, "validator", {
1169
- get: function() {
1170
- return validator;
1171
- }
1172
- });
1173
- Object.defineProperty(Dimmer2, "validProperties", {
1174
- value: Object.keys(schema.properties)
1175
- });
1176
- Object.defineProperty(Dimmer2, "actionProperties", {
1177
- value: ["level"]
1178
- });
1179
- module2.exports = Dimmer2;
1180
- }
1181
- });
1182
-
1183
- // src/schemas/lock.json
1184
- var require_lock = __commonJS({
1185
- "src/schemas/lock.json"(exports2, module2) {
1186
- module2.exports = {
1187
- $schema: "http://json-schema.org/draft-07/schema",
1188
- $id: "https://api.kohost.io/schemas/v3/lock.json",
1189
- title: "Lock",
1190
- description: "Any smart lock",
1191
- type: "object",
1192
- properties: {
1193
- id: {
1194
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
1195
- },
1196
- name: {
1197
- type: "string"
1198
- },
1199
- type: {
1200
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
1201
- },
1202
- offline: {
1203
- type: "boolean"
1204
- },
1205
- supportedNotifications: {
1206
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1207
- },
1208
- notification: {
1209
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
1210
- },
1211
- driver: {
1212
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1213
- },
1214
- state: {
1215
- type: ["string", "null"],
1216
- enum: ["locked", "unlocked", null]
1217
- },
1218
- batteryLevel: {
1219
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/batteryLevel"
1220
- },
1221
- systemData: {
1222
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
1223
- },
1224
- watts: {
1225
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
1226
- }
1227
- },
1228
- additionalProperties: false,
1229
- required: ["id", "type", "systemData", "state", "driver"]
1230
- };
1231
- }
1232
- });
1233
-
1234
- // src/Models/lock.js
1235
- var require_lock2 = __commonJS({
1236
- "src/Models/lock.js"(exports2, module2) {
1237
- var schemas = require_schema();
1238
- var schema = require_lock();
1239
- var Kohost = require_kohost();
1240
- schemas.add(schema);
1241
- var validator = schemas.compile(schema);
1242
- var Lock2 = class extends Kohost {
1243
- static {
1244
- __name(this, "Lock");
1245
- }
1246
- constructor(data) {
1247
- super(data);
1248
- }
1249
- };
1250
- Object.defineProperty(Lock2.prototype, "schema", {
1251
- value: schema
1252
- });
1253
- Object.defineProperty(Lock2.prototype, "validator", {
1254
- get: function() {
1255
- return validator;
1256
- }
1257
- });
1258
- Object.defineProperty(Lock2, "validProperties", {
1259
- value: Object.keys(schema.properties)
1260
- });
1261
- Object.defineProperty(Lock2, "actionProperties", {
1262
- value: ["state"]
1263
- });
1264
- module2.exports = Lock2;
1265
- }
1266
- });
1267
-
1268
- // src/schemas/thermostat.json
1269
- var require_thermostat = __commonJS({
1270
- "src/schemas/thermostat.json"(exports2, module2) {
1271
- module2.exports = {
1272
- $schema: "http://json-schema.org/draft-07/schema",
1273
- $id: "https://api.kohost.io/schemas/v3/thermostat.json",
1274
- title: "Thermostat",
1275
- description: "Any smart thermostat",
1276
- type: "object",
1277
- properties: {
1278
- id: {
1279
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
1280
- },
1281
- name: {
1282
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/name"
1283
- },
1284
- type: {
1285
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type",
1286
- default: "thermostat"
1287
- },
1288
- driver: {
1289
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1290
- },
1291
- offline: {
1292
- type: "boolean"
1293
- },
1294
- supportedNotifications: {
1295
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1296
- },
1297
- notification: {
1298
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
1299
- },
1300
- currentTemperature: {
1301
- type: "number"
1302
- },
1303
- currentHumidity: {
1304
- type: "number",
1305
- minimum: 0,
1306
- maximum: 99
1307
- },
1308
- hvacMode: {
1309
- type: "string",
1310
- $ref: "#/properties/supportedHvacModes/items"
1311
- },
1312
- hvacState: {
1313
- type: ["string", "null"],
1314
- enum: ["cooling", "heating", "off", null]
1315
- },
1316
- fanMode: {
1317
- type: "string",
1318
- $ref: "#/properties/supportedFanModes/items"
1319
- },
1320
- fanState: {
1321
- type: ["string", "null"],
1322
- enum: ["off", "low", "medium", "high", "on", null]
1323
- },
1324
- temperatureScale: {
1325
- type: "string",
1326
- enum: ["celsius", "fahrenheit"],
1327
- default: "fahrenheit"
1328
- },
1329
- humidityScale: {
1330
- type: ["string", "null"],
1331
- enum: ["absolute", "relative", null]
1332
- },
1333
- supportedHvacModes: {
1334
- type: "array",
1335
- uniqueItems: true,
1336
- minItems: 2,
1337
- items: {
1338
- enum: ["cool", "heat", "auto", "off"]
1339
- }
1340
- },
1341
- supportedFanModes: {
1342
- type: "array",
1343
- uniqueItems: true,
1344
- items: {
1345
- enum: ["auto", "low", "medium", "high", "off", "on"]
1346
- }
1347
- },
1348
- setpoints: {
1349
- type: "object",
1350
- additionalProperties: false,
1351
- properties: {
1352
- cool: {
1353
- $ref: "#/$defs/setpoint"
1354
- },
1355
- heat: {
1356
- $ref: "#/$defs/setpoint"
1357
- },
1358
- auto: {
1359
- $ref: "#/$defs/setpoint"
1360
- }
1361
- }
1362
- },
1363
- minAutoDelta: {
1364
- type: "number",
1365
- default: 3
1366
- },
1367
- cycleRate: {
1368
- type: "number"
1369
- },
1370
- batteryLevel: {
1371
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/batteryLevel"
1372
- },
1373
- systemData: {
1374
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData",
1375
- default: {}
1376
- },
1377
- watts: {
1378
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
1379
- }
1380
- },
1381
- additionalProperties: false,
1382
- $defs: {
1383
- setpoint: {
1384
- type: "object",
1385
- additionalProperties: false,
1386
- properties: {
1387
- value: {
1388
- $ref: "#/$defs/setpointValue"
1389
- },
1390
- min: {
1391
- $ref: "#/$defs/setpointMinMax"
1392
- },
1393
- max: {
1394
- $ref: "#/$defs/setpointMinMax"
1395
- }
1396
- }
1397
- },
1398
- setpointValue: {
1399
- type: "number",
1400
- minimum: 0,
1401
- maximum: 99
1402
- },
1403
- setpointMinMax: {
1404
- type: ["number", "null"],
1405
- minimum: 0,
1406
- maximum: 99
1407
- }
1408
- },
1409
- required: [
1410
- "id",
1411
- "type",
1412
- "systemData",
1413
- "hvacMode",
1414
- "fanMode",
1415
- "hvacState",
1416
- "fanState",
1417
- "setpoints",
1418
- "temperatureScale",
1419
- "supportedHvacModes",
1420
- "supportedFanModes",
1421
- "driver"
1422
- ]
1423
- };
1424
- }
1425
- });
1426
-
1427
- // src/Models/thermostat.js
1428
- var require_thermostat2 = __commonJS({
1429
- "src/Models/thermostat.js"(exports2, module2) {
1430
- var schemas = require_schema();
1431
- var schema = require_thermostat();
1432
- var Kohost = require_kohost();
1433
- schemas.add(schema);
1434
- var validator = schemas.compile(schema);
1435
- var Thermostat2 = class extends Kohost {
1436
- static {
1437
- __name(this, "Thermostat");
1438
- }
1439
- constructor(data) {
1440
- super(data);
1441
- }
1442
- toCelsius() {
1443
- if (this.temperatureScale === "fahrenheit")
1444
- this.currentTemperature = (this.currentTemperature - 32) * 5 / 9;
1445
- this.temperatureScale = "celsius";
1446
- return this.currentTemperature;
1447
- }
1448
- toFahrenheit() {
1449
- if (this.temperatureScale === "celsius")
1450
- this.currentTemperature = this.currentTemperature * 9 / 5 + 32;
1451
- this.temperatureScale = "fahrenheit";
1452
- return this.currentTemperature;
1453
- }
1454
- static getActionDelta(old, _new) {
1455
- const delta = {};
1456
- for (const action in _new) {
1457
- if (this.actionProperties.includes(action)) {
1458
- switch (action) {
1459
- case "hvacMode":
1460
- case "fanMode": {
1461
- if (old[action] !== _new[action])
1462
- delta[action] = 1;
1463
- break;
1464
- }
1465
- case "setpoints": {
1466
- const setpoints = _new[action];
1467
- for (const setpoint in setpoints) {
1468
- if (old[action][setpoint].value !== setpoints[setpoint].value) {
1469
- const min = setpoints[setpoint].min || old[action][setpoint].min;
1470
- const max = setpoints[setpoint].max || old[action][setpoint].max;
1471
- const oldValue = old[action][setpoint].value;
1472
- const value = setpoints[setpoint].value;
1473
- const percentChange = (value - oldValue) / (max - min);
1474
- delta[`setpoints.${setpoint}`] = percentChange;
1475
- }
1476
- }
1477
- }
1478
- }
1479
- }
1480
- }
1481
- return delta;
1482
- }
1483
- };
1484
- Object.defineProperty(Thermostat2.prototype, "schema", {
1485
- value: schema
1486
- });
1487
- Object.defineProperty(Thermostat2.prototype, "validator", {
1488
- get: function() {
1489
- return validator;
1490
- }
1491
- });
1492
- Object.defineProperty(Thermostat2, "validProperties", {
1493
- value: Object.keys(schema.properties)
1494
- });
1495
- Object.defineProperty(Thermostat2, "actionProperties", {
1496
- value: ["hvacMode", "fanMode", "setpoints"]
1497
- });
1498
- module2.exports = Thermostat2;
1499
- }
1500
- });
1501
-
1502
- // src/schemas/windowCovering.json
1503
- var require_windowCovering = __commonJS({
1504
- "src/schemas/windowCovering.json"(exports2, module2) {
1505
- module2.exports = {
1506
- $schema: "http://json-schema.org/draft-07/schema",
1507
- $id: "https://api.kohost.io/schemas/v3/windowCovering.json",
1508
- title: "Window Covering",
1509
- description: "Any smart window covering",
1510
- type: "object",
1511
- properties: {
1512
- id: {
1513
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
1514
- },
1515
- name: {
1516
- type: "string"
1517
- },
1518
- type: {
1519
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
1520
- },
1521
- subType: {
1522
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/subType"
1523
- },
1524
- supportedNotifications: {
1525
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1526
- },
1527
- notification: {
1528
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
1529
- },
1530
- driver: {
1531
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1532
- },
1533
- position: {
1534
- type: "number",
1535
- minimum: 0,
1536
- maximum: 100
1537
- },
1538
- systemData: {
1539
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
1540
- },
1541
- watts: {
1542
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
1543
- }
1544
- },
1545
- additionalProperties: false,
1546
- required: ["id", "type", "systemData", "position", "driver"]
1547
- };
1548
- }
1549
- });
1550
-
1551
- // src/Models/windowCovering.js
1552
- var require_windowCovering2 = __commonJS({
1553
- "src/Models/windowCovering.js"(exports2, module2) {
1554
- var schemas = require_schema();
1555
- var schema = require_windowCovering();
1556
- var Kohost = require_kohost();
1557
- schemas.add(schema);
1558
- var validator = schemas.compile(schema);
1559
- var WindowCovering2 = class extends Kohost {
1560
- static {
1561
- __name(this, "WindowCovering");
1562
- }
1563
- constructor(data) {
1564
- super(data);
1565
- }
1566
- static getActionDelta(old, _new) {
1567
- const delta = {};
1568
- for (const action in _new) {
1569
- if (this.actionProperties?.includes(action)) {
1570
- if (action === "position") {
1571
- const oldPos = old[action];
1572
- const newPos = _new[action];
1573
- delta[action] = newPos - oldPos / 100;
1574
- } else if (old[action] !== _new[action]) {
1575
- delta[action] = 1;
1576
- }
1577
- }
1578
- }
1579
- return delta;
1580
- }
1581
- };
1582
- Object.defineProperty(WindowCovering2.prototype, "schema", {
1583
- value: schema
1584
- });
1585
- Object.defineProperty(WindowCovering2.prototype, "validator", {
1586
- get: function() {
1587
- return validator;
1588
- }
1589
- });
1590
- Object.defineProperty(WindowCovering2, "validProperties", {
1591
- value: Object.keys(schema.properties)
1592
- });
1593
- Object.defineProperty(WindowCovering2, "actionProperties", {
1594
- value: ["position"]
1595
- });
1596
- module2.exports = WindowCovering2;
1597
- }
1598
- });
1599
-
1600
- // src/schemas/identification.json
1601
- var require_identification = __commonJS({
1602
- "src/schemas/identification.json"(exports2, module2) {
1603
- module2.exports = {
1604
- $schema: "http://json-schema.org/draft-07/schema",
1605
- $id: "https://api.kohost.io/schemas/v3/identification.json",
1606
- title: "Identification",
1607
- type: "object",
1608
- required: ["type"],
1609
- oneOf: [
1610
- {
1611
- required: ["number"]
1612
- },
1613
- {
1614
- required: ["encryptedNumber"]
1615
- }
1616
- ],
1617
- properties: {
1618
- id: {
1619
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
1620
- },
1621
- type: {
1622
- type: "string",
1623
- enum: ["driversLicense", "passport", "identityCard", "visa"]
1624
- },
1625
- number: {
1626
- string: "string"
1627
- },
1628
- maskedNumber: {
1629
- string: "string"
1630
- },
1631
- encryptedNumber: {
1632
- string: "string"
1633
- },
1634
- issued: {
1635
- type: ["string", "object"],
1636
- format: "date-time"
1637
- },
1638
- expires: {
1639
- type: ["string", "object", "null"],
1640
- format: "date-time"
1641
- },
1642
- verified: {
1643
- type: "boolean"
1644
- },
1645
- matched: {
1646
- type: "boolean"
1647
- },
1648
- firstName: {
1649
- type: "string"
1650
- },
1651
- lastName: {
1652
- type: "string"
1653
- },
1654
- issuingCountry: {
1655
- string: "string",
1656
- minLength: 2,
1657
- maxLength: 2
1658
- },
1659
- systemData: {
1660
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
1661
- }
1662
- }
1663
- };
1664
- }
1665
- });
1666
-
1667
- // src/Models/identification.js
1668
- var require_identification2 = __commonJS({
1669
- "src/Models/identification.js"(exports2, module2) {
1670
- var schemas = require_schema();
1671
- var schema = require_identification();
1672
- var Kohost = require_kohost();
1673
- schemas.add(schema);
1674
- var validator = schemas.compile(schema);
1675
- var Identification2 = class extends Kohost {
1676
- static {
1677
- __name(this, "Identification");
1678
- }
1679
- constructor(data) {
1680
- super(data);
1681
- }
1682
- get isExpired() {
1683
- return new Date(this.expirationDate) < /* @__PURE__ */ new Date();
1684
- }
1685
- };
1686
- Object.defineProperty(Identification2.prototype, "schema", {
1687
- value: schema
1688
- });
1689
- Object.defineProperty(Identification2.prototype, "validator", {
1690
- get: function() {
1691
- return validator;
1692
- }
1693
- });
1694
- Object.defineProperty(Identification2, "validProperties", {
1695
- value: Object.keys(schema.properties)
1696
- });
1697
- module2.exports = Identification2;
1698
- }
1699
- });
1700
-
1701
- // src/schemas/user.json
1702
- var require_user = __commonJS({
1703
- "src/schemas/user.json"(exports2, module2) {
1704
- module2.exports = {
1705
- $schema: "http://json-schema.org/draft-07/schema",
1706
- $id: "https://api.kohost.io/schemas/v3/user.json",
1707
- title: "User",
1708
- type: "object",
1709
- required: ["firstName", "lastName"],
1710
- properties: {
1711
- id: {
1712
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
1713
- },
1714
- type: {
1715
- type: "string",
1716
- default: "user"
1717
- },
1718
- firstName: {
1719
- type: "string"
1720
- },
1721
- lastName: {
1722
- type: "string"
1723
- },
1724
- phone: {
1725
- type: ["string", "null"],
1726
- pattern: "^\\+[0-9]{1,14}$"
1727
- },
1728
- phoneVerified: {
1729
- type: "boolean"
1730
- },
1731
- email: {
1732
- type: ["string", "null"],
1733
- format: "email"
1734
- },
1735
- emailVerified: {
1736
- type: "boolean"
1737
- },
1738
- address: {
1739
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/address"
1740
- },
1741
- secretKey: {
1742
- type: "string"
1743
- },
1744
- photo: {
1745
- $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
1746
- },
1747
- jobTitle: {
1748
- type: "string"
1749
- },
1750
- dob: {
1751
- type: "string"
1752
- },
1753
- gender: {
1754
- type: "string",
1755
- enum: ["male", "female"]
1756
- },
1757
- nationality: {
1758
- type: "string",
1759
- minLength: 2,
1760
- maxLength: 2
1761
- },
1762
- permissions: {
1763
- type: "array",
1764
- default: [],
1765
- items: {
1766
- type: "object",
1767
- required: ["organization", "property", "role"],
1768
- properties: {
1769
- organization: {
1770
- type: "string",
1771
- description: "The ID of the organization the permission is applies to."
1772
- },
1773
- property: {
1774
- type: "string",
1775
- description: "The ID of the property the permission is applies to."
1776
- },
1777
- role: {
1778
- type: "string",
1779
- enum: ["Guest", "User", "Manager", "Administrator", "SuperAdmin"]
1780
- },
1781
- customPermissions: {
1782
- type: "array",
1783
- items: {
1784
- type: "string"
1785
- }
1786
- }
1787
- }
1788
- }
1789
- },
1790
- notes: {
1791
- type: "array",
1792
- items: {
1793
- type: "string"
1794
- }
1795
- },
1796
- files: {
1797
- type: "array",
1798
- items: {
1799
- $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
1800
- }
1801
- },
1802
- identifications: {
1803
- type: "array",
1804
- items: {
1805
- $ref: "https://api.kohost.io/schemas/v3/identification.json#"
1806
- }
1807
- },
1808
- payments: {
1809
- type: "array",
1810
- items: {
1811
- $ref: "https://api.kohost.io/schemas/v3/payment.json#"
1812
- }
1813
- },
1814
- location: {
1815
- type: "object",
1816
- required: ["accuracy", "latitude", "longitude", "timestamp"],
1817
- additionalProperties: false,
1818
- properties: {
1819
- accuracy: {
1820
- type: ["number", "null"]
1821
- },
1822
- latitude: {
1823
- type: ["number", "null"]
1824
- },
1825
- longitude: {
1826
- type: ["number", "null"]
1827
- },
1828
- timestamp: {
1829
- type: ["number", "null"]
1830
- }
1831
- }
1832
- },
1833
- reservations: {
1834
- type: "array",
1835
- items: {
1836
- $ref: "https://api.kohost.io/schemas/v3/reservation.json"
1837
- }
1838
- },
1839
- spaceName: {
1840
- type: "string"
1841
- },
1842
- createdAt: {
1843
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
1844
- },
1845
- updatedAt: {
1846
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/updatedAt"
1847
- },
1848
- systemData: {
1849
- type: "array",
1850
- items: {
1851
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
1852
- }
1853
- }
1854
- }
1855
- };
1856
- }
1857
- });
1858
-
1859
- // src/schemas/payment.json
1860
- var require_payment = __commonJS({
1861
- "src/schemas/payment.json"(exports2, module2) {
1862
- module2.exports = {
1863
- $schema: "http://json-schema.org/draft-07/schema",
1864
- $id: "https://api.kohost.io/schemas/v3/payment.json",
1865
- title: "Payment",
1866
- type: "object",
1867
- required: ["type", "maskedNumber", "expires"],
1868
- properties: {
1869
- id: {
1870
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
1871
- },
1872
- type: {
1873
- type: "string",
1874
- enum: [
1875
- "amex",
1876
- "visa",
1877
- "masterCard",
1878
- "maestro",
1879
- "discover",
1880
- "diners",
1881
- "jcb",
1882
- "applePay",
1883
- "alipay",
1884
- "chinaUnionPay",
1885
- "vpay"
1886
- ]
1887
- },
1888
- enabled: {
1889
- type: "boolean",
1890
- default: true
1891
- },
1892
- storageData: {
1893
- type: ["string", "null"]
1894
- },
1895
- maskedNumber: {
1896
- string: "string"
1897
- },
1898
- issued: {
1899
- type: ["string", "null"]
1900
- },
1901
- expires: {
1902
- string: "string"
1903
- },
1904
- systemData: {
1905
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
1906
- }
1907
- }
1908
- };
1909
- }
1910
- });
1911
-
1912
- // src/Models/user.js
1913
- var require_user2 = __commonJS({
1914
- "src/Models/user.js"(exports2, module2) {
1915
- var schemas = require_schema();
1916
- var schema = require_user();
1917
- var paymentSchema = require_payment();
1918
- var Kohost = require_kohost();
1919
- var MediaFile2 = require_mediaFile2();
1920
- var Reservation2 = require_reservation2();
1921
- var { nanoid } = require("nanoid/async");
1922
- schemas.add(paymentSchema);
1923
- schemas.add(schema);
1924
- var validator = schemas.compile(schema);
1925
- var User2 = class extends Kohost {
1926
- static {
1927
- __name(this, "User");
1928
- }
1929
- constructor(data) {
1930
- if (data.photo)
1931
- data.photo = new MediaFile2(data.photo);
1932
- if (data.reservations)
1933
- data.reservations = data.reservations.map((res) => new Reservation2(res));
1934
- super(data);
1935
- }
1936
- static validatePhone(phoneNumber) {
1937
- const regex = /^\+?[1-9]\d{1,14}$/;
1938
- return regex.test(phoneNumber);
1939
- }
1940
- static validateEmail(email) {
1941
- 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,}))$/;
1942
- return regex.test(email);
1943
- }
1944
- static async generatePassword(len = 16) {
1945
- return await nanoid(len);
1946
- }
1947
- };
1948
- Object.defineProperty(User2.prototype, "schema", {
1949
- value: schema
1950
- });
1951
- Object.defineProperty(User2.prototype, "validator", {
1952
- get: function() {
1953
- return validator;
1954
- }
1955
- });
1956
- Object.defineProperty(User2, "validProperties", {
1957
- value: Object.keys(schema.properties)
1958
- });
1959
- Object.defineProperty(User2.prototype, "fullName", {
1960
- get: function() {
1961
- return `${this.firstName} ${this.lastName}`;
1962
- }
1963
- });
1964
- Object.defineProperty(User2.prototype, "roles", {
1965
- get: function() {
1966
- const roles = /* @__PURE__ */ new Set();
1967
- if (this.permissions) {
1968
- for (const permission of this.permissions) {
1969
- roles.add(permission.role);
1970
- }
1971
- }
1972
- return Array.from(roles);
1973
- }
1974
- });
1975
- module2.exports = User2;
1976
- }
1977
- });
1978
-
1979
- // src/schemas/systemUser.json
1980
- var require_systemUser = __commonJS({
1981
- "src/schemas/systemUser.json"(exports2, module2) {
1982
- module2.exports = {
1983
- $schema: "http://json-schema.org/draft-07/schema",
1984
- $id: "https://api.kohost.io/schemas/v3/systemUser.json",
1985
- title: "System User",
1986
- description: "A system user is a user that originated from an external 3rd party system.",
1987
- type: "object",
1988
- required: ["firstName", "lastName"],
1989
- properties: {
1990
- id: {
1991
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
1992
- },
1993
- type: {
1994
- type: "string",
1995
- default: "systemUser"
1996
- },
1997
- driver: {
1998
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
1999
- },
2000
- firstName: {
2001
- type: "string"
2002
- },
2003
- lastName: {
2004
- type: "string"
2005
- },
2006
- phone: {
2007
- type: ["string", "null"],
2008
- pattern: "^\\+[0-9]{1,14}$"
2009
- },
2010
- email: {
2011
- type: ["string", "null"],
2012
- format: "email"
2013
- },
2014
- address: {
2015
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/address"
2016
- },
2017
- photo: {
2018
- type: "string"
2019
- },
2020
- jobTitle: {
2021
- type: "string"
2022
- },
2023
- dob: {
2024
- type: "string"
2025
- },
2026
- gender: {
2027
- type: "string",
2028
- enum: ["male", "female"]
2029
- },
2030
- roles: {
2031
- type: "array",
2032
- items: {
2033
- type: "string",
2034
- enum: ["Guest", "User", "Manager", "Administrator", "SuperAdmin"]
2035
- }
2036
- },
2037
- nationality: {
2038
- type: "string",
2039
- minLength: 2,
2040
- maxLength: 2
2041
- },
2042
- notes: {
2043
- type: "array",
2044
- items: {
2045
- type: "string"
2046
- }
2047
- },
2048
- files: {
2049
- type: "array",
2050
- items: {
2051
- $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
2052
- }
2053
- },
2054
- identifications: {
2055
- type: "array",
2056
- items: {
2057
- $ref: "https://api.kohost.io/schemas/v3/identification.json#"
2058
- }
2059
- },
2060
- payments: {
2061
- type: "array",
2062
- items: {
2063
- $ref: "https://api.kohost.io/schemas/v3/payment.json#"
2064
- }
2065
- },
2066
- createdAt: {
2067
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
2068
- },
2069
- updatedAt: {
2070
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/updatedAt"
2071
- },
2072
- systemData: {
2073
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
2074
- }
2075
- }
2076
- };
2077
- }
2078
- });
2079
-
2080
- // src/Models/systemUser.js
2081
- var require_systemUser2 = __commonJS({
2082
- "src/Models/systemUser.js"(exports2, module2) {
2083
- var schemas = require_schema();
2084
- var schema = require_systemUser();
2085
- var Kohost = require_kohost();
2086
- schemas.add(schema);
2087
- var validator = schemas.compile(schema);
2088
- var SystemUser2 = class extends Kohost {
2089
- static {
2090
- __name(this, "SystemUser");
2091
- }
2092
- constructor(data) {
2093
- super(data);
2094
- }
2095
- static validatePhone(phoneNumber) {
2096
- const regex = /^\+?[1-9]\d{1,14}$/;
2097
- return regex.test(phoneNumber);
2098
- }
2099
- static validateEmail(email) {
2100
- 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,}))$/;
2101
- return regex.test(email);
2102
- }
2103
- };
2104
- Object.defineProperty(SystemUser2.prototype, "schema", {
2105
- value: schema
2106
- });
2107
- Object.defineProperty(SystemUser2.prototype, "validator", {
2108
- get: function() {
2109
- return validator;
2110
- }
2111
- });
2112
- Object.defineProperty(SystemUser2, "validProperties", {
2113
- value: Object.keys(schema.properties)
2114
- });
2115
- Object.defineProperty(SystemUser2.prototype, "fullName", {
2116
- get: function() {
2117
- return `${this.firstName} ${this.lastName}`;
2118
- }
2119
- });
2120
- module2.exports = SystemUser2;
2121
- }
2122
- });
2123
-
2124
- // src/schemas/courtesy.json
2125
- var require_courtesy = __commonJS({
2126
- "src/schemas/courtesy.json"(exports2, module2) {
2127
- module2.exports = {
2128
- $schema: "http://json-schema.org/draft-07/schema",
2129
- $id: "https://api.kohost.io/schemas/v3/courtesy.json",
2130
- title: "Courtesy",
2131
- description: "Any smart courtesy system",
2132
- type: "object",
2133
- properties: {
2134
- id: {
2135
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
2136
- },
2137
- name: {
2138
- type: "string"
2139
- },
2140
- type: {
2141
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
2142
- },
2143
- supportedNotifications: {
2144
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
2145
- },
2146
- notification: {
2147
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
2148
- },
2149
- driver: {
2150
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
2151
- },
2152
- supportedStates: {
2153
- type: "array",
2154
- uniqueItems: true,
2155
- items: {
2156
- enum: ["privacy", "service", "none"]
2157
- }
2158
- },
2159
- state: {
2160
- type: "string",
2161
- $ref: "#/properties/supportedStates/items"
2162
- },
2163
- systemData: {
2164
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
2165
- },
2166
- watts: {
2167
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
2168
- }
2169
- },
2170
- additionalProperties: false,
2171
- required: ["id", "type", "driver", "supportedStates", "state"]
2172
- };
2173
- }
2174
- });
2175
-
2176
- // src/Models/courtesy.js
2177
- var require_courtesy2 = __commonJS({
2178
- "src/Models/courtesy.js"(exports2, module2) {
2179
- var schemas = require_schema();
2180
- var schema = require_courtesy();
2181
- var Kohost = require_kohost();
2182
- schemas.add(schema);
2183
- var validator = schemas.compile(schema);
2184
- var Courtesy2 = class extends Kohost {
2185
- static {
2186
- __name(this, "Courtesy");
2187
- }
2188
- constructor(data) {
2189
- super(data);
2190
- }
2191
- };
2192
- Object.defineProperty(Courtesy2.prototype, "schema", {
2193
- value: schema
2194
- });
2195
- Object.defineProperty(Courtesy2.prototype, "validator", {
2196
- get: function() {
2197
- return validator;
2198
- }
2199
- });
2200
- Object.defineProperty(Courtesy2, "validProperties", {
2201
- value: Object.keys(schema.properties)
2202
- });
2203
- Object.defineProperty(Courtesy2, "actionProperties", {
2204
- value: ["state"]
2205
- });
2206
- module2.exports = Courtesy2;
2207
- }
2208
- });
2209
-
2210
- // src/schemas/camera.json
2211
- var require_camera = __commonJS({
2212
- "src/schemas/camera.json"(exports2, module2) {
2213
- module2.exports = {
2214
- $schema: "http://json-schema.org/draft-07/schema",
2215
- $id: "https://api.kohost.io/schemas/v3/camera.json",
2216
- title: "Camera",
2217
- description: "Any smart camera",
2218
- type: "object",
2219
- properties: {
2220
- id: {
2221
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
2222
- },
2223
- name: {
2224
- type: "string"
2225
- },
2226
- type: {
2227
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
2228
- },
2229
- supportedNotifications: {
2230
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
2231
- },
2232
- notification: {
2233
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
2234
- },
2235
- driver: {
2236
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
2237
- },
2238
- liveStreams: {
2239
- type: "object",
2240
- additionalProperties: false,
2241
- properties: {
2242
- iframe: {
2243
- type: ["string", "null"]
2244
- },
2245
- hls: {
2246
- type: ["string", "null"]
2247
- },
2248
- webRTC: {
2249
- type: ["string", "null"]
2250
- }
2251
- }
2252
- },
2253
- systemData: {
2254
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
2255
- },
2256
- watts: {
2257
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
2258
- }
2259
- },
2260
- additionalProperties: false,
2261
- required: ["id", "type", "systemData", "streams", "driver"]
2262
- };
2263
- }
2264
- });
2265
-
2266
- // src/Models/camera.js
2267
- var require_camera2 = __commonJS({
2268
- "src/Models/camera.js"(exports2, module2) {
2269
- var schemas = require_schema();
2270
- var schema = require_camera();
2271
- var Kohost = require_kohost();
2272
- schemas.add(schema);
2273
- var validator = schemas.compile(schema);
2274
- var Camera2 = class extends Kohost {
2275
- static {
2276
- __name(this, "Camera");
2277
- }
2278
- constructor(data) {
2279
- super(data);
2280
- }
2281
- };
2282
- Object.defineProperty(Camera2.prototype, "schema", {
2283
- value: schema
2284
- });
2285
- Object.defineProperty(Camera2.prototype, "validator", {
2286
- get: function() {
2287
- return validator;
2288
- }
2289
- });
2290
- Object.defineProperty(Camera2, "validProperties", {
2291
- value: Object.keys(schema.properties)
2292
- });
2293
- module2.exports = Camera2;
2294
- }
2295
- });
2296
-
2297
- // src/schemas/motionSensor.json
2298
- var require_motionSensor = __commonJS({
2299
- "src/schemas/motionSensor.json"(exports2, module2) {
2300
- module2.exports = {
2301
- $schema: "http://json-schema.org/draft-07/schema",
2302
- $id: "https://api.kohost.io/schemas/v3/motionSensor.json",
2303
- title: "Motion Sensor",
2304
- description: "Any smart motion sensor",
2305
- type: "object",
2306
- properties: {
2307
- id: {
2308
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
2309
- },
2310
- type: {
2311
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
2312
- },
2313
- driver: {
2314
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
2315
- },
2316
- systemData: {
2317
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
2318
- },
2319
- supportedNotifications: {
2320
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
2321
- },
2322
- notification: {
2323
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
2324
- },
2325
- watts: {
2326
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
2327
- }
2328
- },
2329
- additionalProperties: false,
2330
- required: ["id", "type", "systemData", "driver"]
2331
- };
2332
- }
2333
- });
2334
-
2335
- // src/Models/motionSensor.js
2336
- var require_motionSensor2 = __commonJS({
2337
- "src/Models/motionSensor.js"(exports2, module2) {
2338
- var schemas = require_schema();
2339
- var schema = require_motionSensor();
2340
- var Kohost = require_kohost();
2341
- schemas.add(schema);
2342
- var validator = schemas.compile(schema);
2343
- var MotionSensor2 = class extends Kohost {
2344
- static {
2345
- __name(this, "MotionSensor");
2346
- }
2347
- constructor(data) {
2348
- super(data);
2349
- }
2350
- };
2351
- Object.defineProperty(MotionSensor2.prototype, "schema", {
2352
- value: schema
2353
- });
2354
- Object.defineProperty(MotionSensor2.prototype, "validator", {
2355
- get: function() {
2356
- return validator;
2357
- }
2358
- });
2359
- Object.defineProperty(MotionSensor2, "validProperties", {
2360
- value: Object.keys(schema.properties)
2361
- });
2362
- module2.exports = MotionSensor2;
2363
- }
2364
- });
2365
-
2366
- // src/schemas/mediaSource.json
2367
- var require_mediaSource = __commonJS({
2368
- "src/schemas/mediaSource.json"(exports2, module2) {
2369
- module2.exports = {
2370
- $schema: "http://json-schema.org/draft-07/schema",
2371
- $id: "https://api.kohost.io/schemas/v3/mediaSource.json",
2372
- title: "Media Source",
2373
- description: "Any media source",
2374
- type: "object",
2375
- required: ["id", "type", "systemData", "audio", "video", "driver"],
2376
- properties: {
2377
- id: {
2378
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
2379
- },
2380
- type: {
2381
- type: "string",
2382
- enum: [
2383
- "tv",
2384
- "dvr",
2385
- "appleTv",
2386
- "discPlayer",
2387
- "mediaPlayer",
2388
- "uncontrolledDevice"
2389
- ]
2390
- },
2391
- name: {
2392
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/name"
2393
- },
2394
- driver: {
2395
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
2396
- },
2397
- audio: {
2398
- type: "boolean"
2399
- },
2400
- video: {
2401
- type: "boolean"
2402
- },
2403
- powerFeedback: {
2404
- type: "boolean"
2405
- },
2406
- volumeFeedback: {
2407
- type: "boolean"
2408
- },
2409
- muted: {
2410
- type: "boolean"
2411
- },
2412
- volume: {
2413
- type: "number",
2414
- minimum: 0,
2415
- maximum: 100
2416
- },
2417
- power: {
2418
- type: "string",
2419
- enum: ["on", "off"]
2420
- },
2421
- input: {
2422
- type: "string"
2423
- },
2424
- supportedInputs: {
2425
- type: "array",
2426
- items: {
2427
- type: "string"
2428
- }
2429
- },
2430
- command: {
2431
- type: ["string", "null"],
2432
- enum: [
2433
- "mute",
2434
- "volumeUp",
2435
- "volumeDown",
2436
- "channelUp",
2437
- "channelDown",
2438
- "number0",
2439
- "number1",
2440
- "number2",
2441
- "number3",
2442
- "number4",
2443
- "number5",
2444
- "number6",
2445
- "number7",
2446
- "number8",
2447
- "number9",
2448
- "lastChannel",
2449
- "display",
2450
- "favoriteChannel",
2451
- "play",
2452
- "stop",
2453
- "pause",
2454
- "fastForward",
2455
- "rewind",
2456
- "instantReplay",
2457
- "record",
2458
- "ac3",
2459
- "pvrMenu",
2460
- "guide",
2461
- "menu",
2462
- "menuUp",
2463
- "menuDown",
2464
- "menuLeft",
2465
- "menuRight",
2466
- "pageUp",
2467
- "pageDown",
2468
- "select",
2469
- "exit",
2470
- "input",
2471
- "power",
2472
- "enterChannel",
2473
- "enterVolume",
2474
- "number10",
2475
- "number11",
2476
- "number12",
2477
- "number13",
2478
- "number14",
2479
- "number15",
2480
- "number16",
2481
- "number10Plus",
2482
- "number20Plus",
2483
- "number100",
2484
- "dash",
2485
- "threeChan",
2486
- "threeD",
2487
- "sixChan",
2488
- "a",
2489
- "add",
2490
- "alarm",
2491
- "am",
2492
- "analog",
2493
- "angle",
2494
- "antenna",
2495
- "antennaEast",
2496
- "antennaWest",
2497
- "aspect",
2498
- "audio1",
2499
- "audio2",
2500
- "audio3",
2501
- "audioDumming",
2502
- "audioLevelDown",
2503
- "audioLevelUp",
2504
- "b",
2505
- "back",
2506
- "c",
2507
- "component1",
2508
- "component2",
2509
- "component3",
2510
- "d",
2511
- "home",
2512
- "list",
2513
- "liveTv",
2514
- "discreteInputCable",
2515
- "powerOff",
2516
- "powerOn",
2517
- "setupMenu",
2518
- "skipForward",
2519
- "skipReverse",
2520
- "video1",
2521
- "video2",
2522
- "video3",
2523
- "video4",
2524
- "video5",
2525
- "details",
2526
- "hdmi1",
2527
- "hdmi2",
2528
- "hdmi3",
2529
- "cecDeviceList",
2530
- "mtsSap",
2531
- "red",
2532
- "green",
2533
- "yellow",
2534
- "blue",
2535
- "alert"
2536
- ]
2537
- },
2538
- supportedNotifications: {
2539
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
2540
- },
2541
- notification: {
2542
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
2543
- },
2544
- systemData: {
2545
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
2546
- },
2547
- watts: {
2548
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
2549
- }
2550
- },
2551
- additionalProperties: false
2552
- };
2553
- }
2554
- });
2555
-
2556
- // src/Models/mediaSource.js
2557
- var require_mediaSource2 = __commonJS({
2558
- "src/Models/mediaSource.js"(exports2, module2) {
2559
- var schemas = require_schema();
2560
- var schema = require_mediaSource();
2561
- var Kohost = require_kohost();
2562
- schemas.add(schema);
2563
- var validator = schemas.compile(schema);
2564
- var MediaSource2 = class extends Kohost {
2565
- static {
2566
- __name(this, "MediaSource");
2567
- }
2568
- constructor(data) {
2569
- super(data);
2570
- }
2571
- };
2572
- Object.defineProperty(MediaSource2.prototype, "schema", {
2573
- value: schema
2574
- });
2575
- Object.defineProperty(MediaSource2.prototype, "validator", {
2576
- get: function() {
2577
- return validator;
2578
- }
2579
- });
2580
- Object.defineProperty(MediaSource2, "validProperties", {
2581
- value: Object.keys(schema.properties)
2582
- });
2583
- module2.exports = MediaSource2;
2584
- }
2585
- });
2586
-
2587
- // src/schemas/room.json
2588
- var require_room = __commonJS({
2589
- "src/schemas/room.json"(exports2, module2) {
2590
- module2.exports = {
2591
- $schema: "http://json-schema.org/draft-07/schema",
2592
- $id: "https://api.kohost.io/schemas/v3/room.json",
2593
- title: "Room",
2594
- description: "A room represents a physical space of controllable IoT devices",
2595
- type: "object",
2596
- properties: {
2597
- id: {
2598
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2599
- },
2600
- name: {
2601
- type: "string"
2602
- },
2603
- floor: {
2604
- type: "string"
2605
- },
2606
- dimmers: {
2607
- type: "array",
2608
- default: [],
2609
- items: {
2610
- $ref: "https://api.kohost.io/schemas/v3/dimmer.json"
2611
- }
2612
- },
2613
- switches: {
2614
- type: "array",
2615
- default: [],
2616
- items: {
2617
- $ref: "https://api.kohost.io/schemas/v3/switch.json"
2618
- }
2619
- },
2620
- thermostats: {
2621
- type: "array",
2622
- default: [],
2623
- items: {
2624
- $ref: "https://api.kohost.io/schemas/v3/thermostat.json"
2625
- }
2626
- },
2627
- locks: {
2628
- type: "array",
2629
- default: [],
2630
- items: {
2631
- $ref: "https://api.kohost.io/schemas/v3/lock.json"
2632
- }
2633
- },
2634
- windowCoverings: {
2635
- type: "array",
2636
- default: [],
2637
- items: {
2638
- $ref: "https://api.kohost.io/schemas/v3/windowCovering.json"
2639
- }
2640
- },
2641
- courtesy: {
2642
- type: "array",
2643
- default: [],
2644
- items: {
2645
- $ref: "https://api.kohost.io/schemas/v3/courtesy.json"
2646
- }
2647
- },
2648
- cameras: {
2649
- type: "array",
2650
- default: [],
2651
- items: {
2652
- $ref: "https://api.kohost.io/schemas/v3/camera.json"
2653
- }
2654
- },
2655
- mediaSources: {
2656
- type: "array",
2657
- default: [],
2658
- items: {
2659
- $ref: "https://api.kohost.io/schemas/v3/mediaSource.json"
2660
- }
2661
- },
2662
- motionSensors: {
2663
- type: "array",
2664
- default: [],
2665
- items: {
2666
- $ref: "https://api.kohost.io/schemas/v3/motionSensor.json"
2667
- }
2668
- },
2669
- alarms: {
2670
- type: "array",
2671
- default: [],
2672
- items: {
2673
- $ref: "https://api.kohost.io/schemas/v3/alarm.json"
2674
- }
2675
- },
2676
- occupiedAt: {
2677
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
2678
- },
2679
- createdAt: {
2680
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
2681
- },
2682
- updatedAt: {
2683
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/updatedAt"
2684
- }
2685
- },
2686
- additionalProperties: false
2687
- };
2688
- }
2689
- });
2690
-
2691
- // src/schemas/scene.json
2692
- var require_scene = __commonJS({
2693
- "src/schemas/scene.json"(exports2, module2) {
2694
- module2.exports = {
2695
- $schema: "http://json-schema.org/draft-07/schema",
2696
- $id: "https://api.kohost.io/schemas/v3/scene.json",
2697
- title: "Scene",
2698
- description: "A room represents a physical space of controllable IoT devices",
2699
- type: "object",
2700
- properties: {
2701
- id: {
2702
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2703
- },
2704
- name: {
2705
- type: "string"
2706
- },
2707
- devices: {
2708
- type: "object",
2709
- properties: {
2710
- switches: {
2711
- type: "array",
2712
- items: {
2713
- type: "object",
2714
- properties: {
2715
- id: {
2716
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2717
- },
2718
- state: {
2719
- $ref: "https://api.kohost.io/schemas/v3/switch.json#/properties/state"
2720
- }
2721
- },
2722
- default: []
2723
- }
2724
- },
2725
- dimmers: {
2726
- type: "array",
2727
- items: {
2728
- type: "object",
2729
- properties: {
2730
- id: {
2731
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2732
- },
2733
- level: {
2734
- $ref: "https://api.kohost.io/schemas/v3/dimmer.json#/properties/level"
2735
- }
2736
- }
2737
- },
2738
- default: []
2739
- },
2740
- windowCoverings: {
2741
- type: "array",
2742
- items: {
2743
- type: "object",
2744
- properties: {
2745
- id: {
2746
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2747
- },
2748
- position: {
2749
- $ref: "https://api.kohost.io/schemas/v3/windowCovering.json#/properties/position"
2750
- }
2751
- }
2752
- },
2753
- default: []
2754
- },
2755
- thermostats: {
2756
- type: "array",
2757
- items: {
2758
- type: "object",
2759
- properties: {
2760
- id: {
2761
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2762
- },
2763
- hvacMode: {
2764
- $ref: "https://api.kohost.io/schemas/v3/thermostat.json#/properties/hvacMode"
2765
- },
2766
- setpoints: {
2767
- $ref: "https://api.kohost.io/schemas/v3/thermostat.json#/properties/setpoints"
2768
- },
2769
- fanMode: {
2770
- $ref: "https://api.kohost.io/schemas/v3/thermostat.json#/properties/fanMode"
2771
- },
2772
- setpointDelta: {
2773
- type: "number"
2774
- }
2775
- }
2776
- },
2777
- default: []
2778
- },
2779
- mediaSources: {
2780
- type: "array",
2781
- items: {
2782
- type: "object",
2783
- properties: {
2784
- id: {
2785
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
2786
- },
2787
- volume: {
2788
- type: "number",
2789
- minimum: 0,
2790
- maximum: 100
2791
- },
2792
- commands: {
2793
- type: "array",
2794
- items: {
2795
- type: "string"
2796
- }
2797
- }
2798
- }
2799
- }
2800
- }
2801
- },
2802
- additionalProperties: false
2803
- },
2804
- isDefault: {
2805
- type: "boolean",
2806
- default: false
2807
- },
2808
- showOnUi: {
2809
- type: "boolean",
2810
- default: true
2811
- }
2812
- },
2813
- additionalProperties: false
2814
- };
2815
- }
2816
- });
2817
-
2818
- // src/Commands/Command.js
2819
- var require_Command = __commonJS({
2820
- "src/Commands/Command.js"(exports2, module2) {
2821
- var Command = class {
2822
- static {
2823
- __name(this, "Command");
2824
- }
2825
- constructor(data) {
2826
- this.data = {};
2827
- if (!data)
2828
- throw new Error("Command data is required");
2829
- if (typeof data !== "object")
2830
- throw new Error("Command data must be an object");
2831
- for (const key in data) {
2832
- this.data[key] = data[key];
2833
- }
2834
- }
2835
- get name() {
2836
- throw new Error("Command name is required");
2837
- }
2838
- get type() {
2839
- return "Command";
2840
- }
2841
- get routingKey() {
2842
- return "";
2843
- }
2844
- get exchange() {
2845
- return "Commands";
2846
- }
2847
- build() {
2848
- return { data: { ...this.data } };
2849
- }
2850
- };
2851
- module2.exports = Command;
2852
- }
2853
- });
2854
-
2855
- // src/Commands/SetSceneCommand.js
2856
- var require_SetSceneCommand = __commonJS({
2857
- "src/Commands/SetSceneCommand.js"(exports2, module2) {
2858
- var Command = require_Command();
2859
- var SetSceneCommand = class extends Command {
2860
- static {
2861
- __name(this, "SetSceneCommand");
2862
- }
2863
- constructor({ id, devices, ...rest }) {
2864
- super({ id, devices, ...rest });
2865
- }
2866
- get name() {
2867
- return "SetScene";
2868
- }
2869
- get routingKey() {
2870
- return `scene.${this.data.id}.set`;
2871
- }
2872
- };
2873
- module2.exports = SetSceneCommand;
2874
- }
2875
- });
2876
-
2877
- // src/Models/scene.js
2878
- var require_scene2 = __commonJS({
2879
- "src/Models/scene.js"(exports2, module2) {
2880
- var schemas = require_schema();
2881
- var schema = require_scene();
2882
- var Kohost = require_kohost();
2883
- var SetSceneCommand = require_SetSceneCommand();
2884
- schemas.add(schema);
2885
- var validator = schemas.compile(schema);
2886
- var Scene2 = class extends Kohost {
2887
- static {
2888
- __name(this, "Scene");
2889
- }
2890
- constructor(data) {
2891
- super(data);
2892
- }
2893
- static createSceneCommandPayload(room, scene) {
2894
- const commandsByDriver = [];
2895
- const sceneDevices = scene?.devices || {};
2896
- const sceneId = scene.id;
2897
- for (const deviceType in sceneDevices) {
2898
- const sceneData = sceneDevices[deviceType];
2899
- const roomDevices = room[deviceType];
2900
- for (const data of sceneData) {
2901
- const { id, ...deviceProps } = data;
2902
- if (id === "*") {
2903
- for (const device of roomDevices) {
2904
- const driver = device.driver;
2905
- const deviceCmd = {
2906
- id: device.systemData?.id
2907
- };
2908
- for (const prop in deviceProps) {
2909
- if (prop === "setpointDelta") {
2910
- const delta = deviceProps[prop];
2911
- const currentMode = device.hvacMode;
2912
- const setpoints = device.setpoints;
2913
- const minAutoDelta = device.minAutoDelta;
2914
- const currentSetpoint = setpoints[currentMode];
2915
- if (currentMode === "heat") {
2916
- const setpointValue = Math.min(
2917
- currentSetpoint.min,
2918
- currentSetpoint.value - delta
2919
- );
2920
- deviceCmd.setpoints = {
2921
- heat: {
2922
- value: setpointValue
2923
- }
2924
- };
2925
- }
2926
- if (currentMode === "cool") {
2927
- const setpointValue = Math.max(
2928
- currentSetpoint.max,
2929
- currentSetpoint.value + delta
2930
- );
2931
- deviceCmd.setpoints = {
2932
- cool: {
2933
- value: setpointValue
2934
- }
2935
- };
2936
- }
2937
- if (currentMode === "auto") {
2938
- if (!currentSetpoint && setpoints.cool && setpoints.heat) {
2939
- const heatSetpoint = Math.min(
2940
- setpoints.heat.min,
2941
- setpoints.heat.value - delta
2942
- );
2943
- const coolSetpoint = Math.max(
2944
- setpoints.cool.max,
2945
- setpoints.cool.value + delta
2946
- );
2947
- if (Math.abs(heatSetpoint - coolSetpoint) < minAutoDelta) {
2948
- continue;
2949
- }
2950
- deviceCmd.setpoints = {
2951
- heat: {
2952
- value: heatSetpoint
2953
- },
2954
- cool: {
2955
- value: coolSetpoint
2956
- }
2957
- };
2958
- }
2959
- }
2960
- if (currentMode === "off") {
2961
- continue;
2962
- }
2963
- } else {
2964
- deviceCmd[prop] = deviceProps[prop];
2965
- }
2966
- }
2967
- if (Object.keys(deviceCmd).length === 1) {
2968
- continue;
2969
- }
2970
- const driverIndex = commandsByDriver.findIndex(
2971
- (c) => c.driver === driver
2972
- );
2973
- if (driverIndex >= 0) {
2974
- commandsByDriver[driverIndex].command.devices.push(deviceCmd);
2975
- } else {
2976
- commandsByDriver.push({
2977
- driver,
2978
- command: {
2979
- id: sceneId,
2980
- devices: [deviceCmd]
2981
- }
2982
- });
2983
- }
2984
- }
2985
- }
2986
- }
2987
- }
2988
- const commands = commandsByDriver.map((c) => {
2989
- const command = new SetSceneCommand(c.command);
2990
- return {
2991
- driver: c.driver,
2992
- command
2993
- };
2994
- });
2995
- return commands;
2996
- }
2997
- };
2998
- Object.defineProperty(Scene2.prototype, "schema", {
2999
- value: schema
3000
- });
3001
- Object.defineProperty(Scene2.prototype, "validator", {
3002
- get: function() {
3003
- return validator;
3004
- }
3005
- });
3006
- Object.defineProperty(Scene2, "validProperties", {
3007
- value: Object.keys(schema.properties)
3008
- });
3009
- module2.exports = Scene2;
3010
- }
3011
- });
3012
-
3013
- // src/Models/room.js
3014
- var require_room2 = __commonJS({
3015
- "src/Models/room.js"(exports2, module2) {
3016
- var schemas = require_schema();
3017
- var schema = require_room();
3018
- var deviceSchema = require_device();
3019
- var Kohost = require_kohost();
3020
- var cloneDeep = require("lodash.clonedeep");
3021
- var Switch2 = require_switch2();
3022
- var Dimmer2 = require_dimmer2();
3023
- var Thermostat2 = require_thermostat2();
3024
- var Lock2 = require_lock2();
3025
- var WindowCovering2 = require_windowCovering2();
3026
- var Courtesy2 = require_courtesy2();
3027
- var Camera2 = require_camera2();
3028
- var Alarm2 = require_alarm2();
3029
- var MediaSource2 = require_mediaSource2();
3030
- var MotionSensor2 = require_motionSensor2();
3031
- var Scene2 = require_scene2();
3032
- schemas.add(schema);
3033
- var validator = schemas.compile(schema);
3034
- var Room2 = class extends Kohost {
3035
- static {
3036
- __name(this, "Room");
3037
- }
3038
- constructor(data) {
3039
- const roomData = mapRoomData(data);
3040
- super(roomData);
3041
- }
3042
- static getDevicePath(type) {
3043
- const validTypes = deviceSchema.definitions.type.enum;
3044
- if (!validTypes.includes(type))
3045
- throw new Error("Invalid device type:" + type);
3046
- switch (type) {
3047
- case "tv":
3048
- case "dvr":
3049
- case "appleTv":
3050
- case "discPlayer":
3051
- case "mediaPlayer":
3052
- case "uncontrolledDevice":
3053
- case "mediaSource":
3054
- return "mediaSources";
3055
- case "courtesy":
3056
- return type;
3057
- case "switch":
3058
- return "switches";
3059
- default:
3060
- return `${type}s`;
3061
- }
3062
- }
3063
- static getDeviceTypeFromPath(path) {
3064
- const validPaths = [
3065
- "dimmers",
3066
- "switches",
3067
- "thermostats",
3068
- "locks",
3069
- "windowCoverings",
3070
- "courtesy",
3071
- "cameras",
3072
- "mediaSources",
3073
- "motionSensors",
3074
- "alarms"
3075
- ];
3076
- if (!validPaths.includes(path))
3077
- throw new Error("Invalid device path:" + path);
3078
- switch (path) {
3079
- case "courtesy":
3080
- return path;
3081
- case "switches":
3082
- return "switch";
3083
- default:
3084
- return path.slice(0, -1);
3085
- }
3086
- }
3087
- get hasDimmer() {
3088
- return this.dimmers?.length > 0;
3089
- }
3090
- get hasSwitch() {
3091
- return this.switches?.length > 0;
3092
- }
3093
- get hasWindowCovering() {
3094
- return this.windowCoverings?.length > 0;
3095
- }
3096
- get hasShade() {
3097
- return this.hasWindowCovering;
3098
- }
3099
- get hasThermostat() {
3100
- return this.thermostats?.length > 0;
3101
- }
3102
- get hasClimate() {
3103
- return this.hasThermostat;
3104
- }
3105
- get hasLock() {
3106
- return this.locks?.length > 0;
3107
- }
3108
- get hasCourtesy() {
3109
- return this.courtesy?.length > 0;
3110
- }
3111
- get hasCamera() {
3112
- return this.cameras?.length > 0;
3113
- }
3114
- get hasAlarm() {
3115
- return this.alarms?.length > 0;
3116
- }
3117
- get hasMedia() {
3118
- return this.mediaSources?.length > 0;
3119
- }
3120
- get hasLight() {
3121
- const hasSubTypeLight = this.switches?.some((sw) => {
3122
- return sw.subType === "light" || sw.subType === "fan";
3123
- });
3124
- return this.hasDimmer || hasSubTypeLight;
3125
- }
3126
- get occupied() {
3127
- const now = /* @__PURE__ */ new Date();
3128
- const lastOccupied = new Date(this.occupiedAt);
3129
- const diff = now - lastOccupied;
3130
- return diff < 60 * 60 * 1e3;
3131
- }
3132
- };
3133
- Object.defineProperty(Room2.prototype, "schema", {
3134
- value: schema
3135
- });
3136
- Object.defineProperty(Room2.prototype, "validator", {
3137
- get: function() {
3138
- return validator;
3139
- }
3140
- });
3141
- Object.defineProperty(Room2, "validProperties", {
3142
- value: Object.keys(schema.properties)
3143
- });
3144
- function mapRoomData(data) {
3145
- const roomData = cloneDeep(data);
3146
- roomData.dimmers?.map((dimmer) => {
3147
- if (dimmer instanceof Dimmer2)
3148
- return dimmer;
3149
- else
3150
- return new Dimmer2(dimmer);
3151
- });
3152
- roomData.switches?.map((switch_) => {
3153
- if (switch_ instanceof Switch2)
3154
- return switch_;
3155
- else
3156
- return new Switch2(switch_);
3157
- });
3158
- roomData.windowCoverings?.map((windowCovering) => {
3159
- if (windowCovering instanceof WindowCovering2)
3160
- return windowCovering;
3161
- else
3162
- return new WindowCovering2(windowCovering);
3163
- });
3164
- roomData.thermostats?.map((thermostat) => {
3165
- if (thermostat instanceof Thermostat2)
3166
- return thermostat;
3167
- else
3168
- return new Thermostat2(thermostat);
3169
- });
3170
- roomData.locks?.map((lock) => {
3171
- if (lock instanceof Lock2)
3172
- return lock;
3173
- else
3174
- return new Lock2(lock);
3175
- });
3176
- roomData.courtesy?.map((courtesy) => {
3177
- if (courtesy instanceof Courtesy2)
3178
- return courtesy;
3179
- else
3180
- return new Courtesy2(courtesy);
3181
- });
3182
- roomData.mediaSources?.map((source) => {
3183
- if (source instanceof MediaSource2)
3184
- return source;
3185
- else
3186
- return new MediaSource2(source);
3187
- });
3188
- roomData.cameras?.map((camera) => {
3189
- if (camera instanceof Camera2)
3190
- return camera;
3191
- else
3192
- return new Camera2(camera);
3193
- });
3194
- roomData.alarms?.map((alarm) => {
3195
- if (alarm instanceof Alarm2)
3196
- return alarm;
3197
- else
3198
- return new Alarm2(alarm);
3199
- });
3200
- roomData.motionSensors?.map((motionSensor) => {
3201
- if (motionSensor instanceof MotionSensor2)
3202
- return motionSensor;
3203
- else
3204
- return new MotionSensor2(motionSensor);
3205
- });
3206
- roomData.scenes?.map((scene) => {
3207
- if (scene instanceof Scene2)
3208
- return scene;
3209
- else
3210
- return new Scene2(scene);
3211
- });
3212
- return roomData;
3213
- }
3214
- __name(mapRoomData, "mapRoomData");
3215
- module2.exports = Room2;
3216
- }
3217
- });
3218
-
3219
- // src/schemas/space.json
3220
- var require_space = __commonJS({
3221
- "src/schemas/space.json"(exports2, module2) {
3222
- module2.exports = {
3223
- $schema: "http://json-schema.org/draft-07/schema",
3224
- $id: "https://api.kohost.io/schemas/v3/space.json",
3225
- title: "Space",
3226
- type: "object",
3227
- properties: {
3228
- id: {
3229
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3230
- },
3231
- name: {
3232
- type: "string",
3233
- minLength: 1
3234
- },
3235
- type: {
3236
- type: ["string"],
3237
- enum: [
3238
- "classRoom",
3239
- "hotelRoom",
3240
- "office",
3241
- "building",
3242
- "commonArea",
3243
- "other"
3244
- ]
3245
- },
3246
- driver: {
3247
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
3248
- },
3249
- subType: {
3250
- type: "string"
3251
- },
3252
- rooms: {
3253
- type: "array",
3254
- items: {
3255
- type: "string"
3256
- }
3257
- },
3258
- subGroups: {
3259
- type: "array",
3260
- items: {
3261
- type: "string"
3262
- }
3263
- },
3264
- occupied: {
3265
- type: "boolean"
3266
- },
3267
- eco: {
3268
- type: "object",
3269
- additionalProperties: false,
3270
- default: {
3271
- active: false,
3272
- allowed: false
3273
- },
3274
- properties: {
3275
- active: {
3276
- type: "boolean",
3277
- default: false
3278
- },
3279
- activatedAt: {
3280
- type: "string",
3281
- format: "date-time"
3282
- },
3283
- allowed: {
3284
- type: "boolean",
3285
- default: false
3286
- }
3287
- }
3288
- },
3289
- features: {
3290
- type: "array",
3291
- items: {
3292
- type: "string"
3293
- }
3294
- },
3295
- maximumOccupancy: {
3296
- type: "number",
3297
- minimum: 1
3298
- },
3299
- housekeepingStatus: {
3300
- type: "string",
3301
- enum: ["clean", "dirty", "inspected", "pickup"]
3302
- },
3303
- serviceStatus: {
3304
- type: "string",
3305
- enum: ["inService", "outOfOrder", "outOfService"]
3306
- },
3307
- systemData: {
3308
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
3309
- }
3310
- },
3311
- if: {
3312
- properties: { type: { const: "hotelRoom" } }
3313
- },
3314
- then: {
3315
- required: [
3316
- "name",
3317
- "type",
3318
- "features",
3319
- "maximumOccupancy",
3320
- "housekeepingStatus",
3321
- "serviceStatus"
3322
- ],
3323
- properties: {
3324
- features: {
3325
- default: []
3326
- },
3327
- maximumOccupancy: {
3328
- default: 2
3329
- },
3330
- housekeepingStatus: {
3331
- default: "dirty"
3332
- },
3333
- serviceStatus: {
3334
- default: "inService"
3335
- }
3336
- }
3337
- },
3338
- else: {
3339
- required: ["name", "type"]
3340
- }
3341
- };
3342
- }
3343
- });
3344
-
3345
- // src/Models/space.js
3346
- var require_space2 = __commonJS({
3347
- "src/Models/space.js"(exports2, module2) {
3348
- var schemas = require_schema();
3349
- var schema = require_space();
3350
- var Kohost = require_kohost();
3351
- var cloneDeep = require("lodash.clonedeep");
3352
- var Room2 = require_room2();
3353
- schemas.add(schema);
3354
- var validator = schemas.compile(schema);
3355
- var Space2 = class extends Kohost {
3356
- static {
3357
- __name(this, "Space");
3358
- }
3359
- constructor(data) {
3360
- const spaceData = mapSpaceData(data);
3361
- super(spaceData);
3362
- }
3363
- get floor() {
3364
- const floors = /* @__PURE__ */ new Set();
3365
- this.room.forEach((room) => {
3366
- if (room.floor)
3367
- floors.add(room.floor);
3368
- });
3369
- return floors.size == 1 ? [...floors][0] : void 0;
3370
- }
3371
- get hasDimmer() {
3372
- return this.rooms.some((room) => room.hasDimmer);
3373
- }
3374
- get hasSwitch() {
3375
- return this.rooms.some((room) => room.hasSwitch);
3376
- }
3377
- get hasWindowCovering() {
3378
- return this.rooms.some((room) => room.hasWindowCovering);
3379
- }
3380
- get hasThermostat() {
3381
- return this.rooms.some((room) => room.hasThermostat);
3382
- }
3383
- get hasLock() {
3384
- return this.rooms.some((room) => room.hasLock);
3385
- }
3386
- get hasCourtesy() {
3387
- return this.rooms.some((room) => room.hasCourtesy);
3388
- }
3389
- get hasCamera() {
3390
- return this.rooms.some((room) => room.hasCamera);
3391
- }
3392
- get hasAlarm() {
3393
- return this.rooms.some((room) => room.hasAlarm);
3394
- }
3395
- get hasMedia() {
3396
- return this.rooms.some((room) => room.hasMedia);
3397
- }
3398
- };
3399
- Object.defineProperty(Space2.prototype, "schema", {
3400
- value: schema
3401
- });
3402
- Object.defineProperty(Space2.prototype, "validator", {
3403
- get: function() {
3404
- return validator;
3405
- }
3406
- });
3407
- Object.defineProperty(Space2, "validProperties", {
3408
- value: Object.keys(schema.properties)
3409
- });
3410
- function mapSpaceData(data) {
3411
- const spaceData = cloneDeep(data);
3412
- if (spaceData.rooms?.length) {
3413
- spaceData.rooms.map((room) => {
3414
- if (typeof room === "string")
3415
- return room;
3416
- if (room instanceof Room2)
3417
- return room;
3418
- return new Room2(room);
3419
- });
3420
- }
3421
- return spaceData;
3422
- }
3423
- __name(mapSpaceData, "mapSpaceData");
3424
- module2.exports = Space2;
3425
- }
3426
- });
3427
-
3428
- // src/schemas/spaceType.json
3429
- var require_spaceType = __commonJS({
3430
- "src/schemas/spaceType.json"(exports2, module2) {
3431
- module2.exports = {
3432
- $schema: "http://json-schema.org/draft-07/schema",
3433
- $id: "https://api.kohost.io/schemas/v3/spaceType.json",
3434
- title: "Space Type",
3435
- type: "object",
3436
- properties: {
3437
- id: {
3438
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3439
- },
3440
- type: {
3441
- type: "string"
3442
- },
3443
- name: {
3444
- type: "string",
3445
- minLength: 1
3446
- },
3447
- driver: {
3448
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
3449
- },
3450
- description: {
3451
- type: "string"
3452
- },
3453
- image: {
3454
- $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
3455
- },
3456
- systemData: {
3457
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
3458
- }
3459
- }
3460
- };
3461
- }
3462
- });
3463
-
3464
- // src/Models/spaceType.js
3465
- var require_spaceType2 = __commonJS({
3466
- "src/Models/spaceType.js"(exports2, module2) {
3467
- var schemas = require_schema();
3468
- var schema = require_spaceType();
3469
- var Kohost = require_kohost();
3470
- schemas.add(schema);
3471
- var validator = schemas.compile(schema);
3472
- var SpaceType2 = class extends Kohost {
3473
- static {
3474
- __name(this, "SpaceType");
3475
- }
3476
- constructor(data) {
3477
- super(data);
3478
- }
3479
- };
3480
- Object.defineProperty(SpaceType2.prototype, "schema", {
3481
- value: schema
3482
- });
3483
- Object.defineProperty(SpaceType2.prototype, "validator", {
3484
- get: function() {
3485
- return validator;
3486
- }
3487
- });
3488
- Object.defineProperty(SpaceType2, "validProperties", {
3489
- value: Object.keys(schema.properties)
3490
- });
3491
- module2.exports = SpaceType2;
3492
- }
3493
- });
3494
-
3495
- // src/schemas/ticket.json
3496
- var require_ticket = __commonJS({
3497
- "src/schemas/ticket.json"(exports2, module2) {
3498
- module2.exports = {
3499
- $schema: "http://json-schema.org/draft-07/schema",
3500
- $id: "https://api.kohost.io/schemas/v3/ticket.json",
3501
- title: "Ticket",
3502
- description: "A ticket is a request for help from a user.",
3503
- type: "object",
3504
- properties: {
3505
- id: {
3506
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3507
- },
3508
- conversation: {
3509
- type: "array",
3510
- default: [],
3511
- items: {
3512
- type: "object",
3513
- additionalProperties: false,
3514
- properties: {
3515
- id: {
3516
- type: "string"
3517
- },
3518
- userId: {
3519
- type: "string"
3520
- },
3521
- userName: {
3522
- type: "string"
3523
- },
3524
- timestamp: {
3525
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
3526
- },
3527
- body: {
3528
- type: "string"
3529
- },
3530
- readBy: {
3531
- type: "array",
3532
- default: [],
3533
- items: {
3534
- type: "string"
3535
- }
3536
- },
3537
- media: {
3538
- $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
3539
- }
3540
- },
3541
- required: ["userId", "id", "timestamp", "body"]
3542
- }
3543
- },
3544
- requester: {
3545
- type: "string"
3546
- },
3547
- assignedTo: {
3548
- type: ["string", "null"]
3549
- },
3550
- status: {
3551
- type: "string",
3552
- enum: ["open", "pending", "solved", "closed"],
3553
- default: "open"
3554
- },
3555
- tags: {
3556
- type: "array",
3557
- default: [],
3558
- items: {
3559
- type: "string"
3560
- }
3561
- },
3562
- rating: {
3563
- type: "number",
3564
- minimum: 0,
3565
- maximum: 5
3566
- },
3567
- ratingComment: {
3568
- type: "string"
3569
- },
3570
- createdAt: {
3571
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3572
- },
3573
- updatedAt: {
3574
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3575
- },
3576
- solvedAt: {
3577
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3578
- },
3579
- closedAt: {
3580
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
3581
- }
3582
- },
3583
- required: [
3584
- "id",
3585
- "conversation",
3586
- "requester",
3587
- "status",
3588
- "tags",
3589
- "createdAt",
3590
- "updatedAt"
3591
- ],
3592
- additionalProperties: false
3593
- };
3594
- }
3595
- });
3596
-
3597
- // src/Models/ticket.js
3598
- var require_ticket2 = __commonJS({
3599
- "src/Models/ticket.js"(exports2, module2) {
3600
- var schemas = require_schema();
3601
- var schema = require_ticket();
3602
- var Kohost = require_kohost();
3603
- var MediaFile2 = require_mediaFile2();
3604
- var sortBy = require("lodash.sortby");
3605
- var findLast = require("lodash.findlast");
3606
- var { nanoid } = require("nanoid");
3607
- var cloneDeep = require("lodash.clonedeep");
3608
- schemas.add(schema);
3609
- var validator = schemas.compile(schema);
3610
- var Ticket2 = class extends Kohost {
3611
- static {
3612
- __name(this, "Ticket");
3613
- }
3614
- constructor(data) {
3615
- const ticketData = mapConversationData(data);
3616
- super(ticketData);
3617
- }
3618
- static generateMessageId(len = 16) {
3619
- return nanoid(len);
3620
- }
3621
- };
3622
- Object.defineProperty(Ticket2.prototype, "schema", {
3623
- value: schema
3624
- });
3625
- Object.defineProperty(Ticket2.prototype, "validator", {
3626
- get: function() {
3627
- return validator;
3628
- }
3629
- });
3630
- Object.defineProperty(Ticket2, "validProperties", {
3631
- value: Object.keys(schema.properties)
3632
- });
3633
- Object.defineProperty(Ticket2.prototype, "responseTime", {
3634
- get: function() {
3635
- const conversation = this.conversation;
3636
- const requester = this.requester;
3637
- if (conversation.length === 0)
3638
- return 0;
3639
- const mapped = conversation.map((msg) => {
3640
- if (typeof msg.timestamp === "string")
3641
- msg.timestamp = new Date(msg.timestamp);
3642
- return msg;
3643
- });
3644
- const sorted = sortBy(mapped, ["timestamp"]);
3645
- const firstMsg = sorted.find((entry) => entry.userId === requester);
3646
- const firstResponse = sorted.find((entry) => entry.userId !== requester);
3647
- if (firstMsg && firstResponse) {
3648
- const firstMsgTime = firstMsg.timestamp.getTime() / 1e3;
3649
- const firstResponseTime = firstResponse.timestamp.getTime() / 1e3;
3650
- return firstResponseTime - firstMsgTime;
3651
- }
3652
- return 0;
3653
- }
3654
- });
3655
- Object.defineProperty(Ticket2.prototype, "resolutionTime", {
3656
- get: function() {
3657
- if (this.status !== "closed")
3658
- return 0;
3659
- const createdAt = this.createdAt.getTime() / 1e3;
3660
- const solvedAt = this.solvedAt ? this.solvedAt.getTime() / 1e3 : this.updatedAt.getTime() / 1e3;
3661
- return Math.abs(solvedAt - createdAt);
3662
- }
3663
- });
3664
- Object.defineProperty(Ticket2.prototype, "lastResponder", {
3665
- get: function() {
3666
- const conversation = this.conversation;
3667
- const requester = this.requester;
3668
- const sorted = sortBy(conversation, ["timestamp"]);
3669
- const lastFromNonRequester = findLast(sorted, function(c) {
3670
- return c.userId !== requester;
3671
- });
3672
- if (!lastFromNonRequester)
3673
- return null;
3674
- else
3675
- return lastFromNonRequester.userId;
3676
- }
3677
- });
3678
- function mapConversationData(data) {
3679
- const ticketData = cloneDeep(data);
3680
- ticketData.conversation = ticketData.conversation.map((msg) => {
3681
- if (msg.media) {
3682
- msg.media = new MediaFile2(msg.media);
3683
- }
3684
- return msg;
3685
- });
3686
- return ticketData;
3687
- }
3688
- __name(mapConversationData, "mapConversationData");
3689
- module2.exports = Ticket2;
3690
- }
3691
- });
3692
-
3693
- // src/schemas/gateway.json
3694
- var require_gateway = __commonJS({
3695
- "src/schemas/gateway.json"(exports2, module2) {
3696
- module2.exports = {
3697
- $schema: "http://json-schema.org/draft-07/schema",
3698
- $id: "https://api.kohost.io/schemas/v3/iotGateway.json",
3699
- title: "IoT Gateway",
3700
- description: "Any smart gateway that is an entrypoint for controlling devices",
3701
- type: "object",
3702
- properties: {
3703
- id: {
3704
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
3705
- },
3706
- type: {
3707
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
3708
- },
3709
- supportedNotifications: {
3710
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
3711
- },
3712
- notification: {
3713
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
3714
- },
3715
- status: {
3716
- type: "string"
3717
- },
3718
- systemData: {
3719
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
3720
- },
3721
- driver: {
3722
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
3723
- },
3724
- watts: {
3725
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
3726
- }
3727
- },
3728
- additionalProperties: false,
3729
- required: ["id", "type", "systemData", "status", "driver"]
3730
- };
3731
- }
3732
- });
3733
-
3734
- // src/Models/gateway.js
3735
- var require_gateway2 = __commonJS({
3736
- "src/Models/gateway.js"(exports2, module2) {
3737
- var schemas = require_schema();
3738
- var schema = require_gateway();
3739
- var Kohost = require_kohost();
3740
- schemas.add(schema);
3741
- var validator = schemas.compile(schema);
3742
- var Gateway2 = class extends Kohost {
3743
- static {
3744
- __name(this, "Gateway");
3745
- }
3746
- constructor(data) {
3747
- super(data);
3748
- }
3749
- };
3750
- Object.defineProperty(Gateway2.prototype, "schema", {
3751
- value: schema
3752
- });
3753
- Object.defineProperty(Gateway2.prototype, "validator", {
3754
- get: function() {
3755
- return validator;
3756
- }
3757
- });
3758
- Object.defineProperty(Gateway2, "validProperties", {
3759
- value: Object.keys(schema.properties)
3760
- });
3761
- module2.exports = Gateway2;
3762
- }
3763
- });
3764
-
3765
- // src/schemas/product.json
3766
- var require_product = __commonJS({
3767
- "src/schemas/product.json"(exports2, module2) {
3768
- module2.exports = {
3769
- $schema: "http://json-schema.org/draft-07/schema",
3770
- $id: "https://api.kohost.io/schemas/v3/product.json",
3771
- title: "Product",
3772
- type: "object",
3773
- required: ["name", "price", "driver"],
3774
- properties: {
3775
- id: {
3776
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3777
- },
3778
- type: {
3779
- type: "string"
3780
- },
3781
- name: {
3782
- type: "string"
3783
- },
3784
- driver: {
3785
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
3786
- },
3787
- description: {
3788
- string: "string"
3789
- },
3790
- price: {
3791
- type: "number"
3792
- },
3793
- image: {
3794
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/file"
3795
- },
3796
- category: {
3797
- type: "string"
3798
- },
3799
- imageUrl: {
3800
- format: "uri",
3801
- pattern: "^https?://"
3802
- },
3803
- systemData: {
3804
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
3805
- }
3806
- }
3807
- };
3808
- }
3809
- });
3810
-
3811
- // src/Models/product.js
3812
- var require_product2 = __commonJS({
3813
- "src/Models/product.js"(exports2, module2) {
3814
- var schemas = require_schema();
3815
- var schema = require_product();
3816
- var Kohost = require_kohost();
3817
- schemas.add(schema);
3818
- var validator = schemas.compile(schema);
3819
- var Product2 = class extends Kohost {
3820
- static {
3821
- __name(this, "Product");
3822
- }
3823
- constructor(data) {
3824
- super(data);
3825
- }
3826
- };
3827
- Object.defineProperty(Product2.prototype, "schema", {
3828
- value: schema
3829
- });
3830
- Object.defineProperty(Product2.prototype, "validator", {
3831
- get: function() {
3832
- return validator;
3833
- }
3834
- });
3835
- Object.defineProperty(Product2, "validProperties", {
3836
- value: Object.keys(schema.properties)
3837
- });
3838
- module2.exports = Product2;
3839
- }
3840
- });
3841
-
3842
- // src/schemas/discoveredDevice.json
3843
- var require_discoveredDevice = __commonJS({
3844
- "src/schemas/discoveredDevice.json"(exports2, module2) {
3845
- module2.exports = {
3846
- $schema: "http://json-schema.org/draft-07/schema",
3847
- $id: "https://api.kohost.io/schemas/v3/discoveredDevice.json",
3848
- title: "Discovered Device",
3849
- description: "A device that has been discovered by Kohost, but not yet added to the Kohost system.",
3850
- type: "object",
3851
- required: ["name", "deviceId", "deviceData"],
3852
- properties: {
3853
- id: {
3854
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3855
- },
3856
- name: {
3857
- type: "string"
3858
- },
3859
- deviceId: {
3860
- type: "string"
3861
- },
3862
- type: {
3863
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
3864
- },
3865
- driver: {
3866
- type: "string"
3867
- },
3868
- deviceData: {
3869
- type: "object"
3870
- },
3871
- ignore: {
3872
- type: "boolean"
3873
- }
3874
- }
3875
- };
3876
- }
3877
- });
3878
-
3879
- // src/Models/discoveredDevice.js
3880
- var require_discoveredDevice2 = __commonJS({
3881
- "src/Models/discoveredDevice.js"(exports2, module2) {
3882
- var schemas = require_schema();
3883
- var schema = require_discoveredDevice();
3884
- var Kohost = require_kohost();
3885
- schemas.add(schema);
3886
- var validator = schemas.compile(schema);
3887
- var DiscoveredDevice2 = class extends Kohost {
3888
- static {
3889
- __name(this, "DiscoveredDevice");
3890
- }
3891
- constructor(data) {
3892
- super(data);
3893
- }
3894
- };
3895
- Object.defineProperty(DiscoveredDevice2.prototype, "schema", {
3896
- value: schema
3897
- });
3898
- Object.defineProperty(DiscoveredDevice2.prototype, "validator", {
3899
- get: function() {
3900
- return validator;
3901
- }
3902
- });
3903
- Object.defineProperty(DiscoveredDevice2, "validProperties", {
3904
- value: Object.keys(schema.properties)
3905
- });
3906
- module2.exports = DiscoveredDevice2;
3907
- }
3908
- });
3909
-
3910
- // src/schemas/credential.json
3911
- var require_credential = __commonJS({
3912
- "src/schemas/credential.json"(exports2, module2) {
3913
- module2.exports = {
3914
- $schema: "http://json-schema.org/draft-07/schema",
3915
- $id: "https://api.kohost.io/schemas/v3/credential.json",
3916
- title: "Credential",
3917
- type: "object",
3918
- required: ["type", "credential", "expires"],
3919
- properties: {
3920
- id: {
3921
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3922
- },
3923
- type: {
3924
- type: "string",
3925
- enum: ["verificationCode", "token", "mobileKey"]
3926
- },
3927
- credential: {
3928
- type: "string"
3929
- },
3930
- user: {
3931
- type: "string"
3932
- },
3933
- userAgent: {
3934
- type: "string"
3935
- },
3936
- expires: {
3937
- string: "string"
3938
- },
3939
- systemData: {
3940
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
3941
- }
3942
- }
3943
- };
3944
- }
3945
- });
3946
-
3947
- // src/Models/credential.js
3948
- var require_credential2 = __commonJS({
3949
- "src/Models/credential.js"(exports2, module2) {
3950
- var schemas = require_schema();
3951
- var schema = require_credential();
3952
- var Kohost = require_kohost();
3953
- schemas.add(schema);
3954
- var validator = schemas.compile(schema);
3955
- var Credential2 = class extends Kohost {
3956
- static {
3957
- __name(this, "Credential");
3958
- }
3959
- constructor(data) {
3960
- super(data);
3961
- }
3962
- };
3963
- Object.defineProperty(Credential2.prototype, "schema", {
3964
- value: schema
3965
- });
3966
- Object.defineProperty(Credential2.prototype, "validator", {
3967
- get: function() {
3968
- return validator;
3969
- }
3970
- });
3971
- Object.defineProperty(Credential2, "validProperties", {
3972
- value: Object.keys(schema.properties)
3973
- });
3974
- module2.exports = Credential2;
3975
- }
3976
- });
3977
-
3978
- // src/schemas/shortLink.json
3979
- var require_shortLink = __commonJS({
3980
- "src/schemas/shortLink.json"(exports2, module2) {
3981
- module2.exports = {
3982
- $schema: "http://json-schema.org/draft-07/schema",
3983
- $id: "https://api.kohost.io/schemas/v3/shortLink.json",
3984
- title: "Short Link",
3985
- type: "object",
3986
- required: ["destination", "url"],
3987
- properties: {
3988
- id: {
3989
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
3990
- },
3991
- type: {
3992
- type: "string",
3993
- default: "shortLink"
3994
- },
3995
- title: {
3996
- type: "string"
3997
- },
3998
- destination: {
3999
- string: "string",
4000
- format: "uri"
4001
- },
4002
- url: {
4003
- string: "string",
4004
- format: "uri"
4005
- },
4006
- systemData: {
4007
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
4008
- }
4009
- }
4010
- };
4011
- }
4012
- });
4013
-
4014
- // src/Models/shortLink.js
4015
- var require_shortLink2 = __commonJS({
4016
- "src/Models/shortLink.js"(exports2, module2) {
4017
- var schemas = require_schema();
4018
- var schema = require_shortLink();
4019
- var Kohost = require_kohost();
4020
- schemas.add(schema);
4021
- var validator = schemas.compile(schema);
4022
- var ShortLink2 = class extends Kohost {
4023
- static {
4024
- __name(this, "ShortLink");
4025
- }
4026
- constructor(data) {
4027
- super(data);
4028
- }
4029
- };
4030
- Object.defineProperty(ShortLink2.prototype, "schema", {
4031
- value: schema
4032
- });
4033
- Object.defineProperty(ShortLink2.prototype, "validator", {
4034
- get: function() {
4035
- return validator;
4036
- }
4037
- });
4038
- Object.defineProperty(ShortLink2, "validProperties", {
4039
- value: Object.keys(schema.properties)
4040
- });
4041
- module2.exports = ShortLink2;
4042
- }
4043
- });
4044
-
4045
- // src/schemas/energyReportShard.json
4046
- var require_energyReportShard = __commonJS({
4047
- "src/schemas/energyReportShard.json"(exports2, module2) {
4048
- module2.exports = {
4049
- $schema: "http://json-schema.org/draft-07/schema",
4050
- $id: "https://api.kohost.io/schemas/v3/energyReportShard.json",
4051
- title: "Energy Report Shard",
4052
- description: "Shard used for Energy Reports",
4053
- type: "object",
4054
- required: [
4055
- "id",
4056
- "type",
4057
- "roomId",
4058
- "first",
4059
- "last",
4060
- "data",
4061
- "ndata",
4062
- "expires"
4063
- ],
4064
- properties: {
4065
- id: {
4066
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4067
- },
4068
- type: {
4069
- type: "string",
4070
- enum: ["energyReportShard"],
4071
- default: "energyReportShard"
4072
- },
4073
- roomId: {
4074
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4075
- },
4076
- first: {
4077
- type: ["string", "object"],
4078
- format: "date-time"
4079
- },
4080
- last: {
4081
- type: ["string", "object"],
4082
- format: "date-time"
4083
- },
4084
- data: {
4085
- type: "array",
4086
- items: {
4087
- type: "object",
4088
- required: ["time", "watts", "id", "type", "value"],
4089
- properties: {
4090
- time: {
4091
- type: ["string", "object"],
4092
- format: "date-time"
4093
- },
4094
- watts: {
4095
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
4096
- },
4097
- id: {
4098
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4099
- },
4100
- type: {
4101
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
4102
- },
4103
- value: {
4104
- type: "number",
4105
- minimum: 0,
4106
- maximum: 1
4107
- }
4108
- }
4109
- }
4110
- },
4111
- ndata: {
4112
- type: "integer",
4113
- minimum: 0,
4114
- maximum: 1e5,
4115
- default: 0
4116
- },
4117
- expires: {
4118
- type: ["string", "object"],
4119
- format: "date-time"
4120
- }
4121
- }
4122
- };
4123
- }
4124
- });
4125
-
4126
- // src/Models/energyReportShard.js
4127
- var require_energyReportShard2 = __commonJS({
4128
- "src/Models/energyReportShard.js"(exports2, module2) {
4129
- var schemas = require_schema();
4130
- var schema = require_energyReportShard();
4131
- var Kohost = require_kohost();
4132
- schemas.add(schema);
4133
- var validator = schemas.compile(schema);
4134
- var EnergyReportShard2 = class extends Kohost {
4135
- static {
4136
- __name(this, "EnergyReportShard");
4137
- }
4138
- constructor(data) {
4139
- super(data);
4140
- }
4141
- };
4142
- Object.defineProperty(EnergyReportShard2.prototype, "schema", {
4143
- value: schema
4144
- });
4145
- Object.defineProperty(EnergyReportShard2.prototype, "validator", {
4146
- get: function() {
4147
- return validator;
4148
- }
4149
- });
4150
- Object.defineProperty(EnergyReportShard2, "validProperties", {
4151
- value: Object.keys(schema.properties)
4152
- });
4153
- module2.exports = EnergyReportShard2;
4154
- }
4155
- });
4156
-
4157
- // src/schemas/energyReport.json
4158
- var require_energyReport = __commonJS({
4159
- "src/schemas/energyReport.json"(exports2, module2) {
4160
- module2.exports = {
4161
- $schema: "http://json-schema.org/draft-07/schema",
4162
- $id: "https://api.kohost.io/schemas/v3/energyReport.json",
4163
- title: "Energy Report Hourly",
4164
- description: "Hourly Report for Energy based on energy report shards",
4165
- type: "object",
4166
- required: [
4167
- "id",
4168
- "type",
4169
- "roomId",
4170
- "first",
4171
- "last",
4172
- "consumption",
4173
- "totals",
4174
- "costPerKw"
4175
- ],
4176
- properties: {
4177
- id: {
4178
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4179
- },
4180
- type: {
4181
- type: "string",
4182
- enum: ["energyReport"],
4183
- default: "energyReport"
4184
- },
4185
- reportTime: {
4186
- time: "string",
4187
- enum: ["hourly", "daily", "monthly"]
4188
- },
4189
- roomId: {
4190
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4191
- },
4192
- first: {
4193
- type: ["string", "object"],
4194
- format: "date-time"
4195
- },
4196
- last: {
4197
- type: ["string", "object"],
4198
- format: "date-time"
4199
- },
4200
- consumption: {
4201
- type: "array",
4202
- items: {
4203
- type: "object",
4204
- required: ["id", "type", "kwh"],
4205
- properties: {
4206
- id: {
4207
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4208
- },
4209
- type: {
4210
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
4211
- },
4212
- kwh: {
4213
- type: "number",
4214
- minimum: 0
4215
- }
4216
- }
4217
- }
4218
- },
4219
- totals: {
4220
- type: "array",
4221
- items: {
4222
- type: "object",
4223
- required: ["lights", "climate", "media"],
4224
- properties: {
4225
- lights: {
4226
- type: "number",
4227
- minimum: 0
4228
- },
4229
- climate: {
4230
- type: "number",
4231
- minimum: 0
4232
- },
4233
- media: {
4234
- type: "number",
4235
- minimum: 0
4236
- }
4237
- }
4238
- }
4239
- },
4240
- costPerKw: {
4241
- type: "number",
4242
- minimum: 0
4243
- }
4244
- }
4245
- };
4246
- }
4247
- });
4248
-
4249
- // src/Models/energyReport.js
4250
- var require_energyReport2 = __commonJS({
4251
- "src/Models/energyReport.js"(exports2, module2) {
4252
- var schemas = require_schema();
4253
- var schema = require_energyReport();
4254
- var Kohost = require_kohost();
4255
- schemas.add(schema);
4256
- var validator = schemas.compile(schema);
4257
- var EnergyReport2 = class extends Kohost {
4258
- static {
4259
- __name(this, "EnergyReport");
4260
- }
4261
- constructor(data) {
4262
- super(data);
4263
- }
4264
- };
4265
- Object.defineProperty(EnergyReport2.prototype, "schema", {
4266
- value: schema
4267
- });
4268
- Object.defineProperty(EnergyReport2.prototype, "validator", {
4269
- get: function() {
4270
- return validator;
4271
- }
4272
- });
4273
- Object.defineProperty(EnergyReport2, "validProperties", {
4274
- value: Object.keys(schema.properties)
4275
- });
4276
- module2.exports = EnergyReport2;
4277
- }
4278
- });
4279
-
4280
- // src/schemas/smsMessage.json
4281
- var require_smsMessage = __commonJS({
4282
- "src/schemas/smsMessage.json"(exports2, module2) {
4283
- module2.exports = {
4284
- $schema: "http://json-schema.org/draft-07/schema",
4285
- $id: "https://api.kohost.io/schemas/v3/smsMessage.json",
4286
- title: "SMS Message",
4287
- type: "object",
4288
- required: ["to", "from", "body", "status"],
4289
- properties: {
4290
- id: {
4291
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4292
- },
4293
- type: {
4294
- type: "string",
4295
- default: "smsMessage"
4296
- },
4297
- to: {
4298
- type: "string",
4299
- pattern: "^\\+[0-9]{1,14}$"
4300
- },
4301
- from: {
4302
- type: "string",
4303
- pattern: "^\\+[0-9]{1,14}$"
4304
- },
4305
- media: {
4306
- type: "string",
4307
- format: "uri"
4308
- },
4309
- status: {
4310
- type: "string",
4311
- enum: [
4312
- "queued",
4313
- "accepted",
4314
- "sending",
4315
- "sent",
4316
- "failed",
4317
- "delivered",
4318
- "undelivered",
4319
- "receiving",
4320
- "received",
4321
- "read"
4322
- ]
4323
- },
4324
- body: {
4325
- type: "string"
4326
- },
4327
- driver: {
4328
- type: "string"
4329
- },
4330
- appData: {
4331
- type: "object"
4332
- },
4333
- createdAt: {
4334
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4335
- },
4336
- updatedAt: {
4337
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4338
- },
4339
- systemData: {
4340
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
4341
- }
4342
- }
4343
- };
4344
- }
4345
- });
4346
-
4347
- // src/Models/smsMessage.js
4348
- var require_smsMessage2 = __commonJS({
4349
- "src/Models/smsMessage.js"(exports2, module2) {
4350
- var schemas = require_schema();
4351
- var schema = require_smsMessage();
4352
- var Kohost = require_kohost();
4353
- schemas.add(schema);
4354
- var validator = schemas.compile(schema);
4355
- var SMSMessage2 = class extends Kohost {
4356
- static {
4357
- __name(this, "SMSMessage");
4358
- }
4359
- constructor(data) {
4360
- super(data);
4361
- }
4362
- };
4363
- Object.defineProperty(SMSMessage2.prototype, "schema", {
4364
- value: schema
4365
- });
4366
- Object.defineProperty(SMSMessage2.prototype, "validator", {
4367
- get: function() {
4368
- return validator;
4369
- }
4370
- });
4371
- Object.defineProperty(SMSMessage2, "validProperties", {
4372
- value: Object.keys(schema.properties)
4373
- });
4374
- module2.exports = SMSMessage2;
4375
- }
4376
- });
4377
-
4378
- // src/schemas/emailMessage.json
4379
- var require_emailMessage = __commonJS({
4380
- "src/schemas/emailMessage.json"(exports2, module2) {
4381
- module2.exports = {
4382
- $schema: "http://json-schema.org/draft-07/schema",
4383
- $id: "https://api.kohost.io/schemas/v3/emailMessage.json",
4384
- title: "Email Message",
4385
- type: "object",
4386
- required: ["to", "from", "status", "subject"],
4387
- properties: {
4388
- id: {
4389
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4390
- },
4391
- type: {
4392
- type: "string",
4393
- default: "emailMessage"
4394
- },
4395
- to: {
4396
- type: "string",
4397
- pattern: "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"
4398
- },
4399
- from: {
4400
- type: "string",
4401
- pattern: ".*<[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+>.*",
4402
- description: "Must be in the format of 'Sender <email@example.com>"
4403
- },
4404
- subject: {
4405
- type: "string"
4406
- },
4407
- status: {
4408
- type: "string",
4409
- enum: [
4410
- "queued",
4411
- "sending",
4412
- "sent",
4413
- "deferred",
4414
- "delivered",
4415
- "undelivered",
4416
- "bounced",
4417
- "blocked",
4418
- "receiving",
4419
- "received",
4420
- "opened",
4421
- "clicked",
4422
- "unsubscribed",
4423
- "spamReport"
4424
- ]
4425
- },
4426
- statusMessage: {
4427
- type: "string"
4428
- },
4429
- html: {
4430
- type: "string"
4431
- },
4432
- text: {
4433
- type: "string"
4434
- },
4435
- driver: {
4436
- type: "string"
4437
- },
4438
- appData: {
4439
- type: "object"
4440
- },
4441
- createdAt: {
4442
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4443
- },
4444
- updatedAt: {
4445
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
4446
- },
4447
- systemData: {
4448
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
4449
- }
4450
- }
4451
- };
4452
- }
4453
- });
4454
-
4455
- // src/Models/emailMessage.js
4456
- var require_emailMessage2 = __commonJS({
4457
- "src/Models/emailMessage.js"(exports2, module2) {
4458
- var schemas = require_schema();
4459
- var schema = require_emailMessage();
4460
- var Kohost = require_kohost();
4461
- schemas.add(schema);
4462
- var validator = schemas.compile(schema);
4463
- var EmailMessage2 = class extends Kohost {
4464
- static {
4465
- __name(this, "EmailMessage");
4466
- }
4467
- constructor(data) {
4468
- super(data);
4469
- }
4470
- };
4471
- Object.defineProperty(EmailMessage2.prototype, "schema", {
4472
- value: schema
4473
- });
4474
- Object.defineProperty(EmailMessage2.prototype, "validator", {
4475
- get: function() {
4476
- return validator;
4477
- }
4478
- });
4479
- Object.defineProperty(EmailMessage2, "validProperties", {
4480
- value: Object.keys(schema.properties)
4481
- });
4482
- module2.exports = EmailMessage2;
4483
- }
4484
- });
4485
-
4486
- // src/schemas/property.json
4487
- var require_property = __commonJS({
4488
- "src/schemas/property.json"(exports2, module2) {
4489
- module2.exports = {
4490
- $schema: "http://json-schema.org/draft-07/schema",
4491
- $id: "https://api.kohost.io/schemas/v3/admin/property.json",
4492
- title: "Property",
4493
- type: "object",
4494
- description: "A property is a physical asset or building",
4495
- required: ["id", "name", "type", "hostname", "organization"],
4496
- properties: {
4497
- id: {
4498
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4499
- },
4500
- name: {
4501
- type: "string"
4502
- },
4503
- type: {
4504
- type: "string",
4505
- enum: ["hospitality", "education", "commercial"]
4506
- },
4507
- timezone: {
4508
- type: "string"
4509
- },
4510
- smsNumber: {
4511
- type: "string"
4512
- },
4513
- hostname: {
4514
- type: "string"
4515
- },
4516
- organization: {
4517
- type: "string",
4518
- description: "Reference (id) to the organization that owns this property"
4519
- },
4520
- address: {
4521
- type: "object",
4522
- properties: {
4523
- street: {
4524
- type: "string"
4525
- },
4526
- city: {
4527
- type: "string"
4528
- },
4529
- state: {
4530
- type: "string"
4531
- },
4532
- zip: {
4533
- type: "string"
4534
- },
4535
- country: {
4536
- type: "string"
4537
- }
4538
- }
4539
- },
4540
- latitude: {
4541
- type: "number"
4542
- },
4543
- longitude: {
4544
- type: "number"
4545
- },
4546
- appManifest: {
4547
- type: "object",
4548
- properties: {
4549
- name: {
4550
- type: "string"
4551
- },
4552
- short_name: {
4553
- type: "string"
4554
- },
4555
- scope: {
4556
- type: "string"
4557
- },
4558
- start_url: {
4559
- type: "string"
4560
- },
4561
- themeColor: {
4562
- type: "string"
4563
- },
4564
- backgroundColor: {
4565
- type: "string"
4566
- },
4567
- display: {
4568
- type: "string",
4569
- enum: ["fullscreen", "standalone", "minimal-ui", "browser"],
4570
- default: "fullscreen"
4571
- },
4572
- orientation: {
4573
- type: "string",
4574
- enum: ["portrait", "landscape"],
4575
- default: "portrait"
4576
- },
4577
- splash: {
4578
- type: "object",
4579
- properties: {
4580
- src: {
4581
- type: "string"
4582
- },
4583
- type: {
4584
- type: "string"
4585
- },
4586
- sizes: {
4587
- type: "string"
4588
- }
4589
- }
4590
- },
4591
- icons: {
4592
- type: "array",
4593
- items: {
4594
- type: "object",
4595
- properties: {
4596
- src: {
4597
- type: "string"
4598
- },
4599
- sizes: {
4600
- type: "string"
4601
- },
4602
- type: {
4603
- type: "string"
4604
- }
4605
- }
4606
- }
4607
- },
4608
- logo: {
4609
- type: "object",
4610
- properties: {
4611
- src: {
4612
- type: "string"
4613
- },
4614
- type: {
4615
- type: "string"
4616
- },
4617
- sizes: {
4618
- type: "string"
4619
- }
4620
- }
4621
- }
4622
- },
4623
- default: {
4624
- name: "Kohost",
4625
- short_name: "Kohost",
4626
- start_url: "/",
4627
- scope: "/",
4628
- display: "fullscreen",
4629
- orientation: "portrait",
4630
- theme_color: "#1d1f22",
4631
- background_color: "#1d1f22",
4632
- icons: [
4633
- {
4634
- src: "https://cdn.kohost.app/defaultIcon.png",
4635
- sizes: "512x512",
4636
- type: "image/png"
4637
- }
4638
- ],
4639
- splash: {
4640
- src: "https://cdn.kohost.app/defaultSplash.jpg",
4641
- sizes: "1500x800",
4642
- type: "image/jpg"
4643
- },
4644
- logo: {
4645
- src: "https://cdn.kohost.app/defaultLogo.png",
4646
- sizes: "300x75",
4647
- type: "image/png"
4648
- }
4649
- }
4650
- },
4651
- appFeatures: {
4652
- type: "object",
4653
- properties: {
4654
- RoomControl: {},
4655
- CheckIn: {
4656
- properties: {
4657
- payment: {},
4658
- identification: {},
4659
- earlyCheckIn: {
4660
- type: "object",
4661
- required: ["dynamic", "checkInTime", "checkOutTime"],
4662
- properties: {
4663
- dynamic: {
4664
- type: "boolean",
4665
- default: false
4666
- },
4667
- checkInTime: {
4668
- type: "string"
4669
- },
4670
- checkOutTime: {
4671
- type: "string"
4672
- }
4673
- }
4674
- },
4675
- roomUpgrades: {}
4676
- }
4677
- },
4678
- CheckOut: {},
4679
- Concierge: {},
4680
- DigitalKey: {
4681
- type: "object",
4682
- properties: {
4683
- system: {
4684
- type: "string",
4685
- enum: ["salto"]
4686
- },
4687
- systemOnline: {
4688
- type: "boolean",
4689
- default: false
4690
- },
4691
- branding: {
4692
- type: "object",
4693
- properties: {
4694
- logo: {
4695
- type: "string",
4696
- format: "uri"
4697
- },
4698
- gradient: {
4699
- type: "array",
4700
- items: {
4701
- type: "string",
4702
- pattern: "^(?!#ffffff)(#[0-9a-fA-F]{6})$"
4703
- },
4704
- minItems: 2,
4705
- maxItems: 2
4706
- },
4707
- highlightedGradient: {
4708
- type: "array",
4709
- items: {
4710
- type: "string",
4711
- pattern: "^(?!#ffffff)(#[0-9a-fA-F]{6})$"
4712
- },
4713
- minItems: 2,
4714
- maxItems: 3
4715
- }
4716
- }
4717
- }
4718
- }
4719
- },
4720
- Elevator: {}
4721
- },
4722
- additionalProperties: false,
4723
- default: {
4724
- RoomControl: {}
4725
- }
4726
- },
4727
- credentials: {
4728
- type: "object",
4729
- additionalProperties: true
4730
- },
4731
- additionalProperties: false
4732
- }
4733
- };
4734
- }
4735
- });
4736
-
4737
- // src/Models/property.js
4738
- var require_property2 = __commonJS({
4739
- "src/Models/property.js"(exports2, module2) {
4740
- var schemas = require_schema();
4741
- var schema = require_property();
4742
- var Kohost = require_kohost();
4743
- schemas.add(schema);
4744
- var validator = schemas.compile(schema);
4745
- var Property2 = class extends Kohost {
4746
- static {
4747
- __name(this, "Property");
4748
- }
4749
- constructor(data) {
4750
- super(data);
4751
- }
4752
- };
4753
- Object.defineProperty(Property2.prototype, "schema", {
4754
- value: schema
4755
- });
4756
- Object.defineProperty(Property2.prototype, "validator", {
4757
- get: function() {
4758
- return validator;
4759
- }
4760
- });
4761
- Object.defineProperty(Property2, "validProperties", {
4762
- value: Object.keys(schema.properties)
4763
- });
4764
- module2.exports = Property2;
4765
- }
4766
- });
4767
-
4768
- // src/schemas/organization.json
4769
- var require_organization = __commonJS({
4770
- "src/schemas/organization.json"(exports2, module2) {
4771
- module2.exports = {
4772
- $schema: "http://json-schema.org/draft-07/schema",
4773
- $id: "https://api.kohost.io/schemas/v3/admin/organization.json",
4774
- title: "Organization",
4775
- type: "object",
4776
- description: "An organization is a group or entity that subscribes to Kohost software.",
4777
- required: ["accountNumber", "name"],
4778
- properties: {
4779
- id: {
4780
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
4781
- },
4782
- accountNumber: {
4783
- type: "number",
4784
- minimum: 1e4
4785
- },
4786
- name: {
4787
- type: "string"
4788
- },
4789
- properties: {
4790
- type: "array",
4791
- items: {
4792
- type: "string"
4793
- }
4794
- },
4795
- credentials: {
4796
- type: "object",
4797
- additionalProperties: true
4798
- },
4799
- createdAt: {
4800
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
4801
- },
4802
- updatedAt: {
4803
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/updatedAt"
4804
- }
4805
- }
4806
- };
4807
- }
4808
- });
4809
-
4810
- // src/Models/organization.js
4811
- var require_organization2 = __commonJS({
4812
- "src/Models/organization.js"(exports2, module2) {
4813
- var schemas = require_schema();
4814
- var schema = require_organization();
4815
- var Kohost = require_kohost();
4816
- schemas.add(schema);
4817
- var validator = schemas.compile(schema);
4818
- var Organization2 = class extends Kohost {
4819
- static {
4820
- __name(this, "Organization");
4821
- }
4822
- constructor(data) {
4823
- super(data);
4824
- }
4825
- };
4826
- Object.defineProperty(Organization2.prototype, "schema", {
4827
- value: schema
4828
- });
4829
- Object.defineProperty(Organization2.prototype, "validator", {
4830
- get: function() {
4831
- return validator;
4832
- }
4833
- });
4834
- Object.defineProperty(Organization2, "validProperties", {
4835
- value: Object.keys(schema.properties)
4836
- });
4837
- module2.exports = Organization2;
4838
- }
4839
- });
4840
-
4841
- // src/Models/index.js
4842
- var Reservation = require_reservation2();
4843
- var MediaFile = require_mediaFile2();
4844
- var Switch = require_switch2();
4845
- var Alarm = require_alarm2();
4846
- var Dimmer = require_dimmer2();
4847
- var Lock = require_lock2();
4848
- var Thermostat = require_thermostat2();
4849
- var WindowCovering = require_windowCovering2();
4850
- var Identification = require_identification2();
4851
- var User = require_user2();
4852
- var SystemUser = require_systemUser2();
4853
- var Courtesy = require_courtesy2();
4854
- var Camera = require_camera2();
4855
- var MotionSensor = require_motionSensor2();
4856
- var MediaSource = require_mediaSource2();
4857
- var Room = require_room2();
4858
- var Space = require_space2();
4859
- var SpaceType = require_spaceType2();
4860
- var Ticket = require_ticket2();
4861
- var Scene = require_scene2();
4862
- var Gateway = require_gateway2();
4863
- var Product = require_product2();
4864
- var DiscoveredDevice = require_discoveredDevice2();
4865
- var Credential = require_credential2();
4866
- var ShortLink = require_shortLink2();
4867
- var EnergyReportShard = require_energyReportShard2();
4868
- var EnergyReport = require_energyReport2();
4869
- var SMSMessage = require_smsMessage2();
4870
- var EmailMessage = require_emailMessage2();
4871
- var Property = require_property2();
4872
- var Organization = require_organization2();
4873
- module.exports = {
4874
- Organization,
4875
- Property,
4876
- MediaFile,
4877
- Gateway,
4878
- Switch,
4879
- Alarm,
4880
- Dimmer,
4881
- Lock,
4882
- Courtesy,
4883
- Camera,
4884
- MotionSensor,
4885
- Thermostat,
4886
- WindowCovering,
4887
- MediaSource,
4888
- Identification,
4889
- Product,
4890
- User,
4891
- SystemUser,
4892
- Room,
4893
- Space,
4894
- SpaceType,
4895
- Ticket,
4896
- Scene,
4897
- DiscoveredDevice,
4898
- Reservation,
4899
- Credential,
4900
- ShortLink,
4901
- EnergyReportShard,
4902
- EnergyReport,
4903
- SMSMessage,
4904
- EmailMessage
4905
- };