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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/dist/cjs/Client.js +5089 -0
  2. package/dist/cjs/Commands.js +568 -0
  3. package/dist/cjs/Errors.js +174 -0
  4. package/dist/cjs/Events.js +375 -0
  5. package/dist/cjs/Models.js +3584 -0
  6. package/dist/cjs/defs.js +175 -0
  7. package/dist/cjs/index.cjs.js +17 -0
  8. package/dist/cjs/utils.js +246 -0
  9. package/dist/esm/Client.js +7428 -0
  10. package/dist/esm/Client.js.map +7 -0
  11. package/dist/esm/Commands.js +574 -0
  12. package/dist/esm/Commands.js.map +7 -0
  13. package/dist/esm/Errors.js +180 -0
  14. package/dist/esm/Errors.js.map +7 -0
  15. package/dist/esm/Events.js +381 -0
  16. package/dist/esm/Events.js.map +7 -0
  17. package/dist/esm/Models.js +13220 -0
  18. package/dist/esm/Models.js.map +7 -0
  19. package/dist/esm/defs.js +2514 -0
  20. package/dist/esm/defs.js.map +7 -0
  21. package/dist/esm/index.js +11 -0
  22. package/dist/esm/utils.js +7281 -0
  23. package/dist/esm/utils.js.map +7 -0
  24. package/dist/useCases/AddDefaultScenesToRooms.js +32 -0
  25. package/dist/useCases/AddScenesToRoom.js +32 -0
  26. package/dist/useCases/AdminCreateProperty.js +32 -0
  27. package/dist/useCases/AdminDescribeProperty.js +32 -0
  28. package/dist/useCases/AdminListCustomers.js +32 -0
  29. package/dist/useCases/AdminListProperties.js +32 -0
  30. package/dist/useCases/AdminUpdateProperty.js +32 -0
  31. package/dist/useCases/BatchNotifyPreArrival.js +32 -0
  32. package/dist/useCases/CheckInReservation.js +32 -0
  33. package/dist/useCases/CheckVerificationCode.js +32 -0
  34. package/dist/useCases/CreateAlarm.js +32 -0
  35. package/dist/useCases/CreateCamera.js +32 -0
  36. package/dist/useCases/CreateCourtesy.js +32 -0
  37. package/dist/useCases/CreateDefaultScenes.js +32 -0
  38. package/dist/useCases/CreateDimmer.js +32 -0
  39. package/dist/useCases/CreateDiscoveredDevice.js +32 -0
  40. package/dist/useCases/CreateDiscoveredDeviceAssociation.js +32 -0
  41. package/dist/useCases/CreateIntegration.js +32 -0
  42. package/dist/useCases/CreateIntegrationDeviceMapEntry.js +32 -0
  43. package/dist/useCases/CreateLock.js +32 -0
  44. package/dist/useCases/CreateReservation.js +32 -0
  45. package/dist/useCases/CreateRoom.js +32 -0
  46. package/dist/useCases/CreateRoomInSpace.js +32 -0
  47. package/dist/useCases/CreateSource.js +32 -0
  48. package/dist/useCases/CreateSpace.js +32 -0
  49. package/dist/useCases/CreateSwitch.js +32 -0
  50. package/dist/useCases/CreateThermostat.js +32 -0
  51. package/dist/useCases/CreateTicket.js +32 -0
  52. package/dist/useCases/CreateTicketMessage.js +32 -0
  53. package/dist/useCases/CreateUser.js +32 -0
  54. package/dist/useCases/CreateWindowCovering.js +32 -0
  55. package/dist/useCases/DeleteAlarm.js +32 -0
  56. package/dist/useCases/DeleteCamera.js +32 -0
  57. package/dist/useCases/DeleteCourtesy.js +32 -0
  58. package/dist/useCases/DeleteDimmer.js +32 -0
  59. package/dist/useCases/DeleteDiscoveredDevice.js +32 -0
  60. package/dist/useCases/DeleteIntegration.js +32 -0
  61. package/dist/useCases/DeleteLock.js +32 -0
  62. package/dist/useCases/DeleteReservation.js +32 -0
  63. package/dist/useCases/DeleteRoom.js +32 -0
  64. package/dist/useCases/DeleteSource.js +32 -0
  65. package/dist/useCases/DeleteSpace.js +32 -0
  66. package/dist/useCases/DeleteSwitch.js +32 -0
  67. package/dist/useCases/DeleteThermostat.js +32 -0
  68. package/dist/useCases/DeleteTicket.js +32 -0
  69. package/dist/useCases/DeleteUser.js +32 -0
  70. package/dist/useCases/DeleteWindowCovering.js +32 -0
  71. package/dist/useCases/DescribeAlarm.js +32 -0
  72. package/dist/useCases/DescribeCamera.js +32 -0
  73. package/dist/useCases/DescribeCourtesy.js +32 -0
  74. package/dist/useCases/DescribeDimmer.js +32 -0
  75. package/dist/useCases/DescribeDiscoveredDevice.js +32 -0
  76. package/dist/useCases/DescribeIntegration.js +32 -0
  77. package/dist/useCases/DescribeLock.js +32 -0
  78. package/dist/useCases/DescribeMyProperty.js +32 -0
  79. package/dist/useCases/DescribeReservation.js +32 -0
  80. package/dist/useCases/DescribeReservationCheckinStatus.js +32 -0
  81. package/dist/useCases/DescribeRoom.js +32 -0
  82. package/dist/useCases/DescribeSelf.js +32 -0
  83. package/dist/useCases/DescribeSource.js +32 -0
  84. package/dist/useCases/DescribeSpace.js +32 -0
  85. package/dist/useCases/DescribeSwitch.js +32 -0
  86. package/dist/useCases/DescribeThermostat.js +32 -0
  87. package/dist/useCases/DescribeTicket.js +32 -0
  88. package/dist/useCases/DescribeUser.js +32 -0
  89. package/dist/useCases/DescribeWindowCovering.js +32 -0
  90. package/dist/useCases/DiscoverReservations.js +32 -0
  91. package/dist/useCases/EmailUserAccountSetup.js +32 -0
  92. package/dist/useCases/ListAlarms.js +32 -0
  93. package/dist/useCases/ListCameras.js +32 -0
  94. package/dist/useCases/ListCourtesy.js +32 -0
  95. package/dist/useCases/ListDimmers.js +32 -0
  96. package/dist/useCases/ListDiscoveredDevices.js +32 -0
  97. package/dist/useCases/ListIntegrations.js +32 -0
  98. package/dist/useCases/ListLocks.js +32 -0
  99. package/dist/useCases/ListMyReservations.js +32 -0
  100. package/dist/useCases/ListMySpaces.js +32 -0
  101. package/dist/useCases/ListReservations.js +32 -0
  102. package/dist/useCases/ListRooms.js +32 -0
  103. package/dist/useCases/ListRoomsInSpace.js +32 -0
  104. package/dist/useCases/ListSources.js +32 -0
  105. package/dist/useCases/ListSpaces.js +32 -0
  106. package/dist/useCases/ListSwitches.js +32 -0
  107. package/dist/useCases/ListThermostats.js +32 -0
  108. package/dist/useCases/ListTickets.js +32 -0
  109. package/dist/useCases/ListUserReservations.js +32 -0
  110. package/dist/useCases/ListUsers.js +32 -0
  111. package/dist/useCases/ListWindowCoverings.js +32 -0
  112. package/dist/useCases/LoginGateway.js +32 -0
  113. package/dist/useCases/LoginUser.js +32 -0
  114. package/dist/useCases/MatchUserIdentification.js +32 -0
  115. package/dist/useCases/OCRDocument.js +32 -0
  116. package/dist/useCases/RefreshToken.js +32 -0
  117. package/dist/useCases/RequestLoginLink.js +32 -0
  118. package/dist/useCases/SendPreArrivalEmail.js +32 -0
  119. package/dist/useCases/SendPreArrivalSMS.js +32 -0
  120. package/dist/useCases/SendVerificationCode.js +32 -0
  121. package/dist/useCases/SetCamera.js +32 -0
  122. package/dist/useCases/SetCourtesy.js +32 -0
  123. package/dist/useCases/SetLock.js +32 -0
  124. package/dist/useCases/SetSource.js +32 -0
  125. package/dist/useCases/SetSwitch.js +32 -0
  126. package/dist/useCases/SetThermostat.js +32 -0
  127. package/dist/useCases/SetWindowCovering.js +32 -0
  128. package/dist/useCases/UpdateAlarm.js +32 -0
  129. package/dist/useCases/UpdateCamera.js +32 -0
  130. package/dist/useCases/UpdateCourtesy.js +32 -0
  131. package/dist/useCases/UpdateDimmer.js +32 -0
  132. package/dist/useCases/UpdateDiscoveredDevice.js +32 -0
  133. package/dist/useCases/UpdateIntegration.js +32 -0
  134. package/dist/useCases/UpdateLock.js +32 -0
  135. package/dist/useCases/UpdateMessageReadStatus.js +32 -0
  136. package/dist/useCases/UpdateReservation.js +32 -0
  137. package/dist/useCases/UpdateRoom.js +32 -0
  138. package/dist/useCases/UpdateSelf.js +32 -0
  139. package/dist/useCases/UpdateSource.js +32 -0
  140. package/dist/useCases/UpdateSpace.js +32 -0
  141. package/dist/useCases/UpdateSwitch.js +32 -0
  142. package/dist/useCases/UpdateThermostat.js +32 -0
  143. package/dist/useCases/UpdateTicket.js +32 -0
  144. package/dist/useCases/UpdateTicketStatus.js +32 -0
  145. package/dist/useCases/UpdateUser.js +32 -0
  146. package/dist/useCases/UpdateWindowCovering.js +32 -0
  147. package/dist/useCases/UpsertDiscoveredDevice.js +32 -0
  148. package/package.json +26 -7
  149. package/.eslintrc.js +0 -10
  150. package/bitbucket-pipelines.yml +0 -71
  151. package/commands/CheckInReservationCommand.js +0 -23
  152. package/commands/Command.js +0 -38
  153. package/commands/DiscoverReservationsCommand.js +0 -24
  154. package/commands/DiscoverRoomsCommand.js +0 -21
  155. package/commands/DiscoverUsersCommand.js +0 -21
  156. package/commands/OCRDocumentCommand.js +0 -20
  157. package/commands/SendEmailCommand.js +0 -24
  158. package/commands/SendSMSCommand.js +0 -21
  159. package/commands/SetAlarmCommand.js +0 -21
  160. package/commands/SetCourtesyCommand.js +0 -21
  161. package/commands/SetDimmerCommand.js +0 -21
  162. package/commands/SetLockCommand.js +0 -21
  163. package/commands/SetSceneControllerCommand.js +0 -21
  164. package/commands/SetSwitchCommand.js +0 -21
  165. package/commands/SetThermostatCommand.js +0 -21
  166. package/commands/SetWindowCoveringCommand.js +0 -21
  167. package/commands/index.js +0 -31
  168. package/defs/deviceTypes.js +0 -15
  169. package/defs/formalDeviceTypes.js +0 -6
  170. package/defs/http.js +0 -7
  171. package/defs/index.js +0 -11
  172. package/errors/AppError.js +0 -8
  173. package/errors/AuthenticationError.js +0 -9
  174. package/errors/AuthorizationError.js +0 -9
  175. package/errors/DeviceCommError.js +0 -9
  176. package/errors/LoginError.js +0 -9
  177. package/errors/NotFoundError.js +0 -9
  178. package/errors/RequestError.js +0 -9
  179. package/errors/SystemCommError.js +0 -9
  180. package/errors/TokenExpiredError.js +0 -9
  181. package/errors/UnprocessableRequestError.js +0 -9
  182. package/errors/ValidationError.js +0 -9
  183. package/errors/index.js +0 -15
  184. package/events/EmailSentEvent.js +0 -17
  185. package/events/Event.js +0 -52
  186. package/events/SMSSentEvent.js +0 -17
  187. package/events/ShortLinkCreatedEvent.js +0 -17
  188. package/events/SystemCameraUpdatedEvent.js +0 -17
  189. package/events/SystemCourtesyUpdatedEvent.js +0 -17
  190. package/events/SystemDimmerUpdatedEvent.js +0 -17
  191. package/events/SystemLockUpdatedEvent.js +0 -17
  192. package/events/SystemReservationUpdatedEvent.js +0 -17
  193. package/events/SystemSceneControllerUpdatedEvent.js +0 -17
  194. package/events/SystemSourceUpdatedEvent.js +0 -17
  195. package/events/SystemSpaceUpdatedEvent.js +0 -17
  196. package/events/SystemSwitchUpdatedEvent.js +0 -17
  197. package/events/SystemThermostatUpdatedEvent.js +0 -17
  198. package/events/SystemUserUpdatedEvent.js +0 -17
  199. package/events/SystemWindowCoveringUpdatedEvent.js +0 -17
  200. package/events/index.js +0 -35
  201. package/http/handleResponseError.js +0 -33
  202. package/http/handleResponseSuccess.js +0 -15
  203. package/http/index.js +0 -169
  204. package/index.js +0 -23
  205. package/models/acl.js +0 -29
  206. package/models/admin/customer.js +0 -28
  207. package/models/admin/property.js +0 -28
  208. package/models/alarm.js +0 -29
  209. package/models/application.js +0 -28
  210. package/models/camera.js +0 -29
  211. package/models/courtesy.js +0 -33
  212. package/models/credential.js +0 -29
  213. package/models/dimmer.js +0 -49
  214. package/models/discoveredDevice.js +0 -30
  215. package/models/gateway.js +0 -29
  216. package/models/identification.js +0 -32
  217. package/models/index.js +0 -56
  218. package/models/integration.js +0 -76
  219. package/models/kohost.js +0 -96
  220. package/models/lock.js +0 -33
  221. package/models/mediaSource.js +0 -29
  222. package/models/motionSensor.js +0 -29
  223. package/models/product.js +0 -30
  224. package/models/reservation.js +0 -83
  225. package/models/room.js +0 -174
  226. package/models/scene.js +0 -28
  227. package/models/shortLink.js +0 -29
  228. package/models/space.js +0 -99
  229. package/models/switch.js +0 -33
  230. package/models/thermostat.js +0 -80
  231. package/models/ticket.js +0 -91
  232. package/models/user.js +0 -56
  233. package/models/windowCovering.js +0 -49
  234. package/prepare.js +0 -4
  235. package/schemas/acl.json +0 -111
  236. package/schemas/admin/customer.json +0 -32
  237. package/schemas/admin/property.json +0 -180
  238. package/schemas/alarm.json +0 -93
  239. package/schemas/application.json +0 -24
  240. package/schemas/camera.json +0 -41
  241. package/schemas/courtesy.json +0 -37
  242. package/schemas/credential.json +0 -28
  243. package/schemas/definitions/common.json +0 -74
  244. package/schemas/definitions/device.json +0 -76
  245. package/schemas/dimmer.json +0 -34
  246. package/schemas/discoveredDevice.json +0 -43
  247. package/schemas/gateway.json +0 -30
  248. package/schemas/identification.json +0 -49
  249. package/schemas/integration.json +0 -94
  250. package/schemas/lock.json +0 -36
  251. package/schemas/mediaSource.json +0 -151
  252. package/schemas/motionSensor.json +0 -26
  253. package/schemas/payment.json +0 -40
  254. package/schemas/product.json +0 -36
  255. package/schemas/reservation.json +0 -71
  256. package/schemas/room.json +0 -131
  257. package/schemas/scene.json +0 -118
  258. package/schemas/shortLink.json +0 -30
  259. package/schemas/space.json +0 -111
  260. package/schemas/switch.json +0 -33
  261. package/schemas/thermostat.json +0 -139
  262. package/schemas/ticket.json +0 -82
  263. package/schemas/user.json +0 -176
  264. package/schemas/windowCovering.json +0 -34
  265. package/tests/unit/models/space.test.js +0 -31
  266. package/tests/unit/models/thermostat.test.js +0 -146
  267. package/tests/unit/models/user.test.js +0 -28
  268. package/useCases/http.json +0 -1161
  269. package/utils/getDeviceTypes.js +0 -7
  270. package/utils/getFormalDeviceType.js +0 -5
  271. package/utils/schema.js +0 -28
@@ -1,15 +0,0 @@
1
- const types = [
2
- "dimmer",
3
- "switch",
4
- "thermostat",
5
- "lock",
6
- "windowCovering",
7
- "sceneController",
8
- "courtesy",
9
- "alarm",
10
- "camera",
11
- "source",
12
- "motionSensor",
13
- ];
14
-
15
- module.exports = types;
@@ -1,6 +0,0 @@
1
- const deviceTypes = require("./deviceTypes");
2
- const formalDeviceTypes = deviceTypes.map(
3
- (type) => type.charAt(0).toUpperCase() + type.slice(1)
4
- );
5
-
6
- module.exports = formalDeviceTypes;
package/defs/http.js DELETED
@@ -1,7 +0,0 @@
1
- const http = {
2
- authTokenHeader: "X-Auth-Token",
3
- refreshTokenHeader: "X-Refresh-Token",
4
- propertyHeader: "X-Property-Id",
5
- };
6
-
7
- module.exports = http;
package/defs/index.js DELETED
@@ -1,11 +0,0 @@
1
- const http = require("./http");
2
- const deviceTypes = require("./deviceTypes");
3
- const formalDeviceTypes = require("./formalDeviceTypes");
4
-
5
- const defs = {
6
- http,
7
- deviceTypes,
8
- formalDeviceTypes,
9
- };
10
-
11
- module.exports = defs;
@@ -1,8 +0,0 @@
1
- module.exports = class AppError extends Error {
2
- constructor(message = "Internal Server Error", options) {
3
- super(message, options);
4
- this.type = this.constructor.name;
5
- this.statusCode = 500;
6
- Object.setPrototypeOf(this, AppError.prototype);
7
- }
8
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class AuthenticationError extends AppError {
4
- constructor(message = "Authentication Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 401;
7
- Object.setPrototypeOf(this, AuthenticationError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class AuthorizationError extends AppError {
4
- constructor(message = "Authorization Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 403;
7
- Object.setPrototypeOf(this, AuthorizationError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class DeviceCommError extends AppError {
4
- constructor(message = "Device Communication Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 503;
7
- Object.setPrototypeOf(this, DeviceCommError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class LoginError extends AppError {
4
- constructor(message = "Invalid Login information provided", options = {}) {
5
- super(message, options);
6
- this.statusCode = 401;
7
- Object.setPrototypeOf(this, LoginError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class NotFoundError extends AppError {
4
- constructor(message = "Resource Not Found", options = {}) {
5
- super(message, options);
6
- this.statusCode = 404;
7
- Object.setPrototypeOf(this, NotFoundError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class RequestError extends AppError {
4
- constructor(message = "Bad Request", options = {}) {
5
- super(message, options);
6
- this.statusCode = 400;
7
- Object.setPrototypeOf(this, RequestError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class SystemCommError extends AppError {
4
- constructor(message = "System Communication Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 503;
7
- Object.setPrototypeOf(this, SystemCommError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class TokenExpiredError extends AppError {
4
- constructor(message = "Token Expired", options = {}) {
5
- super(message, options);
6
- this.statusCode = 401;
7
- Object.setPrototypeOf(this, TokenExpiredError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class UnprocessableRequestError extends AppError {
4
- constructor(message = "Unprocessable Request Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 422;
7
- Object.setPrototypeOf(this, UnprocessableRequestError.prototype);
8
- }
9
- };
@@ -1,9 +0,0 @@
1
- const AppError = require("./AppError");
2
-
3
- module.exports = class ValidationError extends AppError {
4
- constructor(message = "Validation Error", options = {}) {
5
- super(message, options);
6
- this.statusCode = 400;
7
- Object.setPrototypeOf(this, ValidationError.prototype);
8
- }
9
- };
package/errors/index.js DELETED
@@ -1,15 +0,0 @@
1
- const Errors = {
2
- AppError: require("./AppError"),
3
- AuthenticationError: require("./AuthenticationError"),
4
- AuthorizationError: require("./AuthorizationError"),
5
- DeviceCommError: require("./DeviceCommError"),
6
- LoginError: require("./LoginError"),
7
- NotFoundError: require("./NotFoundError"),
8
- RequestError: require("./RequestError"),
9
- SystemCommError: require("./SystemCommError"),
10
- TokenExpiredError: require("./TokenExpiredError"),
11
- UnprocessableRequestError: require("./UnprocessableRequestError"),
12
- ValidationError: require("./ValidationError"),
13
- };
14
-
15
- module.exports = Errors;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class EmailSentEvent extends Event {
4
- constructor(email, context) {
5
- super(email, context);
6
- }
7
-
8
- get name() {
9
- return "EmailSent";
10
- }
11
-
12
- get routingKey() {
13
- return "comm.email.sent";
14
- }
15
- }
16
-
17
- module.exports = EmailSentEvent;
package/events/Event.js DELETED
@@ -1,52 +0,0 @@
1
- class Event {
2
- constructor(data, context) {
3
- this.data = {};
4
- this.context = {};
5
- if (!data) throw new Error("Event data is required");
6
- if (typeof data !== "object")
7
- throw new Error("Event data must be an object");
8
-
9
- if (!data.name) this.data.name = this.name;
10
- if (!data.type) this.data.type = this.type;
11
-
12
- for (const key in data) {
13
- this.data[key] = data[key];
14
- }
15
-
16
- if (data.eventData) {
17
- for (const key in data.eventData) {
18
- this.data[key] = data.eventData[key];
19
- }
20
- delete this.data.eventData;
21
- }
22
-
23
- if (context) {
24
- for (const key in context) {
25
- this.context[key] = context[key];
26
- }
27
- }
28
-
29
- if (!this.data.timestamp) this.data.timestamp = new Date();
30
- }
31
- get name() {
32
- throw new Error("Event name is required");
33
- }
34
-
35
- get type() {
36
- return "Event";
37
- }
38
-
39
- get routingKey() {
40
- return "";
41
- }
42
-
43
- get exchange() {
44
- return "Events";
45
- }
46
-
47
- build() {
48
- return { data: { ...this.data } };
49
- }
50
- }
51
-
52
- module.exports = Event;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SMSSentEvent extends Event {
4
- constructor(email, context) {
5
- super(email, context);
6
- }
7
-
8
- get name() {
9
- return "SMSSent";
10
- }
11
-
12
- get routingKey() {
13
- return "comm.sms.sent";
14
- }
15
- }
16
-
17
- module.exports = SMSSentEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class ShortLinkCreatedEvent extends Event {
4
- constructor(shortLink, context) {
5
- super(shortLink, context);
6
- }
7
-
8
- get name() {
9
- return "ShortLinkCreated";
10
- }
11
-
12
- get routingKey() {
13
- return `shortlink.${this.data.id}.created`;
14
- }
15
- }
16
-
17
- module.exports = ShortLinkCreatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemCameraUpdatedEvent extends Event {
4
- constructor(camera) {
5
- super(camera);
6
- }
7
-
8
- get name() {
9
- return "SystemCameraUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `camera.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemCameraUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemCourtesyUpdatedEvent extends Event {
4
- constructor(courtesy) {
5
- super(courtesy);
6
- }
7
-
8
- get name() {
9
- return "SystemCourtesyUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `courtesy.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemCourtesyUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemDimmerUpdatedEvent extends Event {
4
- constructor(dimmer) {
5
- super(dimmer);
6
- }
7
-
8
- get name() {
9
- return "SystemDimmerUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `dimmer.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemDimmerUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemLockUpdatedEvent extends Event {
4
- constructor(lock) {
5
- super(lock);
6
- }
7
-
8
- get name() {
9
- return "SystemLockUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `lock.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemLockUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemReservationUpdatedEvent extends Event {
4
- constructor(reservation) {
5
- super(reservation);
6
- }
7
-
8
- get name() {
9
- return "SystemReservationUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `reservation.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemReservationUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemSceneControllerUpdatedEvent extends Event {
4
- constructor(sceneController) {
5
- super(sceneController);
6
- }
7
-
8
- get name() {
9
- return "SystemSceneControllerUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `sceneController.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemSceneControllerUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemSourceUpdatedEvent extends Event {
4
- constructor(source) {
5
- super(source);
6
- }
7
-
8
- get name() {
9
- return "SystemSourceUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `source.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemSourceUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemSpaceUpdatedEvent extends Event {
4
- constructor(space) {
5
- super(space);
6
- }
7
-
8
- get name() {
9
- return "SystemSpaceUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `space.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemSpaceUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemSwitchUpdatedEvent extends Event {
4
- constructor(_switch) {
5
- super(_switch);
6
- }
7
-
8
- get name() {
9
- return "SystemSwitchUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `switch.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemSwitchUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemThermostatUpdatedEvent extends Event {
4
- constructor(thermostat) {
5
- super(thermostat);
6
- }
7
-
8
- get name() {
9
- return "SystemThermostatUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `thermostat.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemThermostatUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemUserUpdatedEvent extends Event {
4
- constructor(thermostat) {
5
- super(thermostat);
6
- }
7
-
8
- get name() {
9
- return "SystemUserUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `user.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemUserUpdatedEvent;
@@ -1,17 +0,0 @@
1
- const Event = require("./Event");
2
-
3
- class SystemWindowCoveringUpdatedEvent extends Event {
4
- constructor(wc) {
5
- super(wc);
6
- }
7
-
8
- get name() {
9
- return "SystemWindowCoveringUpdated";
10
- }
11
-
12
- get routingKey() {
13
- return `windowCovering.${this.data.id}.updated`;
14
- }
15
- }
16
-
17
- module.exports = SystemWindowCoveringUpdatedEvent;
package/events/index.js DELETED
@@ -1,35 +0,0 @@
1
- const SystemThermostatUpdatedEvent = require("./SystemThermostatUpdatedEvent");
2
- const SystemDimmerUpdatedEvent = require("./SystemDimmerUpdatedEvent");
3
- const SystemSwitchUpdatedEvent = require("./SystemSwitchUpdatedEvent");
4
- const SystemLockUpdatedEvent = require("./SystemLockUpdatedEvent");
5
- const SystemCameraUpdatedEvent = require("./SystemCameraUpdatedEvent");
6
- const SystemSceneControllerUpdatedEvent = require("./SystemSceneControllerUpdatedEvent");
7
- const SystemWindowCoveringUpdatedEvent = require("./SystemWindowCoveringUpdatedEvent");
8
- const SystemSourceUpdatedEvent = require("./SystemSourceUpdatedEvent");
9
- const SystemCourtesyUpdatedEvent = require("./SystemCourtesyUpdatedEvent");
10
-
11
- const SystemUserUpdatedEvent = require("./SystemUserUpdatedEvent");
12
- const SystemSpaceUpdatedEvent = require("./SystemSpaceUpdatedEvent");
13
- const SystemReservationUpdatedEvent = require("./SystemReservationUpdatedEvent");
14
-
15
- const SMSSentEvent = require("./SMSSentEvent");
16
- const EmailSentEvent = require("./EmailSentEvent");
17
- const ShortLinkCreatedEvent = require("./ShortLinkCreatedEvent");
18
-
19
- module.exports = {
20
- SystemThermostatUpdatedEvent,
21
- SystemDimmerUpdatedEvent,
22
- SystemSwitchUpdatedEvent,
23
- SystemLockUpdatedEvent,
24
- SystemCameraUpdatedEvent,
25
- SystemSceneControllerUpdatedEvent,
26
- SystemWindowCoveringUpdatedEvent,
27
- SystemSourceUpdatedEvent,
28
- SystemCourtesyUpdatedEvent,
29
- SystemUserUpdatedEvent,
30
- SystemSpaceUpdatedEvent,
31
- SystemReservationUpdatedEvent,
32
- SMSSentEvent,
33
- EmailSentEvent,
34
- ShortLinkCreatedEvent,
35
- };
@@ -1,33 +0,0 @@
1
- module.exports = function handleResponseError(error) {
2
- const { config: originalReq } = error;
3
- if (!error.response) return Promise.reject(error);
4
- const { status, data } = error.response;
5
- const errorType = data?.error?.type;
6
- const errorMessage = data?.error?.message;
7
-
8
- try {
9
- const expectedError = status >= 400 && status < 500;
10
- const newTokensNeeded = expectedError && errorType === "TokenExpiredError";
11
-
12
- if (expectedError && errorMessage === "Login Required") {
13
- this.onLoginRequired();
14
- return Promise.reject(error);
15
- }
16
-
17
- if (expectedError && errorMessage === "No token provided") {
18
- this.onLoginRequired();
19
- return Promise.reject(error);
20
- }
21
-
22
- if (expectedError && newTokensNeeded) {
23
- return this.RefreshToken().then(() => {
24
- // retry the original request with the new token
25
- return this.http(originalReq);
26
- });
27
- }
28
- } catch (error) {
29
- console.log(error);
30
- }
31
-
32
- return Promise.reject(error);
33
- };
@@ -1,15 +0,0 @@
1
- module.exports = function handleResponseSuccess(response) {
2
- if (response?.data?.data) {
3
- response.query = response.data.query;
4
- response.pagination = response.data.pagination;
5
- response.data = response.data.data;
6
- }
7
- if (!this.isBrowser && response.headers[this.authTokenHeaderKey]) {
8
- this.authToken = response.headers[this.authTokenHeaderKey];
9
- }
10
-
11
- if (!this.isBrowser && response.headers[this.refreshTokenHeaderKey]) {
12
- this.refreshToken = response.headers[this.refreshTokenHeaderKey];
13
- }
14
- return response;
15
- };