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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/cjs/AMQPClient/index.js +290 -0
  2. package/dist/cjs/Commands/CheckInReservationCommand.js +19 -0
  3. package/dist/cjs/Commands/Command.js +34 -0
  4. package/dist/cjs/Commands/CreateImageUploadEndpointCommand.js +17 -0
  5. package/dist/cjs/Commands/CreateShortLinkCommand.js +20 -0
  6. package/dist/cjs/Commands/DiscoverReservationRoomTypeUpsellOptionsCommand.js +20 -0
  7. package/dist/cjs/Commands/DiscoverReservationsCommand.js +20 -0
  8. package/dist/cjs/Commands/DiscoverRoomTypesCommand.js +19 -0
  9. package/dist/cjs/Commands/DiscoverRoomsCommand.js +35 -0
  10. package/dist/cjs/Commands/DiscoverUsersCommand.js +19 -0
  11. package/dist/cjs/Commands/GetMobileKeyCommand.js +24 -0
  12. package/dist/cjs/Commands/GetProductsCommand.js +17 -0
  13. package/dist/cjs/Commands/OCRDocumentCommand.js +15 -0
  14. package/dist/cjs/Commands/SellProductsCommand.js +17 -0
  15. package/dist/cjs/Commands/SendEmailCommand.js +24 -0
  16. package/dist/cjs/Commands/SendSMSCommand.js +21 -0
  17. package/dist/cjs/Commands/SetAlarmCommand.js +17 -0
  18. package/dist/cjs/Commands/SetCourtesyCommand.js +17 -0
  19. package/dist/cjs/Commands/SetDimmerCommand.js +17 -0
  20. package/dist/cjs/Commands/SetLockCommand.js +17 -0
  21. package/dist/cjs/Commands/SetMediaCommand.js +17 -0
  22. package/dist/cjs/Commands/SetSceneCommand.js +17 -0
  23. package/dist/cjs/Commands/SetSwitchCommand.js +17 -0
  24. package/dist/cjs/Commands/SetThermostatCommand.js +17 -0
  25. package/dist/cjs/Commands/SetWindowCoveringCommand.js +17 -0
  26. package/dist/cjs/Commands/UpdateReservationCommand.js +19 -0
  27. package/dist/cjs/Commands/UpdateUserCommand.js +41 -0
  28. package/dist/cjs/Commands/UploadImageCommand.js +17 -0
  29. package/dist/cjs/Commands/index.js +55 -0
  30. package/dist/cjs/Errors/AppError.js +8 -0
  31. package/dist/cjs/Errors/AuthenticationError.js +9 -0
  32. package/dist/cjs/Errors/AuthorizationError.js +9 -0
  33. package/dist/cjs/Errors/DeviceCommError.js +9 -0
  34. package/dist/cjs/Errors/LoginError.js +9 -0
  35. package/dist/cjs/Errors/NotFoundError.js +9 -0
  36. package/dist/cjs/Errors/RequestError.js +9 -0
  37. package/dist/cjs/Errors/SystemCommError.js +9 -0
  38. package/dist/cjs/Errors/TokenExpiredError.js +9 -0
  39. package/dist/cjs/Errors/UnprocessableRequestError.js +9 -0
  40. package/dist/cjs/Errors/ValidationError.js +9 -0
  41. package/dist/cjs/Errors/index.js +15 -0
  42. package/dist/cjs/Events/ApplicationInUseEvent.js +17 -0
  43. package/dist/cjs/Events/ApplicationOutOfUseEvent.js +17 -0
  44. package/dist/cjs/Events/EmailEvent.js +18 -0
  45. package/dist/cjs/Events/Event.js +55 -0
  46. package/dist/cjs/Events/SMSEvent.js +18 -0
  47. package/dist/cjs/Events/SMSSentEvent.js +17 -0
  48. package/dist/cjs/Events/ShortLinkCreatedEvent.js +17 -0
  49. package/dist/cjs/Events/SystemCameraUpdatedEvent.js +17 -0
  50. package/dist/cjs/Events/SystemCourtesyUpdatedEvent.js +17 -0
  51. package/dist/cjs/Events/SystemDimmerUpdatedEvent.js +17 -0
  52. package/dist/cjs/Events/SystemGatewayUpdatedEvent.js +17 -0
  53. package/dist/cjs/Events/SystemLockUpdatedEvent.js +17 -0
  54. package/dist/cjs/Events/SystemMediaSourceUpdatedEvent.js +17 -0
  55. package/dist/cjs/Events/SystemMotionSensorUpdatedEvent.js +17 -0
  56. package/dist/cjs/Events/SystemProductUpdatedEvent.js +17 -0
  57. package/dist/cjs/Events/SystemReservationUpdatedEvent.js +17 -0
  58. package/dist/cjs/Events/SystemSceneControllerUpdatedEvent.js +17 -0
  59. package/dist/cjs/Events/SystemSpaceTypeUpdatedEvent.js +17 -0
  60. package/dist/cjs/Events/SystemSpaceUpdatedEvent.js +17 -0
  61. package/dist/cjs/Events/SystemSwitchUpdatedEvent.js +17 -0
  62. package/dist/cjs/Events/SystemThermostatUpdatedEvent.js +17 -0
  63. package/dist/cjs/Events/SystemUserUpdatedEvent.js +17 -0
  64. package/dist/cjs/Events/SystemWindowCoveringUpdatedEvent.js +17 -0
  65. package/dist/cjs/Events/index.js +50 -0
  66. package/dist/cjs/Models/Alarm.js +29 -0
  67. package/dist/cjs/Models/Camera.js +29 -0
  68. package/dist/cjs/Models/Courtesy.js +33 -0
  69. package/dist/cjs/Models/Credential.js +29 -0
  70. package/dist/cjs/Models/Dimmer.js +61 -0
  71. package/dist/cjs/Models/DiscoveredDevice.js +30 -0
  72. package/dist/cjs/Models/EmailMessage.js +29 -0
  73. package/dist/cjs/Models/EnergyReport.js +29 -0
  74. package/dist/cjs/Models/EnergyReportShard.js +29 -0
  75. package/dist/cjs/Models/Gateway.js +29 -0
  76. package/dist/cjs/Models/Identification.js +32 -0
  77. package/dist/cjs/Models/Kohost.js +96 -0
  78. package/dist/cjs/Models/Lock.js +33 -0
  79. package/dist/cjs/Models/MediaFile.js +41 -0
  80. package/dist/cjs/Models/MediaSource.js +29 -0
  81. package/dist/cjs/Models/MotionSensor.js +29 -0
  82. package/dist/cjs/Models/Organization.js +28 -0
  83. package/dist/cjs/Models/Product.js +29 -0
  84. package/dist/cjs/Models/Property.js +28 -0
  85. package/dist/cjs/Models/Reservation.js +98 -0
  86. package/dist/cjs/Models/Room.js +212 -0
  87. package/dist/cjs/Models/Scene.js +183 -0
  88. package/dist/cjs/Models/ShortLink.js +29 -0
  89. package/dist/cjs/Models/SmsMessage.js +29 -0
  90. package/dist/cjs/Models/Space.js +97 -0
  91. package/dist/cjs/Models/SpaceType.js +30 -0
  92. package/dist/cjs/Models/Switch.js +33 -0
  93. package/dist/cjs/Models/SystemUser.js +48 -0
  94. package/dist/cjs/Models/Thermostat.js +80 -0
  95. package/dist/cjs/Models/Ticket.js +105 -0
  96. package/dist/cjs/Models/User.js +73 -0
  97. package/dist/cjs/Models/WindowCovering.js +49 -0
  98. package/dist/cjs/Models/index.js +68 -0
  99. package/dist/cjs/{SocketIoClient.js → SocketIoClient/index.js} +19 -14
  100. package/dist/cjs/defs/deviceTypes.js +15 -0
  101. package/dist/cjs/defs/formalDeviceTypes.js +6 -0
  102. package/dist/cjs/defs/index.js +11 -0
  103. package/dist/cjs/index.js +23 -0
  104. package/dist/cjs/schemas/alarm.json +103 -0
  105. package/dist/cjs/schemas/camera.json +50 -0
  106. package/dist/cjs/schemas/courtesy.json +46 -0
  107. package/dist/cjs/schemas/credential.json +31 -0
  108. package/dist/cjs/schemas/definitions.json +191 -0
  109. package/dist/cjs/schemas/dimmer.json +43 -0
  110. package/dist/cjs/schemas/discoveredDevice.json +31 -0
  111. package/dist/cjs/schemas/emailMessage.json +71 -0
  112. package/dist/cjs/schemas/energyReport.json +86 -0
  113. package/dist/cjs/schemas/energyReportShard.json +75 -0
  114. package/dist/cjs/schemas/gateway.json +35 -0
  115. package/dist/cjs/schemas/identification.json +61 -0
  116. package/dist/cjs/schemas/lock.json +45 -0
  117. package/dist/cjs/schemas/mediaFile.json +67 -0
  118. package/dist/cjs/schemas/mediaSource.json +184 -0
  119. package/dist/cjs/schemas/motionSensor.json +32 -0
  120. package/dist/cjs/schemas/organization.json +36 -0
  121. package/dist/cjs/schemas/payment.json +47 -0
  122. package/dist/cjs/schemas/product.json +40 -0
  123. package/dist/cjs/schemas/property.json +246 -0
  124. package/dist/cjs/schemas/reservation.json +118 -0
  125. package/dist/cjs/schemas/room.json +98 -0
  126. package/dist/cjs/schemas/scene.json +121 -0
  127. package/dist/cjs/schemas/shortLink.json +30 -0
  128. package/dist/cjs/schemas/smsMessage.json +61 -0
  129. package/dist/cjs/schemas/space.json +120 -0
  130. package/dist/cjs/schemas/spaceType.json +30 -0
  131. package/dist/cjs/schemas/switch.json +42 -0
  132. package/dist/cjs/schemas/systemUser.json +95 -0
  133. package/dist/cjs/schemas/thermostat.json +153 -0
  134. package/dist/cjs/schemas/ticket.json +96 -0
  135. package/dist/cjs/schemas/user.json +152 -0
  136. package/dist/cjs/schemas/windowCovering.json +43 -0
  137. package/dist/cjs/utils/errorFactory.js +8 -0
  138. package/dist/cjs/utils/eventFactory.js +10 -0
  139. package/dist/cjs/utils/getDeviceTypes.js +7 -0
  140. package/dist/cjs/utils/getFormalDeviceType.js +5 -0
  141. package/dist/cjs/utils/index.js +11 -0
  142. package/dist/cjs/utils/schema.js +25 -0
  143. package/dist/esm/Models.js +451 -435
  144. package/dist/esm/Models.js.map +4 -4
  145. package/dist/esm/utils.js +7 -26
  146. package/dist/esm/utils.js.map +3 -3
  147. package/package.json +12 -7
  148. package/dist/cjs/AMQPClient.js +0 -462
  149. package/dist/cjs/Commands.js +0 -973
  150. package/dist/cjs/Errors.js +0 -209
  151. package/dist/cjs/Events.js +0 -578
  152. package/dist/cjs/Models.js +0 -4905
  153. package/dist/cjs/defs.js +0 -167
  154. package/dist/cjs/index.cjs.js +0 -6755
  155. package/dist/cjs/utils.js +0 -525
  156. /package/dist/cjs/{Client.js → Client/index.js} +0 -0
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class SetMediaCommand extends Command {
4
+ constructor({ id, command, ...rest }) {
5
+ super({ id, command, ...rest });
6
+ }
7
+
8
+ get name() {
9
+ return "SetMedia";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `mediaSource.${this.data.id}.set`;
14
+ }
15
+ }
16
+
17
+ module.exports = SetMediaCommand;
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class SetSceneCommand extends Command {
4
+ constructor({ id, devices, ...rest }) {
5
+ super({ id, devices, ...rest });
6
+ }
7
+
8
+ get name() {
9
+ return "SetScene";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `scene.${this.data.id}.set`;
14
+ }
15
+ }
16
+
17
+ module.exports = SetSceneCommand;
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class SetSwitchCommand extends Command {
4
+ constructor({ id, state }) {
5
+ super({ id, state });
6
+ }
7
+
8
+ get name() {
9
+ return "SetSwitch";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `switch.${this.data.id}.set`;
14
+ }
15
+ }
16
+
17
+ module.exports = SetSwitchCommand;
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class SetThermostatCommand extends Command {
4
+ constructor({ id, setpoints, hvacMode, fanMode }) {
5
+ super({ id, setpoints, hvacMode, fanMode });
6
+ }
7
+
8
+ get name() {
9
+ return "SetThermostat";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `thermostat.${this.data.id}.set`;
14
+ }
15
+ }
16
+
17
+ module.exports = SetThermostatCommand;
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class SetWindowCoveringCommand extends Command {
4
+ constructor({ id, position }) {
5
+ super({ id, position });
6
+ }
7
+
8
+ get name() {
9
+ return "SetWindowCovering";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `windowCovering.${this.data.id}.set`;
14
+ }
15
+ }
16
+
17
+ module.exports = SetWindowCoveringCommand;
@@ -0,0 +1,19 @@
1
+ const Command = require("./Command");
2
+ const RequestError = require("../Errors/RequestError");
3
+
4
+ class UpdateReservationCommand extends Command {
5
+ constructor({ id, ...rest }) {
6
+ if (!id) throw new RequestError("document type is required");
7
+ super({ id, ...rest });
8
+ }
9
+
10
+ get name() {
11
+ return "UpdateReservation";
12
+ }
13
+
14
+ get routingKey() {
15
+ return `reservation.${this.data.id}.update`;
16
+ }
17
+ }
18
+
19
+ module.exports = UpdateReservationCommand;
@@ -0,0 +1,41 @@
1
+ const Command = require("./Command");
2
+ const RequestError = require("../Errors/RequestError");
3
+
4
+ class UpdateUserCommand extends Command {
5
+ constructor({
6
+ id,
7
+ email,
8
+ phone,
9
+ identification,
10
+ address,
11
+ note,
12
+ nationality,
13
+ file,
14
+ payment,
15
+ ...rest
16
+ }) {
17
+ if (!id) throw new RequestError("document type is required");
18
+ super({
19
+ id,
20
+ email,
21
+ phone,
22
+ identification,
23
+ address,
24
+ note,
25
+ nationality,
26
+ file,
27
+ payment,
28
+ ...rest,
29
+ });
30
+ }
31
+
32
+ get name() {
33
+ return "UpdateUser";
34
+ }
35
+
36
+ get routingKey() {
37
+ return `user.${this.data.id}.update`;
38
+ }
39
+ }
40
+
41
+ module.exports = UpdateUserCommand;
@@ -0,0 +1,17 @@
1
+ const Command = require("./Command");
2
+
3
+ class UploadImageCommand extends Command {
4
+ constructor({ id, url, file, ...rest }) {
5
+ super({ id, url, file, ...rest });
6
+ }
7
+
8
+ get name() {
9
+ return "UploadImage";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `image.${this.data.id}.upload`;
14
+ }
15
+ }
16
+
17
+ module.exports = UploadImageCommand;
@@ -0,0 +1,55 @@
1
+ const SetSceneCommand = require("./SetSceneCommand");
2
+ const SetAlarmCommand = require("./SetAlarmCommand");
3
+ const SetDimmerCommand = require("./SetDimmerCommand");
4
+ const SetSwitchCommand = require("./SetSwitchCommand");
5
+ const SetThermostatCommand = require("./SetThermostatCommand");
6
+ const SetLockCommand = require("./SetLockCommand");
7
+ const SetWindowCoveringCommand = require("./SetWindowCoveringCommand");
8
+ const SetCourtesyCommand = require("./SetCourtesyCommand");
9
+ const SetMediaCommand = require("./SetMediaCommand");
10
+ const DiscoverUsersCommand = require("./DiscoverUsersCommand");
11
+ const OCRDocumentCommand = require("./OCRDocumentCommand");
12
+ const CheckInReservationCommand = require("./CheckInReservationCommand");
13
+ const SendEmailCommand = require("./SendEmailCommand");
14
+ const SendSMSCommand = require("./SendSMSCommand");
15
+ const DiscoverReservationsCommand = require("./DiscoverReservationsCommand");
16
+ const DiscoverReservationRoomTypeUpsellOptionsCommand = require("./DiscoverReservationRoomTypeUpsellOptionsCommand");
17
+ const DiscoverRoomsCommand = require("./DiscoverRoomsCommand");
18
+ const DiscoverRoomTypesCommand = require("./DiscoverRoomTypesCommand");
19
+ const CreateShortLinkCommand = require("./CreateShortLinkCommand");
20
+ const UpdateReservationCommand = require("./UpdateReservationCommand");
21
+ const UpdateUserCommand = require("./UpdateUserCommand");
22
+ const GetMobileKeyCommand = require("./GetMobileKeyCommand");
23
+ const CreateImageUploadEndpointCommand = require("./CreateImageUploadEndpointCommand");
24
+ const UploadImageCommand = require("./UploadImageCommand");
25
+ const GetProductsCommand = require("./GetProductsCommand");
26
+ const SellProductsCommand = require("./SellProductsCommand");
27
+
28
+ module.exports = {
29
+ SetSceneCommand,
30
+ SetAlarmCommand,
31
+ SetDimmerCommand,
32
+ SetSwitchCommand,
33
+ SetThermostatCommand,
34
+ SetLockCommand,
35
+ SetWindowCoveringCommand,
36
+ SetCourtesyCommand,
37
+ SetMediaCommand,
38
+ OCRDocumentCommand,
39
+ DiscoverUsersCommand,
40
+ CheckInReservationCommand,
41
+ SendSMSCommand,
42
+ SendEmailCommand,
43
+ DiscoverReservationsCommand,
44
+ DiscoverReservationRoomTypeUpsellOptionsCommand,
45
+ DiscoverRoomsCommand,
46
+ DiscoverRoomTypesCommand,
47
+ CreateShortLinkCommand,
48
+ UpdateReservationCommand,
49
+ UpdateUserCommand,
50
+ GetMobileKeyCommand,
51
+ CreateImageUploadEndpointCommand,
52
+ UploadImageCommand,
53
+ GetProductsCommand,
54
+ SellProductsCommand,
55
+ };
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class ApplicationInUseEvent extends Event {
4
+ constructor({ propertyId }) {
5
+ super({ propertyId });
6
+ }
7
+
8
+ get name() {
9
+ return "ApplicationInUse";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `app.${this.data[0].propertyId}.inUse`;
14
+ }
15
+ }
16
+
17
+ module.exports = ApplicationInUseEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class ApplicationOutOfUseEvent extends Event {
4
+ constructor({ propertyId }) {
5
+ super({ propertyId });
6
+ }
7
+
8
+ get name() {
9
+ return "ApplicationOutOfUse";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `app.${this.data[0].propertyId}.notInUse`;
14
+ }
15
+ }
16
+
17
+ module.exports = ApplicationOutOfUseEvent;
@@ -0,0 +1,18 @@
1
+ const Event = require("./Event");
2
+
3
+ class EmailEvent extends Event {
4
+ constructor(email, context) {
5
+ super(email, context);
6
+ this.status = email.status;
7
+ }
8
+
9
+ get name() {
10
+ return "EmailEvent";
11
+ }
12
+
13
+ get routingKey() {
14
+ return `comm.email.${this.status}`;
15
+ }
16
+ }
17
+
18
+ module.exports = EmailEvent;
@@ -0,0 +1,55 @@
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" && !Array.isArray(data))
7
+ throw new Error("Event data must be an object or array");
8
+
9
+ if (!Array.isArray(data)) this.data = [data];
10
+ else this.data = data;
11
+
12
+ this.data = this.data.map((d) => {
13
+ if (d.eventData) {
14
+ if (!d.eventData.timestamp) d.eventData.timestamp = new Date();
15
+ if (!d.eventData.name) d.eventData.name = this.name;
16
+ if (!d.eventData.type) d.eventData.type = this.type;
17
+ }
18
+ return d;
19
+ });
20
+
21
+ if (context) {
22
+ for (const key in context) {
23
+ this.context[key] = context[key];
24
+ }
25
+ }
26
+ }
27
+
28
+ get keyId() {
29
+ if (Array.isArray(this.data)) return "batch";
30
+ if (this.data.id) return this.data.id;
31
+ return "unknown";
32
+ }
33
+
34
+ get name() {
35
+ throw new Error("Event name is required");
36
+ }
37
+
38
+ get type() {
39
+ return "Event";
40
+ }
41
+
42
+ get routingKey() {
43
+ return "";
44
+ }
45
+
46
+ get exchange() {
47
+ return "Events";
48
+ }
49
+
50
+ build() {
51
+ return { data: { ...this.data } };
52
+ }
53
+ }
54
+
55
+ module.exports = Event;
@@ -0,0 +1,18 @@
1
+ const Event = require("./Event");
2
+
3
+ class SMSEvent extends Event {
4
+ constructor(sms, context) {
5
+ super(sms, context);
6
+ this.status = sms.status;
7
+ }
8
+
9
+ get name() {
10
+ return "SMSEvent";
11
+ }
12
+
13
+ get routingKey() {
14
+ return `comm.sms.${this.status}`;
15
+ }
16
+ }
17
+
18
+ module.exports = SMSEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SMSSentEvent extends Event {
4
+ constructor(sms, context) {
5
+ super(sms, 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;
@@ -0,0 +1,17 @@
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.keyId}.created`;
14
+ }
15
+ }
16
+
17
+ module.exports = ShortLinkCreatedEvent;
@@ -0,0 +1,17 @@
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.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemCameraUpdatedEvent;
@@ -0,0 +1,17 @@
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.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemCourtesyUpdatedEvent;
@@ -0,0 +1,17 @@
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.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemDimmerUpdatedEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SystemGatewayUpdatedEvent extends Event {
4
+ constructor(space) {
5
+ super(space);
6
+ }
7
+
8
+ get name() {
9
+ return "SystemGatewayUpdated";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `gateway.${this.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemGatewayUpdatedEvent;
@@ -0,0 +1,17 @@
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.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemLockUpdatedEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SystemMediaSourceUpdatedEvent extends Event {
4
+ constructor(mediaSource) {
5
+ super(mediaSource);
6
+ }
7
+
8
+ get name() {
9
+ return "SystemMediaSourceUpdated";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `mediaSource.${this.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemMediaSourceUpdatedEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SystemMotionSensorUpdatedEvent extends Event {
4
+ constructor(mediaSource) {
5
+ super(mediaSource);
6
+ }
7
+
8
+ get name() {
9
+ return "SystemMotionSensorUpdated";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `mediaSource.${this.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemMotionSensorUpdatedEvent;
@@ -0,0 +1,17 @@
1
+ const Event = require("./Event");
2
+
3
+ class SystemProductUpdatedEvent extends Event {
4
+ constructor(product) {
5
+ super(product);
6
+ }
7
+
8
+ get name() {
9
+ return "SystemProductUpdated";
10
+ }
11
+
12
+ get routingKey() {
13
+ return `product.${this.keyId}.updated`;
14
+ }
15
+ }
16
+
17
+ module.exports = SystemProductUpdatedEvent;