@kohost/api-client 3.0.0-beta.10 → 3.0.0-beta.101

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 (281) 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} +1973 -624
  4. package/dist/cjs/Commands/CheckInReservationCommand.js +19 -0
  5. package/dist/cjs/Commands/CheckOutReservationCommand.js +20 -0
  6. package/dist/cjs/Commands/Command.js +34 -0
  7. package/dist/cjs/Commands/CreateImageUploadEndpointCommand.js +17 -0
  8. package/dist/cjs/Commands/CreateShortLinkCommand.js +20 -0
  9. package/dist/cjs/Commands/DiscoverCategoriesCommand.js +20 -0
  10. package/dist/cjs/Commands/DiscoverReservationSpaceCategoryAvailabilitiesCommand.js +20 -0
  11. package/dist/cjs/Commands/DiscoverReservationsCommand.js +20 -0
  12. package/dist/cjs/Commands/DiscoverRoomsCommand.js +37 -0
  13. package/dist/cjs/Commands/DiscoverUsersCommand.js +19 -0
  14. package/dist/cjs/Commands/GetMobileKeyCommand.js +24 -0
  15. package/dist/cjs/Commands/GetProductsCommand.js +17 -0
  16. package/dist/cjs/Commands/OCRDocumentCommand.js +15 -0
  17. package/dist/cjs/Commands/SellProductsCommand.js +17 -0
  18. package/dist/cjs/Commands/SendEmailCommand.js +24 -0
  19. package/dist/cjs/Commands/SendSMSCommand.js +22 -0
  20. package/dist/cjs/Commands/SetAlarmCommand.js +17 -0
  21. package/dist/cjs/Commands/SetCourtesyCommand.js +17 -0
  22. package/dist/cjs/Commands/SetDimmerCommand.js +17 -0
  23. package/dist/cjs/Commands/SetLockCommand.js +17 -0
  24. package/dist/cjs/Commands/SetMediaCommand.js +17 -0
  25. package/dist/cjs/Commands/SetSceneCommand.js +17 -0
  26. package/dist/cjs/Commands/SetSwitchCommand.js +17 -0
  27. package/dist/cjs/Commands/SetThermostatCommand.js +17 -0
  28. package/dist/cjs/Commands/SetWindowCoveringCommand.js +17 -0
  29. package/dist/cjs/Commands/UpdateReservationCommand.js +19 -0
  30. package/dist/cjs/Commands/UpdateUserCommand.js +41 -0
  31. package/dist/cjs/Commands/UploadImageCommand.js +17 -0
  32. package/dist/cjs/Commands/index.js +57 -0
  33. package/dist/cjs/Errors/AppError.js +8 -0
  34. package/dist/cjs/Errors/AuthenticationError.js +9 -0
  35. package/dist/cjs/Errors/AuthorizationError.js +9 -0
  36. package/dist/cjs/Errors/ConflictError.js +9 -0
  37. package/dist/cjs/Errors/DeviceCommError.js +9 -0
  38. package/dist/cjs/Errors/LoginError.js +9 -0
  39. package/dist/cjs/Errors/NotFoundError.js +9 -0
  40. package/dist/cjs/Errors/RequestError.js +9 -0
  41. package/dist/cjs/Errors/SystemCommError.js +9 -0
  42. package/dist/cjs/Errors/TokenExpiredError.js +9 -0
  43. package/dist/cjs/Errors/UnprocessableRequestError.js +9 -0
  44. package/dist/cjs/Errors/ValidationError.js +9 -0
  45. package/dist/cjs/Errors/index.js +16 -0
  46. package/dist/cjs/Events/ApplicationInUseEvent.js +25 -0
  47. package/dist/cjs/Events/ApplicationOutOfUseEvent.js +25 -0
  48. package/dist/cjs/Events/EmailEvent.js +18 -0
  49. package/dist/cjs/Events/Event.js +55 -0
  50. package/dist/cjs/Events/SMSEvent.js +18 -0
  51. package/dist/cjs/Events/SMSSentEvent.js +17 -0
  52. package/dist/cjs/Events/SceneSetEvent.js +17 -0
  53. package/dist/cjs/Events/ShortLinkCreatedEvent.js +17 -0
  54. package/dist/cjs/Events/SystemAlarmUpdatedEvent.js +17 -0
  55. package/dist/cjs/Events/SystemCameraUpdatedEvent.js +17 -0
  56. package/dist/cjs/Events/SystemCategoryUpdatedEvent.js +17 -0
  57. package/dist/cjs/Events/SystemCourtesyUpdatedEvent.js +17 -0
  58. package/dist/cjs/Events/SystemCredentialUpdatedEvent.js +17 -0
  59. package/dist/cjs/Events/SystemDimmerUpdatedEvent.js +17 -0
  60. package/dist/cjs/Events/SystemEntityDeletedEvent.js +17 -0
  61. package/dist/cjs/Events/SystemGatewayUpdatedEvent.js +17 -0
  62. package/dist/cjs/Events/SystemLockUpdatedEvent.js +17 -0
  63. package/dist/cjs/Events/SystemMediaSourceUpdatedEvent.js +17 -0
  64. package/dist/cjs/Events/SystemMotionSensorUpdatedEvent.js +17 -0
  65. package/dist/cjs/Events/SystemOrganizationUpdatedEvent.js +17 -0
  66. package/dist/cjs/Events/SystemProductUpdatedEvent.js +17 -0
  67. package/dist/cjs/Events/SystemPropertyUpdatedEvent.js +17 -0
  68. package/dist/cjs/Events/SystemReservationUpdatedEvent.js +17 -0
  69. package/dist/cjs/Events/SystemSceneControllerUpdatedEvent.js +17 -0
  70. package/dist/cjs/Events/SystemSpaceUpdatedEvent.js +17 -0
  71. package/dist/cjs/Events/SystemSwitchUpdatedEvent.js +17 -0
  72. package/dist/cjs/Events/SystemThermostatUpdatedEvent.js +17 -0
  73. package/dist/cjs/Events/SystemUserUpdatedEvent.js +17 -0
  74. package/dist/cjs/Events/SystemWindowCoveringUpdatedEvent.js +17 -0
  75. package/dist/cjs/Events/index.js +65 -0
  76. package/dist/cjs/Models/Alarm.js +35 -0
  77. package/dist/cjs/Models/Announcement.js +34 -0
  78. package/dist/cjs/Models/Camera.js +35 -0
  79. package/dist/cjs/Models/Category.js +36 -0
  80. package/dist/cjs/Models/Courtesy.js +39 -0
  81. package/dist/cjs/Models/Credential.js +35 -0
  82. package/dist/cjs/Models/DeviceRouter.js +36 -0
  83. package/dist/cjs/Models/Dimmer.js +61 -0
  84. package/dist/cjs/Models/DiscoveredDevice.js +36 -0
  85. package/dist/cjs/Models/EmailMessage.js +35 -0
  86. package/dist/cjs/Models/EnergyReport.js +35 -0
  87. package/dist/cjs/Models/EnergyReportShard.js +35 -0
  88. package/dist/cjs/Models/Entity.js +96 -0
  89. package/dist/cjs/Models/Gateway.js +35 -0
  90. package/dist/cjs/Models/Identification.js +38 -0
  91. package/dist/cjs/Models/Lock.js +39 -0
  92. package/dist/cjs/Models/MediaFile.js +48 -0
  93. package/dist/cjs/Models/MediaSource.js +35 -0
  94. package/dist/cjs/Models/MotionSensor.js +35 -0
  95. package/dist/cjs/Models/Order.js +97 -0
  96. package/dist/cjs/Models/Organization.js +34 -0
  97. package/dist/cjs/Models/Product.js +35 -0
  98. package/dist/cjs/Models/Property.js +34 -0
  99. package/dist/cjs/Models/Reservation.js +114 -0
  100. package/dist/cjs/Models/Room.js +217 -0
  101. package/dist/cjs/Models/Scene.js +169 -0
  102. package/dist/cjs/Models/ShortLink.js +35 -0
  103. package/dist/cjs/Models/SmsMessage.js +35 -0
  104. package/dist/cjs/Models/Space.js +97 -0
  105. package/dist/cjs/Models/Switch.js +39 -0
  106. package/dist/cjs/Models/SystemUser.js +55 -0
  107. package/dist/cjs/Models/Thermostat.js +86 -0
  108. package/dist/cjs/Models/Ticket.js +55 -0
  109. package/dist/cjs/Models/User.js +115 -0
  110. package/dist/cjs/Models/WindowCovering.js +55 -0
  111. package/dist/cjs/Models/index.js +77 -0
  112. package/dist/cjs/SocketIoClient/index.js +74 -0
  113. package/dist/cjs/defs/deviceTypes.js +15 -0
  114. package/dist/cjs/defs/formalDeviceTypes.js +6 -0
  115. package/dist/cjs/defs/index.js +11 -0
  116. package/dist/cjs/{index.cjs.js → index.js} +7 -1
  117. package/dist/cjs/schemas/AlarmSchema.d.ts +158 -0
  118. package/dist/cjs/schemas/AnnouncementSchema.d.ts +61 -0
  119. package/dist/cjs/schemas/CameraSchema.d.ts +149 -0
  120. package/dist/cjs/schemas/CategorySchema.d.ts +82 -0
  121. package/dist/cjs/schemas/CourtesySchema.d.ts +148 -0
  122. package/dist/cjs/schemas/CredentialSchema.d.ts +53 -0
  123. package/dist/cjs/schemas/DefinitionsSchema.d.ts +10 -0
  124. package/dist/cjs/schemas/DeviceRouterSchema.d.ts +23 -0
  125. package/dist/cjs/schemas/DimmerSchema.d.ts +147 -0
  126. package/dist/cjs/schemas/DiscoveredDeviceSchema.d.ts +43 -0
  127. package/dist/cjs/schemas/EmailMessageSchema.d.ts +49 -0
  128. package/dist/cjs/schemas/EnergyReportSchema.d.ts +57 -0
  129. package/dist/cjs/schemas/EnergyReportShardSchema.d.ts +61 -0
  130. package/dist/cjs/schemas/GatewaySchema.d.ts +145 -0
  131. package/dist/cjs/schemas/IdentificationSchema.d.ts +45 -0
  132. package/dist/cjs/schemas/LockSchema.d.ts +152 -0
  133. package/dist/cjs/schemas/MediaFileSchema.d.ts +43 -0
  134. package/dist/cjs/schemas/MediaSourceSchema.d.ts +244 -0
  135. package/dist/cjs/schemas/MotionSensorSchema.d.ts +143 -0
  136. package/dist/cjs/schemas/OrderSchema.d.ts +91 -0
  137. package/dist/cjs/schemas/OrganizationSchema.d.ts +34 -0
  138. package/dist/cjs/schemas/PaymentSchema.d.ts +33 -0
  139. package/dist/cjs/schemas/ProductSchema.d.ts +66 -0
  140. package/dist/cjs/schemas/PropertySchema.d.ts +144 -0
  141. package/dist/cjs/schemas/ReservationSchema.d.ts +119 -0
  142. package/dist/cjs/schemas/RoomSchema.d.ts +1103 -0
  143. package/dist/cjs/schemas/SceneSchema.d.ts +57 -0
  144. package/dist/cjs/schemas/ShortLinkSchema.d.ts +20 -0
  145. package/dist/cjs/schemas/SmsMessageSchema.d.ts +40 -0
  146. package/dist/cjs/schemas/SpaceSchema.d.ts +73 -0
  147. package/dist/cjs/schemas/SwitchSchema.d.ts +148 -0
  148. package/dist/cjs/schemas/SystemUserSchema.d.ts +194 -0
  149. package/dist/cjs/schemas/ThermostatSchema.d.ts +178 -0
  150. package/dist/cjs/schemas/TicketSchema.d.ts +90 -0
  151. package/dist/cjs/schemas/UserSchema.d.ts +287 -0
  152. package/dist/cjs/schemas/WindowCoveringSchema.d.ts +147 -0
  153. package/dist/cjs/schemas/alarm.json +81 -0
  154. package/dist/cjs/schemas/announcement.json +47 -0
  155. package/dist/cjs/schemas/camera.json +50 -0
  156. package/dist/cjs/schemas/category.json +42 -0
  157. package/dist/cjs/schemas/courtesy.json +48 -0
  158. package/dist/cjs/schemas/credential.json +51 -0
  159. package/dist/cjs/schemas/definitions.json +223 -0
  160. package/dist/cjs/schemas/deviceRouter.json +28 -0
  161. package/dist/cjs/schemas/dimmer.json +42 -0
  162. package/dist/cjs/schemas/discoveredDevice.json +35 -0
  163. package/dist/cjs/schemas/emailMessage.json +71 -0
  164. package/dist/cjs/schemas/energyReport.json +86 -0
  165. package/dist/cjs/schemas/energyReportShard.json +75 -0
  166. package/dist/cjs/schemas/gateway.json +34 -0
  167. package/dist/cjs/schemas/identification.json +61 -0
  168. package/dist/cjs/schemas/lock.json +50 -0
  169. package/dist/cjs/schemas/mediaFile.json +70 -0
  170. package/dist/cjs/schemas/mediaSource.json +187 -0
  171. package/dist/cjs/schemas/motionSensor.json +32 -0
  172. package/dist/cjs/schemas/order.json +182 -0
  173. package/dist/cjs/schemas/organization.json +40 -0
  174. package/dist/cjs/schemas/payment.json +47 -0
  175. package/dist/cjs/schemas/product.json +41 -0
  176. package/dist/cjs/schemas/property.json +347 -0
  177. package/dist/cjs/schemas/reservation.json +137 -0
  178. package/dist/cjs/schemas/room.json +98 -0
  179. package/dist/cjs/schemas/scene.json +121 -0
  180. package/dist/cjs/schemas/shortLink.json +30 -0
  181. package/dist/cjs/schemas/smsMessage.json +61 -0
  182. package/dist/cjs/schemas/space.json +129 -0
  183. package/dist/cjs/schemas/switch.json +44 -0
  184. package/dist/cjs/schemas/systemUser.json +98 -0
  185. package/dist/cjs/schemas/thermostat.json +150 -0
  186. package/dist/cjs/schemas/ticket.json +181 -0
  187. package/dist/cjs/schemas/user.json +170 -0
  188. package/dist/cjs/schemas/windowCovering.json +42 -0
  189. package/dist/cjs/utils/errorFactory.js +8 -0
  190. package/dist/cjs/utils/eventFactory.js +10 -0
  191. package/dist/cjs/utils/getDeviceTypes.js +7 -0
  192. package/dist/cjs/utils/getFormalDeviceType.js +5 -0
  193. package/dist/cjs/utils/index.js +11 -0
  194. package/dist/cjs/utils/schema.js +25 -0
  195. package/dist/esm/Client.js +2068 -652
  196. package/dist/esm/Client.js.map +4 -4
  197. package/dist/esm/Commands.js +519 -140
  198. package/dist/esm/Commands.js.map +3 -3
  199. package/dist/esm/Errors.js +73 -22
  200. package/dist/esm/Errors.js.map +3 -3
  201. package/dist/esm/Events.js +422 -73
  202. package/dist/esm/Events.js.map +3 -3
  203. package/dist/esm/Models.js +3407 -3923
  204. package/dist/esm/Models.js.map +4 -4
  205. package/dist/esm/SocketIoClient.js +4846 -0
  206. package/dist/esm/SocketIoClient.js.map +7 -0
  207. package/dist/esm/defs.js +168 -112
  208. package/dist/esm/defs.js.map +4 -4
  209. package/dist/esm/index.js +17 -10
  210. package/dist/esm/utils.js +451 -73
  211. package/dist/esm/utils.js.map +3 -3
  212. package/dist/useCases/AdminUpdateCustomer.js +1 -1
  213. package/dist/useCases/AssignSpaceToReservation.js +32 -0
  214. package/dist/useCases/{AdminCreateProperty.js → BatchNotifyCheckIn.js} +2 -2
  215. package/dist/useCases/{AdminCreateCustomer.js → BatchNotifyCheckOut.js} +2 -2
  216. package/dist/useCases/BatchNotifyMissedCheckOut.js +32 -0
  217. package/dist/useCases/{AdminUpdateProperty.js → CheckOutReservation.js} +3 -3
  218. package/dist/useCases/{AdminListCustomers.js → CreateAnnouncement.js} +3 -3
  219. package/dist/useCases/CreateCateory.js +32 -0
  220. package/dist/useCases/CreateImageUploadEndpoint.js +32 -0
  221. package/dist/useCases/CreateMediaSource.js +32 -0
  222. package/dist/useCases/CreateOrganization.js +32 -0
  223. package/dist/useCases/{AdminLoginUser.js → CreateProperty.js} +2 -2
  224. package/dist/useCases/DeleteAnnouncement.js +32 -0
  225. package/dist/useCases/DeleteCategory.js +32 -0
  226. package/dist/useCases/DeleteMediaFile.js +32 -0
  227. package/dist/useCases/DeleteMediaSource.js +32 -0
  228. package/dist/useCases/{AdminCreateAdminUser.js → DescribeAnnouncement.js} +4 -4
  229. package/dist/useCases/{ListIntegrations.js → DescribeCategory.js} +3 -3
  230. package/dist/useCases/DescribeLockCredential.js +32 -0
  231. package/dist/useCases/{AdminListAdminUsers.js → DescribeMediaSource.js} +3 -3
  232. package/dist/useCases/DescribeMyAccessCredentials.js +32 -0
  233. package/dist/useCases/{AdminDescribeCustomer.js → DescribeOrganization.js} +2 -2
  234. package/dist/useCases/{DescribeIntegration.js → DescribeProduct.js} +2 -2
  235. package/dist/useCases/DescribeProperty.js +32 -0
  236. package/dist/useCases/DescribeReservationEarlyCheckInProducts.js +32 -0
  237. package/dist/useCases/DescribeReservationLateCheckOutProducts.js +32 -0
  238. package/dist/useCases/{AdminDescribeProperty.js → DescribeReservationRoomUpgrades.js} +2 -2
  239. package/dist/useCases/{AdminRefreshToken.js → ListAnnouncements.js} +3 -3
  240. package/dist/useCases/ListCategories.js +32 -0
  241. package/dist/useCases/ListMediaSources.js +32 -0
  242. package/dist/useCases/{CreateSource.js → ListMyOrders.js} +4 -4
  243. package/dist/useCases/{AdminListProperties.js → ListMyTickets.js} +2 -2
  244. package/dist/useCases/ListOrders.js +32 -0
  245. package/dist/useCases/{DeleteIntegration.js → ListOrganizations.js} +3 -3
  246. package/dist/useCases/ListProperties.js +32 -0
  247. package/dist/useCases/ListScenes.js +32 -0
  248. package/dist/useCases/ListTeam.js +32 -0
  249. package/dist/useCases/ListUserOrders.js +32 -0
  250. package/dist/useCases/ListUserSpaces.js +32 -0
  251. package/dist/useCases/LogoutUser.js +32 -0
  252. package/dist/useCases/PurchaseReservationEarlyCheckInProducts.js +32 -0
  253. package/dist/useCases/PurchaseReservationLateCheckOutProducts.js +32 -0
  254. package/dist/useCases/{CreateIntegrationDeviceMapEntry.js → PurchaseReservationRoomUpgrades.js} +2 -2
  255. package/dist/useCases/RequestLoginLink.js +1 -1
  256. package/dist/useCases/{CreateIntegration.js → RequestMyKeyToken.js} +2 -2
  257. package/dist/useCases/RequestPWAToken.js +32 -0
  258. package/dist/useCases/SendCheckInSMS.js +32 -0
  259. package/dist/useCases/SendCheckOutSMS.js +32 -0
  260. package/dist/useCases/SendRoomControlSMS.js +32 -0
  261. package/dist/useCases/{DeleteSource.js → SetAlarm.js} +3 -3
  262. package/dist/useCases/{SetSource.js → SetDimmer.js} +2 -2
  263. package/dist/useCases/{DescribeSource.js → SetMediaSource.js} +3 -3
  264. package/dist/useCases/{UpdateSource.js → SetRoomScene.js} +3 -3
  265. package/dist/useCases/SetSpaceScene.js +32 -0
  266. package/dist/useCases/TipUser.js +32 -0
  267. package/dist/useCases/UpdateAnnouncement.js +32 -0
  268. package/dist/useCases/UpdateCategory.js +32 -0
  269. package/dist/useCases/{UpdateIntegration.js → UpdateMediaSource.js} +3 -3
  270. package/dist/useCases/UpdateProperty.js +32 -0
  271. package/dist/useCases/UpdateReservationExpectedArrivalTime.js +32 -0
  272. package/dist/useCases/{ListSources.js → UploadImage.js} +4 -4
  273. package/package.json +37 -14
  274. package/dist/cjs/Commands.js +0 -643
  275. package/dist/cjs/Errors.js +0 -176
  276. package/dist/cjs/Events.js +0 -387
  277. package/dist/cjs/Models.js +0 -3612
  278. package/dist/cjs/defs.js +0 -178
  279. package/dist/cjs/utils.js +0 -250
  280. package/dist/useCases/AdminRequestLoginLink.js +0 -32
  281. package/dist/useCases/DescribeReservationCheckinStatus.js +0 -32
@@ -0,0 +1,35 @@
1
+ // Create the Gateway Model
2
+ const schemas = require("../utils/schema");
3
+ const schema = require("../schemas/gateway.json");
4
+ const Entity = require("./Entity");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class Gateway extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/GatewaySchema").Gateway} GatewayType
12
+ * Create a Gateway instance.
13
+ * @constructor
14
+ * @param {GatewayType} gateway - The gateway object of type Gateway.
15
+ */
16
+ constructor(gateway) {
17
+ super(gateway);
18
+ }
19
+ }
20
+
21
+ Object.defineProperty(Gateway.prototype, "schema", {
22
+ value: schema,
23
+ });
24
+
25
+ Object.defineProperty(Gateway.prototype, "validator", {
26
+ get: function () {
27
+ return validator;
28
+ },
29
+ });
30
+
31
+ Object.defineProperty(Gateway, "validProperties", {
32
+ value: Object.keys(schema.properties),
33
+ });
34
+
35
+ module.exports = Gateway;
@@ -0,0 +1,38 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/identification.json");
3
+ const Entity = require("./Entity");
4
+
5
+ schemas.add(schema);
6
+ const validator = schemas.compile(schema);
7
+
8
+ class Identification extends Entity {
9
+ /**
10
+ * @typedef {import("../schemas/IdentificationSchema").Identification} IdentificationType
11
+ * Create a Identification instance.
12
+ * @constructor
13
+ * @param {IdentificationType} identification - The identification object of type Identification.
14
+ */
15
+ constructor(identification) {
16
+ super(identification);
17
+ }
18
+
19
+ get isExpired() {
20
+ return new Date(this.expires) < new Date();
21
+ }
22
+ }
23
+
24
+ Object.defineProperty(Identification.prototype, "schema", {
25
+ value: schema,
26
+ });
27
+
28
+ Object.defineProperty(Identification.prototype, "validator", {
29
+ get: function () {
30
+ return validator;
31
+ },
32
+ });
33
+
34
+ Object.defineProperty(Identification, "validProperties", {
35
+ value: Object.keys(schema.properties),
36
+ });
37
+
38
+ module.exports = Identification;
@@ -0,0 +1,39 @@
1
+ // Create the Lock Model
2
+ const schemas = require("../utils/schema");
3
+ const schema = require("../schemas/lock.json");
4
+ const Entity = require("./Entity");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class Lock extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/LockSchema").Lock} LockType
12
+ * Create a Lock instance.
13
+ * @constructor
14
+ * @param {LockType} lock - The lock object of type Lock.
15
+ */
16
+ constructor(lock) {
17
+ super(lock);
18
+ }
19
+ }
20
+
21
+ Object.defineProperty(Lock.prototype, "schema", {
22
+ value: schema,
23
+ });
24
+
25
+ Object.defineProperty(Lock.prototype, "validator", {
26
+ get: function () {
27
+ return validator;
28
+ },
29
+ });
30
+
31
+ Object.defineProperty(Lock, "validProperties", {
32
+ value: Object.keys(schema.properties),
33
+ });
34
+
35
+ Object.defineProperty(Lock, "actionProperties", {
36
+ value: ["state"],
37
+ });
38
+
39
+ module.exports = Lock;
@@ -0,0 +1,48 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/mediaFile.json");
3
+ const Entity = require("./Entity");
4
+ const { RequestError } = require("../Errors");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class MediaFile extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/MediaFileSchema").MediaFile} MediaFileType
12
+ * Create a MediaFile instance.
13
+ * @constructor
14
+ * @param {MediaFileType} mediaFile - The mediaFile object of type MediaFile.
15
+ */
16
+ constructor(mediaFile) {
17
+ super(mediaFile);
18
+ }
19
+
20
+ createImageVariant(params) {
21
+ if (this.mimeType != "image/*")
22
+ throw new RequestError("Only dynamic images can have variants");
23
+ if (!this.url) throw new RequestError("MediaFile has no url");
24
+ // convert params to "key=value" pairs
25
+ const query = Object.keys(params)
26
+ .map((key) => `${key}=${params[key]}`)
27
+ .join(",");
28
+
29
+ // replace the final /public with the query above
30
+ return this.url.replace(/\/public$/, `/${query}`);
31
+ }
32
+ }
33
+
34
+ Object.defineProperty(MediaFile.prototype, "schema", {
35
+ value: schema,
36
+ });
37
+
38
+ Object.defineProperty(MediaFile.prototype, "validator", {
39
+ get: function () {
40
+ return validator;
41
+ },
42
+ });
43
+
44
+ Object.defineProperty(MediaFile, "validProperties", {
45
+ value: Object.keys(schema.properties),
46
+ });
47
+
48
+ module.exports = MediaFile;
@@ -0,0 +1,35 @@
1
+ // create the Media Source Model
2
+ const schemas = require("../utils/schema");
3
+ const schema = require("../schemas/mediaSource.json");
4
+ const Entity = require("./Entity");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class MediaSource extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/MediaSourceSchema").MediaSource} MediaSourceType
12
+ * Create a MediaSource instance.
13
+ * @constructor
14
+ * @param {MediaSourceType} mediaSource - The mediaSource object of type MediaSource.
15
+ */
16
+ constructor(mediaSource) {
17
+ super(mediaSource);
18
+ }
19
+ }
20
+
21
+ Object.defineProperty(MediaSource.prototype, "schema", {
22
+ value: schema,
23
+ });
24
+
25
+ Object.defineProperty(MediaSource.prototype, "validator", {
26
+ get: function () {
27
+ return validator;
28
+ },
29
+ });
30
+
31
+ Object.defineProperty(MediaSource, "validProperties", {
32
+ value: Object.keys(schema.properties),
33
+ });
34
+
35
+ module.exports = MediaSource;
@@ -0,0 +1,35 @@
1
+ // create the Motion Sensor Model
2
+ const schemas = require("../utils/schema");
3
+ const schema = require("../schemas/motionSensor.json");
4
+ const Entity = require("./Entity");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class MotionSensor extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/MotionSensorSchema").MotionSensor} MotionSensorType
12
+ * Create a MotionSensor instance.
13
+ * @constructor
14
+ * @param {MotionSensorType} motionSensor - The motionSensor object of type MotionSensor.
15
+ */
16
+ constructor(motionSensor) {
17
+ super(motionSensor);
18
+ }
19
+ }
20
+
21
+ Object.defineProperty(MotionSensor.prototype, "schema", {
22
+ value: schema,
23
+ });
24
+
25
+ Object.defineProperty(MotionSensor.prototype, "validator", {
26
+ get: function () {
27
+ return validator;
28
+ },
29
+ });
30
+
31
+ Object.defineProperty(MotionSensor, "validProperties", {
32
+ value: Object.keys(schema.properties),
33
+ });
34
+
35
+ module.exports = MotionSensor;
@@ -0,0 +1,97 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/order.json");
3
+ const Entity = require("./Entity");
4
+
5
+ schemas.add(schema);
6
+ const validator = schemas.compile(schema);
7
+
8
+ class Order extends Entity {
9
+ /**
10
+ * @typedef {import("../schemas/OrderSchema").Order} OrderType
11
+ * Create a Order instance.
12
+ * @constructor
13
+ * @param {OrderType} order - The order object of type Order.
14
+ */
15
+ constructor(order) {
16
+ super(order);
17
+ }
18
+
19
+ getSubTotal() {
20
+ return this.items.reduce((acc, item) => {
21
+ const qty = item.quantity || 1;
22
+ return acc + item.price * qty;
23
+ }, 0);
24
+ }
25
+
26
+ getTaxTotal() {
27
+ const taxes = this.taxes;
28
+ if (!taxes) return 0;
29
+ return this.items.reduce((acc, item) => {
30
+ if (!item.taxClass) return acc;
31
+ const tax = taxes.find((t) => t.class === item.taxClass);
32
+ if (!tax) return acc;
33
+ const { rateType, rate } = tax;
34
+ if (rateType === "percentage") {
35
+ return acc + item.price * rate;
36
+ }
37
+ return acc + rate;
38
+ }, 0);
39
+ }
40
+
41
+ getDeliveryTotal() {
42
+ const delivery = this.delivery;
43
+ if (!delivery) return 0;
44
+ return this.items.reduce((acc, item) => {
45
+ if (!item.deliveryClass) return acc;
46
+ const d = delivery.find((d) => d.class === item.deliveryClass);
47
+ if (!d) return acc;
48
+ const { rateType, rate } = d;
49
+ if (rateType === "percentage") {
50
+ return acc + item.price * rate;
51
+ }
52
+ return acc + rate;
53
+ }, 0);
54
+ }
55
+
56
+ getFeesTotal() {
57
+ const fees = this.fees;
58
+ return fees.reduce((acc, fee) => {
59
+ return acc + fee.price;
60
+ }, 0);
61
+ }
62
+
63
+ getTotal() {
64
+ return (
65
+ this.getSubTotal() +
66
+ this.getTaxTotal() +
67
+ this.getDeliveryTotal() +
68
+ this.getFeesTotal()
69
+ );
70
+ }
71
+
72
+ getPaymentsTotal() {
73
+ return this.payments.reduce((acc, payment) => {
74
+ return acc + payment.amount;
75
+ }, 0);
76
+ }
77
+
78
+ getBalance() {
79
+ return this.getTotal() - this.getPaymentsTotal();
80
+ }
81
+ }
82
+
83
+ Object.defineProperty(Order.prototype, "schema", {
84
+ value: schema,
85
+ });
86
+
87
+ Object.defineProperty(Order.prototype, "validator", {
88
+ get: function () {
89
+ return validator;
90
+ },
91
+ });
92
+
93
+ Object.defineProperty(Order, "validProperties", {
94
+ value: Object.keys(schema.properties),
95
+ });
96
+
97
+ module.exports = Order;
@@ -0,0 +1,34 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/organization.json");
3
+ const Entity = require("./Entity");
4
+
5
+ schemas.add(schema);
6
+ const validator = schemas.compile(schema);
7
+
8
+ class Organization extends Entity {
9
+ /**
10
+ * @typedef {import("../schemas/OrganizationSchema").Organization} OrganizationType
11
+ * Create a Organization instance.
12
+ * @constructor
13
+ * @param {OrganizationType} organization - The organization object of type Organization.
14
+ */
15
+ constructor(organization) {
16
+ super(organization);
17
+ }
18
+ }
19
+
20
+ Object.defineProperty(Organization.prototype, "schema", {
21
+ value: schema,
22
+ });
23
+
24
+ Object.defineProperty(Organization.prototype, "validator", {
25
+ get: function () {
26
+ return validator;
27
+ },
28
+ });
29
+
30
+ Object.defineProperty(Organization, "validProperties", {
31
+ value: Object.keys(schema.properties),
32
+ });
33
+
34
+ module.exports = Organization;
@@ -0,0 +1,35 @@
1
+ // Create the Product Model
2
+ const schemas = require("../utils/schema");
3
+ const schema = require("../schemas/product.json");
4
+ const Entity = require("./Entity");
5
+
6
+ schemas.add(schema);
7
+ const validator = schemas.compile(schema);
8
+
9
+ class Product extends Entity {
10
+ /**
11
+ * @typedef {import("../schemas/ProductSchema").Product} ProductType
12
+ * Create a Product instance.
13
+ * @constructor
14
+ * @param {ProductType} product - The product object of type Product.
15
+ */
16
+ constructor(product) {
17
+ super(product);
18
+ }
19
+ }
20
+
21
+ Object.defineProperty(Product.prototype, "schema", {
22
+ value: schema,
23
+ });
24
+
25
+ Object.defineProperty(Product.prototype, "validator", {
26
+ get: function () {
27
+ return validator;
28
+ },
29
+ });
30
+
31
+ Object.defineProperty(Product, "validProperties", {
32
+ value: Object.keys(schema.properties),
33
+ });
34
+
35
+ module.exports = Product;
@@ -0,0 +1,34 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/property.json");
3
+ const Entity = require("./Entity");
4
+
5
+ schemas.add(schema);
6
+ const validator = schemas.compile(schema);
7
+
8
+ class Property extends Entity {
9
+ /**
10
+ * @typedef {import("../schemas/PropertySchema").Property} PropertyType
11
+ * Create a Property instance.
12
+ * @constructor
13
+ * @param {PropertyType} property - The property object of type Property.
14
+ */
15
+ constructor(property) {
16
+ super(property);
17
+ }
18
+ }
19
+
20
+ Object.defineProperty(Property.prototype, "schema", {
21
+ value: schema,
22
+ });
23
+
24
+ Object.defineProperty(Property.prototype, "validator", {
25
+ get: function () {
26
+ return validator;
27
+ },
28
+ });
29
+
30
+ Object.defineProperty(Property, "validProperties", {
31
+ value: Object.keys(schema.properties),
32
+ });
33
+
34
+ module.exports = Property;
@@ -0,0 +1,114 @@
1
+ const schemas = require("../utils/schema");
2
+ const schema = require("../schemas/reservation.json");
3
+ const Entity = require("./Entity");
4
+
5
+ schemas.add(schema);
6
+ const validator = schemas.compile(schema);
7
+
8
+ class Reservation extends Entity {
9
+ /**
10
+ * @typedef {import("../schemas/ReservationSchema").Reservation} ReservationType
11
+ * Create a Reservation instance.
12
+ * @constructor
13
+ * @param {ReservationType} reservation - The reservation object of type Reservation.
14
+ */
15
+ constructor(reservation) {
16
+ super(reservation);
17
+ }
18
+
19
+ get peopleCount() {
20
+ return this.adultCount + this.childCount;
21
+ }
22
+
23
+ get hasPayment() {
24
+ return this.paymentId?.length > 0;
25
+ }
26
+
27
+ get nights() {
28
+ const start = new Date(this.checkInDateTime);
29
+ const end = new Date(this.checkOutDateTime);
30
+ let nights = Math.round((end - start) / (1000 * 60 * 60 * 24));
31
+ if (nights <= 0) {
32
+ nights = 1;
33
+ }
34
+ return nights;
35
+ }
36
+
37
+ range(tz) {
38
+ const start = new Date(this.checkInDateTime);
39
+ const end = new Date(this.checkOutDateTime);
40
+
41
+ // output Dec 19 if same day in timezone
42
+
43
+ if (
44
+ start.getDate() === end.getDate() &&
45
+ start.getMonth() === end.getMonth() &&
46
+ start.getFullYear() === end.getFullYear()
47
+ ) {
48
+ return `${start.toLocaleString("default", {
49
+ month: "short",
50
+ timeZone: tz,
51
+ })} ${start.toLocaleString("default", {
52
+ timeZone: tz,
53
+ day: "numeric",
54
+ })}`;
55
+ }
56
+ // output Dec 19-23 if same month and year
57
+ if (
58
+ start.getMonth() === end.getMonth() &&
59
+ start.getFullYear() === end.getFullYear()
60
+ ) {
61
+ return `${start.toLocaleString("default", {
62
+ month: "short",
63
+ timeZone: tz,
64
+ })} ${start.toLocaleString("default", {
65
+ timeZone: tz,
66
+ day: "numeric",
67
+ })}-${end.toLocaleString("default", {
68
+ timeZone: tz,
69
+ day: "numeric",
70
+ })}`;
71
+ }
72
+
73
+ // output Dec 19 - Jan 2 if different month and year
74
+ return `${start.toLocaleString("default", {
75
+ month: "short",
76
+ timeZone: tz,
77
+ })} ${start.getDate()} - ${end.toLocaleString("default", {
78
+ month: "short",
79
+ timeZone: tz,
80
+ })} ${end.getDate()}`;
81
+ }
82
+
83
+ checkInTime(tz) {
84
+ return new Date(this.checkInDateTime).toLocaleString("default", {
85
+ hour: "numeric",
86
+ minute: "numeric",
87
+ timeZone: tz,
88
+ });
89
+ }
90
+
91
+ checkOutTime(tz) {
92
+ return new Date(this.checkOutDateTime).toLocaleString("default", {
93
+ hour: "numeric",
94
+ minute: "numeric",
95
+ timeZone: tz,
96
+ });
97
+ }
98
+ }
99
+
100
+ Object.defineProperty(Reservation.prototype, "schema", {
101
+ value: schema,
102
+ });
103
+
104
+ Object.defineProperty(Reservation.prototype, "validator", {
105
+ get: function () {
106
+ return validator;
107
+ },
108
+ });
109
+
110
+ Object.defineProperty(Reservation, "validProperties", {
111
+ value: Object.keys(schema.properties),
112
+ });
113
+
114
+ module.exports = Reservation;