@golemio/energetics 1.3.8-dev.1350798883 → 1.3.8-dev.1365974407

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/db/example/00_clear_test_data.sql +1 -0
  2. package/db/example/05_access.sql +5 -0
  3. package/db/migrations/postgresql/20240621083051-access-limitation.js +53 -0
  4. package/db/migrations/postgresql/sqls/20240621083051-access-limitation-down.sql +1 -0
  5. package/db/migrations/postgresql/sqls/20240621083051-access-limitation-up.sql +7 -0
  6. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.d.ts +9 -0
  7. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js +45 -0
  8. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js.map +1 -0
  9. package/dist/integration-engine/commodity-providers/ioc/Di.js +5 -1
  10. package/dist/integration-engine/commodity-providers/ioc/Di.js.map +1 -1
  11. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.d.ts +2 -0
  12. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js +2 -0
  13. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js.map +1 -1
  14. package/dist/integration-engine/ioc/Di.js.map +1 -1
  15. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.d.ts +9 -0
  16. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js +78 -0
  17. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js.map +1 -0
  18. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.d.ts +9 -0
  19. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js +32 -0
  20. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js.map +1 -0
  21. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js +2 -0
  22. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js.map +1 -1
  23. package/dist/output-gateway/controllers/v2/AbstractController.d.ts +8 -0
  24. package/dist/output-gateway/controllers/v2/AbstractController.js +28 -0
  25. package/dist/output-gateway/controllers/v2/AbstractController.js.map +1 -0
  26. package/dist/output-gateway/controllers/v2/BuildingsController.d.ts +6 -3
  27. package/dist/output-gateway/controllers/v2/BuildingsController.js +26 -13
  28. package/dist/output-gateway/controllers/v2/BuildingsController.js.map +1 -1
  29. package/dist/output-gateway/controllers/v2/V2DevicesController.d.ts +5 -3
  30. package/dist/output-gateway/controllers/v2/V2DevicesController.js +15 -8
  31. package/dist/output-gateway/controllers/v2/V2DevicesController.js.map +1 -1
  32. package/dist/output-gateway/controllers/v2/V2MeasurementsController.d.ts +5 -3
  33. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js +14 -7
  34. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js.map +1 -1
  35. package/dist/output-gateway/controllers/v2/V2OrganizationsController.d.ts +6 -4
  36. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js +17 -10
  37. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js.map +1 -1
  38. package/dist/output-gateway/ioc/Di.js +9 -1
  39. package/dist/output-gateway/ioc/Di.js.map +1 -1
  40. package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +2 -0
  41. package/dist/output-gateway/ioc/ModuleContainerToken.js +2 -0
  42. package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
  43. package/dist/output-gateway/repositories/AccessLimitationRepository.d.ts +11 -0
  44. package/dist/output-gateway/repositories/AccessLimitationRepository.js +43 -0
  45. package/dist/output-gateway/repositories/AccessLimitationRepository.js.map +1 -0
  46. package/dist/output-gateway/repositories/DevicesRepository.d.ts +4 -3
  47. package/dist/output-gateway/repositories/DevicesRepository.js +19 -5
  48. package/dist/output-gateway/repositories/DevicesRepository.js.map +1 -1
  49. package/dist/output-gateway/repositories/MeasurementRepository.d.ts +3 -2
  50. package/dist/output-gateway/repositories/MeasurementRepository.js +29 -20
  51. package/dist/output-gateway/repositories/MeasurementRepository.js.map +1 -1
  52. package/dist/output-gateway/repositories/OrganizationsRepository.d.ts +3 -3
  53. package/dist/output-gateway/repositories/OrganizationsRepository.js +7 -4
  54. package/dist/output-gateway/repositories/OrganizationsRepository.js.map +1 -1
  55. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.d.ts +4 -3
  56. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js +19 -4
  57. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js.map +1 -1
  58. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js +2 -2
  59. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js.map +1 -1
  60. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.d.ts +3 -0
  61. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js +18 -0
  62. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js.map +1 -0
  63. package/dist/schema-definitions/models/AccessLimitationModel.d.ts +10 -0
  64. package/dist/schema-definitions/models/AccessLimitationModel.js +32 -0
  65. package/dist/schema-definitions/models/AccessLimitationModel.js.map +1 -0
  66. package/dist/schema-definitions/models/interfaces/IAccessLimitation.d.ts +4 -0
  67. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js +3 -0
  68. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js.map +1 -0
  69. package/docs/implementation_documentation.md +21 -0
  70. package/package.json +3 -3
@@ -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,CAAwC;QAEtD,oCAA+B,GAA/B,+BAA+B,CAAiC;QACP,wBAAmB,GAAnB,mBAAmB,CAA4B;QAMhH,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAEM,SAAS;QACZ,qDAAyB,CAAC,yBAAyB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAC7G,qDAAyB,CAAC,kBAAkB,CACxC,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAC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,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+B,GAA/B,+BAA+B,CAAiC;QACP,wBAAmB,GAAnB,mBAAmB,CAA4B;QAMhH,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAEM,SAAS;QACZ,qDAAyB,CAAC,yBAAyB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAC7G,qDAAyB,CAAC,kBAAkB,CACxC,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,mBAAmB,CAAC,cAAc,EACvC,IAAI,CAAC,+BAA+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AAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,oBAAoB,EAAE,EAAE,CAAC,EAAE;oBAC7G,KAAK,EAAE;wBACH,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,IAAI,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;kCAnGY,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,CAmGnC"}
@@ -5,11 +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":";;;;;;;;;;;;;;;;;;;;;AACA,iGAA0E;AAE1E,sEAAmE;AACnE,6EAAwE;AACxE,iEAAgE;AAChE,iFAA8E;AAGvE,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,C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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":";;;;;;;;;;;;;;;;;;;;;AACA,iGAA0E;AAE1E,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;gBAChB,SAAS,EAAE,IAAI;aAClB,CAAC,CAAC;QACP,CAAC,CAAC;QA+CM,6BAAwB,GAAG,CAAC,oBAA8B,EAAE,EAAE;YAClE,OAAO;gBACH,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,IAAA,mBAAO,EAAC,qCAAqC,qBAAS;gCAC3C,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC;aACvE,CAAC;QACN,CAAC,CAAC;QA9DE,IAAI,CAAC,2BAA2B,GAAG,IAAI,2DAA4B,EAAE,CAAC;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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,7 +23,7 @@ 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
  }
@@ -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;AACvE,mFAAoE;AACpE,iEAAgE;AAGzD,IAAM,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,IAAI,yCAAmB,EAAE,CAAC;QAC5C,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,CAAC,GAAG,EAAE,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACpG,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,wBAAW,EACX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IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;4BAtBY,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;;GACA,iBAAiB,CAsB7B"}
@@ -0,0 +1,3 @@
1
+ import { IAccessLimitation } from "../models/interfaces/IAccessLimitation";
2
+ import { JSONSchemaType } from "@golemio/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
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessLimitationModel = void 0;
4
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
5
+ class AccessLimitationModel extends sequelize_1.Model {
6
+ }
7
+ exports.AccessLimitationModel = AccessLimitationModel;
8
+ AccessLimitationModel.TABLE_NAME = "access_limitation";
9
+ AccessLimitationModel.attributeModel = {
10
+ group_name: {
11
+ type: sequelize_1.DataTypes.STRING,
12
+ primaryKey: true,
13
+ },
14
+ organization_ids: {
15
+ type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.INTEGER),
16
+ },
17
+ };
18
+ AccessLimitationModel.jsonSchema = {
19
+ type: "array",
20
+ items: {
21
+ type: "object",
22
+ properties: {
23
+ group_name: { type: "string" },
24
+ organization_ids: {
25
+ type: "array",
26
+ items: { type: "integer" },
27
+ },
28
+ },
29
+ required: ["group_name", "organization_ids"],
30
+ },
31
+ };
32
+ //# sourceMappingURL=AccessLimitationModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessLimitationModel.js","sourceRoot":"","sources":["../../../src/schema-definitions/models/AccessLimitationModel.ts"],"names":[],"mappings":";;;AAAA,mEAAwF;AAIxF,MAAa,qBAAsB,SAAQ,iBAA4B;;AAAvE,sDA8BC;AA7BiB,gCAAU,GAAG,mBAAmB,CAAC;AAKjC,oCAAc,GAA2C;IACnE,UAAU,EAAE;QACR,IAAI,EAAE,qBAAS,CAAC,MAAM;QACtB,UAAU,EAAE,IAAI;KACnB;IACD,gBAAgB,EAAE;QACd,IAAI,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,OAAO,CAAC;KAC3C;CACJ,CAAC;AAEY,gCAAU,GAAwC;IAC5D,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,4 @@
1
+ export interface IAccessLimitation {
2
+ group_name: string;
3
+ organization_ids: number[];
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAccessLimitation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAccessLimitation.js","sourceRoot":"","sources":["../../../../src/schema-definitions/models/interfaces/IAccessLimitation.ts"],"names":[],"mappings":""}
@@ -307,6 +307,24 @@ Metoda sbírá data o spotřebách od různých poskytovalů API (consumption) a
307
307
  - data modely
308
308
  - ConsumptionModel `consumption_energy_consumption`
309
309
 
310
+ #### _task: FetchAccessConfigurationTask_
311
+
312
+ Task aktualizuje lookup tabulku pro limitaci přístupu k output API.
313
+
314
+ - vstupní rabbitmq fronta
315
+ - název: dataplatform.energeticsoict.fetchAccessConfiguration
316
+ - TTL: 10 minutes
317
+ - závislé fronty (do kterých jsou odesílány zprávy z metody workeru)
318
+ - žádné
319
+ - datové zdroje
320
+ - blob storage
321
+ - rabín: https://rabingolemio.blob.core.windows.net/rabin-energetics/access_configuration.json
322
+ - golem: https://golemgolemio.blob.core.windows.net/golem-energetics/access_configuration.json
323
+ - transformace
324
+ - není
325
+ - data modely
326
+ - AccessLimitationModel `access_limitation`
327
+
310
328
  ### _EnergeticsVpalacWorker_
311
329
 
312
330
  Worker se stará o stahování dat (odečty, měřidla a počítadla) z datového zdroje Unimonitor CEM API - Vrtbovský palác
@@ -375,6 +393,9 @@ Metoda sbírá historická data
375
393
  - zdrojový soubor: [openapi-output.yaml](./openapi-output.yaml)
376
394
  - rabin: https://rabin.golemio.cz/v2/docs/openapi/
377
395
  - golem: https://api.golemio.cz/v2/docs/openapi/
396
+ - přístup je řízen pomocí interního parametru `accessLimit`, který musí být vždy nastaven a omezen z permission proxy
397
+ - při obdržení dotazu na API se stáhnou povolené organizace z tabulky `access_limit` a omezí se podle toho dotazy do databáze
398
+ - pokud je `accessLimit` nastaven na `admin`, tak se vždy dotazuje na všechny organizace
378
399
 
379
400
  ### API
380
401
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/energetics",
3
- "version": "1.3.8-dev.1350798883",
3
+ "version": "1.3.8-dev.1365974407",
4
4
  "description": "Golemio Energetics Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "test-debug": "run-s 'test -- --inspect-brk=9230'",
14
14
  "apidocs-test": "npm run apidocs-test-input && npm run apidocs-test-output",
15
15
  "apidocs-test-input": "cross-env NODE_ENV=test golemio swagger api-test --oas docs/openapi-input.yaml --script test/api-docs/input-gateway/server.js",
16
- "apidocs-test-output": "cross-env NODE_ENV=test golemio swagger api-test --oas docs/openapi-output.yaml --script test/api-docs/output-gateway/server.js",
16
+ "apidocs-test-output": "cross-env NODE_ENV=test golemio swagger api-test --oas docs/openapi-output.yaml --script test/api-docs/output-gateway/server.js --config test/api-docs/output-gateway/portman-config.json",
17
17
  "code-coverage": "nyc run-s 'test -- -r source-map-support/register'",
18
18
  "generate-docs": "typedoc --out docs/typedoc src",
19
19
  "lint": "eslint \"{src,test}/**/*.ts\""
@@ -36,7 +36,7 @@
36
36
  "@commitlint/cli": "^11.0.0",
37
37
  "@commitlint/config-conventional": "^11.0.0",
38
38
  "@golemio/cli": "1.5.0",
39
- "@golemio/core": "1.10.4-dev.1350777994",
39
+ "@golemio/core": "1.10.4-dev.1352554894",
40
40
  "@golemio/db-common": "1.1.4",
41
41
  "@golemio/eslint-config": "1.1.2",
42
42
  "@types/chai": "4.2.3",