@kohost/api-client 3.0.0-beta.6 → 3.0.0-beta.60

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