@kohost/api-client 3.0.0-beta.20 → 3.0.0-beta.22
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/AMQPClient.js +427 -0
- package/dist/cjs/Client.js +2 -1
- package/dist/cjs/Commands.js +0 -54
- package/dist/cjs/Events.js +7 -7
- package/dist/cjs/Models.js +305 -252
- package/dist/cjs/defs.js +3 -3
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/utils.js +243 -8
- package/dist/esm/Client.js +18 -13
- package/dist/esm/Client.js.map +2 -2
- package/dist/esm/Commands.js +0 -54
- package/dist/esm/Commands.js.map +2 -2
- package/dist/esm/Events.js +7 -7
- package/dist/esm/Events.js.map +2 -2
- package/dist/esm/Models.js +305 -252
- package/dist/esm/Models.js.map +4 -4
- package/dist/esm/defs.js +19 -15
- package/dist/esm/defs.js.map +2 -2
- package/dist/esm/utils.js +243 -8
- package/dist/esm/utils.js.map +3 -3
- package/package.json +4 -1
package/dist/cjs/defs.js
CHANGED
|
@@ -14,11 +14,10 @@ var require_deviceTypes = __commonJS({
|
|
|
14
14
|
"thermostat",
|
|
15
15
|
"lock",
|
|
16
16
|
"windowCovering",
|
|
17
|
-
"sceneController",
|
|
18
17
|
"courtesy",
|
|
19
18
|
"alarm",
|
|
20
19
|
"camera",
|
|
21
|
-
"
|
|
20
|
+
"mediaSource",
|
|
22
21
|
"motionSensor"
|
|
23
22
|
];
|
|
24
23
|
module2.exports = types;
|
|
@@ -52,6 +51,7 @@ var require_Client = __commonJS({
|
|
|
52
51
|
constructor(options = {
|
|
53
52
|
url: "",
|
|
54
53
|
propertyId: "",
|
|
54
|
+
organizationId: "",
|
|
55
55
|
apiKey: "",
|
|
56
56
|
headers: {}
|
|
57
57
|
}) {
|
|
@@ -120,7 +120,7 @@ var require_Client = __commonJS({
|
|
|
120
120
|
this._onLoginRequired();
|
|
121
121
|
return Promise.reject(error);
|
|
122
122
|
}
|
|
123
|
-
if (expectedError && errorMessage === "No
|
|
123
|
+
if (expectedError && errorMessage === "No auth header or cookie provided") {
|
|
124
124
|
this._onLoginRequired();
|
|
125
125
|
return Promise.reject(error);
|
|
126
126
|
}
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ const defs = require("./defs");
|
|
|
6
6
|
const utils = require("./utils");
|
|
7
7
|
const Client = require("./Client");
|
|
8
8
|
const SocketIoClient = require("./SocketIoClient");
|
|
9
|
+
const AMQPClient = require("./AMQPClient");
|
|
9
10
|
const Kohost = {
|
|
10
11
|
Models,
|
|
11
12
|
Errors,
|
|
@@ -13,6 +14,7 @@ const Kohost = {
|
|
|
13
14
|
Events,
|
|
14
15
|
Client,
|
|
15
16
|
SocketIoClient,
|
|
17
|
+
AMQPClient,
|
|
16
18
|
defs,
|
|
17
19
|
utils
|
|
18
20
|
};
|
package/dist/cjs/utils.js
CHANGED
|
@@ -25,11 +25,10 @@ var require_deviceTypes = __commonJS({
|
|
|
25
25
|
"thermostat",
|
|
26
26
|
"lock",
|
|
27
27
|
"windowCovering",
|
|
28
|
-
"sceneController",
|
|
29
28
|
"courtesy",
|
|
30
29
|
"alarm",
|
|
31
30
|
"camera",
|
|
32
|
-
"
|
|
31
|
+
"mediaSource",
|
|
33
32
|
"motionSensor"
|
|
34
33
|
];
|
|
35
34
|
module2.exports = types;
|
|
@@ -53,10 +52,13 @@ var require_common = __commonJS({
|
|
|
53
52
|
"src/schemas/definitions/common.json"(exports2, module2) {
|
|
54
53
|
module2.exports = {
|
|
55
54
|
$schema: "http://json-schema.org/draft-07/schema",
|
|
56
|
-
$id: "https://api.kohost.
|
|
55
|
+
$id: "https://api.kohost.io/schemas/v3/definitions/common.json",
|
|
57
56
|
definitions: {
|
|
58
57
|
id: {
|
|
59
|
-
type: "string"
|
|
58
|
+
type: "string",
|
|
59
|
+
not: {
|
|
60
|
+
enum: ["global", "system"]
|
|
61
|
+
}
|
|
60
62
|
},
|
|
61
63
|
systemData: {
|
|
62
64
|
type: "object",
|
|
@@ -122,6 +124,28 @@ var require_common = __commonJS({
|
|
|
122
124
|
maxLength: 2
|
|
123
125
|
}
|
|
124
126
|
}
|
|
127
|
+
},
|
|
128
|
+
driver: {
|
|
129
|
+
type: "string",
|
|
130
|
+
enum: [
|
|
131
|
+
"aws-kinesis",
|
|
132
|
+
"butler",
|
|
133
|
+
"crestron",
|
|
134
|
+
"ecobee",
|
|
135
|
+
"igor",
|
|
136
|
+
"kohost-k7",
|
|
137
|
+
"kohost-pms",
|
|
138
|
+
"lirc",
|
|
139
|
+
"mews",
|
|
140
|
+
"pelican-wireless",
|
|
141
|
+
"rebrandly",
|
|
142
|
+
"salto",
|
|
143
|
+
"salto-irn",
|
|
144
|
+
"se",
|
|
145
|
+
"sendgrid",
|
|
146
|
+
"stay-n-touch",
|
|
147
|
+
"twilio"
|
|
148
|
+
]
|
|
125
149
|
}
|
|
126
150
|
}
|
|
127
151
|
};
|
|
@@ -133,13 +157,13 @@ var require_device = __commonJS({
|
|
|
133
157
|
"src/schemas/definitions/device.json"(exports2, module2) {
|
|
134
158
|
module2.exports = {
|
|
135
159
|
$schema: "http://json-schema.org/draft-07/schema",
|
|
136
|
-
$id: "https://api.kohost.
|
|
160
|
+
$id: "https://api.kohost.io/schemas/v3/definitions/device.json",
|
|
137
161
|
definitions: {
|
|
138
162
|
id: {
|
|
139
|
-
$ref: "https://api.kohost.
|
|
163
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
|
|
140
164
|
},
|
|
141
165
|
systemData: {
|
|
142
|
-
$ref: "https://api.kohost.
|
|
166
|
+
$ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
|
|
143
167
|
},
|
|
144
168
|
type: {
|
|
145
169
|
type: "string",
|
|
@@ -239,12 +263,223 @@ var require_schema = __commonJS({
|
|
|
239
263
|
}
|
|
240
264
|
});
|
|
241
265
|
|
|
266
|
+
// src/Errors/AppError.js
|
|
267
|
+
var require_AppError = __commonJS({
|
|
268
|
+
"src/Errors/AppError.js"(exports2, module2) {
|
|
269
|
+
module2.exports = /* @__PURE__ */ __name(class AppError extends Error {
|
|
270
|
+
constructor(message = "Internal Server Error", options) {
|
|
271
|
+
super(message, options);
|
|
272
|
+
this.type = this.constructor.name;
|
|
273
|
+
this.statusCode = 500;
|
|
274
|
+
Object.setPrototypeOf(this, AppError.prototype);
|
|
275
|
+
}
|
|
276
|
+
}, "AppError");
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// src/Errors/AuthenticationError.js
|
|
281
|
+
var require_AuthenticationError = __commonJS({
|
|
282
|
+
"src/Errors/AuthenticationError.js"(exports2, module2) {
|
|
283
|
+
var AppError = require_AppError();
|
|
284
|
+
module2.exports = /* @__PURE__ */ __name(class AuthenticationError extends AppError {
|
|
285
|
+
constructor(message = "Authentication Error", options = {}) {
|
|
286
|
+
super(message, options);
|
|
287
|
+
this.statusCode = 401;
|
|
288
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
289
|
+
}
|
|
290
|
+
}, "AuthenticationError");
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// src/Errors/AuthorizationError.js
|
|
295
|
+
var require_AuthorizationError = __commonJS({
|
|
296
|
+
"src/Errors/AuthorizationError.js"(exports2, module2) {
|
|
297
|
+
var AppError = require_AppError();
|
|
298
|
+
module2.exports = /* @__PURE__ */ __name(class AuthorizationError extends AppError {
|
|
299
|
+
constructor(message = "Authorization Error", options = {}) {
|
|
300
|
+
super(message, options);
|
|
301
|
+
this.statusCode = 403;
|
|
302
|
+
Object.setPrototypeOf(this, AuthorizationError.prototype);
|
|
303
|
+
}
|
|
304
|
+
}, "AuthorizationError");
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// src/Errors/DeviceCommError.js
|
|
309
|
+
var require_DeviceCommError = __commonJS({
|
|
310
|
+
"src/Errors/DeviceCommError.js"(exports2, module2) {
|
|
311
|
+
var AppError = require_AppError();
|
|
312
|
+
module2.exports = /* @__PURE__ */ __name(class DeviceCommError extends AppError {
|
|
313
|
+
constructor(message = "Device Communication Error", options = {}) {
|
|
314
|
+
super(message, options);
|
|
315
|
+
this.statusCode = 503;
|
|
316
|
+
Object.setPrototypeOf(this, DeviceCommError.prototype);
|
|
317
|
+
}
|
|
318
|
+
}, "DeviceCommError");
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// src/Errors/LoginError.js
|
|
323
|
+
var require_LoginError = __commonJS({
|
|
324
|
+
"src/Errors/LoginError.js"(exports2, module2) {
|
|
325
|
+
var AppError = require_AppError();
|
|
326
|
+
module2.exports = /* @__PURE__ */ __name(class LoginError extends AppError {
|
|
327
|
+
constructor(message = "Invalid Login information provided", options = {}) {
|
|
328
|
+
super(message, options);
|
|
329
|
+
this.statusCode = 401;
|
|
330
|
+
Object.setPrototypeOf(this, LoginError.prototype);
|
|
331
|
+
}
|
|
332
|
+
}, "LoginError");
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// src/Errors/NotFoundError.js
|
|
337
|
+
var require_NotFoundError = __commonJS({
|
|
338
|
+
"src/Errors/NotFoundError.js"(exports2, module2) {
|
|
339
|
+
var AppError = require_AppError();
|
|
340
|
+
module2.exports = /* @__PURE__ */ __name(class NotFoundError extends AppError {
|
|
341
|
+
constructor(message = "Resource Not Found", options = {}) {
|
|
342
|
+
super(message, options);
|
|
343
|
+
this.statusCode = 404;
|
|
344
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
345
|
+
}
|
|
346
|
+
}, "NotFoundError");
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// src/Errors/RequestError.js
|
|
351
|
+
var require_RequestError = __commonJS({
|
|
352
|
+
"src/Errors/RequestError.js"(exports2, module2) {
|
|
353
|
+
var AppError = require_AppError();
|
|
354
|
+
module2.exports = /* @__PURE__ */ __name(class RequestError extends AppError {
|
|
355
|
+
constructor(message = "Bad Request", options = {}) {
|
|
356
|
+
super(message, options);
|
|
357
|
+
this.statusCode = 400;
|
|
358
|
+
Object.setPrototypeOf(this, RequestError.prototype);
|
|
359
|
+
}
|
|
360
|
+
}, "RequestError");
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// src/Errors/SystemCommError.js
|
|
365
|
+
var require_SystemCommError = __commonJS({
|
|
366
|
+
"src/Errors/SystemCommError.js"(exports2, module2) {
|
|
367
|
+
var AppError = require_AppError();
|
|
368
|
+
module2.exports = /* @__PURE__ */ __name(class SystemCommError extends AppError {
|
|
369
|
+
constructor(message = "System Communication Error", options = {}) {
|
|
370
|
+
super(message, options);
|
|
371
|
+
this.statusCode = 503;
|
|
372
|
+
Object.setPrototypeOf(this, SystemCommError.prototype);
|
|
373
|
+
}
|
|
374
|
+
}, "SystemCommError");
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// src/Errors/TokenExpiredError.js
|
|
379
|
+
var require_TokenExpiredError = __commonJS({
|
|
380
|
+
"src/Errors/TokenExpiredError.js"(exports2, module2) {
|
|
381
|
+
var AppError = require_AppError();
|
|
382
|
+
module2.exports = /* @__PURE__ */ __name(class TokenExpiredError extends AppError {
|
|
383
|
+
constructor(message = "Token Expired", options = {}) {
|
|
384
|
+
super(message, options);
|
|
385
|
+
this.statusCode = 401;
|
|
386
|
+
Object.setPrototypeOf(this, TokenExpiredError.prototype);
|
|
387
|
+
}
|
|
388
|
+
}, "TokenExpiredError");
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// src/Errors/UnprocessableRequestError.js
|
|
393
|
+
var require_UnprocessableRequestError = __commonJS({
|
|
394
|
+
"src/Errors/UnprocessableRequestError.js"(exports2, module2) {
|
|
395
|
+
var AppError = require_AppError();
|
|
396
|
+
module2.exports = /* @__PURE__ */ __name(class UnprocessableRequestError extends AppError {
|
|
397
|
+
constructor(message = "Unprocessable Request Error", options = {}) {
|
|
398
|
+
super(message, options);
|
|
399
|
+
this.statusCode = 422;
|
|
400
|
+
Object.setPrototypeOf(this, UnprocessableRequestError.prototype);
|
|
401
|
+
}
|
|
402
|
+
}, "UnprocessableRequestError");
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// src/Errors/ValidationError.js
|
|
407
|
+
var require_ValidationError = __commonJS({
|
|
408
|
+
"src/Errors/ValidationError.js"(exports2, module2) {
|
|
409
|
+
var AppError = require_AppError();
|
|
410
|
+
module2.exports = /* @__PURE__ */ __name(class ValidationError extends AppError {
|
|
411
|
+
constructor(message = "Validation Error", options = {}) {
|
|
412
|
+
super(message, options);
|
|
413
|
+
this.statusCode = 400;
|
|
414
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
415
|
+
}
|
|
416
|
+
}, "ValidationError");
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// src/Errors/index.js
|
|
421
|
+
var require_Errors = __commonJS({
|
|
422
|
+
"src/Errors/index.js"(exports2, module2) {
|
|
423
|
+
var Errors = {
|
|
424
|
+
AppError: require_AppError(),
|
|
425
|
+
AuthenticationError: require_AuthenticationError(),
|
|
426
|
+
AuthorizationError: require_AuthorizationError(),
|
|
427
|
+
DeviceCommError: require_DeviceCommError(),
|
|
428
|
+
LoginError: require_LoginError(),
|
|
429
|
+
NotFoundError: require_NotFoundError(),
|
|
430
|
+
RequestError: require_RequestError(),
|
|
431
|
+
SystemCommError: require_SystemCommError(),
|
|
432
|
+
TokenExpiredError: require_TokenExpiredError(),
|
|
433
|
+
UnprocessableRequestError: require_UnprocessableRequestError(),
|
|
434
|
+
ValidationError: require_ValidationError()
|
|
435
|
+
};
|
|
436
|
+
module2.exports = Errors;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
// src/utils/errorFactory.js
|
|
441
|
+
var require_errorFactory = __commonJS({
|
|
442
|
+
"src/utils/errorFactory.js"(exports2, module2) {
|
|
443
|
+
var Errors = require_Errors();
|
|
444
|
+
module2.exports = /* @__PURE__ */ __name(function errorFactory2(err) {
|
|
445
|
+
switch (err.type) {
|
|
446
|
+
case "AppError":
|
|
447
|
+
return new Errors.AppError(err.message);
|
|
448
|
+
case "AuthenticationError":
|
|
449
|
+
return new Errors.AuthenticationError(err.message);
|
|
450
|
+
case "AuthorizationError":
|
|
451
|
+
return new Errors.AuthorizationError(err.message);
|
|
452
|
+
case "DeviceCommError":
|
|
453
|
+
return new Errors.DeviceCommError(err.message);
|
|
454
|
+
case "LoginError":
|
|
455
|
+
return new Errors.LoginError(err.message);
|
|
456
|
+
case "NotFoundError":
|
|
457
|
+
return new Errors.NotFoundError(err.message);
|
|
458
|
+
case "RequestError":
|
|
459
|
+
return new Errors.RequestError(err.message);
|
|
460
|
+
case "SystemCommError":
|
|
461
|
+
return new Errors.SystemCommError(err.message);
|
|
462
|
+
case "TokenExpiredError":
|
|
463
|
+
return new Errors.TokenExpiredError(err.message);
|
|
464
|
+
case "UnprocessableRequestError":
|
|
465
|
+
return new Errors.UnprocessableRequestError(err.message);
|
|
466
|
+
case "ValidationError":
|
|
467
|
+
return new Errors.ValidationError(err.message);
|
|
468
|
+
default:
|
|
469
|
+
return new Error(err.message);
|
|
470
|
+
}
|
|
471
|
+
}, "errorFactory");
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
242
475
|
// src/utils/index.js
|
|
243
476
|
var getFormalDeviceType = require_getFormalDeviceType();
|
|
244
477
|
var getDeviceTypes = require_getDeviceTypes();
|
|
245
478
|
var schema = require_schema();
|
|
479
|
+
var errorFactory = require_errorFactory();
|
|
246
480
|
module.exports = {
|
|
247
481
|
getFormalDeviceType,
|
|
248
482
|
getDeviceTypes,
|
|
249
|
-
schema
|
|
483
|
+
schema,
|
|
484
|
+
errorFactory
|
|
250
485
|
};
|
package/dist/esm/Client.js
CHANGED
|
@@ -5390,8 +5390,9 @@ var require_axios = __commonJS({
|
|
|
5390
5390
|
var isFileList = kindOfTest("FileList");
|
|
5391
5391
|
var isStream = /* @__PURE__ */ __name((val) => isObject(val) && isFunction(val.pipe), "isStream");
|
|
5392
5392
|
var isFormData = /* @__PURE__ */ __name((thing) => {
|
|
5393
|
-
|
|
5394
|
-
return thing && (typeof FormData === "function" && thing instanceof FormData ||
|
|
5393
|
+
let kind;
|
|
5394
|
+
return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
|
|
5395
|
+
kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
|
|
5395
5396
|
}, "isFormData");
|
|
5396
5397
|
var isURLSearchParams = kindOfTest("URLSearchParams");
|
|
5397
5398
|
var trim = /* @__PURE__ */ __name((str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), "trim");
|
|
@@ -6286,10 +6287,7 @@ var require_axios = __commonJS({
|
|
|
6286
6287
|
return tokens;
|
|
6287
6288
|
}
|
|
6288
6289
|
__name(parseTokens, "parseTokens");
|
|
6289
|
-
|
|
6290
|
-
return /^[-_a-zA-Z]+$/.test(str.trim());
|
|
6291
|
-
}
|
|
6292
|
-
__name(isValidHeaderName, "isValidHeaderName");
|
|
6290
|
+
var isValidHeaderName = /* @__PURE__ */ __name((str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim()), "isValidHeaderName");
|
|
6293
6291
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
6294
6292
|
if (utils.isFunction(filter)) {
|
|
6295
6293
|
return filter.call(this, value, header);
|
|
@@ -6995,7 +6993,7 @@ var require_axios = __commonJS({
|
|
|
6995
6993
|
return config;
|
|
6996
6994
|
}
|
|
6997
6995
|
__name(mergeConfig, "mergeConfig");
|
|
6998
|
-
var VERSION = "1.3.
|
|
6996
|
+
var VERSION = "1.3.6";
|
|
6999
6997
|
var validators$1 = {};
|
|
7000
6998
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
7001
6999
|
validators$1[type] = /* @__PURE__ */ __name(function validator2(thing) {
|
|
@@ -7087,11 +7085,17 @@ var require_axios = __commonJS({
|
|
|
7087
7085
|
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
7088
7086
|
}, false);
|
|
7089
7087
|
}
|
|
7090
|
-
if (paramsSerializer
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7088
|
+
if (paramsSerializer != null) {
|
|
7089
|
+
if (utils.isFunction(paramsSerializer)) {
|
|
7090
|
+
config.paramsSerializer = {
|
|
7091
|
+
serialize: paramsSerializer
|
|
7092
|
+
};
|
|
7093
|
+
} else {
|
|
7094
|
+
validator.assertOptions(paramsSerializer, {
|
|
7095
|
+
encode: validators.function,
|
|
7096
|
+
serialize: validators.function
|
|
7097
|
+
}, true);
|
|
7098
|
+
}
|
|
7095
7099
|
}
|
|
7096
7100
|
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
7097
7101
|
let contextHeaders;
|
|
@@ -7540,6 +7544,7 @@ var require_Client = __commonJS({
|
|
|
7540
7544
|
constructor(options = {
|
|
7541
7545
|
url: "",
|
|
7542
7546
|
propertyId: "",
|
|
7547
|
+
organizationId: "",
|
|
7543
7548
|
apiKey: "",
|
|
7544
7549
|
headers: {}
|
|
7545
7550
|
}) {
|
|
@@ -7606,7 +7611,7 @@ var require_Client = __commonJS({
|
|
|
7606
7611
|
this._onLoginRequired();
|
|
7607
7612
|
return Promise.reject(error);
|
|
7608
7613
|
}
|
|
7609
|
-
if (expectedError && errorMessage === "No
|
|
7614
|
+
if (expectedError && errorMessage === "No auth header or cookie provided") {
|
|
7610
7615
|
this._onLoginRequired();
|
|
7611
7616
|
return Promise.reject(error);
|
|
7612
7617
|
}
|