@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,51 @@
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
+ try {
34
+ const data = yield this.getAll();
35
+ const limitation = data.find((d) => d.group_name === groupName);
36
+ if (!limitation) {
37
+ throw new golemio_errors_1.GeneralError(`Access limitation for group ${groupName} not found`, this.constructor.name, undefined, 500);
38
+ }
39
+ return limitation.organization_ids;
40
+ }
41
+ catch (err) {
42
+ if (err instanceof golemio_errors_1.GeneralError) {
43
+ throw err;
44
+ }
45
+ throw new golemio_errors_1.GeneralError("Database error - getOrganizationsByGroupName", this.constructor.name, err, 500);
46
+ }
47
+ });
48
+ }
49
+ }
50
+ exports.AccessLimitationRepository = AccessLimitationRepository;
51
+ //# sourceMappingURL=AccessLimitationRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessLimitationRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/AccessLimitationRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDA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AAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC3G;QACL,CAAC;KAAA;CACJ;AAvCD,gEAuCC"}
@@ -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 output_gateway_1 = require("@golemio/core/dist/output-gateway");
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: { id },
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":";;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwC;AACxC,sEAAmE;AACnE,iEAAgE;AAChE,4DAA2C;AAE3C,6EAAwE;AAIjE,IAAM,iBAAiB,+BAAvB,MAAM,iBAAkB,SAAQ,+BAAc;IACjD;QACI,KAAK,CAAC,mBAAmB,EAAE,qBAAY,CAAC,UAAU,EAAE,qBAAY,CAAC,cAAc,EAAE;YAC7E,MAAM,EAAE,uBAAgB,CAAC,QAAQ;SACpC,CAAC,CAAC;IACP,CAAC;IAEY,MAAM,CAAC,MAAyB;;YACzC,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;oBACrC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBACtB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACxB,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;IAEY,MAAM,CAAC,EAAU;;YAC1B,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;oBACrC,KAAK,EAAE,EAAE,EAAE,EAAE;iBAChB,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;CACJ,CAAA;4BA5BY,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;;GACA,iBAAiB,CA4B7B"}
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,MAAM,iBAAkB,SAAQ,+BAAc;IACjD;QACI,KAAK,CAAC,mBAAmB,EAAE,qBAAY,CAAC,UAAU,EAAE,qBAAY,CAAC,cAAc,EAAE;YAC7E,MAAM,EAAE,uBAAgB,CAAC,QAAQ;SACpC,CAAC,CAAC;QA+BC,6BAAwB,GAAG,CAAC,oBAA8B,EAAE,EAAE;YAClE,OAAO;gBACH,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,IAA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;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 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
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.default.Op.and]: [
42
- ...(options.variable ? [{ var: { [sequelize_1.default.Op.eq]: options.variable } }] : []),
43
- ...(options.type ? [{ type: { [sequelize_1.default.Op.eq]: options.type } }] : []),
44
- ...(options.addr1 && options.addr2
45
- ? [{ addr: { [sequelize_1.default.Op.like]: sequelize_1.default.literal(`'/${options.addr1}/${options.addr2}/%'`) } }]
46
- : []),
47
- ...(options.dateFrom ? [{ timestamp: { [sequelize_1.default.Op.gte]: options.dateFrom } }] : []),
48
- ...(options.dateTo ? [{ timestamp: { [sequelize_1.default.Op.lte]: options.dateTo } }] : []),
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.default.Op.and]: {
69
- var: { [sequelize_1.default.Op.eq]: options.variable },
70
- addr: { [sequelize_1.default.Op.eq]: options.address },
71
- timestamp: { [sequelize_1.default.Op.between]: [options.from, options.to] },
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.default.fn("SUM", sequelize_1.default.col("value")), "value"], "meter", "type", "addr", "var"],
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":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwC;AACxC,sEAAmE;AACnE,oFAA4D;AAC5D,iEAAgE;AAChE,6EAAwE;AAGxE,yFAAiE;AAG1D,IAAM,qBAAqB,mCAA3B,MAAM,qBAAsB,SAAQ,+BAAc;IACrD;QACI,KAAK,CAAC,wBAAwB,EAAE,oCAAgB,CAAC,SAAS,EAAE,oCAAg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AO,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;oBACpG,KAAK;oBACL,GAAG,EAAE,IAAI;oBACT,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,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;CACJ,CAAA;gCA7DY,qBAAqB;IADjC,IAAA,qBAAU,GAAE;;GACA,qBAAqB,CA6DjC"}
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,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MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;oBACrC,UAAU,EAAE,CAAC,CAAC,IAAA,cAAE,EAAC,KAAK,EAAE,IAAA,eAAG,EAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;oBAChF,KAAK;oBACL,GAAG,EAAE,IAAI;oBACT,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,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
  }
@@ -32,6 +32,7 @@ const OrganizationResponsibleUsersRepository_1 = require("./OrganizationResponsi
32
32
  const PrimaryBuildingsRepository_1 = require("./PrimaryBuildingsRepository");
33
33
  const OrganizationsAssociations_1 = require("./helpers/OrganizationsAssociations");
34
34
  const OrganizationBuildingsRepository_1 = require("./OrganizationBuildingsRepository");
35
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
35
36
  let OrganizationsRepository = exports.OrganizationsRepository = class OrganizationsRepository extends output_gateway_1.SequelizeModel {
36
37
  constructor(userRepository, organizationBuildingsRepository, buildingsRepository) {
37
38
  super("OrganizationsRepository", OrganizationsModel_1.OrganizationsModel.TABLE_NAME, OrganizationsModel_1.OrganizationsModel.attributeModel, {
@@ -46,11 +47,12 @@ let OrganizationsRepository = exports.OrganizationsRepository = class Organizati
46
47
  OrganizationsAssociations_1.OrganizationsAssociations.associateResponsibleUsers(this.sequelizeModel, this.userRepository.sequelizeModel);
47
48
  OrganizationsAssociations_1.OrganizationsAssociations.associateBuildings(this.sequelizeModel, this.buildingsRepository.sequelizeModel, this.organizationBuildingsRepository.sequelizeModel);
48
49
  }
49
- GetAllPublic(params) {
50
+ GetAllPublic(params, allowedOrganizations = []) {
50
51
  return __awaiter(this, void 0, void 0, function* () {
51
52
  try {
52
53
  return yield this.sequelizeModel.findAll({
53
54
  attributes: ["id", "name"],
55
+ where: allowedOrganizations === null ? {} : { id: { [sequelize_1.Op.in]: allowedOrganizations } },
54
56
  order: [["id", "ASC"]],
55
57
  limit: params.limit,
56
58
  offset: params.offset,
@@ -61,7 +63,7 @@ let OrganizationsRepository = exports.OrganizationsRepository = class Organizati
61
63
  }
62
64
  });
63
65
  }
64
- GetAll(params) {
66
+ GetAll(params, allowedOrganizations = []) {
65
67
  return __awaiter(this, void 0, void 0, function* () {
66
68
  try {
67
69
  return yield this.sequelizeModel.findAll({
@@ -78,6 +80,7 @@ let OrganizationsRepository = exports.OrganizationsRepository = class Organizati
78
80
  through: { attributes: [] },
79
81
  },
80
82
  ],
83
+ where: allowedOrganizations === null ? {} : { id: { [sequelize_1.Op.in]: allowedOrganizations } },
81
84
  order: [
82
85
  ["id", "ASC"],
83
86
  [{ model: this.userRepository.sequelizeModel, as: "responsible_user" }, "id", "ASC"],
@@ -92,7 +95,7 @@ let OrganizationsRepository = exports.OrganizationsRepository = class Organizati
92
95
  }
93
96
  });
94
97
  }
95
- GetOne(id) {
98
+ GetOne(id, allowedOrganizations = []) {
96
99
  return __awaiter(this, void 0, void 0, function* () {
97
100
  try {
98
101
  return yield this.sequelizeModel.findOne({
@@ -108,7 +111,7 @@ let OrganizationsRepository = exports.OrganizationsRepository = class Organizati
108
111
  through: { attributes: [] },
109
112
  },
110
113
  ],
111
- where: { id },
114
+ where: { [sequelize_1.Op.and]: [{ id }, allowedOrganizations === null ? {} : { id: { [sequelize_1.Op.in]: allowedOrganizations } }] },
112
115
  order: [
113
116
  [{ model: this.userRepository.sequelizeModel, as: "responsible_user" }, "id", "ASC"],
114
117
  [{ model: this.buildingsRepository.sequelizeModel, as: "buildings" }, "id", "ASC"],
@@ -1 +1 @@
1
- {"version":3,"file":"OrganizationsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/OrganizationsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAoE;AACpE,mDAAwC;AACxC,sEAAmE;AACnE,6EAAwE;AACxE,iEAAwE;AACxE,2FAAoE;AAEpE,qGAAiH;AAGjH,6EAAyF;AACzF,mFAA+F;AAC/F,uFAAmG;AAG5F,IAAM,uBAAuB,qCAA7B,MAAM,uBAAwB,SAAQ,+BAAc;IACvD,YAEY,cAAsD,EAEtD,+BAAgE,EACP,mBAA+C;QAEhH,KAAK,CAAC,yBAAyB,EAAE,uCAAkB,CAAC,UAAU,EAAE,uCAAkB,CAAC,cAAc,EAAE;YAC/F,MAAM,EAAE,uBAAgB,CAAC,QAAQ;SACpC,CAAC,CAAC;QAPK,mBAAc,GAAd,cAAc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EAAE,KAAK,CAAC;wBACpF,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC;qBACrF;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;CACJ,CAAA;kCA3FY,uBAAuB;IADnC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,sCAAsC,CAAC,CAAA;IAEnE,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,+BAA+B,CAAC,CAAA;IAE5D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAAA;qCAHhC,+EAAsC;QAErB,iEAA+B;QACc,uDAA0B;GAN3G,uBAAuB,CA2FnC"}
1
+ {"version":3,"file":"OrganizationsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/OrganizationsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAoE;AACpE,mDAAwC;AACxC,sEAAmE;AACnE,6EAAwE;AACxE,iEAAwE;AACxE,2FAAoE;AAEpE,qGAAiH;AAGjH,6EAAyF;AACzF,mFAA+F;AAC/F,uFAAmG;AACnG,mEAAyD;AAGlD,IAAM,uBAAuB,qCAA7B,MAAM,uBAAwB,SAAQ,+BAAc;IACvD,YAEY,cAAsD,EAEtD,+BAAgE,EACP,mBAA+C;QAEhH,KAAK,CAAC,yBAAyB,EAAE,uCAAkB,CAAC,UAAU,EAAE,uCAAkB,CAAC,cAAc,EAAE;YAC/F,MAAM,EAAE,uBAAgB,CAAC,QAAQ;SACpC,CAAC,CAAC;QAPK,mBAAc,GAAd,cAAc,CAAwC;QAEtD,oCAA+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 +5,12 @@ export declare class PrimaryBuildingsRepository extends SequelizeModel {
5
5
  private secondaryBuildingRepository;
6
6
  constructor();
7
7
  associate: () => void;
8
- GetAll(): Promise<IBuildingsPrimary[]>;
9
- GetAllFull(): Promise<Array<IBuildingsPrimary & {
8
+ GetAll(allowedOrganizations: number[] | null): Promise<IBuildingsPrimary[]>;
9
+ GetAllFull(allowedOrganizations: number[] | null): Promise<Array<IBuildingsPrimary & {
10
10
  secondary: ISecondaryBuildingsOutput;
11
11
  }>>;
12
- GetOne(id: number): Promise<(IBuildingsPrimary & {
12
+ GetOne(id: number, allowedOrganizations?: number[] | null): Promise<(IBuildingsPrimary & {
13
13
  secondary: ISecondaryBuildingsOutput;
14
14
  }) | null>;
15
+ private getWhereAccessLimitation;
15
16
  }
@@ -24,6 +24,8 @@ const output_gateway_1 = require("@golemio/core/dist/output-gateway");
24
24
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
25
25
  const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
26
26
  const SecondaryBuildingsRepository_1 = require("./SecondaryBuildingsRepository");
27
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
28
+ const constants_1 = require("../../schema-definitions/constants");
27
29
  let PrimaryBuildingsRepository = exports.PrimaryBuildingsRepository = class PrimaryBuildingsRepository extends output_gateway_1.SequelizeModel {
28
30
  constructor() {
29
31
  super(BuildingsPrimaryModel_1.BuildingsPrimaryModel.modelName, BuildingsPrimaryModel_1.BuildingsPrimaryModel.tableName, BuildingsPrimaryModel_1.BuildingsPrimaryModel.attributeModel, {
@@ -36,13 +38,20 @@ let PrimaryBuildingsRepository = exports.PrimaryBuildingsRepository = class Prim
36
38
  sourceKey: "id",
37
39
  });
38
40
  };
41
+ this.getWhereAccessLimitation = (allowedOrganizations) => {
42
+ return {
43
+ [sequelize_1.Op.in]: (0, sequelize_1.literal)(`(select distinct building_id from ${constants_1.PG_SCHEMA}.organizations_buildings
44
+ where organization_id = any('{${allowedOrganizations.join(",")}}'::integer[]))`),
45
+ };
46
+ };
39
47
  this.secondaryBuildingRepository = new SecondaryBuildingsRepository_1.SecondaryBuildingsRepository();
40
48
  this.associate();
41
49
  }
42
- GetAll() {
50
+ GetAll(allowedOrganizations) {
43
51
  return __awaiter(this, void 0, void 0, function* () {
44
52
  try {
45
53
  return this.sequelizeModel.findAll({
54
+ where: allowedOrganizations === null ? {} : { id: this.getWhereAccessLimitation(allowedOrganizations) },
46
55
  order: [["id", "DESC"]],
47
56
  raw: true,
48
57
  });
@@ -52,11 +61,12 @@ let PrimaryBuildingsRepository = exports.PrimaryBuildingsRepository = class Prim
52
61
  }
53
62
  });
54
63
  }
55
- GetAllFull() {
64
+ GetAllFull(allowedOrganizations) {
56
65
  return __awaiter(this, void 0, void 0, function* () {
57
66
  try {
58
67
  return this.sequelizeModel.findAll({
59
68
  include: [{ as: "secondary", model: this.secondaryBuildingRepository.sequelizeModel }],
69
+ where: allowedOrganizations === null ? {} : { id: this.getWhereAccessLimitation(allowedOrganizations) },
60
70
  order: [["id", "DESC"]],
61
71
  });
62
72
  }
@@ -65,12 +75,17 @@ let PrimaryBuildingsRepository = exports.PrimaryBuildingsRepository = class Prim
65
75
  }
66
76
  });
67
77
  }
68
- GetOne(id) {
78
+ GetOne(id, allowedOrganizations = []) {
69
79
  return __awaiter(this, void 0, void 0, function* () {
70
80
  try {
71
81
  return yield this.sequelizeModel.findOne({
72
82
  include: [{ as: "secondary", model: this.secondaryBuildingRepository.sequelizeModel }],
73
- where: { id: id },
83
+ where: {
84
+ [sequelize_1.Op.and]: [
85
+ { id: id },
86
+ allowedOrganizations === null ? {} : { id: this.getWhereAccessLimitation(allowedOrganizations) },
87
+ ],
88
+ },
74
89
  });
75
90
  }
76
91
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrimaryBuildingsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/PrimaryBuildingsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA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BACV,MAAM,IAAI,6BAAY,CAAC,6CAA6C,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC9F;QACL,CAAC;KAAA;IAEY,MAAM,CAAC,EAAU;;YAC1B,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAmE;oBACvG,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,cAAc,EAAE,CAAC;oBACtF,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;iBACpB,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,6CAA6C,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC9F;QACL,CAAC;KAAA;CACJ,CAAA;qCAlDY,0BAA0B;IADtC,IAAA,qBAAU,GAAE;;GACA,0BAA0B,CAkDtC"}
1
+ {"version":3,"file":"PrimaryBuildingsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/PrimaryBuildingsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2EAAyE;AAGzE,sEAAmE;AACnE,6EAAwE;AACxE,iEAAgE;AAChE,iFAA8E;AAC9E,mEAAkE;AAClE,kEAA2C;AAGpC,IAAM,0BAA0B,wCAAhC,MAAM,0BAA2B,SAAQ,+BAAc;IAE1D;QACI,KAAK,CAAC,6CAAqB,CAAC,SAAS,EAAE,6CAAqB,CAAC,SAAS,EAAE,6CAAqB,CAAC,cAAc,EAAE;YAC1G,MAAM,EAAE,YAAY;SACvB,CAAC,CAAC;QAKA,cAAS,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,cAAc,EAAE;gBACxE,EAAE,EAAE,WAAW;gBACf,UAAU,EAAE,IAAI;gBACh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;oBACvG,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;iBAC1B,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,6CAA6C,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC9F;QACL,CAAC;KAAA;IAEqB,MAAM,CACxB,EAAU,EACV,uBAAwC,EAAE;;YAE1C,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAmE;oBACvG,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,cAAc,EAAE,CAAC;oBACtF,KAAK,EAAE;wBACH,CAAC,cAAE,CAAC,GAAG,CAAC,EAAE;4BACN,EAAE,EAAE,EAAE,EAAE,EAAE;4BACV,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,EAAE;yBACnG;qBACJ;iBACJ,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,6CAA6C,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC9F;QACL,CAAC;KAAA;CAQJ,CAAA;qCArEY,0BAA0B;IADtC,IAAA,qBAAU,GAAE;;GACA,0BAA0B,CAqEtC"}
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.V2BuildingsRouter = void 0;
13
13
  const Links_1 = require("../../constants/Links");
14
14
  const RouteVersion_1 = require("../../constants/RouteVersion");
15
- const BuildingsController_1 = require("../../controllers/v2/BuildingsController");
16
15
  const Di_1 = require("../../ioc/Di");
16
+ const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
17
17
  const AbstractRouter_1 = require("@golemio/core/dist/helpers/routing/AbstractRouter");
18
18
  const Validation_1 = require("@golemio/core/dist/output-gateway/Validation");
19
19
  const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
@@ -23,13 +23,13 @@ let V2BuildingsRouter = exports.V2BuildingsRouter = class V2BuildingsRouter exte
23
23
  constructor() {
24
24
  super(RouteVersion_1.RouteVersion.v2, Links_1.BUILDING_PATH);
25
25
  this.maxAge = 6 * 60 * 60; // 6 hours
26
- this.controller = new BuildingsController_1.BuildingsController();
26
+ this.controller = Di_1.OGEnergeticsContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.BuildingsController);
27
27
  this.cacheHeaderMiddleware = Di_1.OGEnergeticsContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
28
28
  this.initRoutes();
29
29
  }
30
30
  initRoutes() {
31
- this.router.get("/", this.cacheHeaderMiddleware.getMiddleware(this.maxAge), this.controller.getAll);
32
- this.router.get("/:id", this.cacheHeaderMiddleware.getMiddleware(this.maxAge), (0, express_validator_1.param)("id").exists().isNumeric().not().isArray(), Validation_1.checkErrors, this.controller.getOne);
31
+ this.router.get("/", (0, express_validator_1.query)("accessLimit").exists(), Validation_1.checkErrors, this.cacheHeaderMiddleware.getMiddleware(this.maxAge), this.controller.getAll);
32
+ this.router.get("/:id", this.cacheHeaderMiddleware.getMiddleware(this.maxAge), (0, express_validator_1.param)("id").exists().isNumeric().not().isArray(), (0, express_validator_1.query)("accessLimit").exists(), Validation_1.checkErrors, this.controller.getOne);
33
33
  }
34
34
  };
35
35
  exports.V2BuildingsRouter = V2BuildingsRouter = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"V2BuildingsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2BuildingsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAoD;AACpD,+DAA0D;AAC1D,kFAA6E;AAC7E,qCAAmD;AACnD,sFAAmF;AAEnF,6EAA2E;AAC3E,+DAAuE;A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AAM,iBAAiB,+BAAvB,MAAM,iBAAkB,SAAQ,+BAAc;IAKjD;QACI,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,qBAAa,CAAC,CAAC;QAHlC,WAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;QAIpC,IAAI,CAAC,UAAU,GAAG,0BAAqB,CAAC,OAAO,CAAsB,2CAAoB,CAAC,mBAAmB,CAAC,CAAC;QAC/G,IAAI,CAAC,qBAAqB,GAAG,0BAAqB,CAAC,OAAO,CAAwB,oBAAc,CAAC,qBAAqB,CAAC,CAAC;QACxH,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,GAAG,EACH,IAAA,yBAAK,EAAC,aAAa,CAAC,CAAC,MAAM,EAAE,EAC7B,wBAAW,EACX,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EACrD,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,MAAM,EACN,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EACrD,IAAA,yBAAK,EAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAChD,IAAA,yBAAK,EAAC,aAAa,CAAC,CAAC,MAAM,EAAE,EAC7B,wBAAW,EACX,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;4BA7BY,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;;GACA,iBAAiB,CA6B7B"}
@@ -29,8 +29,8 @@ let V2DevicesRouter = exports.V2DevicesRouter = class V2DevicesRouter extends Ab
29
29
  this.initRoutes();
30
30
  }
31
31
  initRoutes() {
32
- this.router.get("/", Validation_1.pagination, Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getAll);
33
- this.router.get("/:id", (0, express_validator_1.param)("id").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(), Validation_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.controller.getOne);
32
+ this.router.get("/", (0, express_validator_1.query)("accessLimit").exists(), Validation_1.pagination, Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getAll);
33
+ this.router.get("/:id", (0, express_validator_1.param)("id").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(), (0, express_validator_1.query)("accessLimit").exists(), Validation_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.controller.getOne);
34
34
  }
35
35
  };
36
36
  exports.V2DevicesRouter = V2DevicesRouter = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"V2DevicesRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2DevicesRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAAmF;AACnF,sEAAuE;AACvE,6EAAkH;AAClH,mFAAoE;AACpE,kFAA6E;AAC7E,+DAA0D;AAC1D,iEAAwE;AACxE,yEAAoE;AACpE,iDAAmD;AAG5C,IAAM,eAAe,6BAArB,MAAM,eAAgB,SAAQ,+BAAc;IAC/C,YAAsE,UAA+B;QACjG,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,oBAAY,CAAC,CAAC;QAD6B,eAAU,GAAV,UAAU,CAAqB;QAGjG,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,GAAG,EACH,uBAAU,EACV,wBAAW,EACX,IAAA,sCAAyB,EAAC,IAAI,CAAC,IAAI,CAAC,EACpC,IAAA,mCAAkB,GAAE,EACpB,IAAI,CAAC,UAAU,CAAC,MAA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C,MAAM,CAAC,GAAG,CACX,MAAM,EACN,IAAA,yBAAK,EAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAC/E,IAAA,yBAAK,EAAC,aAAa,CAAC,CAAC,MAAM,EAAE,EAC7B,wBAAW,EACX,IAAA,mCAAkB,GAAE,EACpB,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;0BA3BY,eAAe;IAD3B,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,mBAAmB,CAAC,CAAA;qCAAqB,yCAAmB;GAD5F,eAAe,CA2B3B"}
@@ -48,6 +48,7 @@ let V2MeasurementsRouter = exports.V2MeasurementsRouter = class V2MeasurementsRo
48
48
  ]),
49
49
  (0, express_validator_1.query)("dateFrom").optional().isISO8601().not().isArray(),
50
50
  (0, express_validator_1.query)("dateTo").optional().isISO8601().not().isArray(),
51
+ (0, express_validator_1.query)("accessLimit").exists(),
51
52
  ], Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getMeasurements);
52
53
  this.router.get("/monthly-reading", [
53
54
  (0, express_validator_1.query)("addr1").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(),
@@ -55,6 +56,7 @@ let V2MeasurementsRouter = exports.V2MeasurementsRouter = class V2MeasurementsRo
55
56
  (0, express_validator_1.query)("variable").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray().isIn(MeasurementConstants_1.MEASUREMENT_VARIABLES),
56
57
  (0, express_validator_1.query)("year").exists().isInt().not().isArray(),
57
58
  (0, express_validator_1.query)("month").exists().isInt({ min: 1, max: 12 }).not().isArray(),
59
+ (0, express_validator_1.query)("accessLimit").exists(),
58
60
  ], Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getMonthlyReadings);
59
61
  }
60
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"V2MeasurementsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2MeasurementsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAAmF;AACnF,sEAAuE;AACvE,6EAAkH;AAClH,mFAA2E;AAC3E,4FAAuF;AACvF,+DAA0D;AAC1D,iEAAwE;AACxE,yEAAoE;AACpE,iDAAwD;AACxD,4GAAsG;AAG/F,IAAM,oBAAoB,kCAA1B,MAAM,oBAAqB,SAAQ,+BAAc;IACpD,YAA2E,UAAoC;QAC3G,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,yBAAiB,CAAC,CAAC;QAD6B,eAAU,GAAV,UAAU,CAA0B;QAG3G,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,GAAG,EACH;YACI,IAAA,yBAAK,EAAC,UAAU,CAAC;iBACZ,QAAQ,EAAE;iBACV,GAAG,EAAE;iBACL,OAAO,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;iBACpC,GAAG,EAAE;iBACL,OAAO,EAAE;iBACT,IAAI,CAAC,4CAAqB,CAAC;YAChC,IAAA,yBAAK,EAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,wCAAiB,CAAC;YAC3G,IAAA,yBAAK,EAAC;gBACF;oBACI,IAAA,yBAAK,EAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC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EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,4CAAqB,CAAC;YACjH,IAAA,yBAAK,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;YAC9C,IAAA,yBAAK,EAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE;SACrE,EACD,wBAAW,EACX,IAAA,sCAAyB,EAAC,IAAI,CAAC,IAAI,CAAC,EACpC,IAAA,mCAAkB,GAAE,EACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACrC,CAAC;IACN,CAAC;CACJ,CAAA;+BAlDY,oBAAoB;IADhC,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,wBAAwB,CAAC,CAAA;qCAAqB,mDAAwB;GADtG,oBAAoB,CAkDhC"}
1
+ {"version":3,"file":"V2MeasurementsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2MeasurementsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAAmF;AACnF,sEAAuE;AACvE,6EAAkH;AAClH,mFAA2E;AAC3E,4FAAuF;AACvF,+DAA0D;AAC1D,iEAAwE;AACxE,yEAAoE;AACpE,iDAAwD;AACxD,4GAAsG;AAG/F,IAAM,oBAAoB,kCAA1B,MAAM,oBAAqB,SAAQ,+BAAc;IACpD,YAA2E,UAAoC;QAC3G,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,yBAAiB,CAAC,CAAC;QAD6B,eAAU,GAAV,UAAU,CAA0B;QAG3G,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,C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;+BApDY,oBAAoB;IADhC,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,wBAAwB,CAAC,CAAA;qCAAqB,mDAAwB;GADtG,oBAAoB,CAoDhC"}
@@ -29,8 +29,8 @@ let V2OrganizationsRouter = exports.V2OrganizationsRouter = class V2Organization
29
29
  this.initRoutes();
30
30
  }
31
31
  initRoutes() {
32
- this.router.get("/", [(0, express_validator_1.query)("full").optional().isBoolean().not().isArray()], Validation_1.pagination, Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getAll);
33
- this.router.get("/:id", (0, express_validator_1.param)("id").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(), Validation_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.controller.getOne);
32
+ this.router.get("/", [(0, express_validator_1.query)("full").optional().isBoolean().not().isArray()], (0, express_validator_1.query)("accessLimit").exists(), Validation_1.pagination, Validation_1.checkErrors, (0, Validation_1.paginationLimitMiddleware)(this.path), (0, output_gateway_1.useCacheMiddleware)(), this.controller.getAll);
33
+ this.router.get("/:id", (0, express_validator_1.param)("id").exists().not().isEmpty({ ignore_whitespace: true }).not().isArray(), (0, express_validator_1.query)("accessLimit").exists(), Validation_1.checkErrors, (0, output_gateway_1.useCacheMiddleware)(), this.controller.getOne);
34
34
  }
35
35
  };
36
36
  exports.V2OrganizationsRouter = V2OrganizationsRouter = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"V2OrganizationsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2OrganizationsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAAmF;AACnF,sEAAuE;AACvE,6EAAkH;AAClH,mFAA2E;AAC3E,8FAAyF;AACzF,+DAA0D;AAC1D,iEAAwE;AACxE,yEAAoE;AACpE,iDAAwD;AAGjD,IAAM,qBAAqB,mCAA3B,MAAM,qBAAsB,SAAQ,+BAAc;IACrD,YAA4E,UAAqC;QAC7G,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,yBAAiB,CAAC,CAAC;QAD8B,eAAU,GAAV,UAAU,CAA2B;QAG7G,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,GAAG,EACH,CAAC,IAAA,yBAAK,EAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,EACtD,uBAAU,EACV,wBAAW,EACX,IAAA,sCAAyB,EAAC,IAAI,CAAC,IAAI,CAAC,EACpC,IAAA,mCAAkB,GAAE,EACpB,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,MAAM,EACN,IAAA,yBAAK,EAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAC/E,wBAAW,EACX,IAAA,mCAAkB,GAAE,EACpB,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;gCA1BY,qBAAqB;IADjC,IAAA,qBAAU,GAAE;IAEI,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,yBAAyB,CAAC,CAAA;qCAAqB,qDAAyB;GADxG,qBAAqB,CA0BjC"}
1
+ {"version":3,"file":"V2OrganizationsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2OrganizationsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sFAAmF;AACnF,sEAAuE;AACvE,6EAAkH;AAClH,mFAA2E;AAC3E,8FAAyF;AACzF,+DAA0D;AAC1D,iEAAwE;AACxE,yEAAoE;AACpE,iDAA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core/dist/shared/ajv";
3
+ export declare const accessConfigurationJsonSchema: JSONSchemaType<IAccessLimitation[]>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.accessConfigurationJsonSchema = void 0;
4
+ exports.accessConfigurationJsonSchema = {
5
+ type: "array",
6
+ items: {
7
+ type: "object",
8
+ properties: {
9
+ group_name: { type: "string" },
10
+ organization_ids: {
11
+ type: "array",
12
+ items: { type: "integer" },
13
+ },
14
+ },
15
+ required: ["group_name", "organization_ids"],
16
+ },
17
+ };
18
+ //# sourceMappingURL=AccessConfigurationJsonSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessConfigurationJsonSchema.js","sourceRoot":"","sources":["../../../src/schema-definitions/datasources/AccessConfigurationJsonSchema.ts"],"names":[],"mappings":";;;AAGa,QAAA,6BAA6B,GAAwC;IAC9E,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC9B,gBAAgB,EAAE;gBACd,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;aAC7B;SACJ;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;KAC/C;CACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Model, ModelAttributes } from "@golemio/core/dist/shared/sequelize";
2
+ import { IAccessLimitation } from "./interfaces/IAccessLimitation";
3
+ import { JSONSchemaType } from "@golemio/core/dist/shared/ajv";
4
+ export declare class AccessLimitationModel extends Model<AccessLimitationModel> implements IAccessLimitation {
5
+ static TABLE_NAME: string;
6
+ group_name: string;
7
+ organization_ids: number[];
8
+ static attributeModel: ModelAttributes<AccessLimitationModel>;
9
+ static jsonSchema: JSONSchemaType<IAccessLimitation[]>;
10
+ }