@golemio/energetics 1.3.8-dev.1347421314 → 1.3.8-dev.1352571662

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 (82) 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/input-gateway/ptas/PtasRouter.d.ts +1 -1
  7. package/dist/input-gateway/ptas/PtasRouter.js +9 -42
  8. package/dist/input-gateway/ptas/PtasRouter.js.map +1 -1
  9. package/dist/input-gateway/ptas/interfaces/IExtendedPtasRequest.d.ts +9 -0
  10. package/dist/input-gateway/ptas/interfaces/IExtendedPtasRequest.js +3 -0
  11. package/dist/input-gateway/ptas/interfaces/IExtendedPtasRequest.js.map +1 -0
  12. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.d.ts +9 -0
  13. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js +45 -0
  14. package/dist/integration-engine/commodity-providers/datasources/static-data/AccessConfigurationDataSource.js.map +1 -0
  15. package/dist/integration-engine/commodity-providers/ioc/Di.js +5 -1
  16. package/dist/integration-engine/commodity-providers/ioc/Di.js.map +1 -1
  17. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.d.ts +2 -0
  18. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js +2 -0
  19. package/dist/integration-engine/commodity-providers/ioc/WorkerContainerToken.js.map +1 -1
  20. package/dist/integration-engine/commodity-providers/workers/tasks/FetchPtasWebScrapedMeasurementsTask.js +2 -2
  21. package/dist/integration-engine/commodity-providers/workers/tasks/FetchPtasWebScrapedMeasurementsTask.js.map +1 -1
  22. package/dist/integration-engine/ioc/Di.js.map +1 -1
  23. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.d.ts +9 -0
  24. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js +78 -0
  25. package/dist/integration-engine/repositories/oict-energetika/AccessLimitationRepository.js.map +1 -0
  26. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.d.ts +9 -0
  27. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js +32 -0
  28. package/dist/integration-engine/tasks/oict-energetika/FetchAccessConfigurationTask.js.map +1 -0
  29. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js +2 -0
  30. package/dist/integration-engine/workers/oict-energetika/OictEnergetikaWorker.js.map +1 -1
  31. package/dist/output-gateway/controllers/v2/AbstractController.d.ts +8 -0
  32. package/dist/output-gateway/controllers/v2/AbstractController.js +28 -0
  33. package/dist/output-gateway/controllers/v2/AbstractController.js.map +1 -0
  34. package/dist/output-gateway/controllers/v2/BuildingsController.d.ts +6 -3
  35. package/dist/output-gateway/controllers/v2/BuildingsController.js +26 -13
  36. package/dist/output-gateway/controllers/v2/BuildingsController.js.map +1 -1
  37. package/dist/output-gateway/controllers/v2/V2DevicesController.d.ts +5 -3
  38. package/dist/output-gateway/controllers/v2/V2DevicesController.js +15 -8
  39. package/dist/output-gateway/controllers/v2/V2DevicesController.js.map +1 -1
  40. package/dist/output-gateway/controllers/v2/V2MeasurementsController.d.ts +5 -3
  41. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js +14 -7
  42. package/dist/output-gateway/controllers/v2/V2MeasurementsController.js.map +1 -1
  43. package/dist/output-gateway/controllers/v2/V2OrganizationsController.d.ts +6 -4
  44. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js +17 -10
  45. package/dist/output-gateway/controllers/v2/V2OrganizationsController.js.map +1 -1
  46. package/dist/output-gateway/ioc/Di.js +9 -1
  47. package/dist/output-gateway/ioc/Di.js.map +1 -1
  48. package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +2 -0
  49. package/dist/output-gateway/ioc/ModuleContainerToken.js +2 -0
  50. package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
  51. package/dist/output-gateway/repositories/AccessLimitationRepository.d.ts +11 -0
  52. package/dist/output-gateway/repositories/AccessLimitationRepository.js +43 -0
  53. package/dist/output-gateway/repositories/AccessLimitationRepository.js.map +1 -0
  54. package/dist/output-gateway/repositories/DevicesRepository.d.ts +4 -3
  55. package/dist/output-gateway/repositories/DevicesRepository.js +19 -5
  56. package/dist/output-gateway/repositories/DevicesRepository.js.map +1 -1
  57. package/dist/output-gateway/repositories/MeasurementRepository.d.ts +3 -2
  58. package/dist/output-gateway/repositories/MeasurementRepository.js +29 -20
  59. package/dist/output-gateway/repositories/MeasurementRepository.js.map +1 -1
  60. package/dist/output-gateway/repositories/OrganizationsRepository.d.ts +3 -3
  61. package/dist/output-gateway/repositories/OrganizationsRepository.js +7 -4
  62. package/dist/output-gateway/repositories/OrganizationsRepository.js.map +1 -1
  63. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.d.ts +4 -3
  64. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js +19 -4
  65. package/dist/output-gateway/repositories/PrimaryBuildingsRepository.js.map +1 -1
  66. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js +2 -2
  67. package/dist/output-gateway/routers/v2/V2BuildingsRouter.js.map +1 -1
  68. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.d.ts +3 -0
  69. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js +18 -0
  70. package/dist/schema-definitions/datasources/AccessConfigurationJsonSchema.js.map +1 -0
  71. package/dist/schema-definitions/datasources/PtasWebScrapingJsonSchema.js +2 -2
  72. package/dist/schema-definitions/datasources/PtasWebScrapingJsonSchema.js.map +1 -1
  73. package/dist/schema-definitions/datasources/interfaces/PtasWebScrapingInput.d.ts +1 -1
  74. package/dist/schema-definitions/models/AccessLimitationModel.d.ts +10 -0
  75. package/dist/schema-definitions/models/AccessLimitationModel.js +32 -0
  76. package/dist/schema-definitions/models/AccessLimitationModel.js.map +1 -0
  77. package/dist/schema-definitions/models/interfaces/IAccessLimitation.d.ts +4 -0
  78. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js +3 -0
  79. package/dist/schema-definitions/models/interfaces/IAccessLimitation.js.map +1 -0
  80. package/docs/implementation_documentation.md +21 -0
  81. package/docs/openapi-input.yaml +2 -2
  82. package/package.json +3 -5
@@ -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.eq]: `/${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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AAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;oBACrC,UAAU,EAAE,CAAC,CAAC,mBAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAS,CAAC,GAAG,CAAC,OAAO,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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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,EAAE;qBACrG;iBACJ,CAAC;gBAEF,OAAO,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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E,EAAE,EAAE;oBACb,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;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,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AA,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,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;QAVE,IAAI,CAAC,2BAA2B,GAAG,IAAI,2DAA4B,EAAE,CAAC;QACtE,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAUY,MAAM;;YACf,IAAI;gBACA,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAwB;oBACtD,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;oBACvB,GAAG,EAAE,IAAI;iBACZ,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;IAEY,UAAU;;YACnB,IAAI;gBACA,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAmE;oBACjG,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,cAAc,EAAE,CAAC;oBACtF,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;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":";;;;;;;;;;;;;;;;;;;;;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;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K,EAAE,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,EAAE;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,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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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,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"}
@@ -4,7 +4,7 @@ exports.ptasWebScrapingJsonSchema = void 0;
4
4
  exports.ptasWebScrapingJsonSchema = {
5
5
  type: "object",
6
6
  properties: {
7
- idOdbernehoMista: { type: "string" },
7
+ placeId: { type: "string" },
8
8
  measurements: {
9
9
  type: "array",
10
10
  items: {
@@ -36,6 +36,6 @@ exports.ptasWebScrapingJsonSchema = {
36
36
  },
37
37
  },
38
38
  },
39
- required: ["idOdbernehoMista", "measurements"],
39
+ required: ["placeId", "measurements"],
40
40
  };
41
41
  //# sourceMappingURL=PtasWebScrapingJsonSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PtasWebScrapingJsonSchema.js","sourceRoot":"","sources":["../../../src/schema-definitions/datasources/PtasWebScrapingJsonSchema.ts"],"names":[],"mappings":";;;AAGa,QAAA,yBAAyB,GAA0C;IAC5E,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpC,YAAY,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,4BAA4B,EAAE;oBACzE,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAChC,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACnC,eAAe,EAAE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QAAQ,EAAE;oBAC/B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC9B,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAChC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAChC,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBACtC;gBACD,QAAQ,EAAE;oBACN,cAAc;oBACd,YAAY;oBACZ,eAAe;oBACf,eAAe;oBACf,QAAQ;oBACR,WAAW;oBACX,UAAU;oBACV,YAAY;oBACZ,YAAY;oBACZ,eAAe;iBAClB;aACJ;SACJ;KACJ;IACD,QAAQ,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC;CACxC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export interface IPtasWebScrapingInput {
2
- idOdbernehoMista: string;
2
+ placeId: string;
3
3
  measurements: IPtasMeasurement[];
4
4
  }
5
5
  export interface IPtasMeasurement {
@@ -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
 
@@ -31,11 +31,11 @@ paths:
31
31
  summary: Receive and save data
32
32
  requestBody:
33
33
  content:
34
- text/plain:
34
+ text/csv:
35
35
  schema:
36
36
  $ref: "#/components/schemas/PtasMeasurement"
37
37
  examples:
38
- text/plain:
38
+ text/csv:
39
39
  summary: Sample data
40
40
  value:
41
41
  "Datum odečtu;Čas odečtu;Výrobní číslo;Druh registru;Odečet;MJ odečtu;MJ zúčt.;OM závislé;Typ odečtu;Status odečtu
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/energetics",
3
- "version": "1.3.8-dev.1347421314",
3
+ "version": "1.3.8-dev.1352571662",
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.3",
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",
@@ -46,8 +46,6 @@
46
46
  "@types/papaparse": "^5.3.14",
47
47
  "@types/sinon": "^9.0.10",
48
48
  "@types/supertest": "^6.0.2",
49
- "body-parser": "^1.20.2",
50
- "body-parser-csv": "^1.1.0",
51
49
  "chai": "4.2.0",
52
50
  "chai-as-promised": "7.1.1",
53
51
  "cross-env": "^7.0.3",