@golemio/energetics 1.3.8 → 1.3.9-rc.1367638314

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.
Files changed (93) hide show
  1. package/db/example/00_clear_test_data.sql +1 -0
  2. package/db/example/04_measurements.sql +26 -26
  3. package/db/example/05_access.sql +5 -0
  4. package/db/migrations/postgresql/20240621083051-access-limitation.js +53 -0
  5. package/db/migrations/postgresql/20240625134438-fix-pk-measurements.js +53 -0
  6. package/db/migrations/postgresql/sqls/20240621083051-access-limitation-down.sql +1 -0
  7. package/db/migrations/postgresql/sqls/20240621083051-access-limitation-up.sql +7 -0
  8. package/db/migrations/postgresql/sqls/20240625134438-fix-pk-measurements-down.sql +2 -0
  9. package/db/migrations/postgresql/sqls/20240625134438-fix-pk-measurements-up.sql +2 -0
  10. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.d.ts +9 -0
  11. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js +45 -0
  12. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js.map +1 -0
  13. package/dist/integration-engine/commodity-providers/ioc/Di.js +8 -4
  14. package/dist/integration-engine/commodity-providers/ioc/Di.js.map +1 -1
  15. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.d.ts +2 -0
  16. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js +2 -0
  17. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js.map +1 -1
  18. package/dist/integration-engine/commodity-providers/transformations/AveMeasurementTransformation.d.ts +0 -1
  19. package/dist/integration-engine/commodity-providers/transformations/AveMeasurementTransformation.js +1 -4
  20. package/dist/integration-engine/commodity-providers/transformations/AveMeasurementTransformation.js.map +1 -1
  21. package/dist/integration-engine/commodity-providers/transformations/CemMeasurementTransformation.d.ts +1 -1
  22. package/dist/integration-engine/commodity-providers/transformations/CemMeasurementTransformation.js +6 -6
  23. package/dist/integration-engine/commodity-providers/transformations/CemMeasurementTransformation.js.map +1 -1
  24. package/dist/integration-engine/commodity-providers/transformations/PreElectroTransformation.js +1 -1
  25. package/dist/integration-engine/commodity-providers/transformations/PreElectroTransformation.js.map +1 -1
  26. package/dist/integration-engine/ioc/Di.js.map +1 -1
  27. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.d.ts +9 -0
  28. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js +78 -0
  29. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js.map +1 -0
  30. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.d.ts +9 -0
  31. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js +32 -0
  32. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js.map +1 -0
  33. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js +2 -0
  34. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js.map +1 -1
  35. package/dist/output-gateway/controllers/v2/AbstractController.d.ts +8 -0
  36. package/dist/output-gateway/controllers/v2/AbstractController.js +28 -0
  37. package/dist/output-gateway/controllers/v2/AbstractController.js.map +1 -0
  38. package/dist/output-gateway/controllers/v2/BuildingsController.d.ts +6 -3
  39. package/dist/output-gateway/controllers/v2/BuildingsController.js +26 -13
  40. package/dist/output-gateway/controllers/v2/BuildingsController.js.map +1 -1
  41. package/dist/output-gateway/controllers/v2/V2DevicesController.d.ts +5 -3
  42. package/dist/output-gateway/controllers/v2/V2DevicesController.js +15 -8
  43. package/dist/output-gateway/controllers/v2/V2DevicesController.js.map +1 -1
  44. package/dist/output-gateway/controllers/v2/V2MeasurementsController.d.ts +5 -3
  45. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js +15 -8
  46. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js.map +1 -1
  47. package/dist/output-gateway/controllers/v2/V2OrganizationsController.d.ts +6 -4
  48. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js +17 -10
  49. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js.map +1 -1
  50. package/dist/output-gateway/ioc/Di.js +9 -1
  51. package/dist/output-gateway/ioc/Di.js.map +1 -1
  52. package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +2 -0
  53. package/dist/output-gateway/ioc/ModuleContainerToken.js +2 -0
  54. package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
  55. package/dist/output-gateway/repositories/AccessLimitationRepository.d.ts +11 -0
  56. package/dist/output-gateway/repositories/AccessLimitationRepository.js +51 -0
  57. package/dist/output-gateway/repositories/AccessLimitationRepository.js.map +1 -0
  58. package/dist/output-gateway/repositories/DevicesRepository.d.ts +4 -3
  59. package/dist/output-gateway/repositories/DevicesRepository.js +19 -5
  60. package/dist/output-gateway/repositories/DevicesRepository.js.map +1 -1
  61. package/dist/output-gateway/repositories/MeasurementRepository.d.ts +3 -2
  62. package/dist/output-gateway/repositories/MeasurementRepository.js +29 -20
  63. package/dist/output-gateway/repositories/MeasurementRepository.js.map +1 -1
  64. package/dist/output-gateway/repositories/OrganizationsRepository.d.ts +3 -3
  65. package/dist/output-gateway/repositories/OrganizationsRepository.js +7 -4
  66. package/dist/output-gateway/repositories/OrganizationsRepository.js.map +1 -1
  67. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.d.ts +4 -3
  68. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js +19 -4
  69. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js.map +1 -1
  70. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js +4 -4
  71. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js.map +1 -1
  72. package/dist/output-gateway/routers/v2/V2DevicesRouter.js +2 -2
  73. package/dist/output-gateway/routers/v2/V2DevicesRouter.js.map +1 -1
  74. package/dist/output-gateway/routers/v2/V2MeasurementsRouter.js +2 -0
  75. package/dist/output-gateway/routers/v2/V2MeasurementsRouter.js.map +1 -1
  76. package/dist/output-gateway/routers/v2/V2OrganizationsRouter.js +2 -2
  77. package/dist/output-gateway/routers/v2/V2OrganizationsRouter.js.map +1 -1
  78. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.d.ts +3 -0
  79. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js +18 -0
  80. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js.map +1 -0
  81. package/dist/schema-definitions/models/AccessLimitationModel.d.ts +10 -0
  82. package/dist/schema-definitions/models/AccessLimitationModel.js +32 -0
  83. package/dist/schema-definitions/models/AccessLimitationModel.js.map +1 -0
  84. package/dist/schema-definitions/models/MeasurementsModel.js +0 -1
  85. package/dist/schema-definitions/models/MeasurementsModel.js.map +1 -1
  86. package/dist/schema-definitions/models/constants/MeasurementConstants.js +2 -0
  87. package/dist/schema-definitions/models/constants/MeasurementConstants.js.map +1 -1
  88. package/dist/schema-definitions/models/interfaces/IAccessLimitation.d.ts +4 -0
  89. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js +3 -0
  90. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js.map +1 -0
  91. package/docs/implementation_documentation.md +21 -0
  92. package/docs/openapi-output.yaml +6 -0
  93. package/package.json +3 -3
@@ -0,0 +1,32 @@
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.FetchAccessConfigurationTask = void 0;
13
+ const Di_1 = require("../../commodity-providers/ioc/Di");
14
+ const WorkerContainerToken_1 = require("../../commodity-providers/ioc/WorkerContainerToken");
15
+ const AbstractEmptyTask_1 = require("@golemio/core/dist/integration-engine/workers/AbstractEmptyTask");
16
+ class FetchAccessConfigurationTask extends AbstractEmptyTask_1.AbstractEmptyTask {
17
+ constructor(queuePrefix) {
18
+ super(queuePrefix);
19
+ this.queueName = "fetchAccessConfiguration";
20
+ this.queueTtl = 10 * 60 * 1000; // 10 minutes
21
+ this.accessConfigurationDataSource = Di_1.CommodityContainer.resolve(WorkerContainerToken_1.WorkerContainerToken.AccessConfigurationDataSource);
22
+ this.accessRepository = Di_1.CommodityContainer.resolve(WorkerContainerToken_1.WorkerContainerToken.AccessLimitationRepository);
23
+ }
24
+ execute() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const results = yield this.accessConfigurationDataSource.getDataSource().getAll();
27
+ yield this.accessRepository.updateData(results);
28
+ });
29
+ }
30
+ }
31
+ exports.FetchAccessConfigurationTask = FetchAccessConfigurationTask;
32
+ //# sourceMappingURL=FetchAccessConfigurationTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchAccessConfigurationTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,yDAAoE;AACpE,6FAAwF;AAExF,uGAAoG;AAEpG,MAAa,4BAA6B,SAAQ,qCAAiB;IAM/D,YAAY,WAAmB;QAC3B,KAAK,CAAC,WAAW,CAAC,CAAC;QANvB,cAAS,GAAW,0BAA0B,CAAC;QAC/B,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;QAMpD,IAAI,CAAC,6BAA6B,GAAG,uBAAkB,CAAC,OAAO,CAC3D,2CAAoB,CAAC,6BAA6B,CACrD,CAAC;QACF,IAAI,CAAC,gBAAgB,GAAG,uBAAkB,CAAC,OAAO,CAC9C,2CAAoB,CAAC,0BAA0B,CAClD,CAAC;IACN,CAAC;IAEe,OAAO;;YACnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,6BAA6B,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,CAAC;YAClF,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACJ;AApBD,oEAoBC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OictEnergetikaWorker = void 0;
4
+ const FetchAccessConfigurationTask_1 = require("../../tasks/oict-energetika/FetchAccessConfigurationTask");
4
5
  const FetchConsumptionTask_1 = require("../../tasks/oict-energetika/FetchConsumptionTask");
5
6
  const FetchDataTask_1 = require("../../tasks/oict-energetika/FetchDataTask");
6
7
  const AbstractWorker_1 = require("@golemio/core/dist/integration-engine/workers/AbstractWorker");
@@ -11,6 +12,7 @@ class OictEnergetikaWorker extends AbstractWorker_1.AbstractWorker {
11
12
  // Register tasks
12
13
  this.registerTask(new FetchDataTask_1.FetchDataTask(this.getQueuePrefix()));
13
14
  this.registerTask(new FetchConsumptionTask_1.FetchConsumptionTask(this.getQueuePrefix()));
15
+ this.registerTask(new FetchAccessConfigurationTask_1.FetchAccessConfigurationTask(this.getQueuePrefix()));
14
16
  }
15
17
  }
16
18
  exports.OictEnergetikaWorker = OictEnergetikaWorker;
@@ -1 +1 @@
1
- {"version":3,"file":"OictEnergetikaWorker.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/oict-energetika/OictEnergetikaWorker.ts"],"names":[],"mappings":";;;AAAA,2FAAsF;AACtF,6EAAwE;AACxE,iGAA8F;AAE9F,MAAa,oBAAqB,SAAQ,+BAAc;IAGpD;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,gBAAgB,CAAC;QAK9B,iBAAiB;QACjB,IAAI,CAAC,YAAY,CAAC,IAAI,6BAAa,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,CAAC,IAAI,2CAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ;AAVD,oDAUC"}
1
+ {"version":3,"file":"OictEnergetikaWorker.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/oict-energetika/OictEnergetikaWorker.ts"],"names":[],"mappings":";;;AAAA,2GAAsG;AACtG,2FAAsF;AACtF,6EAAwE;AACxE,iGAA8F;AAE9F,MAAa,oBAAqB,SAAQ,+BAAc;IAGpD;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,gBAAgB,CAAC;QAK9B,iBAAiB;QACjB,IAAI,CAAC,YAAY,CAAC,IAAI,6BAAa,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,CAAC,IAAI,2CAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,CAAC,IAAI,2DAA4B,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IAC/E,CAAC;CACJ;AAXD,oDAWC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="express" />
2
+ import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
3
+ import { Request } from "@golemio/core/dist/shared/express";
4
+ export declare class AbstractController {
5
+ protected accessLimitationRepository: AccessLimitationRepository;
6
+ constructor(accessLimitationRepository: AccessLimitationRepository);
7
+ protected getAllowedOrganizationIds(req: Request): Promise<number[] | null>;
8
+ }
@@ -0,0 +1,28 @@
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.AbstractController = void 0;
13
+ class AbstractController {
14
+ constructor(accessLimitationRepository) {
15
+ this.accessLimitationRepository = accessLimitationRepository;
16
+ }
17
+ getAllowedOrganizationIds(req) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const accessLimit = req.query.accessLimit;
20
+ if (accessLimit === "admin") {
21
+ return null;
22
+ }
23
+ return yield this.accessLimitationRepository.getOrganizationsByGroupName(accessLimit);
24
+ });
25
+ }
26
+ }
27
+ exports.AbstractController = AbstractController;
28
+ //# sourceMappingURL=AbstractController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AbstractController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/AbstractController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,MAAa,kBAAkB;IAG3B,YAAY,0BAAsD;QAC9D,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;IACjE,CAAC;IAEe,yBAAyB,CAAC,GAAY;;YAClD,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,WAAqB,CAAC;YAEpD,IAAI,WAAW,KAAK,OAAO,EAAE;gBACzB,OAAO,IAAI,CAAC;aACf;YAED,OAAO,MAAM,IAAI,CAAC,0BAA0B,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC;QAC1F,CAAC;KAAA;CACJ;AAhBD,gDAgBC"}
@@ -1,9 +1,12 @@
1
+ import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
2
+ import { BuildingTransformationFull } from "../../transformations/BuildingTransformationFull";
1
3
  import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
2
- export declare class BuildingsController {
4
+ import { AbstractController } from "./AbstractController";
5
+ export declare class BuildingsController extends AbstractController {
6
+ private fullDataTransformation;
3
7
  private buildingsRepository;
4
8
  private transformation;
5
- private fullDataTransformation;
6
- constructor();
9
+ constructor(accessLimitationRepository: AccessLimitationRepository, fullDataTransformation: BuildingTransformationFull);
7
10
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
8
11
  getOne: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9
12
  private getFullData;
@@ -8,6 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
11
14
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
15
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
16
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,19 +22,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
22
  };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  exports.BuildingsController = void 0;
25
+ const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
26
+ const AccessLimitationRepository_1 = require("../../repositories/AccessLimitationRepository");
22
27
  const PrimaryBuildingsRepository_1 = require("../../repositories/PrimaryBuildingsRepository");
28
+ const BuildingTransformationFull_1 = require("../../transformations/BuildingTransformationFull");
23
29
  const BuildingsTransformation_1 = require("../../transformations/BuildingsTransformation");
30
+ const Utils_1 = require("@golemio/core/dist/output-gateway/Utils");
24
31
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
25
32
  const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
26
- const Utils_1 = require("@golemio/core/dist/output-gateway/Utils");
27
- const Di_1 = require("../../ioc/Di");
28
- const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
29
- let BuildingsController = exports.BuildingsController = class BuildingsController {
30
- constructor() {
33
+ const AbstractController_1 = require("./AbstractController");
34
+ let BuildingsController = exports.BuildingsController = class BuildingsController extends AbstractController_1.AbstractController {
35
+ constructor(accessLimitationRepository, fullDataTransformation) {
36
+ super(accessLimitationRepository);
37
+ this.fullDataTransformation = fullDataTransformation;
31
38
  this.getAll = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
32
39
  try {
40
+ const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
33
41
  const fullParam = (0, Utils_1.parseBooleanQueryParam)(req.query.full);
34
- const transformedResult = fullParam ? yield this.getFullData() : yield this.getPrimaryData();
42
+ const transformedResult = fullParam
43
+ ? yield this.getFullData(allowedOrganizations)
44
+ : yield this.getPrimaryData(allowedOrganizations);
35
45
  res.json(transformedResult);
36
46
  }
37
47
  catch (err) {
@@ -40,8 +50,9 @@ let BuildingsController = exports.BuildingsController = class BuildingsControlle
40
50
  });
41
51
  this.getOne = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
42
52
  try {
53
+ const allowedOrganizations = yield this.getAllowedOrganizationIds(req);
43
54
  const id = parseInt(req.params.id);
44
- const result = yield this.buildingsRepository.GetOne(id);
55
+ const result = yield this.buildingsRepository.GetOne(id, allowedOrganizations);
45
56
  if (result === null) {
46
57
  throw new golemio_errors_1.GeneralError("not_found", "V2BuildingsController", undefined, 404);
47
58
  }
@@ -52,23 +63,25 @@ let BuildingsController = exports.BuildingsController = class BuildingsControlle
52
63
  next(err);
53
64
  }
54
65
  });
55
- this.getFullData = () => __awaiter(this, void 0, void 0, function* () {
56
- const result = yield this.buildingsRepository.GetAllFull();
66
+ this.getFullData = (allowedOrganizations) => __awaiter(this, void 0, void 0, function* () {
67
+ const result = yield this.buildingsRepository.GetAllFull(allowedOrganizations);
57
68
  const transformedResult = this.fullDataTransformation.transformArray(result);
58
69
  return transformedResult;
59
70
  });
60
- this.getPrimaryData = () => __awaiter(this, void 0, void 0, function* () {
61
- const result = yield this.buildingsRepository.GetAll();
71
+ this.getPrimaryData = (allowedOrganizations) => __awaiter(this, void 0, void 0, function* () {
72
+ const result = yield this.buildingsRepository.GetAll(allowedOrganizations);
62
73
  const transformedResult = this.transformation.transformArray(result);
63
74
  return transformedResult;
64
75
  });
65
76
  this.buildingsRepository = new PrimaryBuildingsRepository_1.PrimaryBuildingsRepository();
66
77
  this.transformation = new BuildingsTransformation_1.BuildingsTransformation();
67
- this.fullDataTransformation = Di_1.OGEnergeticsContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.BuildingTransformationFull);
68
78
  }
69
79
  };
70
80
  exports.BuildingsController = BuildingsController = __decorate([
71
81
  (0, tsyringe_1.injectable)(),
72
- __metadata("design:paramtypes", [])
82
+ __param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.AccessLimitationRepository)),
83
+ __param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.BuildingTransformationFull)),
84
+ __metadata("design:paramtypes", [AccessLimitationRepository_1.AccessLimitationRepository,
85
+ BuildingTransformationFull_1.BuildingTransformationFull])
73
86
  ], BuildingsController);
74
87
  //# sourceMappingURL=BuildingsController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuildingsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/BuildingsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8FAAyF;AAEzF,2FAAsF;AAEtF,6EAAwE;AACxE,iEAAgE;AAChE,mEAAiF;AACjF,qCAAmD;AACnD,yEAAoE;AAG7D,IAAM,mBAAmB,iCAAzB,MAAM,mBAAmB;IAK5B;QAMO,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,SAAS,GAAG,IAAA,8BAAsB,EAAC,GAAG,CAAC,KAAK,CAAC,IAAc,CAAC,CAAC;gBACnE,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,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Ac,CAAC,MAAM,CAAC,CAAC;YACrE,OAAO,iBAAiB,CAAC;QAC7B,CAAC,CAAA,CAAC;QAxCE,IAAI,CAAC,mBAAmB,GAAG,IAAI,uDAA0B,EAAE,CAAC;QAC5D,IAAI,CAAC,cAAc,GAAG,IAAI,iDAAuB,EAAE,CAAC;QACpD,IAAI,CAAC,sBAAsB,GAAG,0BAAqB,CAAC,OAAO,CAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAC;IACjH,CAAC;CAsCJ,CAAA;8BA/CY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;;GACA,mBAAmB,CA+C/B"}
1
+ {"version":3,"file":"BuildingsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/BuildingsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAoE;AACpE,8FAAyF;AACzF,8FAAyF;AACzF,iGAA4F;AAC5F,2FAAsF;AACtF,mEAAiF;AAEjF,6EAAwE;AACxE,iEAAwE;AACxE,6DAA0D;AAGnD,IAAM,mBAAmB,iCAAzB,MAAM,mBAAoB,SAAQ,uCAAkB;IAIvD,YAC6D,0BAAsD,EACtD,sBAA0D;QAEnH,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAF+B,2BAAsB,GAAtB,sBAAsB,CAA4B;QAOhH,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,SAAS,GAAG,IAAA,8BAAsB,EAAC,GAAG,CAAC,KAAK,CAAC,IAAc,CAAC,CAAC;gBACnE,MAAM,iBAAiB,GAAG,SAAS;oBAC/B,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;oBAC9C,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;gB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CAAC,oBAAoB,CAAC,CAAC;YAC3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACrE,OAAO,iBAAiB,CAAC;QAC7B,CAAC,CAAA,CAAC;QA3CE,IAAI,CAAC,mBAAmB,GAAG,IAAI,uDAA0B,EAAE,CAAC;QAC5D,IAAI,CAAC,cAAc,GAAG,IAAI,iDAAuB,EAAE,CAAC;IACxD,CAAC;CA0CJ,CAAA;8BArDY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;IAMJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;IACvD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;qCAD6B,uDAA0B;QACtB,uDAA0B;GAN9G,mBAAmB,CAqD/B"}
@@ -1,11 +1,13 @@
1
1
  /// <reference types="express" />
2
- import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
2
+ import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
3
3
  import { DevicesRepository } from "../../repositories/DevicesRepository";
4
4
  import { DeviceDtoTransformation } from "../../transformations/DeviceDtoTransformation";
5
- export declare class V2DevicesController {
5
+ import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
6
+ import { AbstractController } from "./AbstractController";
7
+ export declare class V2DevicesController extends AbstractController {
6
8
  private devicesRepository;
7
9
  private transformation;
8
- constructor(devicesRepository: DevicesRepository, transformation: DeviceDtoTransformation);
10
+ constructor(devicesRepository: DevicesRepository, transformation: DeviceDtoTransformation, accessLimitationRepository: AccessLimitationRepository);
9
11
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
10
12
  getOne: (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
11
13
  }
@@ -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 golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
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 parsePaginationParams_1 = require("../helpers/parsePaginationParams");
31
- let V2DevicesController = exports.V2DevicesController = class V2DevicesController {
32
- constructor(devicesRepository, transformation) {
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":";;;;;;;;;;;;;;;;;;;;;;;;AACA,6EAAwE;AACxE,iEAAwE;AACxE,yEAAoE;AAEpE,4EAAuE;AACvE,2FAAsF;AACtF,4EAAsF;AAG/E,IAAM,mBAAmB,iCAAzB,MAAM,mBAAmB;IAC5B,YACoD,iBAA4C,EAE5F,cAA+C;QAFS,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpF,mBAAc,GAAd,cAAc,CAAyB;QAG5C,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,MAAM,GAAsB,IAAA,6CAAqB,EAAC,GAAG,CAAC,CAAC;gBAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC3D,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;aAC/D;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;QAEK,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAEvD,IAAI,CAAC,MAAM,EAAE;oBACT,OAAO,IAAI,CACP,IAAI,6BAAY,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,CACzG,CAAC;iBACL;gBAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;aACjE;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;IA3BC,CAAC;CA4BP,CAAA;8BAjCY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,iBAAiB,CAAC,CAAA;IAC9C,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,uBAAuB,CAAC,CAAA;qCADsB,qCAAiB;QAEpE,iDAAuB;GAJ1C,mBAAmB,CAiC/B"}
1
+ {"version":3,"file":"V2DevicesController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2DevicesController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsF;AAEtF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AAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,CACzG,CAAC;iBACL;gBAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;aACjE;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;IA7BF,CAAC;CA8BJ,CAAA;8BAtCY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,iBAAiB,CAAC,CAAA;IAC9C,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,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 { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
2
+ import { AccessLimitationRepository } from "../../repositories/AccessLimitationRepository";
3
3
  import { MeasurementRepository } from "../../repositories/MeasurementRepository";
4
- export declare class V2MeasurementsController {
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 tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
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
- let V2MeasurementsController = exports.V2MeasurementsController = class V2MeasurementsController {
31
- constructor(measurementRepository) {
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,18 +46,19 @@ 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" });
48
53
  const fromDate = startDateUtc.startOf("month").toISO();
49
54
  const toDate = startDateUtc.endOf("month").toISO();
50
55
  const params = {
51
- address: `/${req.query.addr1}/${req.query.addr2}/${req.query.variable}`,
56
+ address: `/${req.query.addr1}/${req.query.addr2}`,
52
57
  variable: req.query.variable,
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
- __metadata("design:paramtypes", [MeasurementRepository_1.MeasurementRepository])
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":";;;;;;;;;;;;;;;;;;;;;;;;AACA,iEAAwE;AACxE,yEAAoE;AACpE,oFAA+E;AAE/E,4EAAsF;AACtF,2DAA2D;AAGpD,IAAM,wBAAwB,sCAA9B,MAAM,wBAAwB;IACjC,YAAgE,qBAAoD;QAA5C,0BAAqB,GAAr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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,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACvE,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,CAAC,CAAC;gBAC3E,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;IAzCqH,CAAC;CA0C3H,CAAA;mCA3CY,wBAAwB;IADpC,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,qBAAqB,CAAC,CAAA;qCAAgC,6CAAqB;GAD3G,wBAAwB,CA2CpC"}
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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K,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;gBAClG,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,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 { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
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
- export declare class V2OrganizationsController {
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 golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
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 parsePaginationParams_1 = require("../helpers/parsePaginationParams");
30
+ const OrganizationDtoTransformation_1 = require("../../transformations/OrganizationDtoTransformation");
32
31
  const Utils_1 = require("@golemio/core/dist/output-gateway/Utils");
33
- let V2OrganizationsController = exports.V2OrganizationsController = class V2OrganizationsController {
34
- constructor(organizationsRepository, transformation, transformationDetail) {
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":";;;;;;;;;;;;;;;;;;;;;;;;AACA,6EAAwE;AACxE,iEAAwE;AACxE,yEAAoE;AACpE,wFAAmF;AAEnF,uGAAkG;AAClG,mHAA8G;AAC9G,4EAAsF;AACtF,mEAAiF;AAG1E,IAAM,yBAAyB,uCAA/B,MAAM,yBAAyB;IAClC,YAC0D,uBAAwD,EAClD,cAAqD,EAEjH,oBAAiE;QAHH,4BAAuB,GAAvB,uBAAuB,CAAyB;QAC1C,mBAAc,GAAd,cAAc,CAA+B;QAEzG,yBAAoB,GAApB,oBAAoB,CAAqC;QAG9D,WAAM,GAAG,CAAO,GAAY,EAAE,G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AC;aACvE;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;IAnCC,CAAC;CAoCP,CAAA;oCA1CY,yBAAyB;IADrC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,uBAAuB,CAAC,CAAA;IACpD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,6BAA6B,CAAC,CAAA;IAC1D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,mCAAmC,CAAC,CAAA;qCAFsB,iDAAuB;QAC1B,6DAA6B;QAEnF,yEAAmC;GAL5D,yBAAyB,CA0CrC"}
1
+ {"version":3,"file":"V2OrganizationsController.js","sourceRoot":"","sources":["../../../../src/output-gateway/controllers/v2/V2OrganizationsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsF;AAEtF,yEAAoE;AACpE,8FAAyF;AACzF,wFAAmF;AACnF,mHAA8G;AAC9G,uGAAkG;AAClG,mEAAiF;AAEjF,6EAAwE;AACxE,iEAAwE;AACxE,6DAA0D;AAGnD,IAAM,yBAAyB,uCAA/B,MAAM,yBAA0B,SAAQ,uCAAkB;IAC7D,YAC0D,uBAAwD,EAClD,cAAqD,EAEjH,oBAAiE,EACR,0BAAsD;QAE/G,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAN4B,4BAAuB,GAAvB,uBAAuB,CAAyB;QAC1C,mBAAc,GAAd,cAAc,CAA+B;QAEzG,yBAAoB,GAApB,oBAAoB,CAAqC;QAM9D,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,EAAC,GAAG,CAAC,CAAC;gBAC7D,MA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C,CAAC;aACvE;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;QACL,CAAC,CAAA,CAAC;IAzCF,CAAC;CA0CJ,CAAA;oCAnDY,yBAAyB;IADrC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,uBAAuB,CAAC,CAAA;IACpD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,6BAA6B,CAAC,CAAA;IAC1D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,mCAAmC,CAAC,CAAA;IAEhE,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;qCAJ+B,iDAAuB;QAC1B,6DAA6B;QAEnF,yEAAmC;QACoB,uDAA0B;GAN1G,yBAAyB,CAmDrC"}
@@ -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;AAEpE,+DAA+E;AAC/E,qFAAmF;AACnF,2FAAyF;AACzF,mHAAiH;AACjH,2FAAy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AC,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,0BAA0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,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
+ }