@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.
- package/dist/cjs/Client.js +5089 -0
- package/dist/cjs/Commands.js +568 -0
- package/dist/cjs/Errors.js +174 -0
- package/dist/cjs/Events.js +375 -0
- package/dist/cjs/Models.js +3584 -0
- package/dist/cjs/defs.js +175 -0
- package/dist/cjs/index.cjs.js +17 -0
- package/dist/cjs/utils.js +246 -0
- package/dist/esm/Client.js +7428 -0
- package/dist/esm/Client.js.map +7 -0
- package/dist/esm/Commands.js +574 -0
- package/dist/esm/Commands.js.map +7 -0
- package/dist/esm/Errors.js +180 -0
- package/dist/esm/Errors.js.map +7 -0
- package/dist/esm/Events.js +381 -0
- package/dist/esm/Events.js.map +7 -0
- package/dist/esm/Models.js +13220 -0
- package/dist/esm/Models.js.map +7 -0
- package/dist/esm/defs.js +2514 -0
- package/dist/esm/defs.js.map +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/utils.js +7281 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/useCases/AddDefaultScenesToRooms.js +32 -0
- package/dist/useCases/AddScenesToRoom.js +32 -0
- package/dist/useCases/AdminCreateProperty.js +32 -0
- package/dist/useCases/AdminDescribeProperty.js +32 -0
- package/dist/useCases/AdminListCustomers.js +32 -0
- package/dist/useCases/AdminListProperties.js +32 -0
- package/dist/useCases/AdminUpdateProperty.js +32 -0
- package/dist/useCases/BatchNotifyPreArrival.js +32 -0
- package/dist/useCases/CheckInReservation.js +32 -0
- package/dist/useCases/CheckVerificationCode.js +32 -0
- package/dist/useCases/CreateAlarm.js +32 -0
- package/dist/useCases/CreateCamera.js +32 -0
- package/dist/useCases/CreateCourtesy.js +32 -0
- package/dist/useCases/CreateDefaultScenes.js +32 -0
- package/dist/useCases/CreateDimmer.js +32 -0
- package/dist/useCases/CreateDiscoveredDevice.js +32 -0
- package/dist/useCases/CreateDiscoveredDeviceAssociation.js +32 -0
- package/dist/useCases/CreateIntegration.js +32 -0
- package/dist/useCases/CreateIntegrationDeviceMapEntry.js +32 -0
- package/dist/useCases/CreateLock.js +32 -0
- package/dist/useCases/CreateReservation.js +32 -0
- package/dist/useCases/CreateRoom.js +32 -0
- package/dist/useCases/CreateRoomInSpace.js +32 -0
- package/dist/useCases/CreateSource.js +32 -0
- package/dist/useCases/CreateSpace.js +32 -0
- package/dist/useCases/CreateSwitch.js +32 -0
- package/dist/useCases/CreateThermostat.js +32 -0
- package/dist/useCases/CreateTicket.js +32 -0
- package/dist/useCases/CreateTicketMessage.js +32 -0
- package/dist/useCases/CreateUser.js +32 -0
- package/dist/useCases/CreateWindowCovering.js +32 -0
- package/dist/useCases/DeleteAlarm.js +32 -0
- package/dist/useCases/DeleteCamera.js +32 -0
- package/dist/useCases/DeleteCourtesy.js +32 -0
- package/dist/useCases/DeleteDimmer.js +32 -0
- package/dist/useCases/DeleteDiscoveredDevice.js +32 -0
- package/dist/useCases/DeleteIntegration.js +32 -0
- package/dist/useCases/DeleteLock.js +32 -0
- package/dist/useCases/DeleteReservation.js +32 -0
- package/dist/useCases/DeleteRoom.js +32 -0
- package/dist/useCases/DeleteSource.js +32 -0
- package/dist/useCases/DeleteSpace.js +32 -0
- package/dist/useCases/DeleteSwitch.js +32 -0
- package/dist/useCases/DeleteThermostat.js +32 -0
- package/dist/useCases/DeleteTicket.js +32 -0
- package/dist/useCases/DeleteUser.js +32 -0
- package/dist/useCases/DeleteWindowCovering.js +32 -0
- package/dist/useCases/DescribeAlarm.js +32 -0
- package/dist/useCases/DescribeCamera.js +32 -0
- package/dist/useCases/DescribeCourtesy.js +32 -0
- package/dist/useCases/DescribeDimmer.js +32 -0
- package/dist/useCases/DescribeDiscoveredDevice.js +32 -0
- package/dist/useCases/DescribeIntegration.js +32 -0
- package/dist/useCases/DescribeLock.js +32 -0
- package/dist/useCases/DescribeMyProperty.js +32 -0
- package/dist/useCases/DescribeReservation.js +32 -0
- package/dist/useCases/DescribeReservationCheckinStatus.js +32 -0
- package/dist/useCases/DescribeRoom.js +32 -0
- package/dist/useCases/DescribeSelf.js +32 -0
- package/dist/useCases/DescribeSource.js +32 -0
- package/dist/useCases/DescribeSpace.js +32 -0
- package/dist/useCases/DescribeSwitch.js +32 -0
- package/dist/useCases/DescribeThermostat.js +32 -0
- package/dist/useCases/DescribeTicket.js +32 -0
- package/dist/useCases/DescribeUser.js +32 -0
- package/dist/useCases/DescribeWindowCovering.js +32 -0
- package/dist/useCases/DiscoverReservations.js +32 -0
- package/dist/useCases/EmailUserAccountSetup.js +32 -0
- package/dist/useCases/ListAlarms.js +32 -0
- package/dist/useCases/ListCameras.js +32 -0
- package/dist/useCases/ListCourtesy.js +32 -0
- package/dist/useCases/ListDimmers.js +32 -0
- package/dist/useCases/ListDiscoveredDevices.js +32 -0
- package/dist/useCases/ListIntegrations.js +32 -0
- package/dist/useCases/ListLocks.js +32 -0
- package/dist/useCases/ListMyReservations.js +32 -0
- package/dist/useCases/ListMySpaces.js +32 -0
- package/dist/useCases/ListReservations.js +32 -0
- package/dist/useCases/ListRooms.js +32 -0
- package/dist/useCases/ListRoomsInSpace.js +32 -0
- package/dist/useCases/ListSources.js +32 -0
- package/dist/useCases/ListSpaces.js +32 -0
- package/dist/useCases/ListSwitches.js +32 -0
- package/dist/useCases/ListThermostats.js +32 -0
- package/dist/useCases/ListTickets.js +32 -0
- package/dist/useCases/ListUserReservations.js +32 -0
- package/dist/useCases/ListUsers.js +32 -0
- package/dist/useCases/ListWindowCoverings.js +32 -0
- package/dist/useCases/LoginGateway.js +32 -0
- package/dist/useCases/LoginUser.js +32 -0
- package/dist/useCases/MatchUserIdentification.js +32 -0
- package/dist/useCases/OCRDocument.js +32 -0
- package/dist/useCases/RefreshToken.js +32 -0
- package/dist/useCases/RequestLoginLink.js +32 -0
- package/dist/useCases/SendPreArrivalEmail.js +32 -0
- package/dist/useCases/SendPreArrivalSMS.js +32 -0
- package/dist/useCases/SendVerificationCode.js +32 -0
- package/dist/useCases/SetCamera.js +32 -0
- package/dist/useCases/SetCourtesy.js +32 -0
- package/dist/useCases/SetLock.js +32 -0
- package/dist/useCases/SetSource.js +32 -0
- package/dist/useCases/SetSwitch.js +32 -0
- package/dist/useCases/SetThermostat.js +32 -0
- package/dist/useCases/SetWindowCovering.js +32 -0
- package/dist/useCases/UpdateAlarm.js +32 -0
- package/dist/useCases/UpdateCamera.js +32 -0
- package/dist/useCases/UpdateCourtesy.js +32 -0
- package/dist/useCases/UpdateDimmer.js +32 -0
- package/dist/useCases/UpdateDiscoveredDevice.js +32 -0
- package/dist/useCases/UpdateIntegration.js +32 -0
- package/dist/useCases/UpdateLock.js +32 -0
- package/dist/useCases/UpdateMessageReadStatus.js +32 -0
- package/dist/useCases/UpdateReservation.js +32 -0
- package/dist/useCases/UpdateRoom.js +32 -0
- package/dist/useCases/UpdateSelf.js +32 -0
- package/dist/useCases/UpdateSource.js +32 -0
- package/dist/useCases/UpdateSpace.js +32 -0
- package/dist/useCases/UpdateSwitch.js +32 -0
- package/dist/useCases/UpdateThermostat.js +32 -0
- package/dist/useCases/UpdateTicket.js +32 -0
- package/dist/useCases/UpdateTicketStatus.js +32 -0
- package/dist/useCases/UpdateUser.js +32 -0
- package/dist/useCases/UpdateWindowCovering.js +32 -0
- package/dist/useCases/UpsertDiscoveredDevice.js +32 -0
- package/package.json +26 -7
- 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/http/index.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
const { EventEmitter } = require("events");
|
|
2
|
-
const defs = require("../defs").http;
|
|
3
|
-
const handleResponseError = require("./handleResponseError");
|
|
4
|
-
const handleResponseSuccess = require("./handleResponseSuccess");
|
|
5
|
-
|
|
6
|
-
const useCases = require("../useCases/http.json");
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
Creates methods for each use case in the API
|
|
10
|
-
|
|
11
|
-
@param {Object} Client - The client class
|
|
12
|
-
@returns undefined
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function useCaseMethodFactory(Client) {
|
|
16
|
-
const map = new Map(useCases);
|
|
17
|
-
for (const [useCase, data] of map.entries()) {
|
|
18
|
-
if (data.http) {
|
|
19
|
-
const { method, path } = data.http;
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
Creates a method for each use case in the API
|
|
23
|
-
@param {Object} options - The options to send to the API
|
|
24
|
-
@param {Object} options.headers - The headers to send to the API
|
|
25
|
-
@param {Object} options.params - The params for the reuquest to build the URL
|
|
26
|
-
@param {Object} options.data - The body to send to the API. Valid for POST and PUT requests
|
|
27
|
-
@parms {Object} options.query - The query for the request to build the URL
|
|
28
|
-
@returns {Promise} The response from the API
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
//eslint-disable-next-line no-inner-declarations
|
|
32
|
-
function UseCase(requestData, options = {}) {
|
|
33
|
-
if (!this._init) {
|
|
34
|
-
// wait a second for the client to initialize
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
resolve(UseCase.call(this, requestData));
|
|
38
|
-
}, 500);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!requestData) requestData = {};
|
|
42
|
-
|
|
43
|
-
// get parameters from path
|
|
44
|
-
const pathParams = path.match(/:[a-zA-Z0-9]+/g);
|
|
45
|
-
|
|
46
|
-
const { data, query, headers } = requestData;
|
|
47
|
-
|
|
48
|
-
// replace path parameters with values from params
|
|
49
|
-
let url = path;
|
|
50
|
-
if (pathParams && data) {
|
|
51
|
-
for (const param of pathParams) {
|
|
52
|
-
const paramName = param.replace(":", "");
|
|
53
|
-
url = url.replace(param, data[paramName]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// make sure all parameters have been replaced
|
|
58
|
-
if (url.match(/:[a-zA-Z0-9]+/g)) {
|
|
59
|
-
const missingParams = url.match(/:[a-zA-Z0-9]+/g);
|
|
60
|
-
// remove the colon from the parameter name
|
|
61
|
-
const missing = missingParams.map((param) => param.replace(":", ""));
|
|
62
|
-
return Promise.reject(
|
|
63
|
-
new Error(`Missing parameters: ${missing.join(", ")}`)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const config = {
|
|
68
|
-
method: method.toLowerCase(),
|
|
69
|
-
url: url,
|
|
70
|
-
...options,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (data) config.data = data;
|
|
74
|
-
if (query) config.params = query;
|
|
75
|
-
if (headers) config.headers = headers;
|
|
76
|
-
|
|
77
|
-
return this._http.request(config);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Client.prototype[useCase] = UseCase;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
class KohostApiClient extends EventEmitter {
|
|
86
|
-
/*
|
|
87
|
-
@param {Object} options - The options to create the client
|
|
88
|
-
@param {String} options.propertyId - The property ID
|
|
89
|
-
@param {String} options.url - The base URL for the API endpint
|
|
90
|
-
@param {Object} options.headers - Additional headers to send with each request
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
constructor(
|
|
94
|
-
options = {
|
|
95
|
-
url: "",
|
|
96
|
-
propertyId: "",
|
|
97
|
-
headers: {},
|
|
98
|
-
}
|
|
99
|
-
) {
|
|
100
|
-
super();
|
|
101
|
-
if (!options.url) throw new Error("options.url is required");
|
|
102
|
-
if (!options.propertyId) throw new Error("options.property is required");
|
|
103
|
-
this.options = options;
|
|
104
|
-
// eslint-disable-next-line no-undef
|
|
105
|
-
this.isBrowser = typeof window !== "undefined";
|
|
106
|
-
this._init = false;
|
|
107
|
-
|
|
108
|
-
import("axios").then((axiosModule) => {
|
|
109
|
-
const axios = axiosModule.default;
|
|
110
|
-
this._http = axios.create({
|
|
111
|
-
baseURL: options.url,
|
|
112
|
-
responseType: "json",
|
|
113
|
-
withCredentials: true,
|
|
114
|
-
headers: {
|
|
115
|
-
"Content-Type": "application/json",
|
|
116
|
-
Accept: "application/json",
|
|
117
|
-
[defs.propertyHeader]: options.propertyId,
|
|
118
|
-
...options.headers,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
this._http.interceptors.response.use(
|
|
123
|
-
handleResponseSuccess.bind(this),
|
|
124
|
-
handleResponseError.bind(this)
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
this._http.interceptors.request.use((config) => {
|
|
128
|
-
if (!this.isBrowser) {
|
|
129
|
-
config.headers[defs.authTokenHeader] = this.authToken;
|
|
130
|
-
}
|
|
131
|
-
return config;
|
|
132
|
-
});
|
|
133
|
-
this._init = true;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
get authTokenHeaderKey() {
|
|
138
|
-
return defs.authTokenHeader.toLowerCase();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
get refreshTokenHeaderKey() {
|
|
142
|
-
return defs.refreshTokenHeader.toLowerCase();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get lsTokenKey() {
|
|
146
|
-
return `${this.options.propertyId}_${defs.authTokenHeader}`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
get authToken() {
|
|
150
|
-
return this._authToken;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/*
|
|
154
|
-
@param {String} token - The token to set
|
|
155
|
-
@returns undefined
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
set authToken(token) {
|
|
159
|
-
this._authToken = token;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
onLoginRequired() {
|
|
163
|
-
this.emit("LoginRequired");
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
useCaseMethodFactory(KohostApiClient);
|
|
168
|
-
|
|
169
|
-
module.exports = KohostApiClient;
|
package/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const Models = require("./models");
|
|
2
|
-
const Errors = require("./errors");
|
|
3
|
-
const Commands = require("./commands");
|
|
4
|
-
const Events = require("./events");
|
|
5
|
-
const HttpClient = require("./http");
|
|
6
|
-
const defs = require("./defs");
|
|
7
|
-
const getFormalDeviceType = require("./utils/getFormalDeviceType");
|
|
8
|
-
const getDeviceTypes = require("./utils/getDeviceTypes");
|
|
9
|
-
|
|
10
|
-
const Kohost = {
|
|
11
|
-
Models,
|
|
12
|
-
Errors,
|
|
13
|
-
Commands,
|
|
14
|
-
Events,
|
|
15
|
-
defs,
|
|
16
|
-
Client: HttpClient,
|
|
17
|
-
utils: {
|
|
18
|
-
getFormalDeviceType: getFormalDeviceType,
|
|
19
|
-
getDeviceTypes: getDeviceTypes,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports = Kohost;
|
package/models/acl.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// create the ACL model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/acl.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class ACL extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(ACL.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(ACL.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(ACL, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
module.exports = ACL;
|
package/models/admin/customer.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const schemas = require("../../utils/schema");
|
|
2
|
-
const schema = require("../../schemas/admin/customer.json");
|
|
3
|
-
const Kohost = require("../kohost");
|
|
4
|
-
|
|
5
|
-
schemas.add(schema);
|
|
6
|
-
const validator = schemas.compile(schema);
|
|
7
|
-
|
|
8
|
-
class Customer extends Kohost {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(Customer.prototype, "schema", {
|
|
15
|
-
value: schema,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(Customer.prototype, "validator", {
|
|
19
|
-
get: function () {
|
|
20
|
-
return validator;
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(Customer, "validProperties", {
|
|
25
|
-
value: Object.keys(schema.properties),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
module.exports = Customer;
|
package/models/admin/property.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const schemas = require("../../utils/schema");
|
|
2
|
-
const schema = require("../../schemas/admin/property.json");
|
|
3
|
-
const Kohost = require("../kohost");
|
|
4
|
-
|
|
5
|
-
schemas.add(schema);
|
|
6
|
-
const validator = schemas.compile(schema);
|
|
7
|
-
|
|
8
|
-
class Property extends Kohost {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(Property.prototype, "schema", {
|
|
15
|
-
value: schema,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(Property.prototype, "validator", {
|
|
19
|
-
get: function () {
|
|
20
|
-
return validator;
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(Property, "validProperties", {
|
|
25
|
-
value: Object.keys(schema.properties),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
module.exports = Property;
|
package/models/alarm.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// create the Alarm Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/alarm.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Alarm extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Alarm.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Alarm.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Alarm, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
module.exports = Alarm;
|
package/models/application.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// create the Application model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/application.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
class Application extends Kohost {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(Application.prototype, "schema", {
|
|
15
|
-
value: schema,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(Application.prototype, "validator", {
|
|
19
|
-
get: function () {
|
|
20
|
-
return validator;
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(Application, "validProperties", {
|
|
25
|
-
value: Object.keys(schema.properties),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
module.exports = Application;
|
package/models/camera.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// create the Alarm Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/camera.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Camera extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Camera.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Camera.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Camera, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
module.exports = Camera;
|
package/models/courtesy.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// create the Courtesy Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/courtesy.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Courtesy extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Courtesy.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Courtesy.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Courtesy, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(Courtesy, "actionProperties", {
|
|
30
|
-
value: ["state"],
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
module.exports = Courtesy;
|
package/models/credential.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// create the Credential Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/credential.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Credential extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Credential.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Credential.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Credential, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
module.exports = Credential;
|
package/models/dimmer.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Create the Dimmer Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/dimmer.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Dimmer 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 === "level") {
|
|
19
|
-
const oldLevel = old[action];
|
|
20
|
-
const newLevel = _new[action];
|
|
21
|
-
delta[action] = newLevel - oldLevel / 100;
|
|
22
|
-
} else {
|
|
23
|
-
delta[action] = 1;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return delta;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(Dimmer.prototype, "schema", {
|
|
32
|
-
value: schema,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(Dimmer.prototype, "validator", {
|
|
36
|
-
get: function () {
|
|
37
|
-
return validator;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
Object.defineProperty(Dimmer, "validProperties", {
|
|
42
|
-
value: Object.keys(schema.properties),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(Dimmer, "actionProperties", {
|
|
46
|
-
value: ["level"],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
module.exports = Dimmer;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Create the Discovered Device Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/discoveredDevice.json");
|
|
4
|
-
|
|
5
|
-
const Kohost = require("./kohost");
|
|
6
|
-
|
|
7
|
-
schemas.add(schema);
|
|
8
|
-
const validator = schemas.compile(schema);
|
|
9
|
-
|
|
10
|
-
class DiscoveredDevice extends Kohost {
|
|
11
|
-
constructor(data) {
|
|
12
|
-
super(data);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(DiscoveredDevice.prototype, "schema", {
|
|
17
|
-
value: schema,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Object.defineProperty(DiscoveredDevice.prototype, "validator", {
|
|
21
|
-
get: function () {
|
|
22
|
-
return validator;
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
Object.defineProperty(DiscoveredDevice, "validProperties", {
|
|
27
|
-
value: Object.keys(schema.properties),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
module.exports = DiscoveredDevice;
|
package/models/gateway.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Create the Gateway Model
|
|
2
|
-
const schemas = require("../utils/schema");
|
|
3
|
-
const schema = require("../schemas/gateway.json");
|
|
4
|
-
const Kohost = require("./kohost");
|
|
5
|
-
|
|
6
|
-
schemas.add(schema);
|
|
7
|
-
const validator = schemas.compile(schema);
|
|
8
|
-
|
|
9
|
-
class Gateway extends Kohost {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(Gateway.prototype, "schema", {
|
|
16
|
-
value: schema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(Gateway.prototype, "validator", {
|
|
20
|
-
get: function () {
|
|
21
|
-
return validator;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(Gateway, "validProperties", {
|
|
26
|
-
value: Object.keys(schema.properties),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
module.exports = Gateway;
|
package/models/identification.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const schemas = require("../utils/schema");
|
|
2
|
-
const schema = require("../schemas/identification.json");
|
|
3
|
-
const Kohost = require("./kohost");
|
|
4
|
-
|
|
5
|
-
schemas.add(schema);
|
|
6
|
-
const validator = schemas.compile(schema);
|
|
7
|
-
|
|
8
|
-
class Identification extends Kohost {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
get isExpired() {
|
|
14
|
-
return new Date(this.expirationDate) < new Date();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(Identification.prototype, "schema", {
|
|
19
|
-
value: schema,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(Identification.prototype, "validator", {
|
|
23
|
-
get: function () {
|
|
24
|
-
return validator;
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(Identification, "validProperties", {
|
|
29
|
-
value: Object.keys(schema.properties),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
module.exports = Identification;
|
package/models/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const Switch = require("./switch");
|
|
2
|
-
const Alarm = require("./alarm");
|
|
3
|
-
const Dimmer = require("./dimmer");
|
|
4
|
-
const Lock = require("./lock");
|
|
5
|
-
const Thermostat = require("./thermostat");
|
|
6
|
-
const WindowCovering = require("./windowCovering");
|
|
7
|
-
const Identification = require("./identification");
|
|
8
|
-
const User = require("./user");
|
|
9
|
-
const Courtesy = require("./courtesy");
|
|
10
|
-
const Camera = require("./camera");
|
|
11
|
-
const MotionSensor = require("./motionSensor");
|
|
12
|
-
const MediaSource = require("./mediaSource");
|
|
13
|
-
const Room = require("./room");
|
|
14
|
-
const Reservation = require("./reservation");
|
|
15
|
-
const Application = require("./application");
|
|
16
|
-
const Space = require("./space");
|
|
17
|
-
const Ticket = require("./ticket");
|
|
18
|
-
const Scene = require("./scene");
|
|
19
|
-
const Gateway = require("./gateway");
|
|
20
|
-
const Product = require("./product");
|
|
21
|
-
const DiscoveredDevice = require("./discoveredDevice");
|
|
22
|
-
const Credential = require("./credential");
|
|
23
|
-
const ShortLink = require("./shortLink");
|
|
24
|
-
|
|
25
|
-
const AdminCustomer = require("./admin/customer");
|
|
26
|
-
const AdminProperty = require("./admin/property");
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
Admin: {
|
|
30
|
-
Customer: AdminCustomer,
|
|
31
|
-
Property: AdminProperty,
|
|
32
|
-
},
|
|
33
|
-
Gateway,
|
|
34
|
-
Switch,
|
|
35
|
-
Alarm,
|
|
36
|
-
Dimmer,
|
|
37
|
-
Lock,
|
|
38
|
-
Courtesy,
|
|
39
|
-
Camera,
|
|
40
|
-
MotionSensor,
|
|
41
|
-
Thermostat,
|
|
42
|
-
WindowCovering,
|
|
43
|
-
MediaSource,
|
|
44
|
-
Identification,
|
|
45
|
-
Product,
|
|
46
|
-
User,
|
|
47
|
-
Room,
|
|
48
|
-
Application,
|
|
49
|
-
Space,
|
|
50
|
-
Ticket,
|
|
51
|
-
Scene,
|
|
52
|
-
DiscoveredDevice,
|
|
53
|
-
Reservation,
|
|
54
|
-
Credential,
|
|
55
|
-
ShortLink,
|
|
56
|
-
};
|