dt-common-device 3.1.1 → 3.1.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/admin/Admin.repository.d.ts +7 -0
- package/dist/admin/Admin.repository.js +182 -0
- package/dist/admin/Admin.service.d.ts +5 -0
- package/dist/admin/Admin.service.js +17 -0
- package/dist/admin/index.d.ts +1 -0
- package/dist/admin/index.js +17 -0
- package/dist/config/config.types.d.ts +1 -0
- package/dist/constants/ConnectionProviders.d.ts +2 -0
- package/dist/constants/ConnectionProviders.js +2 -0
- package/dist/device/cloud/entities/DeviceFactory.js +73 -14
- package/dist/device/local/services/Device.service.js +294 -239
- package/dist/device/local/services/Hub.service.js +92 -38
- package/dist/events/BaseEventHandler.js +6 -1
- package/dist/events/DeviceEventHandler.js +6 -1
- package/dist/events/EventHandler.js +158 -104
- package/dist/events/EventProcessingService.js +8 -3
- package/dist/microservice/MicroServiceFactory.d.ts +1 -1
- package/dist/microservice/MicroServiceFactory.js +5 -3
- package/dist/property/Property.service.js +86 -27
- package/dist/queue/services/QueueService.js +6 -1
- package/dist/queue/utils/rateLimit.utils.js +19 -9
- package/package.json +1 -1
|
@@ -1,36 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
2
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
44
|
exports.LocalPropertyService = void 0;
|
|
4
45
|
const Property_repository_1 = require("./Property.repository");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
46
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
47
|
+
const typedi_2 = require("typedi");
|
|
48
|
+
let LocalPropertyService = (() => {
|
|
49
|
+
let _classDecorators = [(0, typedi_2.Service)()];
|
|
50
|
+
let _classDescriptor;
|
|
51
|
+
let _classExtraInitializers = [];
|
|
52
|
+
let _classThis;
|
|
53
|
+
var LocalPropertyService = _classThis = class {
|
|
54
|
+
constructor() {
|
|
55
|
+
// Use dependency injection instead of creating new instance
|
|
56
|
+
this.propertyRepository = typedi_1.default.get(Property_repository_1.PropertyRepository);
|
|
12
57
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
58
|
+
async getPropertyPreferences(propertyId) {
|
|
59
|
+
if (!propertyId) {
|
|
60
|
+
throw new Error("Property ID is required");
|
|
61
|
+
}
|
|
62
|
+
return await this.propertyRepository.getPropertyPreferences(propertyId);
|
|
18
63
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
async getProperty(propertyId) {
|
|
65
|
+
if (!propertyId) {
|
|
66
|
+
throw new Error("Property ID is required");
|
|
67
|
+
}
|
|
68
|
+
return await this.propertyRepository.getProperty(propertyId);
|
|
24
69
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
70
|
+
async getPropertyTimeZone(propertyId) {
|
|
71
|
+
if (!propertyId) {
|
|
72
|
+
throw new Error("Property ID is required");
|
|
73
|
+
}
|
|
74
|
+
const property = await this.propertyRepository.getProperty(propertyId);
|
|
75
|
+
if (!property) {
|
|
76
|
+
throw new Error("Property not found");
|
|
77
|
+
}
|
|
78
|
+
return property.timezone;
|
|
28
79
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
80
|
+
async getAllProperties() {
|
|
81
|
+
const properties = await this.propertyRepository.getAllProperties();
|
|
82
|
+
return properties;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__setFunctionName(_classThis, "LocalPropertyService");
|
|
86
|
+
(() => {
|
|
87
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
88
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
89
|
+
LocalPropertyService = _classThis = _classDescriptor.value;
|
|
90
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
91
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
92
|
+
})();
|
|
93
|
+
return LocalPropertyService = _classThis;
|
|
94
|
+
})();
|
|
36
95
|
exports.LocalPropertyService = LocalPropertyService;
|
|
@@ -37,10 +37,14 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
37
37
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
38
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
39
|
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
40
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
44
|
exports.QueueService = void 0;
|
|
42
45
|
const typedi_1 = require("typedi");
|
|
43
46
|
const HybridHttpQueue_1 = require("../entities/HybridHttpQueue");
|
|
47
|
+
const typedi_2 = __importDefault(require("typedi"));
|
|
44
48
|
let QueueService = (() => {
|
|
45
49
|
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
50
|
let _classDescriptor;
|
|
@@ -48,7 +52,8 @@ let QueueService = (() => {
|
|
|
48
52
|
let _classThis;
|
|
49
53
|
var QueueService = _classThis = class {
|
|
50
54
|
constructor() {
|
|
51
|
-
|
|
55
|
+
// Use dependency injection instead of creating new instance
|
|
56
|
+
this.hybridQueue = typedi_2.default.get(HybridHttpQueue_1.HybridHttpQueue);
|
|
52
57
|
}
|
|
53
58
|
async request(options) {
|
|
54
59
|
return this.hybridQueue.request(options);
|
|
@@ -34,28 +34,38 @@ class RateLimitUtils {
|
|
|
34
34
|
const configs = new Map();
|
|
35
35
|
// Configure rate limits for different providers
|
|
36
36
|
configs.set(constants_1.CONNECTION_PROVIDERS.SENSIBO, {
|
|
37
|
-
maxRequests:
|
|
38
|
-
windowMs:
|
|
37
|
+
maxRequests: 10,
|
|
38
|
+
windowMs: 10000, // 10 seconds
|
|
39
39
|
provider: constants_1.CONNECTION_PROVIDERS.SENSIBO,
|
|
40
40
|
});
|
|
41
41
|
configs.set(constants_1.CONNECTION_PROVIDERS.CLOUDBEDS, {
|
|
42
42
|
maxRequests: 10,
|
|
43
|
-
windowMs:
|
|
43
|
+
windowMs: 10000, // 10 seconds
|
|
44
44
|
provider: constants_1.CONNECTION_PROVIDERS.CLOUDBEDS,
|
|
45
45
|
});
|
|
46
|
+
configs.set(constants_1.CONNECTION_PROVIDERS.STAYNTOUCH, {
|
|
47
|
+
maxRequests: 10,
|
|
48
|
+
windowMs: 10000, // 10 seconds
|
|
49
|
+
provider: constants_1.CONNECTION_PROVIDERS.STAYNTOUCH,
|
|
50
|
+
});
|
|
51
|
+
configs.set(constants_1.CONNECTION_PROVIDERS.HOTELKEY, {
|
|
52
|
+
maxRequests: 10,
|
|
53
|
+
windowMs: 10000, // 10 seconds
|
|
54
|
+
provider: constants_1.CONNECTION_PROVIDERS.HOTELKEY,
|
|
55
|
+
});
|
|
46
56
|
configs.set(constants_1.CONNECTION_PROVIDERS.TTLOCK, {
|
|
47
|
-
maxRequests:
|
|
48
|
-
windowMs: 60000,
|
|
57
|
+
maxRequests: 15,
|
|
58
|
+
windowMs: 60000, // 1 minute
|
|
49
59
|
provider: constants_1.CONNECTION_PROVIDERS.TTLOCK,
|
|
50
60
|
});
|
|
51
61
|
configs.set(constants_1.CONNECTION_PROVIDERS.SCHLAGE, {
|
|
52
|
-
maxRequests:
|
|
53
|
-
windowMs: 60000,
|
|
62
|
+
maxRequests: 120,
|
|
63
|
+
windowMs: 60000, // 1 minute
|
|
54
64
|
provider: constants_1.CONNECTION_PROVIDERS.SCHLAGE,
|
|
55
65
|
});
|
|
56
66
|
configs.set(constants_1.CONNECTION_PROVIDERS.SMARTTHINGS, {
|
|
57
|
-
maxRequests:
|
|
58
|
-
windowMs: 60000,
|
|
67
|
+
maxRequests: 250,
|
|
68
|
+
windowMs: 60000, // 1 minute
|
|
59
69
|
provider: constants_1.CONNECTION_PROVIDERS.SMARTTHINGS,
|
|
60
70
|
});
|
|
61
71
|
configs.set(constants_1.CONNECTION_PROVIDERS.YALEWIFI, {
|