@golemio/energetics 1.3.8-dev.1350798883 → 1.3.8-dev.1365974407
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/db/example/00_clear_test_data.sql +1 -0
- package/db/example/05_access.sql +5 -0
- package/db/migrations/postgresql/20240621083051-access-limitation.js +53 -0
- package/db/migrations/postgresql/sqls/20240621083051-access-limitation-down.sql +1 -0
- package/db/migrations/postgresql/sqls/20240621083051-access-limitation-up.sql +7 -0
- package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.d.ts +9 -0
- package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js +45 -0
- package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js.map +1 -0
- package/dist/integration-engine/commodity-providers/ioc/Di.js +5 -1
- package/dist/integration-engine/commodity-providers/ioc/Di.js.map +1 -1
- package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.d.ts +2 -0
- package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js +2 -0
- package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js.map +1 -1
- package/dist/integration-engine/ioc/Di.js.map +1 -1
- package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.d.ts +9 -0
- package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js +78 -0
- package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js.map +1 -0
- package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.d.ts +9 -0
- package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js +32 -0
- package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js.map +1 -0
- package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js +2 -0
- package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js.map +1 -1
- package/dist/output-gateway/controllers/v2/AbstractController.d.ts +8 -0
- package/dist/output-gateway/controllers/v2/AbstractController.js +28 -0
- package/dist/output-gateway/controllers/v2/AbstractController.js.map +1 -0
- package/dist/output-gateway/controllers/v2/BuildingsController.d.ts +6 -3
- package/dist/output-gateway/controllers/v2/BuildingsController.js +26 -13
- package/dist/output-gateway/controllers/v2/BuildingsController.js.map +1 -1
- package/dist/output-gateway/controllers/v2/V2DevicesController.d.ts +5 -3
- package/dist/output-gateway/controllers/v2/V2DevicesController.js +15 -8
- package/dist/output-gateway/controllers/v2/V2DevicesController.js.map +1 -1
- package/dist/output-gateway/controllers/v2/V2MeasurementsController.d.ts +5 -3
- package/dist/output-gateway/controllers/v2/V2MeasurementsController.js +14 -7
- package/dist/output-gateway/controllers/v2/V2MeasurementsController.js.map +1 -1
- package/dist/output-gateway/controllers/v2/V2OrganizationsController.d.ts +6 -4
- package/dist/output-gateway/controllers/v2/V2OrganizationsController.js +17 -10
- package/dist/output-gateway/controllers/v2/V2OrganizationsController.js.map +1 -1
- package/dist/output-gateway/ioc/Di.js +9 -1
- package/dist/output-gateway/ioc/Di.js.map +1 -1
- package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +2 -0
- package/dist/output-gateway/ioc/ModuleContainerToken.js +2 -0
- package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
- package/dist/output-gateway/repositories/AccessLimitationRepository.d.ts +11 -0
- package/dist/output-gateway/repositories/AccessLimitationRepository.js +43 -0
- package/dist/output-gateway/repositories/AccessLimitationRepository.js.map +1 -0
- package/dist/output-gateway/repositories/DevicesRepository.d.ts +4 -3
- package/dist/output-gateway/repositories/DevicesRepository.js +19 -5
- package/dist/output-gateway/repositories/DevicesRepository.js.map +1 -1
- package/dist/output-gateway/repositories/MeasurementRepository.d.ts +3 -2
- package/dist/output-gateway/repositories/MeasurementRepository.js +29 -20
- package/dist/output-gateway/repositories/MeasurementRepository.js.map +1 -1
- package/dist/output-gateway/repositories/OrganizationsRepository.d.ts +3 -3
- package/dist/output-gateway/repositories/OrganizationsRepository.js +7 -4
- package/dist/output-gateway/repositories/OrganizationsRepository.js.map +1 -1
- package/dist/output-gateway/repositories/PrimaryBuildingsRepository.d.ts +4 -3
- package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js +19 -4
- package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js.map +1 -1
- package/dist/output-gateway/routers/v2/V2BuildingsRouter.js +2 -2
- package/dist/output-gateway/routers/v2/V2BuildingsRouter.js.map +1 -1
- package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.d.ts +3 -0
- package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js +18 -0
- package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js.map +1 -0
- package/dist/schema-definitions/models/AccessLimitationModel.d.ts +10 -0
- package/dist/schema-definitions/models/AccessLimitationModel.js +32 -0
- package/dist/schema-definitions/models/AccessLimitationModel.js.map +1 -0
- package/dist/schema-definitions/models/interfaces/IAccessLimitation.d.ts +4 -0
- package/dist/schema-definitions/models/interfaces/IAccessLimitation.js +3 -0
- package/dist/schema-definitions/models/interfaces/IAccessLimitation.js.map +1 -0
- package/docs/implementation_documentation.md +21 -0
- package/package.json +3 -3
|
@@ -22,20 +22,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.V2DevicesController = void 0;
|
|
25
|
-
const
|
|
26
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
25
|
+
const parsePaginationParams_1 = require("../helpers/parsePaginationParams");
|
|
27
26
|
const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
|
|
27
|
+
const AccessLimitationRepository_1 = require("../../repositories/AccessLimitationRepository");
|
|
28
28
|
const DevicesRepository_1 = require("../../repositories/DevicesRepository");
|
|
29
29
|
const DeviceDtoTransformation_1 = require("../../transformations/DeviceDtoTransformation");
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
31
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
32
|
+
const AbstractController_1 = require("./AbstractController");
|
|
33
|
+
let V2DevicesController = exports.V2DevicesController = class V2DevicesController extends AbstractController_1.AbstractController {
|
|
34
|
+
constructor(devicesRepository, transformation, accessLimitationRepository) {
|
|
35
|
+
super(accessLimitationRepository);
|
|
33
36
|
this.devicesRepository = devicesRepository;
|
|
34
37
|
this.transformation = transformation;
|
|
35
38
|
this.getAll = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
36
39
|
try {
|
|
40
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
37
41
|
const params = (0, parsePaginationParams_1.parsePaginationParams)(req);
|
|
38
|
-
const result = yield this.devicesRepository.GetAll(params);
|
|
42
|
+
const result = yield this.devicesRepository.GetAll(params, allowedOrganizations);
|
|
39
43
|
return res.json(this.transformation.transformArray(result));
|
|
40
44
|
}
|
|
41
45
|
catch (err) {
|
|
@@ -44,8 +48,9 @@ let V2DevicesController = exports.V2DevicesController = class V2DevicesControlle
|
|
|
44
48
|
});
|
|
45
49
|
this.getOne = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
46
50
|
try {
|
|
51
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
47
52
|
const id = req.params.id;
|
|
48
|
-
const result = yield this.devicesRepository.GetOne(id);
|
|
53
|
+
const result = yield this.devicesRepository.GetOne(id, allowedOrganizations);
|
|
49
54
|
if (!result) {
|
|
50
55
|
return next(new golemio_errors_1.GeneralError("not_found", this.constructor.name, `Device with id ${req.params.id} not found`, 404));
|
|
51
56
|
}
|
|
@@ -61,7 +66,9 @@ exports.V2DevicesController = V2DevicesController = __decorate([
|
|
|
61
66
|
(0, tsyringe_1.injectable)(),
|
|
62
67
|
__param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.DevicesRepository)),
|
|
63
68
|
__param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.DeviceDtoTransformation)),
|
|
69
|
+
__param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.AccessLimitationRepository)),
|
|
64
70
|
__metadata("design:paramtypes", [DevicesRepository_1.DevicesRepository,
|
|
65
|
-
DeviceDtoTransformation_1.DeviceDtoTransformation
|
|
71
|
+
DeviceDtoTransformation_1.DeviceDtoTransformation,
|
|
72
|
+
AccessLimitationRepository_1.AccessLimitationRepository])
|
|
66
73
|
], V2DevicesController);
|
|
67
74
|
//# sourceMappingURL=V2DevicesController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2DevicesController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2DevicesController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"V2DevicesController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2DevicesController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsF;AAEtF,yEAAoE;AACpE,8FAAyF;AACzF,4EAAuE;AACvE,2FAAsF;AAEtF,6EAAwE;AACxE,iEAAwE;AACxE,6DAA0D;AAGnD,IAAM,mBAAmB,iCAAzB,MAAM,mBAAoB,SAAQ,uCAAkB;IACvD,YACoD,iBAA4C,EAE5F,cAA+C,EACU,0BAAsD;QAE/G,KAAK,CAAC,0BAA0B,CAAC,CAAC;QALsB,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpF,mBAAc,GAAd,cAAc,CAAyB;QAM5C,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;gBACvE,MAAM,MAAM,GAAsB,IAAA,6CAAqB,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AC,uBAAuB,CAAC,CAAA;IAEpD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;qCAHmB,qCAAiB;QAEpE,iDAAuB;QACsC,uDAA0B;GAL1G,mBAAmB,CAsC/B"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="express" />
|
|
2
|
-
import {
|
|
2
|
+
import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
|
|
3
3
|
import { MeasurementRepository } from "../../repositories/MeasurementRepository";
|
|
4
|
-
|
|
4
|
+
import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
|
|
5
|
+
import { AbstractController } from "./AbstractController";
|
|
6
|
+
export declare class V2MeasurementsController extends AbstractController {
|
|
5
7
|
private measurementRepository;
|
|
6
|
-
constructor(measurementRepository: MeasurementRepository);
|
|
8
|
+
constructor(measurementRepository: MeasurementRepository, accessLimitationRepository: AccessLimitationRepository);
|
|
7
9
|
getMeasurements: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
8
10
|
getMonthlyReadings: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
9
11
|
}
|
|
@@ -22,18 +22,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.V2MeasurementsController = void 0;
|
|
25
|
-
const
|
|
25
|
+
const parsePaginationParams_1 = require("../helpers/parsePaginationParams");
|
|
26
26
|
const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
|
|
27
|
+
const AccessLimitationRepository_1 = require("../../repositories/AccessLimitationRepository");
|
|
27
28
|
const MeasurementRepository_1 = require("../../repositories/MeasurementRepository");
|
|
28
|
-
const parsePaginationParams_1 = require("../helpers/parsePaginationParams");
|
|
29
29
|
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
31
|
+
const AbstractController_1 = require("./AbstractController");
|
|
32
|
+
let V2MeasurementsController = exports.V2MeasurementsController = class V2MeasurementsController extends AbstractController_1.AbstractController {
|
|
33
|
+
constructor(measurementRepository, accessLimitationRepository) {
|
|
34
|
+
super(accessLimitationRepository);
|
|
32
35
|
this.measurementRepository = measurementRepository;
|
|
33
36
|
this.getMeasurements = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
34
37
|
try {
|
|
38
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
35
39
|
const params = Object.assign({ variable: req.query.variable, type: req.query.type, addr1: req.query.addr1, addr2: req.query.addr2, dateFrom: req.query.dateFrom, dateTo: req.query.dateTo }, (0, parsePaginationParams_1.parsePaginationParams)(req));
|
|
36
|
-
const result = yield this.measurementRepository.getMeasurements(params);
|
|
40
|
+
const result = yield this.measurementRepository.getMeasurements(params, allowedOrganizations);
|
|
37
41
|
return res.json(result);
|
|
38
42
|
}
|
|
39
43
|
catch (err) {
|
|
@@ -42,6 +46,7 @@ let V2MeasurementsController = exports.V2MeasurementsController = class V2Measur
|
|
|
42
46
|
});
|
|
43
47
|
this.getMonthlyReadings = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
44
48
|
try {
|
|
49
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
45
50
|
const month = parseInt(req.query.month);
|
|
46
51
|
const year = parseInt(req.query.year);
|
|
47
52
|
const startDateUtc = luxon_1.DateTime.fromJSDate(new Date(year, month - 1, 1), { zone: "Europe/Prague" });
|
|
@@ -53,7 +58,7 @@ let V2MeasurementsController = exports.V2MeasurementsController = class V2Measur
|
|
|
53
58
|
from: fromDate,
|
|
54
59
|
to: toDate,
|
|
55
60
|
};
|
|
56
|
-
const result = yield this.measurementRepository.getMonthlyReadings(params);
|
|
61
|
+
const result = yield this.measurementRepository.getMonthlyReadings(params, allowedOrganizations);
|
|
57
62
|
return res.json(result.map((el) => (Object.assign({ time: fromDate }, el))));
|
|
58
63
|
}
|
|
59
64
|
catch (err) {
|
|
@@ -65,6 +70,8 @@ let V2MeasurementsController = exports.V2MeasurementsController = class V2Measur
|
|
|
65
70
|
exports.V2MeasurementsController = V2MeasurementsController = __decorate([
|
|
66
71
|
(0, tsyringe_1.injectable)(),
|
|
67
72
|
__param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementRepository)),
|
|
68
|
-
|
|
73
|
+
__param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.AccessLimitationRepository)),
|
|
74
|
+
__metadata("design:paramtypes", [MeasurementRepository_1.MeasurementRepository,
|
|
75
|
+
AccessLimitationRepository_1.AccessLimitationRepository])
|
|
69
76
|
], V2MeasurementsController);
|
|
70
77
|
//# sourceMappingURL=V2MeasurementsController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2MeasurementsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2MeasurementsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"V2MeasurementsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2MeasurementsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsF;AAEtF,yEAAoE;AACpE,8FAAyF;AACzF,oFAA+E;AAE/E,2DAA2D;AAC3D,iEAAwE;AACxE,6DAA0D;AAGnD,IAAM,wBAAwB,sCAA9B,MAAM,wBAAyB,SAAQ,uCAAkB;IAC5D,YACwD,qBAAoD,EAC/C,0BAAsD;QAE/G,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAH0B,0BAAqB,GAArB,qBAAqB,CAAuB;QAMrG,oBAAe,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YAC/E,IAAI;g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O,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;gBACvD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;gBAEnD,MAAM,MAAM,GAAyB;oBACjC,OAAO,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE;oBACjD,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,QAAkB;oBACtC,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,MAAM;iBACb,CAAC;gBAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;gBACjG,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,iBAAG,IAAI,EAAE,QAAQ,IAAK,EAAE,EAAG,CAAC,CAAC,CAAC;aACpE;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;IA3CF,CAAC;CA4CJ,CAAA;mCAlDY,wBAAwB;IADpC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,qBAAqB,CAAC,CAAA;IAClD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;qCAD2B,6CAAqB;QACnB,uDAA0B;GAH1G,wBAAwB,CAkDpC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/// <reference types="express" />
|
|
2
|
-
import {
|
|
2
|
+
import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
|
|
3
3
|
import { OrganizationsRepository } from "../../repositories/OrganizationsRepository";
|
|
4
|
-
import { OrganizationDtoTransformation } from "../../transformations/OrganizationDtoTransformation";
|
|
5
4
|
import { OrganizationDetailDtoTransformation } from "../../transformations/OrganizationDetailDtoTransformation";
|
|
6
|
-
|
|
5
|
+
import { OrganizationDtoTransformation } from "../../transformations/OrganizationDtoTransformation";
|
|
6
|
+
import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
|
|
7
|
+
import { AbstractController } from "./AbstractController";
|
|
8
|
+
export declare class V2OrganizationsController extends AbstractController {
|
|
7
9
|
private organizationsRepository;
|
|
8
10
|
private transformation;
|
|
9
11
|
private transformationDetail;
|
|
10
|
-
constructor(organizationsRepository: OrganizationsRepository, transformation: OrganizationDtoTransformation, transformationDetail: OrganizationDetailDtoTransformation);
|
|
12
|
+
constructor(organizationsRepository: OrganizationsRepository, transformation: OrganizationDtoTransformation, transformationDetail: OrganizationDetailDtoTransformation, accessLimitationRepository: AccessLimitationRepository);
|
|
11
13
|
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
12
14
|
getOne: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
13
15
|
}
|
|
@@ -22,29 +22,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.V2OrganizationsController = void 0;
|
|
25
|
-
const
|
|
26
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
25
|
+
const parsePaginationParams_1 = require("../helpers/parsePaginationParams");
|
|
27
26
|
const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
|
|
27
|
+
const AccessLimitationRepository_1 = require("../../repositories/AccessLimitationRepository");
|
|
28
28
|
const OrganizationsRepository_1 = require("../../repositories/OrganizationsRepository");
|
|
29
|
-
const OrganizationDtoTransformation_1 = require("../../transformations/OrganizationDtoTransformation");
|
|
30
29
|
const OrganizationDetailDtoTransformation_1 = require("../../transformations/OrganizationDetailDtoTransformation");
|
|
31
|
-
const
|
|
30
|
+
const OrganizationDtoTransformation_1 = require("../../transformations/OrganizationDtoTransformation");
|
|
32
31
|
const Utils_1 = require("@golemio/core/dist/output-gateway/Utils");
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
33
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
34
|
+
const AbstractController_1 = require("./AbstractController");
|
|
35
|
+
let V2OrganizationsController = exports.V2OrganizationsController = class V2OrganizationsController extends AbstractController_1.AbstractController {
|
|
36
|
+
constructor(organizationsRepository, transformation, transformationDetail, accessLimitationRepository) {
|
|
37
|
+
super(accessLimitationRepository);
|
|
35
38
|
this.organizationsRepository = organizationsRepository;
|
|
36
39
|
this.transformation = transformation;
|
|
37
40
|
this.transformationDetail = transformationDetail;
|
|
38
41
|
this.getAll = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
39
42
|
try {
|
|
43
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
40
44
|
const params = (0, parsePaginationParams_1.parsePaginationParams)(req);
|
|
41
45
|
const full = (0, Utils_1.parseBooleanQueryParam)(req.query.full) || false;
|
|
42
46
|
let result = [];
|
|
43
47
|
if (!full) {
|
|
44
|
-
result = this.transformation.transformArray(yield this.organizationsRepository.GetAllPublic(params));
|
|
48
|
+
result = this.transformation.transformArray(yield this.organizationsRepository.GetAllPublic(params, allowedOrganizations));
|
|
45
49
|
}
|
|
46
50
|
else {
|
|
47
|
-
result = this.transformationDetail.transformArray(yield this.organizationsRepository.GetAll(params));
|
|
51
|
+
result = this.transformationDetail.transformArray(yield this.organizationsRepository.GetAll(params, allowedOrganizations));
|
|
48
52
|
}
|
|
49
53
|
return res.json(result);
|
|
50
54
|
}
|
|
@@ -54,8 +58,9 @@ let V2OrganizationsController = exports.V2OrganizationsController = class V2Orga
|
|
|
54
58
|
});
|
|
55
59
|
this.getOne = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
56
60
|
try {
|
|
61
|
+
const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
|
|
57
62
|
const id = req.params.id;
|
|
58
|
-
const result = yield this.organizationsRepository.GetOne(id);
|
|
63
|
+
const result = yield this.organizationsRepository.GetOne(id, allowedOrganizations);
|
|
59
64
|
if (!result) {
|
|
60
65
|
return next(new golemio_errors_1.GeneralError("not_found", this.constructor.name, `Organization with id ${req.params.id} not found`, 404));
|
|
61
66
|
}
|
|
@@ -72,8 +77,10 @@ exports.V2OrganizationsController = V2OrganizationsController = __decorate([
|
|
|
72
77
|
__param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OrganizationsRepository)),
|
|
73
78
|
__param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OrganizationDtoTransformation)),
|
|
74
79
|
__param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OrganizationDetailDtoTransformation)),
|
|
80
|
+
__param(3, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.AccessLimitationRepository)),
|
|
75
81
|
__metadata("design:paramtypes", [OrganizationsRepository_1.OrganizationsRepository,
|
|
76
82
|
OrganizationDtoTransformation_1.OrganizationDtoTransformation,
|
|
77
|
-
OrganizationDetailDtoTransformation_1.OrganizationDetailDtoTransformation
|
|
83
|
+
OrganizationDetailDtoTransformation_1.OrganizationDetailDtoTransformation,
|
|
84
|
+
AccessLimitationRepository_1.AccessLimitationRepository])
|
|
78
85
|
], V2OrganizationsController);
|
|
79
86
|
//# sourceMappingURL=V2OrganizationsController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2OrganizationsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2OrganizationsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"V2OrganizationsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2OrganizationsController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mDrC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OGEnergeticsContainer = void 0;
|
|
4
4
|
const ModuleContainerToken_1 = require("./ModuleContainerToken");
|
|
5
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
5
6
|
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
|
|
6
7
|
const OrganizationsRepository_1 = require("../repositories/OrganizationsRepository");
|
|
7
8
|
const V2OrganizationsController_1 = require("../controllers/v2/V2OrganizationsController");
|
|
@@ -21,6 +22,9 @@ const MeasurementRepository_1 = require("../repositories/MeasurementRepository")
|
|
|
21
22
|
const V2MeasurementsRouter_1 = require("../routers/v2/V2MeasurementsRouter");
|
|
22
23
|
const V2MeasurementsController_1 = require("../controllers/v2/V2MeasurementsController");
|
|
23
24
|
const V2BuildingsRouter_1 = require("../routers/v2/V2BuildingsRouter");
|
|
25
|
+
const AccessLimitationRepository_1 = require("../repositories/AccessLimitationRepository");
|
|
26
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
27
|
+
const BuildingsController_1 = require("../controllers/v2/BuildingsController");
|
|
24
28
|
//#region Initialization
|
|
25
29
|
const energeticsContainer = ioc_1.OutputGatewayContainer.createChildContainer();
|
|
26
30
|
exports.OGEnergeticsContainer = energeticsContainer;
|
|
@@ -39,10 +43,14 @@ energeticsContainer
|
|
|
39
43
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.OrganizationBuildingsRepository, OrganizationBuildingsRepository_1.OrganizationBuildingsRepository)
|
|
40
44
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.OrganizationResponsibleUsersRepository, OrganizationResponsibleUsersRepository_1.OrganizationResponsibleUsersRepository)
|
|
41
45
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.DevicesRepository, DevicesRepository_1.DevicesRepository)
|
|
42
|
-
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.MeasurementRepository, MeasurementRepository_1.MeasurementRepository)
|
|
46
|
+
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.MeasurementRepository, MeasurementRepository_1.MeasurementRepository)
|
|
47
|
+
.register(ModuleContainerToken_1.ModuleContainerToken.AccessLimitationRepository, {
|
|
48
|
+
useFactory: (0, tsyringe_1.instanceCachingFactory)((c) => new AccessLimitationRepository_1.AccessLimitationRepository(c.resolve(CoreToken_1.CoreToken.PostgresConnector), c.resolve(CoreToken_1.CoreToken.Logger))),
|
|
49
|
+
});
|
|
43
50
|
//#endregion
|
|
44
51
|
//#region Controllers
|
|
45
52
|
energeticsContainer
|
|
53
|
+
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.BuildingsController, BuildingsController_1.BuildingsController)
|
|
46
54
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.V2OrganizationsController, V2OrganizationsController_1.V2OrganizationsController)
|
|
47
55
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.V2DevicesController, V2DevicesController_1.V2DevicesController)
|
|
48
56
|
.registerSingleton(ModuleContainerToken_1.ModuleContainerToken.V2MeasurementsController, V2MeasurementsController_1.V2MeasurementsController);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/output-gateway/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,iEAAoE;
|
|
1
|
+
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/output-gateway/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,iEAAoE;AACpE,iEAAiG;AACjG,+DAA+E;AAC/E,qFAAmF;AACnF,2FAAyF;AACzF,mHAAiH;AACjH,2FAAyF;AACzF,qGAAmG;AACnG,yEAAuE;AACvE,+EAA6E;AAC7E,+EAA6E;AAC7E,mEAAiE;AACjE,oGAAkG;AAClG,gHAA8G;AAC9G,wFAAsF;AACtF,8FAA4F;AAC5F,kEAAgE;AAChE,iFAA+E;AAC/E,6E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BAAiB,CAAsB,2CAAoB,CAAC,mBAAmB,EAAE,yCAAmB,CAAC;KACrG,iBAAiB,CAA4B,2CAAoB,CAAC,yBAAyB,EAAE,qDAAyB,CAAC;KACvH,iBAAiB,CAAsB,2CAAoB,CAAC,mBAAmB,EAAE,yCAAmB,CAAC;KACrG,iBAAiB,CAA2B,2CAAoB,CAAC,wBAAwB,EAAE,mDAAwB,CAAC,CAAC;AAC1H,YAAY;AAEZ,iBAAiB;AACjB,mBAAmB;KACd,iBAAiB,CAAoB,2CAAoB,CAAC,iBAAiB,EAAE,qCAAiB,CAAC;KAC/F,iBAAiB,CAAwB,2CAAoB,CAAC,qBAAqB,EAAE,6CAAqB,CAAC;KAC3G,iBAAiB,CAAkB,2CAAoB,CAAC,eAAe,EAAE,iCAAe,CAAC;KACzF,iBAAiB,CAAuB,2CAAoB,CAAC,oBAAoB,EAAE,2CAAoB,CAAC,CAAC;AAC9G,YAAY;AAEZ,iBAAiB;AACjB,mBAAmB,CAAC,iBAAiB,CAAmB,2CAAoB,CAAC,gBAAgB,EAAE,mCAAgB,CAAC,CAAC"}
|
|
@@ -11,7 +11,9 @@ declare const ModuleContainerToken: {
|
|
|
11
11
|
OrganizationResponsibleUsersRepository: symbol;
|
|
12
12
|
DevicesRepository: symbol;
|
|
13
13
|
MeasurementRepository: symbol;
|
|
14
|
+
AccessLimitationRepository: symbol;
|
|
14
15
|
/** controllers */
|
|
16
|
+
BuildingsController: symbol;
|
|
15
17
|
V2OrganizationsController: symbol;
|
|
16
18
|
V2DevicesController: symbol;
|
|
17
19
|
V2MeasurementsController: symbol;
|
|
@@ -14,7 +14,9 @@ const ModuleContainerToken = {
|
|
|
14
14
|
OrganizationResponsibleUsersRepository: Symbol("OrganizationResponsibleUsersRepository"),
|
|
15
15
|
DevicesRepository: Symbol("DevicesRepository"),
|
|
16
16
|
MeasurementRepository: Symbol("MeasurementRepository"),
|
|
17
|
+
AccessLimitationRepository: Symbol(),
|
|
17
18
|
/** controllers */
|
|
19
|
+
BuildingsController: Symbol("BuildingController"),
|
|
18
20
|
V2OrganizationsController: Symbol("V2OrganizationsController"),
|
|
19
21
|
V2DevicesController: Symbol("V2DevicesController"),
|
|
20
22
|
V2MeasurementsController: Symbol("V2MeasurementsController"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleContainerToken.js","sourceRoot":"","sources":["../../../src/output-gateway/ioc/ModuleContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG;IACzB,sBAAsB;IACtB,6BAA6B,EAAE,MAAM,CAAC,+BAA+B,CAAC;IACtE,mCAAmC,EAAE,MAAM,CAAC,qCAAqC,CAAC;IAClF,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAC1D,0BAA0B,EAAE,MAAM,CAAC,4BAA4B,CAAC;IAChE,mBAAmB;IACnB,0BAA0B,EAAE,MAAM,CAAC,4BAA4B,CAAC;IAChE,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAC1D,+BAA+B,EAAE,MAAM,CAAC,iCAAiC,CAAC;IAC1E,sCAAsC,EAAE,MAAM,CAAC,wCAAwC,CAAC;IACxF,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC9C,qBAAqB,EAAE,MAAM,CAAC,uBAAuB,CAAC;IACtD,kBAAkB;IAClB,yBAAyB,EAAE,MAAM,CAAC,2BAA2B,CAAC;IAC9D,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,wBAAwB,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC5D,cAAc;IACd,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC9C,qBAAqB,EAAE,MAAM,CAAC,uBAAuB,CAAC;IACtD,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,oBAAoB,EAAE,MAAM,CAAC,sBAAsB,CAAC;IACpD,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAC,0BAA0B,CAAC;CACvD,CAAC;AAEO,oDAAoB"}
|
|
1
|
+
{"version":3,"file":"ModuleContainerToken.js","sourceRoot":"","sources":["../../../src/output-gateway/ioc/ModuleContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG;IACzB,sBAAsB;IACtB,6BAA6B,EAAE,MAAM,CAAC,+BAA+B,CAAC;IACtE,mCAAmC,EAAE,MAAM,CAAC,qCAAqC,CAAC;IAClF,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAC1D,0BAA0B,EAAE,MAAM,CAAC,4BAA4B,CAAC;IAChE,mBAAmB;IACnB,0BAA0B,EAAE,MAAM,CAAC,4BAA4B,CAAC;IAChE,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAC1D,+BAA+B,EAAE,MAAM,CAAC,iCAAiC,CAAC;IAC1E,sCAAsC,EAAE,MAAM,CAAC,wCAAwC,CAAC;IACxF,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC9C,qBAAqB,EAAE,MAAM,CAAC,uBAAuB,CAAC;IACtD,0BAA0B,EAAE,MAAM,EAAE;IACpC,kBAAkB;IAClB,mBAAmB,EAAE,MAAM,CAAC,oBAAoB,CAAC;IACjD,yBAAyB,EAAE,MAAM,CAAC,2BAA2B,CAAC;IAC9D,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,wBAAwB,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC5D,cAAc;IACd,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC9C,qBAAqB,EAAE,MAAM,CAAC,uBAAuB,CAAC;IACtD,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,oBAAoB,EAAE,MAAM,CAAC,sBAAsB,CAAC;IACpD,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAC,0BAA0B,CAAC;CACvD,CAAC;AAEO,oDAAoB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IAccessLimitation } from "../../schema-definitions/models/interfaces/IAccessLimitation";
|
|
2
|
+
import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
|
|
3
|
+
import { AbstractCachedRepository } from "@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractCachedRepository";
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
5
|
+
export declare class AccessLimitationRepository extends AbstractCachedRepository<IAccessLimitation> {
|
|
6
|
+
schema: string;
|
|
7
|
+
tableName: string;
|
|
8
|
+
constructor(connector: IDatabaseConnector, log: ILogger, cacheTTLInSeconds?: number);
|
|
9
|
+
protected getAllInternal(): Promise<IAccessLimitation[]>;
|
|
10
|
+
getOrganizationsByGroupName(groupName: string): Promise<number[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AccessLimitationRepository = void 0;
|
|
13
|
+
const _sch_1 = require("../../schema-definitions");
|
|
14
|
+
const AccessLimitationModel_1 = require("../../schema-definitions/models/AccessLimitationModel");
|
|
15
|
+
const AbstractCachedRepository_1 = require("@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractCachedRepository");
|
|
16
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
17
|
+
class AccessLimitationRepository extends AbstractCachedRepository_1.AbstractCachedRepository {
|
|
18
|
+
constructor(connector, log, cacheTTLInSeconds = 60 * 5) {
|
|
19
|
+
super(connector, log, cacheTTLInSeconds);
|
|
20
|
+
this.schema = _sch_1.EnergeticsSchema.pgSchema;
|
|
21
|
+
this.tableName = AccessLimitationModel_1.AccessLimitationModel.TABLE_NAME;
|
|
22
|
+
AccessLimitationModel_1.AccessLimitationModel.init(AccessLimitationModel_1.AccessLimitationModel.attributeModel, {
|
|
23
|
+
tableName: AccessLimitationModel_1.AccessLimitationModel.TABLE_NAME,
|
|
24
|
+
schema: _sch_1.EnergeticsSchema.pgSchema,
|
|
25
|
+
sequelize: this.connector.getConnection(),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getAllInternal() {
|
|
29
|
+
return AccessLimitationModel_1.AccessLimitationModel.findAll({ raw: true });
|
|
30
|
+
}
|
|
31
|
+
getOrganizationsByGroupName(groupName) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const data = yield this.getAll();
|
|
34
|
+
const limitation = data.find((d) => d.group_name === groupName);
|
|
35
|
+
if (!limitation) {
|
|
36
|
+
throw new golemio_errors_1.GeneralError(`Access limitation for group ${groupName} not found`, this.constructor.name, undefined, 500);
|
|
37
|
+
}
|
|
38
|
+
return limitation.organization_ids;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.AccessLimitationRepository = AccessLimitationRepository;
|
|
43
|
+
//# sourceMappingURL=AccessLimitationRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessLimitationRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/AccessLimitationRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAwC;AACxC,iGAA0E;AAG1E,oIAAiI;AAEjI,6EAAwE;AAExE,MAAa,0BAA2B,SAAQ,mDAA2C;IAIvF,YAAY,SAA6B,EAAE,GAAY,EAAE,oBAA4B,EAAE,GAAG,CAAC;QACvF,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QAJ7C,WAAM,GAAG,uBAAgB,CAAC,QAAQ,CAAC;QACnC,cAAS,GAAG,6CAAqB,CAAC,UAAU,CAAC;QAIzC,6CAAqB,CAAC,IAAI,CAAC,6CAAqB,CAAC,cAAc,EAAE;YAC7D,SAAS,EAAE,6CAAqB,CAAC,UAAU;YAC3C,MAAM,EAAE,uBAAgB,CAAC,QAAQ;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;SAC5C,CAAC,CAAC;IACP,CAAC;IAES,cAAc;QACpB,OAAO,6CAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAEY,2BAA2B,CAAC,SAAiB;;YACtD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,EAAE;gBACb,MAAM,IAAI,6BAAY,CAAC,+BAA+B,SAAS,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;aACvH;YAED,OAAO,UAAU,CAAC,gBAAgB,CAAC;QACvC,CAAC;KAAA;CACJ;AA1BD,gEA0BC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { SequelizeModel } from "@golemio/core/dist/output-gateway";
|
|
2
1
|
import { IPaginationParams } from "../controllers/interfaces/IPaginationParams";
|
|
3
2
|
import { IDevicesModel } from "../../schema-definitions/models/interfaces";
|
|
3
|
+
import { SequelizeModel } from "@golemio/core/dist/output-gateway";
|
|
4
4
|
export declare class DevicesRepository extends SequelizeModel {
|
|
5
5
|
constructor();
|
|
6
|
-
GetAll(params: IPaginationParams): Promise<IDevicesModel[]>;
|
|
7
|
-
GetOne(id: string): Promise<IDevicesModel | null>;
|
|
6
|
+
GetAll(params: IPaginationParams, allowedOrganizations?: number[] | null): Promise<IDevicesModel[]>;
|
|
7
|
+
GetOne(id: string, allowedOrganizations?: number[] | null): Promise<IDevicesModel | null>;
|
|
8
|
+
private getWhereAccessLimitation;
|
|
8
9
|
}
|
|
@@ -20,20 +20,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.DevicesRepository = void 0;
|
|
22
22
|
const _sch_1 = require("../../schema-definitions");
|
|
23
|
-
const
|
|
24
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
23
|
+
const constants_1 = require("../../schema-definitions/constants");
|
|
25
24
|
const models_1 = require("../../schema-definitions/models");
|
|
25
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
26
26
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
27
|
+
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
28
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
27
29
|
let DevicesRepository = exports.DevicesRepository = class DevicesRepository extends output_gateway_1.SequelizeModel {
|
|
28
30
|
constructor() {
|
|
29
31
|
super("DevicesRepository", models_1.DevicesModel.TABLE_NAME, models_1.DevicesModel.attributeModel, {
|
|
30
32
|
schema: _sch_1.EnergeticsSchema.pgSchema,
|
|
31
33
|
});
|
|
34
|
+
this.getWhereAccessLimitation = (allowedOrganizations) => {
|
|
35
|
+
return {
|
|
36
|
+
[sequelize_1.Op.in]: (0, sequelize_1.literal)(`(select distinct building_id from ${constants_1.PG_SCHEMA}.organizations_buildings
|
|
37
|
+
where organization_id = any('{${allowedOrganizations.join(",")}}'::integer[]))`),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
32
40
|
}
|
|
33
|
-
GetAll(params) {
|
|
41
|
+
GetAll(params, allowedOrganizations = []) {
|
|
34
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
43
|
try {
|
|
36
44
|
return yield this.sequelizeModel.findAll({
|
|
45
|
+
where: allowedOrganizations === null ? {} : { building_id: this.getWhereAccessLimitation(allowedOrganizations) },
|
|
37
46
|
order: [["id", "ASC"]],
|
|
38
47
|
limit: params.limit,
|
|
39
48
|
offset: params.offset,
|
|
@@ -44,11 +53,16 @@ let DevicesRepository = exports.DevicesRepository = class DevicesRepository exte
|
|
|
44
53
|
}
|
|
45
54
|
});
|
|
46
55
|
}
|
|
47
|
-
GetOne(id) {
|
|
56
|
+
GetOne(id, allowedOrganizations = []) {
|
|
48
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
58
|
try {
|
|
50
59
|
return yield this.sequelizeModel.findOne({
|
|
51
|
-
where: {
|
|
60
|
+
where: {
|
|
61
|
+
[sequelize_1.Op.and]: [
|
|
62
|
+
{ id: id },
|
|
63
|
+
allowedOrganizations === null ? {} : { building_id: this.getWhereAccessLimitation(allowedOrganizations) },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
52
66
|
});
|
|
53
67
|
}
|
|
54
68
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevicesRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/DevicesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DevicesRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/DevicesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,mDAAwC;AACxC,kEAA2C;AAC3C,4DAA2C;AAE3C,sEAAmE;AACnE,6EAAwE;AACxE,mEAAkE;AAClE,iEAAgE;AAGzD,IAAM,iBAAiB,+BAAvB,MAA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C,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,EAAE;yBAC5G;qBACJ;iBACJ,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,yBAAyB,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC1E;QACL,CAAC;KAAA;CAQJ,CAAA;4BAzCY,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;;GACA,iBAAiB,CAyC7B"}
|
|
@@ -3,8 +3,9 @@ import { IMeasurements, IMeasurementsMonthly } from "../controllers/interfaces/I
|
|
|
3
3
|
import { IMeasurementResponse } from "../routers/interfaces/IMeasurementResponse";
|
|
4
4
|
export declare class MeasurementRepository extends SequelizeModel {
|
|
5
5
|
constructor();
|
|
6
|
-
getMeasurements(options: IMeasurements): Promise<IMeasurementResponse[]>;
|
|
7
|
-
getMonthlyReadings(options: IMeasurementsMonthly): Promise<Array<Omit<IMeasurementResponse, "time">>>;
|
|
6
|
+
getMeasurements(options: IMeasurements, allowedOrganizations: number[] | null): Promise<IMeasurementResponse[]>;
|
|
7
|
+
getMonthlyReadings(options: IMeasurementsMonthly, allowedOrganizations: number[] | null): Promise<Array<Omit<IMeasurementResponse, "time">>>;
|
|
8
8
|
GetAll(): Promise<never>;
|
|
9
9
|
GetOne(): Promise<never>;
|
|
10
|
+
private getWhereAccessLimitation;
|
|
10
11
|
}
|
|
@@ -17,35 +17,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
-
};
|
|
23
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
21
|
exports.MeasurementRepository = void 0;
|
|
25
22
|
const _sch_1 = require("../../schema-definitions");
|
|
26
23
|
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
27
|
-
const sequelize_1 =
|
|
24
|
+
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
|
|
28
25
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
29
26
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
30
27
|
const MeasurementsModel_1 = require("../../schema-definitions/models/MeasurementsModel");
|
|
28
|
+
const constants_1 = require("../../schema-definitions/constants");
|
|
31
29
|
let MeasurementRepository = exports.MeasurementRepository = class MeasurementRepository extends output_gateway_1.SequelizeModel {
|
|
32
30
|
constructor() {
|
|
33
31
|
super("MeasurementsRepository", MeasurementsModel_1.MeasurementModel.tableName, MeasurementsModel_1.MeasurementModel.attributeModel, {
|
|
34
32
|
schema: _sch_1.EnergeticsSchema.pgSchema,
|
|
35
33
|
});
|
|
34
|
+
this.getWhereAccessLimitation = (allowedOrganizations) => {
|
|
35
|
+
return {
|
|
36
|
+
[sequelize_1.Op.in]: (0, sequelize_1.literal)(`(select distinct d.addr from ${constants_1.PG_SCHEMA}.organizations_buildings b
|
|
37
|
+
inner join ${constants_1.PG_SCHEMA}.consumption_energy_devices d on b.building_id = d.building_id
|
|
38
|
+
where b.organization_id = any('{${allowedOrganizations.join(",")}}'::integer[]))`),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
36
41
|
}
|
|
37
|
-
getMeasurements(options) {
|
|
42
|
+
getMeasurements(options, allowedOrganizations) {
|
|
38
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
44
|
try {
|
|
40
45
|
const where = {
|
|
41
|
-
[sequelize_1.
|
|
42
|
-
...(options.variable ? [{ var: { [sequelize_1.
|
|
43
|
-
...(options.type ? [{ type: { [sequelize_1.
|
|
44
|
-
...(options.addr1 && options.addr2
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
[sequelize_1.Op.and]: [
|
|
47
|
+
...(options.variable ? [{ var: { [sequelize_1.Op.eq]: options.variable } }] : []),
|
|
48
|
+
...(options.type ? [{ type: { [sequelize_1.Op.eq]: options.type } }] : []),
|
|
49
|
+
...(options.addr1 && options.addr2 ? [{ addr: { [sequelize_1.Op.eq]: `/${options.addr1}/${options.addr2}` } }] : []),
|
|
50
|
+
...(options.dateFrom ? [{ timestamp: { [sequelize_1.Op.gte]: options.dateFrom } }] : []),
|
|
51
|
+
...(options.dateTo ? [{ timestamp: { [sequelize_1.Op.lte]: options.dateTo } }] : []),
|
|
52
|
+
allowedOrganizations === null
|
|
53
|
+
? {}
|
|
54
|
+
: {
|
|
55
|
+
addr: this.getWhereAccessLimitation(allowedOrganizations),
|
|
56
|
+
},
|
|
49
57
|
],
|
|
50
58
|
};
|
|
51
59
|
return yield this.sequelizeModel.findAll({
|
|
@@ -61,18 +69,19 @@ let MeasurementRepository = exports.MeasurementRepository = class MeasurementRep
|
|
|
61
69
|
}
|
|
62
70
|
});
|
|
63
71
|
}
|
|
64
|
-
getMonthlyReadings(options) {
|
|
72
|
+
getMonthlyReadings(options, allowedOrganizations) {
|
|
65
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
74
|
try {
|
|
67
75
|
const where = {
|
|
68
|
-
[sequelize_1.
|
|
69
|
-
var: { [sequelize_1.
|
|
70
|
-
addr: { [sequelize_1.
|
|
71
|
-
timestamp: { [sequelize_1.
|
|
72
|
-
|
|
76
|
+
[sequelize_1.Op.and]: [
|
|
77
|
+
{ var: { [sequelize_1.Op.eq]: options.variable } },
|
|
78
|
+
{ addr: { [sequelize_1.Op.eq]: options.address } },
|
|
79
|
+
{ timestamp: { [sequelize_1.Op.between]: [options.from, options.to] } },
|
|
80
|
+
allowedOrganizations === null ? {} : { addr: this.getWhereAccessLimitation(allowedOrganizations) },
|
|
81
|
+
],
|
|
73
82
|
};
|
|
74
83
|
return yield this.sequelizeModel.findAll({
|
|
75
|
-
attributes: [[sequelize_1.
|
|
84
|
+
attributes: [[(0, sequelize_1.fn)("SUM", (0, sequelize_1.col)("value")), "value"], "meter", "type", "addr", "var"],
|
|
76
85
|
where,
|
|
77
86
|
raw: true,
|
|
78
87
|
group: ["meter", "type", "addr", "var"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeasurementRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/MeasurementRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MeasurementRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/MeasurementRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwC;AACxC,sEAAmE;AACnE,mEAAyF;AACzF,iEAAgE;AAChE,6EAAwE;AAGxE,yFAAiE;AACjE,kEAA2C;AAGpC,IAAM,qBAAqB,mCAA3B,MAAM,qBAAsB,SAAQ,+BAAc;IACrD;QACI,KAAK,CAAC,wBAAwB,EAAE,oCAAgB,CAAC,SAAS,EAAE,oCAAgB,CAAC,cAAc,EAAE;YACzF,MAAM,EAAE,uBAAgB,CAAC,QAAQ;SACpC,CAAC,CAAC;QAiEC,6BAAwB,GAAG,CAAC,oBAA8B,EAAE,EAAE;YAClE,OAAO;gBACH,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,IAAA,mBAAO,EAAC,gCAAgC,qBAAS;6BACzC,qBAAS;kDACY,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC;aACzF,CAAC;QACN,CAAC,CAAC;IAtEF,CAAC;IAEY,eAAe,CAAC,OAAsB,EAAE,oBAAqC;;YACtF,IAAI;gBACA,MAAM,KAAK,GAAiB;oBACxB,CAAC,cAAE,CAAC,GAAG,CAAC,EAAE;wBACN,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,O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M,EAAE,KAAK,CAAC;iBAC1C,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,mDAAmD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aACpG;QACL,CAAC;KAAA;IAEY,MAAM;;YACf,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;KAAA;IAEY,MAAM;;YACf,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;KAAA;CASJ,CAAA;gCA5EY,qBAAqB;IADjC,IAAA,qBAAU,GAAE;;GACA,qBAAqB,CA4EjC"}
|
|
@@ -11,7 +11,7 @@ export declare class OrganizationsRepository extends SequelizeModel {
|
|
|
11
11
|
private buildingsRepository;
|
|
12
12
|
constructor(userRepository: OrganizationResponsibleUsersRepository, organizationBuildingsRepository: OrganizationBuildingsRepository, buildingsRepository: PrimaryBuildingsRepository);
|
|
13
13
|
associate(): void;
|
|
14
|
-
GetAllPublic(params: IPaginationParams): Promise<IOrganizationDto[]>;
|
|
15
|
-
GetAll(params: IPaginationParams): Promise<IOrganizationDetailDto[]>;
|
|
16
|
-
GetOne(id: string): Promise<IOrganizationDetailDto | null>;
|
|
14
|
+
GetAllPublic(params: IPaginationParams, allowedOrganizations?: number[] | null): Promise<IOrganizationDto[]>;
|
|
15
|
+
GetAll(params: IPaginationParams, allowedOrganizations?: number[] | null): Promise<IOrganizationDetailDto[]>;
|
|
16
|
+
GetOne(id: string, allowedOrganizations?: number[] | null): Promise<IOrganizationDetailDto | null>;
|
|
17
17
|
}
|