@kohost/api-client 1.0.0-beta.3 → 1.0.0-beta.4
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/dist/Client.js +19632 -0
- package/dist/commands.js +568 -0
- package/dist/defs.js +196 -0
- package/dist/errors.js +174 -0
- package/dist/events.js +375 -0
- package/dist/models.js +3584 -0
- package/dist/useCases/AddDefaultScenesToRooms.js +39 -0
- package/dist/useCases/AddScenesToRoom.js +39 -0
- package/dist/useCases/AdminCreateProperty.js +39 -0
- package/dist/useCases/AdminDescribeProperty.js +39 -0
- package/dist/useCases/AdminListCustomers.js +39 -0
- package/dist/useCases/AdminListProperties.js +39 -0
- package/dist/useCases/AdminUpdateProperty.js +39 -0
- package/dist/useCases/BatchNotifyPreArrival.js +39 -0
- package/dist/useCases/CheckInReservation.js +39 -0
- package/dist/useCases/CheckVerificationCode.js +39 -0
- package/dist/useCases/CreateAlarm.js +39 -0
- package/dist/useCases/CreateCamera.js +39 -0
- package/dist/useCases/CreateCourtesy.js +39 -0
- package/dist/useCases/CreateDefaultScenes.js +39 -0
- package/dist/useCases/CreateDimmer.js +39 -0
- package/dist/useCases/CreateDiscoveredDevice.js +39 -0
- package/dist/useCases/CreateDiscoveredDeviceAssociation.js +39 -0
- package/dist/useCases/CreateIntegration.js +39 -0
- package/dist/useCases/CreateIntegrationDeviceMapEntry.js +39 -0
- package/dist/useCases/CreateLock.js +39 -0
- package/dist/useCases/CreateReservation.js +39 -0
- package/dist/useCases/CreateRoom.js +39 -0
- package/dist/useCases/CreateRoomInSpace.js +39 -0
- package/dist/useCases/CreateSource.js +39 -0
- package/dist/useCases/CreateSpace.js +39 -0
- package/dist/useCases/CreateSwitch.js +39 -0
- package/dist/useCases/CreateThermostat.js +39 -0
- package/dist/useCases/CreateTicket.js +39 -0
- package/dist/useCases/CreateTicketMessage.js +39 -0
- package/dist/useCases/CreateUser.js +39 -0
- package/dist/useCases/CreateWindowCovering.js +39 -0
- package/dist/useCases/DeleteAlarm.js +39 -0
- package/dist/useCases/DeleteCamera.js +39 -0
- package/dist/useCases/DeleteCourtesy.js +39 -0
- package/dist/useCases/DeleteDimmer.js +39 -0
- package/dist/useCases/DeleteDiscoveredDevice.js +39 -0
- package/dist/useCases/DeleteIntegration.js +39 -0
- package/dist/useCases/DeleteLock.js +39 -0
- package/dist/useCases/DeleteReservation.js +39 -0
- package/dist/useCases/DeleteRoom.js +39 -0
- package/dist/useCases/DeleteSource.js +39 -0
- package/dist/useCases/DeleteSpace.js +39 -0
- package/dist/useCases/DeleteSwitch.js +39 -0
- package/dist/useCases/DeleteThermostat.js +39 -0
- package/dist/useCases/DeleteTicket.js +39 -0
- package/dist/useCases/DeleteUser.js +39 -0
- package/dist/useCases/DeleteWindowCovering.js +39 -0
- package/dist/useCases/DescribeAlarm.js +39 -0
- package/dist/useCases/DescribeCamera.js +39 -0
- package/dist/useCases/DescribeCourtesy.js +39 -0
- package/dist/useCases/DescribeDimmer.js +39 -0
- package/dist/useCases/DescribeDiscoveredDevice.js +39 -0
- package/dist/useCases/DescribeIntegration.js +39 -0
- package/dist/useCases/DescribeLock.js +39 -0
- package/dist/useCases/DescribeMyProperty.js +39 -0
- package/dist/useCases/DescribeReservation.js +39 -0
- package/dist/useCases/DescribeReservationCheckinStatus.js +39 -0
- package/dist/useCases/DescribeRoom.js +39 -0
- package/dist/useCases/DescribeSelf.js +39 -0
- package/dist/useCases/DescribeSource.js +39 -0
- package/dist/useCases/DescribeSpace.js +39 -0
- package/dist/useCases/DescribeSwitch.js +39 -0
- package/dist/useCases/DescribeThermostat.js +39 -0
- package/dist/useCases/DescribeTicket.js +39 -0
- package/dist/useCases/DescribeUser.js +39 -0
- package/dist/useCases/DescribeWindowCovering.js +39 -0
- package/dist/useCases/DiscoverReservations.js +39 -0
- package/dist/useCases/EmailUserAccountSetup.js +39 -0
- package/dist/useCases/ListAlarms.js +39 -0
- package/dist/useCases/ListCameras.js +39 -0
- package/dist/useCases/ListCourtesy.js +39 -0
- package/dist/useCases/ListDimmers.js +39 -0
- package/dist/useCases/ListDiscoveredDevices.js +39 -0
- package/dist/useCases/ListIntegrations.js +39 -0
- package/dist/useCases/ListLocks.js +39 -0
- package/dist/useCases/ListMyReservations.js +39 -0
- package/dist/useCases/ListMySpaces.js +39 -0
- package/dist/useCases/ListReservations.js +39 -0
- package/dist/useCases/ListRooms.js +39 -0
- package/dist/useCases/ListRoomsInSpace.js +39 -0
- package/dist/useCases/ListSources.js +39 -0
- package/dist/useCases/ListSpaces.js +39 -0
- package/dist/useCases/ListSwitches.js +39 -0
- package/dist/useCases/ListThermostats.js +39 -0
- package/dist/useCases/ListTickets.js +39 -0
- package/dist/useCases/ListUserReservations.js +39 -0
- package/dist/useCases/ListUsers.js +39 -0
- package/dist/useCases/ListWindowCoverings.js +39 -0
- package/dist/useCases/LoginGateway.js +39 -0
- package/dist/useCases/LoginUser.js +39 -0
- package/dist/useCases/MatchUserIdentification.js +39 -0
- package/dist/useCases/OCRDocument.js +39 -0
- package/dist/useCases/RefreshToken.js +39 -0
- package/dist/useCases/RequestLoginLink.js +39 -0
- package/dist/useCases/SendPreArrivalEmail.js +39 -0
- package/dist/useCases/SendPreArrivalSMS.js +39 -0
- package/dist/useCases/SendVerificationCode.js +39 -0
- package/dist/useCases/SetCamera.js +39 -0
- package/dist/useCases/SetCourtesy.js +39 -0
- package/dist/useCases/SetLock.js +39 -0
- package/dist/useCases/SetSource.js +39 -0
- package/dist/useCases/SetSwitch.js +39 -0
- package/dist/useCases/SetThermostat.js +39 -0
- package/dist/useCases/SetWindowCovering.js +39 -0
- package/dist/useCases/UpdateAlarm.js +39 -0
- package/dist/useCases/UpdateCamera.js +39 -0
- package/dist/useCases/UpdateCourtesy.js +39 -0
- package/dist/useCases/UpdateDimmer.js +39 -0
- package/dist/useCases/UpdateDiscoveredDevice.js +39 -0
- package/dist/useCases/UpdateIntegration.js +39 -0
- package/dist/useCases/UpdateLock.js +39 -0
- package/dist/useCases/UpdateMessageReadStatus.js +39 -0
- package/dist/useCases/UpdateReservation.js +39 -0
- package/dist/useCases/UpdateRoom.js +39 -0
- package/dist/useCases/UpdateSelf.js +39 -0
- package/dist/useCases/UpdateSource.js +39 -0
- package/dist/useCases/UpdateSpace.js +39 -0
- package/dist/useCases/UpdateSwitch.js +39 -0
- package/dist/useCases/UpdateThermostat.js +39 -0
- package/dist/useCases/UpdateTicket.js +39 -0
- package/dist/useCases/UpdateTicketStatus.js +39 -0
- package/dist/useCases/UpdateUser.js +39 -0
- package/dist/useCases/UpdateWindowCovering.js +39 -0
- package/dist/useCases/UpsertDiscoveredDevice.js +39 -0
- package/dist/utils.js +53 -0
- package/package.json +8 -2
- package/.eslintrc.js +0 -10
- package/bitbucket-pipelines.yml +0 -71
- package/commands/CheckInReservationCommand.js +0 -23
- package/commands/Command.js +0 -38
- package/commands/DiscoverReservationsCommand.js +0 -24
- package/commands/DiscoverRoomsCommand.js +0 -21
- package/commands/DiscoverUsersCommand.js +0 -21
- package/commands/OCRDocumentCommand.js +0 -20
- package/commands/SendEmailCommand.js +0 -24
- package/commands/SendSMSCommand.js +0 -21
- package/commands/SetAlarmCommand.js +0 -21
- package/commands/SetCourtesyCommand.js +0 -21
- package/commands/SetDimmerCommand.js +0 -21
- package/commands/SetLockCommand.js +0 -21
- package/commands/SetSceneControllerCommand.js +0 -21
- package/commands/SetSwitchCommand.js +0 -21
- package/commands/SetThermostatCommand.js +0 -21
- package/commands/SetWindowCoveringCommand.js +0 -21
- package/commands/index.js +0 -31
- package/defs/deviceTypes.js +0 -15
- package/defs/formalDeviceTypes.js +0 -6
- package/defs/http.js +0 -7
- package/defs/index.js +0 -11
- package/errors/AppError.js +0 -8
- package/errors/AuthenticationError.js +0 -9
- package/errors/AuthorizationError.js +0 -9
- package/errors/DeviceCommError.js +0 -9
- package/errors/LoginError.js +0 -9
- package/errors/NotFoundError.js +0 -9
- package/errors/RequestError.js +0 -9
- package/errors/SystemCommError.js +0 -9
- package/errors/TokenExpiredError.js +0 -9
- package/errors/UnprocessableRequestError.js +0 -9
- package/errors/ValidationError.js +0 -9
- package/errors/index.js +0 -15
- package/events/EmailSentEvent.js +0 -17
- package/events/Event.js +0 -52
- package/events/SMSSentEvent.js +0 -17
- package/events/ShortLinkCreatedEvent.js +0 -17
- package/events/SystemCameraUpdatedEvent.js +0 -17
- package/events/SystemCourtesyUpdatedEvent.js +0 -17
- package/events/SystemDimmerUpdatedEvent.js +0 -17
- package/events/SystemLockUpdatedEvent.js +0 -17
- package/events/SystemReservationUpdatedEvent.js +0 -17
- package/events/SystemSceneControllerUpdatedEvent.js +0 -17
- package/events/SystemSourceUpdatedEvent.js +0 -17
- package/events/SystemSpaceUpdatedEvent.js +0 -17
- package/events/SystemSwitchUpdatedEvent.js +0 -17
- package/events/SystemThermostatUpdatedEvent.js +0 -17
- package/events/SystemUserUpdatedEvent.js +0 -17
- package/events/SystemWindowCoveringUpdatedEvent.js +0 -17
- package/events/index.js +0 -35
- package/http/handleResponseError.js +0 -33
- package/http/handleResponseSuccess.js +0 -15
- package/http/index.js +0 -169
- package/index.js +0 -23
- package/models/acl.js +0 -29
- package/models/admin/customer.js +0 -28
- package/models/admin/property.js +0 -28
- package/models/alarm.js +0 -29
- package/models/application.js +0 -28
- package/models/camera.js +0 -29
- package/models/courtesy.js +0 -33
- package/models/credential.js +0 -29
- package/models/dimmer.js +0 -49
- package/models/discoveredDevice.js +0 -30
- package/models/gateway.js +0 -29
- package/models/identification.js +0 -32
- package/models/index.js +0 -56
- package/models/integration.js +0 -76
- package/models/kohost.js +0 -96
- package/models/lock.js +0 -33
- package/models/mediaSource.js +0 -29
- package/models/motionSensor.js +0 -29
- package/models/product.js +0 -30
- package/models/reservation.js +0 -83
- package/models/room.js +0 -174
- package/models/scene.js +0 -28
- package/models/shortLink.js +0 -29
- package/models/space.js +0 -99
- package/models/switch.js +0 -33
- package/models/thermostat.js +0 -80
- package/models/ticket.js +0 -91
- package/models/user.js +0 -56
- package/models/windowCovering.js +0 -49
- package/prepare.js +0 -4
- package/schemas/acl.json +0 -111
- package/schemas/admin/customer.json +0 -32
- package/schemas/admin/property.json +0 -180
- package/schemas/alarm.json +0 -93
- package/schemas/application.json +0 -24
- package/schemas/camera.json +0 -41
- package/schemas/courtesy.json +0 -37
- package/schemas/credential.json +0 -28
- package/schemas/definitions/common.json +0 -74
- package/schemas/definitions/device.json +0 -76
- package/schemas/dimmer.json +0 -34
- package/schemas/discoveredDevice.json +0 -43
- package/schemas/gateway.json +0 -30
- package/schemas/identification.json +0 -49
- package/schemas/integration.json +0 -94
- package/schemas/lock.json +0 -36
- package/schemas/mediaSource.json +0 -151
- package/schemas/motionSensor.json +0 -26
- package/schemas/payment.json +0 -40
- package/schemas/product.json +0 -36
- package/schemas/reservation.json +0 -71
- package/schemas/room.json +0 -131
- package/schemas/scene.json +0 -118
- package/schemas/shortLink.json +0 -30
- package/schemas/space.json +0 -111
- package/schemas/switch.json +0 -33
- package/schemas/thermostat.json +0 -139
- package/schemas/ticket.json +0 -82
- package/schemas/user.json +0 -176
- package/schemas/windowCovering.json +0 -34
- package/tests/unit/models/space.test.js +0 -31
- package/tests/unit/models/thermostat.test.js +0 -146
- package/tests/unit/models/user.test.js +0 -28
- package/useCases/http.json +0 -1161
- package/utils/getDeviceTypes.js +0 -7
- package/utils/getFormalDeviceType.js +0 -5
- package/utils/schema.js +0 -28
package/models/switch.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// create the Switch model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/switch.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Switch extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Switch.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Switch.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Switch, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(Switch, "actionProperties", {
|
|
30
|
-
value: ["state"],
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
module.exports = Switch;
|
package/models/thermostat.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const schemas = require("../utils/schema");
|
|
2
|
-
const schema = require("../schemas/thermostat.json");
|
|
3
|
-
const Kohost = require("./kohost");
|
|
4
|
-
|
|
5
|
-
schemas.add(schema);
|
|
6
|
-
const validator = schemas.compile(schema);
|
|
7
|
-
|
|
8
|
-
class Thermostat extends Kohost {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
toCelsius() {
|
|
14
|
-
if (this.temperatureScale === "fahrenheit")
|
|
15
|
-
this.currentTemperature = ((this.currentTemperature - 32) * 5) / 9;
|
|
16
|
-
this.temperatureScale = "celsius";
|
|
17
|
-
return this.currentTemperature;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
toFahrenheit() {
|
|
21
|
-
if (this.temperatureScale === "celsius")
|
|
22
|
-
this.currentTemperature = (this.currentTemperature * 9) / 5 + 32;
|
|
23
|
-
this.temperatureScale = "fahrenheit";
|
|
24
|
-
return this.currentTemperature;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static getActionDelta(old, _new) {
|
|
28
|
-
const delta = {};
|
|
29
|
-
for (const action in _new) {
|
|
30
|
-
if (this.actionProperties.includes(action)) {
|
|
31
|
-
switch (action) {
|
|
32
|
-
case "hvacMode":
|
|
33
|
-
case "fanMode": {
|
|
34
|
-
if (old[action] !== _new[action]) delta[action] = 1;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
case "setpoints": {
|
|
38
|
-
const setpoints = _new[action];
|
|
39
|
-
for (const setpoint in setpoints) {
|
|
40
|
-
if (old[action][setpoint].value !== setpoints[setpoint].value) {
|
|
41
|
-
const min =
|
|
42
|
-
setpoints[setpoint].min || old[action][setpoint].min;
|
|
43
|
-
const max =
|
|
44
|
-
setpoints[setpoint].max || old[action][setpoint].max;
|
|
45
|
-
const oldValue = old[action][setpoint].value;
|
|
46
|
-
const value = setpoints[setpoint].value;
|
|
47
|
-
// get percentage change relative to min and max
|
|
48
|
-
const percentChange = (value - oldValue) / (max - min);
|
|
49
|
-
// get the delta
|
|
50
|
-
delta[`setpoints.${setpoint}`] = percentChange;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return delta;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
Object.defineProperty(Thermostat.prototype, "schema", {
|
|
63
|
-
value: schema,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(Thermostat.prototype, "validator", {
|
|
67
|
-
get: function () {
|
|
68
|
-
return validator;
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
Object.defineProperty(Thermostat, "validProperties", {
|
|
73
|
-
value: Object.keys(schema.properties),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
Object.defineProperty(Thermostat, "actionProperties", {
|
|
77
|
-
value: ["hvacMode", "fanMode", "setpoints"],
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
module.exports = Thermostat;
|
package/models/ticket.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// Create the User Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/ticket.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
const sortBy = require("lodash.sortby");
|
|
7
|
-
const findLast = require("lodash.findlast");
|
|
8
|
-
|
|
9
|
-
const { nanoid } = require("nanoid");
|
|
10
|
-
|
|
11
|
-
schemas.add(schema);
|
|
12
|
-
const validator = schemas.compile(schema);
|
|
13
|
-
|
|
14
|
-
class Ticket extends Kohost {
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super(data);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static generateMessageId(len = 16) {
|
|
20
|
-
return nanoid(len);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(Ticket.prototype, "schema", {
|
|
25
|
-
value: schema,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(Ticket.prototype, "validator", {
|
|
29
|
-
get: function () {
|
|
30
|
-
return validator;
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(Ticket, "validProperties", {
|
|
35
|
-
value: Object.keys(schema.properties),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
Object.defineProperty(Ticket.prototype, "responseTime", {
|
|
39
|
-
get: function () {
|
|
40
|
-
const conversation = this.conversation;
|
|
41
|
-
const requester = this.requester;
|
|
42
|
-
|
|
43
|
-
if (conversation.length === 0) return 0;
|
|
44
|
-
const mapped = conversation.map((msg) => {
|
|
45
|
-
if (typeof msg.timestamp === "string")
|
|
46
|
-
msg.timestamp = new Date(msg.timestamp);
|
|
47
|
-
return msg;
|
|
48
|
-
});
|
|
49
|
-
const sorted = sortBy(mapped, ["timestamp"]);
|
|
50
|
-
const firstMsg = sorted.find((entry) => entry.user === requester);
|
|
51
|
-
const firstResponse = sorted.find((entry) => entry.user !== requester);
|
|
52
|
-
|
|
53
|
-
if (firstMsg && firstResponse) {
|
|
54
|
-
const firstMsgTime = firstMsg.timestamp.getTime() / 1000;
|
|
55
|
-
const firstResponseTime = firstResponse.timestamp.getTime() / 1000;
|
|
56
|
-
return firstResponseTime - firstMsgTime;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return 0;
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
Object.defineProperty(Ticket.prototype, "resolutionTime", {
|
|
64
|
-
get: function () {
|
|
65
|
-
if (this.status !== "closed") return 0;
|
|
66
|
-
const createdAt = this.createdAt.getTime() / 1000;
|
|
67
|
-
const solvedAt = this.solvedAt
|
|
68
|
-
? this.solvedAt.getTime() / 1000
|
|
69
|
-
: this.updatedAt.getTime() / 1000;
|
|
70
|
-
|
|
71
|
-
return Math.abs(solvedAt - createdAt);
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
Object.defineProperty(Ticket.prototype, "lastResponder", {
|
|
76
|
-
get: function () {
|
|
77
|
-
const conversation = this.conversation;
|
|
78
|
-
const requester = this.requester;
|
|
79
|
-
|
|
80
|
-
const sorted = sortBy(conversation, ["timestamp"]);
|
|
81
|
-
|
|
82
|
-
const lastFromNonRequester = findLast(sorted, function (c) {
|
|
83
|
-
return c.user !== requester;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
if (!lastFromNonRequester) return null;
|
|
87
|
-
else return lastFromNonRequester.user;
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
module.exports = Ticket;
|
package/models/user.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Create the User Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/user.json");
|
|
4
|
-
const paymentSchema = require("../schemas/payment.json");
|
|
5
|
-
const Kohost = require("./kohost");
|
|
6
|
-
|
|
7
|
-
const { nanoid } = require("nanoid/async");
|
|
8
|
-
|
|
9
|
-
schemas.add(paymentSchema);
|
|
10
|
-
schemas.add(schema);
|
|
11
|
-
|
|
12
|
-
const validator = schemas.compile(schema);
|
|
13
|
-
|
|
14
|
-
class User extends Kohost {
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super(data);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static validatePhone(phoneNumber) {
|
|
20
|
-
const regex = /^\+?[1-9]\d{1,14}$/;
|
|
21
|
-
return regex.test(phoneNumber);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static validateEmail(email) {
|
|
25
|
-
//eslint-disable-next-line no-useless-escape
|
|
26
|
-
const regex =
|
|
27
|
-
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
28
|
-
return regex.test(email);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static async generatePassword(len = 16) {
|
|
32
|
-
return await nanoid(len);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(User.prototype, "schema", {
|
|
37
|
-
value: schema,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
Object.defineProperty(User.prototype, "validator", {
|
|
41
|
-
get: function () {
|
|
42
|
-
return validator;
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
Object.defineProperty(User, "validProperties", {
|
|
47
|
-
value: Object.keys(schema.properties),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
Object.defineProperty(User.prototype, "fullName", {
|
|
51
|
-
get: function () {
|
|
52
|
-
return `${this.firstName} ${this.lastName}`;
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
module.exports = User;
|
package/models/windowCovering.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Create the WindowCovering Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/windowCovering.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class WindowCovering extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static getActionDelta(old, _new) {
|
|
15
|
-
const delta = {};
|
|
16
|
-
for (const action in _new) {
|
|
17
|
-
if (this.actionProperties?.includes(action)) {
|
|
18
|
-
if (action === "position") {
|
|
19
|
-
const oldPos = old[action];
|
|
20
|
-
const newPos = _new[action];
|
|
21
|
-
delta[action] = newPos - oldPos / 100;
|
|
22
|
-
} else if (old[action] !== _new[action]) {
|
|
23
|
-
delta[action] = 1;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return delta;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(WindowCovering.prototype, "schema", {
|
|
32
|
-
value: schema,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(WindowCovering.prototype, "validator", {
|
|
36
|
-
get: function () {
|
|
37
|
-
return validator;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
Object.defineProperty(WindowCovering, "validProperties", {
|
|
42
|
-
value: Object.keys(schema.properties),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(WindowCovering, "actionProperties", {
|
|
46
|
-
value: ["position"],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
module.exports = WindowCovering;
|
package/prepare.js
DELETED
package/schemas/acl.json
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "https://api.kohost.app/schemas/v3/acl.json",
|
|
4
|
-
"title": "Access Control List Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": ["id", "name", "resource", "resourceFilter", "permissions"],
|
|
7
|
-
"properties": {
|
|
8
|
-
"id": {
|
|
9
|
-
"type": "string"
|
|
10
|
-
},
|
|
11
|
-
"name": {
|
|
12
|
-
"type": "string"
|
|
13
|
-
},
|
|
14
|
-
"resourceType": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"enum": [
|
|
17
|
-
"*",
|
|
18
|
-
"Guest",
|
|
19
|
-
"Reservation",
|
|
20
|
-
"User",
|
|
21
|
-
"Manager",
|
|
22
|
-
"Admin",
|
|
23
|
-
"SuperAdmin",
|
|
24
|
-
"Ticket",
|
|
25
|
-
"Group",
|
|
26
|
-
"HotelRoom",
|
|
27
|
-
"Room",
|
|
28
|
-
"Notification",
|
|
29
|
-
"Image",
|
|
30
|
-
"EnergyReport",
|
|
31
|
-
"RoomType",
|
|
32
|
-
"SceneTemplate",
|
|
33
|
-
"Setting",
|
|
34
|
-
"Subscription",
|
|
35
|
-
"Integration",
|
|
36
|
-
"PMS",
|
|
37
|
-
"Source",
|
|
38
|
-
"ACL"
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"resource": {
|
|
42
|
-
"type": "array",
|
|
43
|
-
"items": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"resourceFilter": {
|
|
48
|
-
"type": "array",
|
|
49
|
-
"items": {
|
|
50
|
-
"type": "object",
|
|
51
|
-
"properties": {
|
|
52
|
-
"resourceType": {
|
|
53
|
-
"type": "string",
|
|
54
|
-
"enum": ["SubSystem"]
|
|
55
|
-
},
|
|
56
|
-
"resource": {
|
|
57
|
-
"type": "array",
|
|
58
|
-
"items": {
|
|
59
|
-
"type": "string"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"permissions": {
|
|
63
|
-
"type": "array",
|
|
64
|
-
"uniqueItems": true,
|
|
65
|
-
"items": {
|
|
66
|
-
"type": "string",
|
|
67
|
-
"enum": [
|
|
68
|
-
"*",
|
|
69
|
-
"read",
|
|
70
|
-
"write",
|
|
71
|
-
"delete",
|
|
72
|
-
"create",
|
|
73
|
-
"update",
|
|
74
|
-
"list",
|
|
75
|
-
"execute"
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
"permissions": {
|
|
83
|
-
"type": "array",
|
|
84
|
-
"uniqueItems": true,
|
|
85
|
-
"items": {
|
|
86
|
-
"type": "string",
|
|
87
|
-
"enum": [
|
|
88
|
-
"*",
|
|
89
|
-
"read",
|
|
90
|
-
"write",
|
|
91
|
-
"delete",
|
|
92
|
-
"create",
|
|
93
|
-
"update",
|
|
94
|
-
"list",
|
|
95
|
-
"execute"
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
"begins": {
|
|
100
|
-
"type": ["object", "null"]
|
|
101
|
-
},
|
|
102
|
-
"expires": {
|
|
103
|
-
"type": ["object", "null"]
|
|
104
|
-
},
|
|
105
|
-
"global": {
|
|
106
|
-
"type": "boolean",
|
|
107
|
-
"default": false
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"definitions": {}
|
|
111
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "https://api.kohost.app/schemas/v3/admin/customer.json",
|
|
4
|
-
"title": "Customer",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"description": "A Kohost customer",
|
|
7
|
-
"required": ["accountNumber", "name"],
|
|
8
|
-
"properties": {
|
|
9
|
-
"id": {
|
|
10
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
11
|
-
},
|
|
12
|
-
"accountNumber": {
|
|
13
|
-
"type": "number",
|
|
14
|
-
"minimum": 10000
|
|
15
|
-
},
|
|
16
|
-
"name": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
},
|
|
19
|
-
"properties": {
|
|
20
|
-
"type": "array",
|
|
21
|
-
"items": {
|
|
22
|
-
"type": "string"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"createdAt": {
|
|
26
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
|
|
27
|
-
},
|
|
28
|
-
"updatedAt": {
|
|
29
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "https://api.kohost.app/schemas/v3/admin/property.json",
|
|
4
|
-
"title": "Property",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"description": "A property is a physical asset or building",
|
|
7
|
-
"required": ["id", "name", "type", "hostname"],
|
|
8
|
-
"properties": {
|
|
9
|
-
"id": {
|
|
10
|
-
"$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
|
|
11
|
-
},
|
|
12
|
-
"name": {
|
|
13
|
-
"type": "string"
|
|
14
|
-
},
|
|
15
|
-
"type": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"enum": ["hospitality", "education", "commercial"]
|
|
18
|
-
},
|
|
19
|
-
"timezone": {
|
|
20
|
-
"type": "string"
|
|
21
|
-
},
|
|
22
|
-
"smsNumber": {
|
|
23
|
-
"type": "string"
|
|
24
|
-
},
|
|
25
|
-
"hostname": {
|
|
26
|
-
"type": "string"
|
|
27
|
-
},
|
|
28
|
-
"address": {
|
|
29
|
-
"type": "object",
|
|
30
|
-
"properties": {
|
|
31
|
-
"street": {
|
|
32
|
-
"type": "string"
|
|
33
|
-
},
|
|
34
|
-
"city": {
|
|
35
|
-
"type": "string"
|
|
36
|
-
},
|
|
37
|
-
"state": {
|
|
38
|
-
"type": "string"
|
|
39
|
-
},
|
|
40
|
-
"zip": {
|
|
41
|
-
"type": "string"
|
|
42
|
-
},
|
|
43
|
-
"country": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"latitude": {
|
|
49
|
-
"type": "number"
|
|
50
|
-
},
|
|
51
|
-
"longitude": {
|
|
52
|
-
"type": "number"
|
|
53
|
-
},
|
|
54
|
-
"appManifest": {
|
|
55
|
-
"type": "object",
|
|
56
|
-
|
|
57
|
-
"properties": {
|
|
58
|
-
"name": {
|
|
59
|
-
"type": "string"
|
|
60
|
-
},
|
|
61
|
-
"short_name": {
|
|
62
|
-
"type": "string"
|
|
63
|
-
},
|
|
64
|
-
"scope": {
|
|
65
|
-
"type": "string"
|
|
66
|
-
},
|
|
67
|
-
"start_url": {
|
|
68
|
-
"type": "string"
|
|
69
|
-
},
|
|
70
|
-
"themeColor": {
|
|
71
|
-
"type": "string"
|
|
72
|
-
},
|
|
73
|
-
"backgroundColor": {
|
|
74
|
-
"type": "string"
|
|
75
|
-
},
|
|
76
|
-
"display": {
|
|
77
|
-
"type": "string",
|
|
78
|
-
"enum": ["fullscreen", "standalone", "minimal-ui", "browser"],
|
|
79
|
-
"default": "fullscreen"
|
|
80
|
-
},
|
|
81
|
-
"orientation": {
|
|
82
|
-
"type": "string",
|
|
83
|
-
"enum": ["portrait", "landscape"],
|
|
84
|
-
"default": "portrait"
|
|
85
|
-
},
|
|
86
|
-
"splash": {
|
|
87
|
-
"type": "object",
|
|
88
|
-
"properties": {
|
|
89
|
-
"src": {
|
|
90
|
-
"type": "string"
|
|
91
|
-
},
|
|
92
|
-
"type": {
|
|
93
|
-
"type": "string"
|
|
94
|
-
},
|
|
95
|
-
"sizes": {
|
|
96
|
-
"type": "string"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"icons": {
|
|
101
|
-
"type": "array",
|
|
102
|
-
"items": {
|
|
103
|
-
"type": "object",
|
|
104
|
-
"properties": {
|
|
105
|
-
"src": {
|
|
106
|
-
"type": "string"
|
|
107
|
-
},
|
|
108
|
-
"sizes": {
|
|
109
|
-
"type": "string"
|
|
110
|
-
},
|
|
111
|
-
"type": {
|
|
112
|
-
"type": "string"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"logo": {
|
|
118
|
-
"type": "object",
|
|
119
|
-
"properties": {
|
|
120
|
-
"src": {
|
|
121
|
-
"type": "string"
|
|
122
|
-
},
|
|
123
|
-
"type": {
|
|
124
|
-
"type": "string"
|
|
125
|
-
},
|
|
126
|
-
"sizes": {
|
|
127
|
-
"type": "string"
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
"default": {
|
|
133
|
-
"name": "Kohost",
|
|
134
|
-
"short_name": "Kohost",
|
|
135
|
-
"start_url": "/",
|
|
136
|
-
"scope": "/",
|
|
137
|
-
"display": "fullscreen",
|
|
138
|
-
"orientation": "portrait",
|
|
139
|
-
"theme_color": "#1d1f22",
|
|
140
|
-
"background_color": "#1d1f22",
|
|
141
|
-
"icons": [
|
|
142
|
-
{
|
|
143
|
-
"src": "https://cdn.kohost.app/defaultIcon.png",
|
|
144
|
-
"sizes": "512x512",
|
|
145
|
-
"type": "image/png"
|
|
146
|
-
}
|
|
147
|
-
],
|
|
148
|
-
"splash": {
|
|
149
|
-
"src": "https://cdn.kohost.app/defaultSplash.jpg",
|
|
150
|
-
"sizes": "1500x800",
|
|
151
|
-
"type": "image/jpg"
|
|
152
|
-
},
|
|
153
|
-
"logo": {
|
|
154
|
-
"src": "https://cdn.kohost.app/defaultLogo.png",
|
|
155
|
-
"sizes": "300x75",
|
|
156
|
-
"type": "image/png"
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
"appFeatures": {
|
|
161
|
-
"type": "object",
|
|
162
|
-
"properties": {
|
|
163
|
-
"RoomControl": {},
|
|
164
|
-
"CheckIn": {},
|
|
165
|
-
"CheckOut": {},
|
|
166
|
-
"Concierge": {},
|
|
167
|
-
"Elevator": {}
|
|
168
|
-
},
|
|
169
|
-
"additionalProperties": false,
|
|
170
|
-
"default": {
|
|
171
|
-
"RoomControl": {}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"credentials": {
|
|
175
|
-
"type": "object",
|
|
176
|
-
"additionalProperties": true
|
|
177
|
-
},
|
|
178
|
-
"additionalProperties": false
|
|
179
|
-
}
|
|
180
|
-
}
|