@kohost/api-client 3.0.0-beta.8 → 3.0.0-beta.81

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