@kohost/api-client 1.0.0-alpha.1 → 1.0.0-alpha.3
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.
- package/.eslintrc.js +10 -0
- package/bitbucket-pipelines.yml +39 -0
- package/commands/Command.js +38 -0
- package/commands/SetAlarmCommand.js +21 -0
- package/commands/SetCourtesyCommand.js +21 -0
- package/commands/SetDimmerCommand.js +21 -0
- package/commands/SetLockCommand.js +21 -0
- package/commands/SetSceneControllerCommand.js +21 -0
- package/commands/SetSwitchCommand.js +21 -0
- package/commands/SetThermostatCommand.js +21 -0
- package/commands/SetWindowCoveringCommand.js +21 -0
- package/commands/VerifyDocumentCommand.js +24 -0
- package/commands/index.js +21 -0
- package/defs/deviceTypes.js +15 -0
- package/defs/formalDeviceTypes.js +6 -0
- package/defs/http.js +7 -0
- package/defs/index.js +11 -0
- package/errors/AppError.js +8 -0
- package/errors/AuthenticationError.js +9 -0
- package/errors/AuthorizationError.js +9 -0
- package/errors/DeviceCommError.js +9 -0
- package/errors/LoginError.js +9 -0
- package/errors/NotFoundError.js +9 -0
- package/errors/RequestError.js +9 -0
- package/errors/SystemCommError.js +9 -0
- package/errors/TokenExpiredError.js +9 -0
- package/errors/UnprocessableRequestError.js +9 -0
- package/errors/ValidationError.js +9 -0
- package/errors/index.js +15 -0
- package/events/Event.js +33 -0
- package/events/SystemCameraUpdatedEvent.js +17 -0
- package/events/SystemCourtesyUpdatedEvent.js +17 -0
- package/events/SystemDimmerUpdatedEvent.js +17 -0
- package/events/SystemLockUpdatedEvent.js +17 -0
- package/events/SystemReservationUpdatedEvent.js +17 -0
- package/events/SystemSceneControllerUpdatedEvent.js +17 -0
- package/events/SystemSourceUpdatedEvent.js +17 -0
- package/events/SystemSpaceUpdatedEvent.js +17 -0
- package/events/SystemSwitchUpdatedEvent.js +17 -0
- package/events/SystemThermostatUpdatedEvent.js +17 -0
- package/events/SystemUserUpdatedEvent.js +17 -0
- package/events/SystemWindowCoveringUpdatedEvent.js +17 -0
- package/events/index.js +28 -0
- package/http/handleResponseError.js +53 -0
- package/http/handleResponseSuccess.js +15 -0
- package/http/index.js +159 -0
- package/index.js +21 -71
- package/models/acl.js +29 -0
- package/models/admin/customer.js +28 -0
- package/models/admin/property.js +28 -0
- package/models/alarm.js +29 -0
- package/models/application.js +28 -0
- package/models/camera.js +29 -0
- package/models/courtesy.js +33 -0
- package/models/dimmer.js +49 -0
- package/models/discoveredDevice.js +30 -0
- package/models/gateway.js +37 -0
- package/models/index.js +56 -0
- package/models/integration.js +76 -0
- package/models/iotGateway.js +29 -0
- package/models/kohost.js +95 -0
- package/models/lock.js +33 -0
- package/models/mediaSource.js +29 -0
- package/models/motionSensor.js +29 -0
- package/models/reservation.js +36 -0
- package/models/room.js +185 -0
- package/models/scene.js +28 -0
- package/models/sceneController.js +29 -0
- package/models/space.js +99 -0
- package/models/switch.js +33 -0
- package/models/thermostat.js +80 -0
- package/models/ticket.js +91 -0
- package/models/user.js +58 -0
- package/models/windowCovering.js +49 -0
- package/package.json +27 -5
- package/prepare.js +4 -0
- package/schemas/acl.json +111 -0
- package/schemas/admin/customer.json +32 -0
- package/schemas/admin/property.json +54 -0
- package/schemas/alarm.json +5 -5
- package/schemas/application.json +24 -0
- package/schemas/camera.json +41 -0
- package/schemas/courtesy.json +5 -6
- package/schemas/definitions/common.json +21 -0
- package/schemas/{device.json → definitions/device.json} +22 -4
- package/schemas/dimmer.json +8 -5
- package/schemas/discoveredDevice.json +43 -0
- package/schemas/gateway.json +45 -13
- package/schemas/identification.json +35 -0
- package/schemas/integration.json +94 -0
- package/schemas/iotGateway.json +29 -0
- package/schemas/lock.json +8 -5
- package/schemas/mediaSource.json +151 -0
- package/schemas/motionSensor.json +26 -0
- package/schemas/payment.json +38 -0
- package/schemas/reservation.json +66 -0
- package/schemas/room.json +138 -0
- package/schemas/scene.json +118 -0
- package/schemas/sceneController.json +18 -6
- package/schemas/space.json +111 -0
- package/schemas/switch.json +8 -5
- package/schemas/thermostat.json +19 -10
- package/schemas/ticket.json +82 -0
- package/schemas/user.json +124 -0
- package/schemas/windowCovering.json +8 -5
- package/tests/unit/models/space.test.js +31 -0
- package/tests/unit/models/thermostat.test.js +146 -0
- package/useCases/http.json +902 -0
- package/utils/getDeviceTypes.js +7 -0
- package/utils/getFormalDeviceType.js +5 -0
- package/utils/schema.js +28 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
image: node:14
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
pull-requests:
|
|
5
|
+
"**":
|
|
6
|
+
- step:
|
|
7
|
+
name: Install dependencies and build
|
|
8
|
+
caches:
|
|
9
|
+
- node
|
|
10
|
+
script:
|
|
11
|
+
- npm install
|
|
12
|
+
- npm version prerelease --preid=alpha -m "Upgrade to %s [skip ci]"
|
|
13
|
+
- git push && git push --tags
|
|
14
|
+
- pipe: atlassian/npm-publish:0.2.6
|
|
15
|
+
variables:
|
|
16
|
+
NPM_TOKEN: $NPM_TOKEN
|
|
17
|
+
branches:
|
|
18
|
+
master:
|
|
19
|
+
- step:
|
|
20
|
+
name: Build and publish to NPM
|
|
21
|
+
caches:
|
|
22
|
+
- node
|
|
23
|
+
script:
|
|
24
|
+
- npm install
|
|
25
|
+
- pipe: atlassian/npm-publish:0.2.6
|
|
26
|
+
variables:
|
|
27
|
+
NPM_TOKEN: $NPM_TOKEN
|
|
28
|
+
dev:
|
|
29
|
+
- step:
|
|
30
|
+
name: Build and publish to NPM
|
|
31
|
+
caches:
|
|
32
|
+
- node
|
|
33
|
+
script:
|
|
34
|
+
- npm install
|
|
35
|
+
- npm version prerelease --preid=beta -m "Upgrade to %s [skip ci]"
|
|
36
|
+
- git push && git push --tags
|
|
37
|
+
- pipe: atlassian/npm-publish:0.2.6
|
|
38
|
+
variables:
|
|
39
|
+
NPM_TOKEN: $NPM_TOKEN
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class Command {
|
|
2
|
+
constructor(data) {
|
|
3
|
+
this.data = {};
|
|
4
|
+
if (!data) throw new Error("Command data is required");
|
|
5
|
+
if (typeof data !== "object")
|
|
6
|
+
throw new Error("Command data must be an object");
|
|
7
|
+
|
|
8
|
+
for (const key in data) {
|
|
9
|
+
this.data[key] = data[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get name() {
|
|
14
|
+
throw new Error("Command name is required");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get type() {
|
|
18
|
+
return "Command";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get routingKey() {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get exchange() {
|
|
26
|
+
return "Commands";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get replyTo() {
|
|
30
|
+
return "amq.rabbitmq.reply-to";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
build() {
|
|
34
|
+
return { data: { ...this.data } };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = Command;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
|
|
3
|
+
class SetAlarmCommand extends Command {
|
|
4
|
+
constructor({ id, zones, areas }) {
|
|
5
|
+
super({ id, zones, areas });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return "SetAlarm";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get routingKey() {
|
|
13
|
+
return `alarm.${this.data.id}.set`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetAlarmCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
|
|
3
|
+
class SetCourtesyCommand extends Command {
|
|
4
|
+
constructor({ id, state }) {
|
|
5
|
+
super({ id, state });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return "SetCourtesy";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get routingKey() {
|
|
13
|
+
return `courtesy.${this.data.id}.set`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetCourtesyCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
|
|
3
|
+
class SetDimmerCommand extends Command {
|
|
4
|
+
constructor({ id, level }) {
|
|
5
|
+
super({ id, level });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return "SetDimmer";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get routingKey() {
|
|
13
|
+
return `dimmer.${this.data.id}.set`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetDimmerCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
|
|
3
|
+
class SetLockCommand extends Command {
|
|
4
|
+
constructor({ id, state }) {
|
|
5
|
+
super({ id, state });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return "SetLock";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get routingKey() {
|
|
13
|
+
return `lock.${this.data.id}.set`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetLockCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
|
|
3
|
+
class SetSceneControllerCommand extends Command {
|
|
4
|
+
constructor({ id, scene }) {
|
|
5
|
+
super({ id, scene });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return "SetSceneController";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get routingKey() {
|
|
13
|
+
return `sceneController.${this.data.id}.set`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetSceneControllerCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetSwitchCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetThermostatCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
get replyTo() {
|
|
17
|
+
return "system.response.devices";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SetWindowCoveringCommand;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const Command = require("./Command");
|
|
2
|
+
const RequestError = require("../errors/RequestError");
|
|
3
|
+
|
|
4
|
+
class VerifyDocumentCommand extends Command {
|
|
5
|
+
constructor({ type, image }) {
|
|
6
|
+
if (!type) throw new RequestError("document type is required");
|
|
7
|
+
if (!image) throw new RequestError("document image is required");
|
|
8
|
+
super({ type, image });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get name() {
|
|
12
|
+
return "VerifyDocument";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get routingKey() {
|
|
16
|
+
return `document.${this.data.type}.verify`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get replyTo() {
|
|
20
|
+
return "system.response.documents";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = VerifyDocumentCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const SetAlarmCommand = require("./SetAlarmCommand");
|
|
2
|
+
const SetDimmerCommand = require("./SetDimmerCommand");
|
|
3
|
+
const SetSwitchCommand = require("./SetSwitchCommand");
|
|
4
|
+
const SetThermostatCommand = require("./SetThermostatCommand");
|
|
5
|
+
const SetLockCommand = require("./SetLockCommand");
|
|
6
|
+
const SetSceneControllerCommand = require("./SetSceneControllerCommand");
|
|
7
|
+
const SetWindowCoveringCommand = require("./SetWindowCoveringCommand");
|
|
8
|
+
const SetCourtesyCommand = require("./SetCourtesyCommand");
|
|
9
|
+
const VerifyDocumentCommand = require("./VerifyDocumentCommand");
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
SetAlarmCommand,
|
|
13
|
+
SetDimmerCommand,
|
|
14
|
+
SetSwitchCommand,
|
|
15
|
+
SetThermostatCommand,
|
|
16
|
+
SetLockCommand,
|
|
17
|
+
SetSceneControllerCommand,
|
|
18
|
+
SetWindowCoveringCommand,
|
|
19
|
+
SetCourtesyCommand,
|
|
20
|
+
VerifyDocumentCommand,
|
|
21
|
+
};
|
package/defs/http.js
ADDED
package/defs/index.js
ADDED
|
@@ -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
|
+
};
|
package/errors/index.js
ADDED
|
@@ -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;
|
package/events/Event.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Event {
|
|
2
|
+
constructor(data) {
|
|
3
|
+
this.data = {};
|
|
4
|
+
if (!data) throw new Error("Event data is required");
|
|
5
|
+
if (typeof data !== "object")
|
|
6
|
+
throw new Error("Event data must be an object");
|
|
7
|
+
|
|
8
|
+
for (const key in data) {
|
|
9
|
+
this.data[key] = data[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
throw new Error("Event name is required");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get type() {
|
|
17
|
+
return "Event";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get routingKey() {
|
|
21
|
+
return "";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get exchange() {
|
|
25
|
+
return "Events";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
build() {
|
|
29
|
+
return { data: { ...this.data } };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = Event;
|
|
@@ -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.data.id}.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.data.id}.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.data.id}.updated`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = SystemDimmerUpdatedEvent;
|
|
@@ -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.data.id}.updated`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = SystemLockUpdatedEvent;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|