dt-common-device 4.0.8 → 4.0.11
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/audit/IAuditProperties.d.ts +32 -0
- package/dist/audit/IAuditProperties.js +13 -0
- package/dist/audit/PushAudit.d.ts +5 -0
- package/dist/audit/PushAudit.js +16 -0
- package/dist/audit/index.d.ts +2 -0
- package/dist/audit/index.js +18 -0
- package/dist/config/constants.d.ts +49 -0
- package/dist/config/constants.js +64 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +5 -0
- package/dist/entities/accessGroup/AccessGroup.repository.js +72 -0
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +5 -0
- package/dist/entities/accessGroup/AccessGroup.service.js +105 -0
- package/dist/entities/accessGroup/IAccessGroup.d.ts +14 -0
- package/dist/entities/accessGroup/IAccessGroup.js +2 -0
- package/dist/entities/accessGroup/index.d.ts +2 -0
- package/dist/entities/accessGroup/index.js +18 -0
- package/dist/entities/admin/Admin.repository.d.ts +7 -0
- package/dist/entities/admin/Admin.repository.js +182 -0
- package/dist/entities/admin/Admin.service.d.ts +5 -0
- package/dist/entities/admin/Admin.service.js +17 -0
- package/dist/entities/admin/index.d.ts +1 -0
- package/dist/entities/admin/index.js +17 -0
- package/dist/entities/connection/Connection.repository.d.ts +8 -0
- package/dist/entities/connection/Connection.repository.js +92 -0
- package/dist/entities/connection/Connection.service.d.ts +8 -0
- package/dist/entities/connection/Connection.service.js +32 -0
- package/dist/entities/connection/IConnection.d.ts +28 -0
- package/dist/entities/connection/IConnection.js +16 -0
- package/dist/entities/connection/index.d.ts +2 -0
- package/dist/entities/connection/index.js +18 -0
- package/dist/entities/device/cloud/entities/CloudDevice.d.ts +16 -0
- package/dist/entities/device/cloud/entities/CloudDevice.js +26 -0
- package/dist/entities/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/entities/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/entities/device/cloud/entities/DeviceFactory.d.ts +7 -0
- package/dist/entities/device/cloud/entities/DeviceFactory.js +80 -0
- package/dist/entities/device/cloud/entities/index.d.ts +3 -0
- package/dist/entities/device/cloud/entities/index.js +19 -0
- package/dist/entities/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
- package/dist/entities/device/cloud/interfaces/ICloudDevice.js +2 -0
- package/dist/entities/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/ICloudDeviceService.js +2 -0
- package/dist/entities/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/entities/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
- package/dist/entities/device/cloud/interfaces/IRawDataTransformer.js +2 -0
- package/dist/entities/device/cloud/interfaces/IRawDevice.d.ts +17 -0
- package/dist/entities/device/cloud/interfaces/IRawDevice.js +11 -0
- package/dist/entities/device/cloud/interfaces/index.d.ts +5 -0
- package/dist/entities/device/cloud/interfaces/index.js +21 -0
- package/dist/entities/device/local/interfaces/IDevice.d.ts +68 -0
- package/dist/entities/device/local/interfaces/IDevice.js +10 -0
- package/dist/entities/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/entities/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/entities/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/entities/device/local/interfaces/ISchedule.js +2 -0
- package/dist/entities/device/local/interfaces/index.d.ts +3 -0
- package/dist/entities/device/local/interfaces/index.js +19 -0
- package/dist/entities/device/local/repository/Device.repository.d.ts +30 -0
- package/dist/entities/device/local/repository/Device.repository.js +325 -0
- package/dist/entities/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/entities/device/local/repository/Hub.repository.js +139 -0
- package/dist/entities/device/local/repository/Schedule.repository.d.ts +9 -0
- package/dist/entities/device/local/repository/Schedule.repository.js +109 -0
- package/dist/entities/device/local/services/Device.service.d.ts +40 -0
- package/dist/entities/device/local/services/Device.service.js +391 -0
- package/dist/entities/device/local/services/Hub.service.d.ts +12 -0
- package/dist/entities/device/local/services/Hub.service.js +107 -0
- package/dist/entities/device/local/services/Schedule.service.d.ts +9 -0
- package/dist/entities/device/local/services/Schedule.service.js +26 -0
- package/dist/entities/device/local/services/index.d.ts +3 -0
- package/dist/entities/device/local/services/index.js +19 -0
- package/dist/entities/guest/Guest.repository.d.ts +6 -0
- package/dist/entities/guest/Guest.repository.js +74 -0
- package/dist/entities/guest/Guest.service.d.ts +6 -0
- package/dist/entities/guest/Guest.service.js +104 -0
- package/dist/entities/guest/IGuest.d.ts +12 -0
- package/dist/entities/guest/IGuest.js +2 -0
- package/dist/entities/guest/index.d.ts +2 -0
- package/dist/entities/guest/index.js +18 -0
- package/dist/entities/pms/IPms.d.ts +6 -0
- package/dist/entities/pms/IPms.js +10 -0
- package/dist/entities/pms/index.d.ts +1 -0
- package/dist/entities/pms/index.js +17 -0
- package/dist/entities/property/IProperty.d.ts +29 -0
- package/dist/entities/property/IProperty.js +2 -0
- package/dist/entities/property/Property.repository.d.ts +8 -0
- package/dist/entities/property/Property.repository.js +109 -0
- package/dist/entities/property/Property.service.d.ts +8 -0
- package/dist/entities/property/Property.service.js +124 -0
- package/dist/entities/property/index.d.ts +2 -0
- package/dist/entities/property/index.js +18 -0
- package/dist/entities/schedules/ISchedule.d.ts +14 -0
- package/dist/entities/schedules/ISchedule.js +2 -0
- package/dist/entities/schedules/Schedule.repository.d.ts +6 -0
- package/dist/entities/schedules/Schedule.repository.js +74 -0
- package/dist/entities/schedules/Schedule.service.d.ts +6 -0
- package/dist/entities/schedules/Schedule.service.js +104 -0
- package/dist/entities/schedules/index.d.ts +2 -0
- package/dist/entities/schedules/index.js +18 -0
- package/dist/entities/user/IUser.d.ts +15 -0
- package/dist/entities/user/IUser.js +2 -0
- package/dist/entities/user/User.repository.d.ts +5 -0
- package/dist/entities/user/User.repository.js +68 -0
- package/dist/entities/user/User.service.d.ts +6 -0
- package/dist/entities/user/User.service.js +103 -0
- package/dist/entities/zone/IZone.d.ts +10 -0
- package/dist/entities/zone/IZone.js +2 -0
- package/dist/entities/zone/Zone.repository.d.ts +6 -0
- package/dist/entities/zone/Zone.repository.js +77 -0
- package/dist/entities/zone/Zone.service.d.ts +6 -0
- package/dist/entities/zone/Zone.service.js +104 -0
- package/dist/entities/zone/index.d.ts +2 -0
- package/dist/entities/zone/index.js +18 -0
- package/dist/queue/utils/rateLimit.utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum Resource {
|
|
2
|
+
ORGANIZATION = "organization",
|
|
3
|
+
PROPERTY = "property",
|
|
4
|
+
ACCESS_GROUP = "accessGroup",
|
|
5
|
+
ZONE = "zone",
|
|
6
|
+
DEVICE = "device",
|
|
7
|
+
SCHEDULE = "schedule",
|
|
8
|
+
USER = "user"
|
|
9
|
+
}
|
|
10
|
+
export interface IAuditProperties {
|
|
11
|
+
resource: Resource;
|
|
12
|
+
propertyId: string;
|
|
13
|
+
propertyName?: string;
|
|
14
|
+
userId?: string;
|
|
15
|
+
userName?: string;
|
|
16
|
+
guestId?: string;
|
|
17
|
+
guestName?: string;
|
|
18
|
+
deviceId?: string;
|
|
19
|
+
deviceName?: string;
|
|
20
|
+
zoneId?: string;
|
|
21
|
+
zoneName?: string;
|
|
22
|
+
accessGroupId?: string;
|
|
23
|
+
accessGroupName?: string;
|
|
24
|
+
scheduleId?: string;
|
|
25
|
+
scheduleStartDate?: string;
|
|
26
|
+
scheduleEndDate?: string;
|
|
27
|
+
scheduleDuration?: number;
|
|
28
|
+
scheduleSource?: string;
|
|
29
|
+
scheduleStatus?: string;
|
|
30
|
+
eventData?: any;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resource = void 0;
|
|
4
|
+
var Resource;
|
|
5
|
+
(function (Resource) {
|
|
6
|
+
Resource["ORGANIZATION"] = "organization";
|
|
7
|
+
Resource["PROPERTY"] = "property";
|
|
8
|
+
Resource["ACCESS_GROUP"] = "accessGroup";
|
|
9
|
+
Resource["ZONE"] = "zone";
|
|
10
|
+
Resource["DEVICE"] = "device";
|
|
11
|
+
Resource["SCHEDULE"] = "schedule";
|
|
12
|
+
Resource["USER"] = "user";
|
|
13
|
+
})(Resource || (exports.Resource = Resource = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pushAudit = pushAudit;
|
|
7
|
+
const dt_audit_library_1 = require("dt-audit-library");
|
|
8
|
+
const AuditUtils_1 = require("./AuditUtils");
|
|
9
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
10
|
+
async function pushAudit(data) {
|
|
11
|
+
const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
|
|
12
|
+
await (0, dt_audit_library_1.publishAudit)({
|
|
13
|
+
eventType: data.auditType,
|
|
14
|
+
properties: audit,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./PushAudit"), exports);
|
|
18
|
+
__exportStar(require("./IAuditProperties"), exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const CONFIG_KEYS: {
|
|
2
|
+
REQUIRED: {
|
|
3
|
+
envs: string[];
|
|
4
|
+
};
|
|
5
|
+
ACCESS: {
|
|
6
|
+
env: string[];
|
|
7
|
+
INTERNAL_EVENT_HANDLER: boolean;
|
|
8
|
+
db_keys: {
|
|
9
|
+
base: string;
|
|
10
|
+
admin: string;
|
|
11
|
+
pms: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
ADMIN: {
|
|
15
|
+
env: string[];
|
|
16
|
+
INTERNAL_EVENT_HANDLER: boolean;
|
|
17
|
+
db_keys: {
|
|
18
|
+
base: string;
|
|
19
|
+
access: string;
|
|
20
|
+
pms: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
ENERGY: {
|
|
24
|
+
env: string[];
|
|
25
|
+
INTERNAL_EVENT_HANDLER: boolean;
|
|
26
|
+
db_keys: {
|
|
27
|
+
base: string;
|
|
28
|
+
admin: string;
|
|
29
|
+
pms: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
REMOTE: {
|
|
33
|
+
env: string[];
|
|
34
|
+
INTERNAL_EVENT_HANDLER: boolean;
|
|
35
|
+
db_keys: {
|
|
36
|
+
admin: string;
|
|
37
|
+
pms: string;
|
|
38
|
+
access: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
SCHEDULE: {
|
|
42
|
+
env: string[];
|
|
43
|
+
INTERNAL_EVENT_HANDLER: boolean;
|
|
44
|
+
db_keys: {
|
|
45
|
+
admin: string;
|
|
46
|
+
access: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_KEYS = void 0;
|
|
4
|
+
exports.CONFIG_KEYS = {
|
|
5
|
+
REQUIRED: {
|
|
6
|
+
envs: [
|
|
7
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
8
|
+
"AWS_REGION",
|
|
9
|
+
"AWS_ACCESS_KEY_ID",
|
|
10
|
+
"EVENT_BUS_NAME",
|
|
11
|
+
"MONGODB_URI",
|
|
12
|
+
"REDIS_HOST",
|
|
13
|
+
"REDIS_PORT",
|
|
14
|
+
"POSTHOG_API_KEY",
|
|
15
|
+
"POSTHOG_HOST",
|
|
16
|
+
"DEVICE_SERVICE",
|
|
17
|
+
"DT_API_KEY"
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
ACCESS: {
|
|
21
|
+
env: ["ADMIN_DB_URI", "PMS_DB_URI"],
|
|
22
|
+
INTERNAL_EVENT_HANDLER: true,
|
|
23
|
+
db_keys: {
|
|
24
|
+
base: "DATABASE_URL",
|
|
25
|
+
admin: "ADMIN_DB_URI",
|
|
26
|
+
pms: "PMS_DB_URI",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
ADMIN: {
|
|
30
|
+
env: ["ACCESS_DB_URI", "PMS_DB_URI"],
|
|
31
|
+
INTERNAL_EVENT_HANDLER: false,
|
|
32
|
+
db_keys: {
|
|
33
|
+
base: "DATABASE_URL",
|
|
34
|
+
access: "ACCESS_DB_URI",
|
|
35
|
+
pms: "PMS_DB_URI",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
ENERGY: {
|
|
39
|
+
env: ["ADMIN_DB_URI", "PMS_DB_URI"],
|
|
40
|
+
INTERNAL_EVENT_HANDLER: true,
|
|
41
|
+
db_keys: {
|
|
42
|
+
base: "DATABASE_URL",
|
|
43
|
+
admin: "ADMIN_DB_URI",
|
|
44
|
+
pms: "PMS_DB_URI",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
REMOTE: {
|
|
48
|
+
env: ["ADMIN_DB_URI", "PMS_DB_URI", "ACCESS_DB_URI"],
|
|
49
|
+
INTERNAL_EVENT_HANDLER: false,
|
|
50
|
+
db_keys: {
|
|
51
|
+
admin: "ADMIN_DB_URI",
|
|
52
|
+
pms: "PMS_DB_URI",
|
|
53
|
+
access: "ACCESS_DB_URI",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
SCHEDULE: {
|
|
57
|
+
env: ["ADMIN_DB_URI", "ACCESS_DB_URI"],
|
|
58
|
+
INTERNAL_EVENT_HANDLER: true,
|
|
59
|
+
db_keys: {
|
|
60
|
+
admin: "ADMIN_DB_URI",
|
|
61
|
+
access: "ACCESS_DB_URI",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.AccessGroupRepository = void 0;
|
|
42
|
+
const typedi_1 = require("typedi");
|
|
43
|
+
const db_1 = require("../../db");
|
|
44
|
+
let AccessGroupRepository = (() => {
|
|
45
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
46
|
+
let _classDescriptor;
|
|
47
|
+
let _classExtraInitializers = [];
|
|
48
|
+
let _classThis;
|
|
49
|
+
var AccessGroupRepository = _classThis = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.postgres = (0, db_1.getPostgresClient)();
|
|
52
|
+
}
|
|
53
|
+
async getAccessGroup(accessGroupId) {
|
|
54
|
+
const query = `
|
|
55
|
+
SELECT * FROM dt_collections
|
|
56
|
+
WHERE "id" = $1
|
|
57
|
+
`;
|
|
58
|
+
const result = await this.postgres.query(query, [accessGroupId]);
|
|
59
|
+
return result.rows[0];
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
__setFunctionName(_classThis, "AccessGroupRepository");
|
|
63
|
+
(() => {
|
|
64
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
65
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
66
|
+
AccessGroupRepository = _classThis = _classDescriptor.value;
|
|
67
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
68
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
69
|
+
})();
|
|
70
|
+
return AccessGroupRepository = _classThis;
|
|
71
|
+
})();
|
|
72
|
+
exports.AccessGroupRepository = AccessGroupRepository;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
21
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
22
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
23
|
+
var _, done = false;
|
|
24
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
25
|
+
var context = {};
|
|
26
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
27
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
28
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
29
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
}
|
|
37
|
+
else if (_ = accept(result)) {
|
|
38
|
+
if (kind === "field") initializers.unshift(_);
|
|
39
|
+
else descriptor[key] = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
43
|
+
done = true;
|
|
44
|
+
};
|
|
45
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
46
|
+
var useValue = arguments.length > 2;
|
|
47
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
48
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
49
|
+
}
|
|
50
|
+
return useValue ? value : void 0;
|
|
51
|
+
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
70
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
71
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.AccessGroupService = void 0;
|
|
75
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
76
|
+
const AccessGroup_repository_1 = require("./AccessGroup.repository");
|
|
77
|
+
let AccessGroupService = (() => {
|
|
78
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
79
|
+
let _classDescriptor;
|
|
80
|
+
let _classExtraInitializers = [];
|
|
81
|
+
let _classThis;
|
|
82
|
+
var AccessGroupService = _classThis = class {
|
|
83
|
+
constructor() {
|
|
84
|
+
this.accessGroupRepository = typedi_1.default.get(AccessGroup_repository_1.AccessGroupRepository);
|
|
85
|
+
}
|
|
86
|
+
async getAccessGroup(accessGroupId) {
|
|
87
|
+
if (!accessGroupId) {
|
|
88
|
+
throw new Error("Access Group ID is required");
|
|
89
|
+
}
|
|
90
|
+
return await this.accessGroupRepository.getAccessGroup(accessGroupId);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
__setFunctionName(_classThis, "AccessGroupService");
|
|
94
|
+
(() => {
|
|
95
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
96
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
97
|
+
AccessGroupService = _classThis = _classDescriptor.value;
|
|
98
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
99
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
100
|
+
})();
|
|
101
|
+
return AccessGroupService = _classThis;
|
|
102
|
+
})();
|
|
103
|
+
exports.AccessGroupService = AccessGroupService;
|
|
104
|
+
// Accessgroup.getAccessGroup(accessGroupId)
|
|
105
|
+
// GetAccessGroup()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IAccessGroup {
|
|
2
|
+
id: string;
|
|
3
|
+
propertyId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
type: string;
|
|
7
|
+
externalId?: string;
|
|
8
|
+
refId?: string;
|
|
9
|
+
isDeleted: boolean;
|
|
10
|
+
createdBy: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
accessibleBy: string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AccessGroup.service"), exports);
|
|
18
|
+
__exportStar(require("./IAccessGroup"), exports);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
21
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
22
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
23
|
+
var _, done = false;
|
|
24
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
25
|
+
var context = {};
|
|
26
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
27
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
28
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
29
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
}
|
|
37
|
+
else if (_ = accept(result)) {
|
|
38
|
+
if (kind === "field") initializers.unshift(_);
|
|
39
|
+
else descriptor[key] = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
43
|
+
done = true;
|
|
44
|
+
};
|
|
45
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
46
|
+
var useValue = arguments.length > 2;
|
|
47
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
48
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
49
|
+
}
|
|
50
|
+
return useValue ? value : void 0;
|
|
51
|
+
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
70
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
71
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.AdminRepository = void 0;
|
|
75
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
76
|
+
const utils_1 = require("../../utils");
|
|
77
|
+
const Device_repository_1 = require("../device/local/repository/Device.repository");
|
|
78
|
+
const db_1 = require("../../db/db");
|
|
79
|
+
const interfaces_1 = require("../device/cloud/interfaces");
|
|
80
|
+
let AdminRepository = (() => {
|
|
81
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
82
|
+
let _classDescriptor;
|
|
83
|
+
let _classExtraInitializers = [];
|
|
84
|
+
let _classThis;
|
|
85
|
+
var AdminRepository = _classThis = class {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.axiosInstance = (0, utils_1.getAdminServiceAxiosInstance)();
|
|
88
|
+
this.deviceRepository = typedi_1.default.get(Device_repository_1.DeviceRepository);
|
|
89
|
+
this.postgres = (0, db_1.getPostgresClient)();
|
|
90
|
+
}
|
|
91
|
+
async getZonesByAccessGroupIds(accessGroupIds) {
|
|
92
|
+
const result = await this.postgres.query(`SELECT "zc".*, "z"."id", "z"."name"
|
|
93
|
+
FROM "dt_zones_collection_map" "zc"
|
|
94
|
+
INNER JOIN "dt_zones" "z" ON "zc"."zoneId" = "z"."id"
|
|
95
|
+
WHERE "zc"."collectionId" = ANY($1)`, [accessGroupIds]);
|
|
96
|
+
const response = result.rows;
|
|
97
|
+
const _zones = (nestedZones, allzones = []) => {
|
|
98
|
+
nestedZones.forEach((z) => {
|
|
99
|
+
const onlyZone = { ...z };
|
|
100
|
+
delete onlyZone.childZones;
|
|
101
|
+
allzones.push(onlyZone);
|
|
102
|
+
if (!Array.isArray(z.childZones)) {
|
|
103
|
+
if (z.childZones.id)
|
|
104
|
+
z.childZones = [z.childZones];
|
|
105
|
+
}
|
|
106
|
+
if (z.childZones.length) {
|
|
107
|
+
_zones(z.childZones, allzones);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return allzones.map((e) => e.id);
|
|
111
|
+
};
|
|
112
|
+
// const zones = _zones(response);
|
|
113
|
+
const zoneIds = response.map((el) => el.id);
|
|
114
|
+
const collectionZone = [];
|
|
115
|
+
for (let i = 0; i < response.length; i++) {
|
|
116
|
+
let zoneIds = [];
|
|
117
|
+
const zones = await this.axiosInstance.get(`/zones/child?zoneId=${response[i].zoneId}`);
|
|
118
|
+
zoneIds.push(response[i].zoneId);
|
|
119
|
+
if (zones.childZones?.length > 0) {
|
|
120
|
+
const nestedZoneIds = new Set(_zones(zones.childZones));
|
|
121
|
+
zoneIds = [...zoneIds, ...nestedZoneIds];
|
|
122
|
+
}
|
|
123
|
+
if (collectionZone.length == 0) {
|
|
124
|
+
const obj = {
|
|
125
|
+
collectionId: response[i].collectionId,
|
|
126
|
+
zoneIds,
|
|
127
|
+
};
|
|
128
|
+
collectionZone.push(obj);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const obj = collectionZone.find((e) => e.collectionId == response[i].collectionId);
|
|
132
|
+
if (obj) {
|
|
133
|
+
obj.zoneIds = [...obj.zoneIds, ...zoneIds];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
collectionZone.push({
|
|
137
|
+
collectionId: response[i].collectionId,
|
|
138
|
+
zoneIds,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
let _zoneIds = collectionZone.flatMap((e) => {
|
|
144
|
+
return e.zoneIds.map((z) => z);
|
|
145
|
+
});
|
|
146
|
+
if (_zoneIds.length === 0)
|
|
147
|
+
return [];
|
|
148
|
+
const deviecDetail = await this.deviceRepository.queryDevices({
|
|
149
|
+
zoneIds: _zoneIds,
|
|
150
|
+
excludeDeviceType: interfaces_1.DeviceType.HUB,
|
|
151
|
+
});
|
|
152
|
+
const _collectionZone = collectionZone.map((e) => {
|
|
153
|
+
const zones = e.zoneIds;
|
|
154
|
+
let devices = [];
|
|
155
|
+
zones.forEach((element) => {
|
|
156
|
+
const device = deviecDetail.filter((d) => d.zoneId == element);
|
|
157
|
+
// Add collectionId to each device
|
|
158
|
+
device.forEach((dev) => {
|
|
159
|
+
dev.collectionId = e.collectionId;
|
|
160
|
+
});
|
|
161
|
+
const _devices = devices.concat(device);
|
|
162
|
+
devices = _devices;
|
|
163
|
+
});
|
|
164
|
+
e.devices = devices;
|
|
165
|
+
e.parentZone = response;
|
|
166
|
+
return e;
|
|
167
|
+
});
|
|
168
|
+
const collectionZoneDevices = Array.from(new Set(_collectionZone));
|
|
169
|
+
return collectionZoneDevices;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
__setFunctionName(_classThis, "AdminRepository");
|
|
173
|
+
(() => {
|
|
174
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
175
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
176
|
+
AdminRepository = _classThis = _classDescriptor.value;
|
|
177
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
178
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
179
|
+
})();
|
|
180
|
+
return AdminRepository = _classThis;
|
|
181
|
+
})();
|
|
182
|
+
exports.AdminRepository = AdminRepository;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AdminService = void 0;
|
|
7
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
8
|
+
const Admin_repository_1 = require("./Admin.repository");
|
|
9
|
+
class AdminService {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.adminRepository = typedi_1.default.get(Admin_repository_1.AdminRepository);
|
|
12
|
+
}
|
|
13
|
+
async getZonesByAccessGroupIds(accessGroupIds) {
|
|
14
|
+
return await this.adminRepository.getZonesByAccessGroupIds(accessGroupIds);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.AdminService = AdminService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Admin.service";
|