@golemio/energetics 1.12.2-dev.2740928370 → 1.12.2-dev.2741327856

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 (137) hide show
  1. package/db/example/00_clear_test_data.sql +19 -0
  2. package/db/example/06_eno.sql +36 -0
  3. package/db/example/07_enapo_om_detail.sql +140 -0
  4. package/db/example/08_ded_search.sql +25 -0
  5. package/db/migrations/postgresql/20260807090000-enapo-gid-mapping-om-detail.js +53 -0
  6. package/db/migrations/postgresql/20260807091000-enapo-om-detail-porsenna.js +53 -0
  7. package/db/migrations/postgresql/20260807092000-ded-building-search.js +53 -0
  8. package/db/migrations/postgresql/sqls/20260807090000-enapo-gid-mapping-om-detail-down.sql +3 -0
  9. package/db/migrations/postgresql/sqls/20260807090000-enapo-gid-mapping-om-detail-up.sql +182 -0
  10. package/db/migrations/postgresql/sqls/20260807091000-enapo-om-detail-porsenna-down.sql +135 -0
  11. package/db/migrations/postgresql/sqls/20260807091000-enapo-om-detail-porsenna-up.sql +292 -0
  12. package/db/migrations/postgresql/sqls/20260807092000-ded-building-search-down.sql +41 -0
  13. package/db/migrations/postgresql/sqls/20260807092000-ded-building-search-up.sql +262 -0
  14. package/db/scripts/ded_gid_mapping_mock_import.sql +107 -0
  15. package/dist/integration-engine/enapo/ioc/Di.js +5 -1
  16. package/dist/integration-engine/enapo/ioc/Di.js.map +1 -1
  17. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.d.ts +2 -0
  18. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js +2 -0
  19. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js.map +1 -1
  20. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.d.ts +7 -0
  21. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js +50 -0
  22. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js.map +1 -0
  23. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.d.ts +7 -0
  24. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.js +3 -0
  25. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.js.map +1 -0
  26. package/dist/integration-engine/enapo/workers/EnapoWorker.js +1 -0
  27. package/dist/integration-engine/enapo/workers/EnapoWorker.js.map +1 -1
  28. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.d.ts +21 -0
  29. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.js +58 -0
  30. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.js.map +1 -0
  31. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.d.ts +13 -1
  32. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.js +25 -2
  33. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.js.map +1 -1
  34. package/dist/output-gateway/constants/DedSearchWeights.d.ts +60 -0
  35. package/dist/output-gateway/constants/DedSearchWeights.js +42 -0
  36. package/dist/output-gateway/constants/DedSearchWeights.js.map +1 -0
  37. package/dist/output-gateway/constants/Links.d.ts +1 -0
  38. package/dist/output-gateway/constants/Links.js +2 -1
  39. package/dist/output-gateway/constants/Links.js.map +1 -1
  40. package/dist/output-gateway/controllers/v2/EnoBuildingsController.d.ts +16 -0
  41. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js +80 -0
  42. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js.map +1 -0
  43. package/dist/output-gateway/helpers/objectMappers.d.ts +10 -0
  44. package/dist/output-gateway/helpers/objectMappers.js +37 -0
  45. package/dist/output-gateway/helpers/objectMappers.js.map +1 -0
  46. package/dist/output-gateway/index.js +8 -1
  47. package/dist/output-gateway/index.js.map +1 -1
  48. package/dist/output-gateway/ioc/Di.js +13 -1
  49. package/dist/output-gateway/ioc/Di.js.map +1 -1
  50. package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +6 -0
  51. package/dist/output-gateway/ioc/ModuleContainerToken.js +6 -0
  52. package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
  53. package/dist/output-gateway/models/DedBuildingSearchViewModel.d.ts +30 -0
  54. package/dist/output-gateway/models/DedBuildingSearchViewModel.js +38 -0
  55. package/dist/output-gateway/models/DedBuildingSearchViewModel.js.map +1 -0
  56. package/dist/output-gateway/models/EnoBuildingDetailViewModel.d.ts +49 -0
  57. package/dist/output-gateway/models/EnoBuildingDetailViewModel.js +57 -0
  58. package/dist/output-gateway/models/EnoBuildingDetailViewModel.js.map +1 -0
  59. package/dist/output-gateway/models/EnoConsumptionPointViewModel.d.ts +106 -0
  60. package/dist/output-gateway/models/EnoConsumptionPointViewModel.js +119 -0
  61. package/dist/output-gateway/models/EnoConsumptionPointViewModel.js.map +1 -0
  62. package/dist/output-gateway/models/EnoPorsennaDeviceViewModel.d.ts +27 -0
  63. package/dist/output-gateway/models/EnoPorsennaDeviceViewModel.js +41 -0
  64. package/dist/output-gateway/models/EnoPorsennaDeviceViewModel.js.map +1 -0
  65. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.d.ts +24 -0
  66. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.js +3 -0
  67. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.js.map +1 -0
  68. package/dist/output-gateway/models/interfaces/IEnoBuildingDetailView.d.ts +44 -0
  69. package/dist/output-gateway/models/interfaces/IEnoBuildingDetailView.js +3 -0
  70. package/dist/output-gateway/models/interfaces/IEnoBuildingDetailView.js.map +1 -0
  71. package/dist/output-gateway/models/interfaces/IEnoConsumptionPointView.d.ts +106 -0
  72. package/dist/output-gateway/models/interfaces/IEnoConsumptionPointView.js +3 -0
  73. package/dist/output-gateway/models/interfaces/IEnoConsumptionPointView.js.map +1 -0
  74. package/dist/output-gateway/models/interfaces/IEnoPorsennaDeviceView.d.ts +22 -0
  75. package/dist/output-gateway/models/interfaces/IEnoPorsennaDeviceView.js +3 -0
  76. package/dist/output-gateway/models/interfaces/IEnoPorsennaDeviceView.js.map +1 -0
  77. package/dist/output-gateway/repositories/AbstractNumericParsingRepository.d.ts +12 -0
  78. package/dist/output-gateway/repositories/AbstractNumericParsingRepository.js +41 -0
  79. package/dist/output-gateway/repositories/AbstractNumericParsingRepository.js.map +1 -0
  80. package/dist/output-gateway/repositories/DedBuildingSearchRepository.d.ts +16 -0
  81. package/dist/output-gateway/repositories/DedBuildingSearchRepository.js +250 -0
  82. package/dist/output-gateway/repositories/DedBuildingSearchRepository.js.map +1 -0
  83. package/dist/output-gateway/repositories/EnoBuildingAddressesRepository.d.ts +8 -0
  84. package/dist/output-gateway/repositories/EnoBuildingAddressesRepository.js +62 -0
  85. package/dist/output-gateway/repositories/EnoBuildingAddressesRepository.js.map +1 -0
  86. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.d.ts +18 -0
  87. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js +100 -0
  88. package/dist/output-gateway/repositories/EnoBuildingDetailRepository.js.map +1 -0
  89. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.d.ts +8 -0
  90. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js +51 -0
  91. package/dist/output-gateway/repositories/EnoConsumptionPointsRepository.js.map +1 -0
  92. package/dist/output-gateway/repositories/EnoPorsennaDevicesRepository.d.ts +8 -0
  93. package/dist/output-gateway/repositories/EnoPorsennaDevicesRepository.js +51 -0
  94. package/dist/output-gateway/repositories/EnoPorsennaDevicesRepository.js.map +1 -0
  95. package/dist/output-gateway/repositories/PorsennaConsumptionsRepository.d.ts +8 -0
  96. package/dist/output-gateway/repositories/PorsennaConsumptionsRepository.js +52 -0
  97. package/dist/output-gateway/repositories/PorsennaConsumptionsRepository.js.map +1 -0
  98. package/dist/output-gateway/repositories/PpasInvoiceChildRepository.d.ts +13 -0
  99. package/dist/output-gateway/repositories/PpasInvoiceChildRepository.js +39 -0
  100. package/dist/output-gateway/repositories/PpasInvoiceChildRepository.js.map +1 -0
  101. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.d.ts +14 -0
  102. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.js +3 -0
  103. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.js.map +1 -0
  104. package/dist/output-gateway/repositories/interfaces/IEnoBuildingDetailAggregate.d.ts +22 -0
  105. package/dist/output-gateway/repositories/interfaces/IEnoBuildingDetailAggregate.js +3 -0
  106. package/dist/output-gateway/repositories/interfaces/IEnoBuildingDetailAggregate.js.map +1 -0
  107. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.d.ts +50 -0
  108. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.js +3 -0
  109. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.js.map +1 -0
  110. package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.d.ts +130 -0
  111. package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.js +3 -0
  112. package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.js.map +1 -0
  113. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.d.ts +11 -0
  114. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.js +3 -0
  115. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.js.map +1 -0
  116. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.d.ts +11 -0
  117. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js +45 -0
  118. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js.map +1 -0
  119. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.d.ts +11 -0
  120. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.js +57 -0
  121. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.js.map +1 -0
  122. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.d.ts +18 -0
  123. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js +193 -0
  124. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js.map +1 -0
  125. package/dist/schema-definitions/models/enapo/EnapoGidMappingModel.d.ts +17 -0
  126. package/dist/schema-definitions/models/enapo/EnapoGidMappingModel.js +63 -0
  127. package/dist/schema-definitions/models/enapo/EnapoGidMappingModel.js.map +1 -0
  128. package/dist/schema-definitions/models/enapo/interfaces/IEnapoGidMapping.d.ts +11 -0
  129. package/dist/schema-definitions/models/enapo/interfaces/IEnapoGidMapping.js +3 -0
  130. package/dist/schema-definitions/models/enapo/interfaces/IEnapoGidMapping.js.map +1 -0
  131. package/dist/schema-definitions/models/eno/AddressModel.d.ts +1 -1
  132. package/dist/schema-definitions/models/eno/AddressModel.js +1 -1
  133. package/dist/schema-definitions/models/eno/AddressModel.js.map +1 -1
  134. package/dist/schema-definitions/models/eno/interfaces/IAddress.d.ts +1 -1
  135. package/docs/implementation_documentation.md +90 -2
  136. package/docs/openapi-output.yaml +554 -1
  137. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnoPorsennaDeviceView.js","sourceRoot":"","sources":["../../../../src/output-gateway/models/interfaces/IEnoPorsennaDeviceView.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { SequelizeModel } from "@golemio/core/dist/output-gateway";
2
+ /**
3
+ * Base for read repositories over tables/views with NUMERIC or BIGINT columns, which pg returns
4
+ * as strings. Derives the affected columns from the Sequelize attribute definitions and coerces
5
+ * them back to numbers, so `raw: true` rows match the declared model typing.
6
+ */
7
+ export declare abstract class AbstractNumericParsingRepository extends SequelizeModel {
8
+ private numericAttributeNames;
9
+ protected parseNumericColumns: <T extends object>(rows: T[]) => T[];
10
+ protected parseNumericRow: <T extends object>(row: T | null) => T | null;
11
+ private getNumericAttributeNames;
12
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractNumericParsingRepository = void 0;
4
+ const objectMappers_1 = require("../helpers/objectMappers");
5
+ const output_gateway_1 = require("@golemio/core/dist/output-gateway");
6
+ const NUMERIC_TYPE_KEYS = ["DECIMAL", "BIGINT"];
7
+ /**
8
+ * Base for read repositories over tables/views with NUMERIC or BIGINT columns, which pg returns
9
+ * as strings. Derives the affected columns from the Sequelize attribute definitions and coerces
10
+ * them back to numbers, so `raw: true` rows match the declared model typing.
11
+ */
12
+ class AbstractNumericParsingRepository extends output_gateway_1.SequelizeModel {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.numericAttributeNames = null;
16
+ this.parseNumericColumns = (rows) => {
17
+ const keys = this.getNumericAttributeNames();
18
+ if (keys.length === 0) {
19
+ return rows;
20
+ }
21
+ return rows.map((row) => (0, objectMappers_1.parseNumericFields)(row, keys));
22
+ };
23
+ this.parseNumericRow = (row) => {
24
+ return row === null ? null : this.parseNumericColumns([row])[0];
25
+ };
26
+ this.getNumericAttributeNames = () => {
27
+ if (this.numericAttributeNames === null) {
28
+ this.numericAttributeNames = Object.entries(this.sequelizeModel.getAttributes())
29
+ .filter(([, attribute]) => {
30
+ const type = attribute.type;
31
+ const typeKey = typeof type === "string" ? type : type.key;
32
+ return typeKey !== undefined && NUMERIC_TYPE_KEYS.includes(typeKey);
33
+ })
34
+ .map(([name]) => name);
35
+ }
36
+ return this.numericAttributeNames;
37
+ };
38
+ }
39
+ }
40
+ exports.AbstractNumericParsingRepository = AbstractNumericParsingRepository;
41
+ //# sourceMappingURL=AbstractNumericParsingRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AbstractNumericParsingRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/AbstractNumericParsingRepository.ts"],"names":[],"mappings":";;;AAAA,4DAA+D;AAC/D,sEAAmE;AAEnE,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAsB,gCAAiC,SAAQ,+BAAc;IAA7E;;QACY,0BAAqB,GAAoB,IAAI,CAAC;QAE5C,wBAAmB,GAAG,CAAmB,IAAS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16 @@
1
+ import { IDedSearchWeights } from "../constants/DedSearchWeights";
2
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ import { IDedBuildingSearchRow } from "./interfaces/IDedBuildingSearchRow";
4
+ export declare class DedBuildingSearchRepository extends AbstractNumericParsingRepository {
5
+ constructor();
6
+ Search(query: string, limit: number, weights: IDedSearchWeights, exactScore: number): Promise<IDedBuildingSearchRow[]>;
7
+ GetAll(): never;
8
+ GetOne(): never;
9
+ /**
10
+ * Builds a prefix tsquery from the raw input. Splitting the normalised query on everything that
11
+ * is not alphanumeric also strips every tsquery metacharacter, so the input cannot alter the
12
+ * query structure. Returns an empty string when nothing tokenizable remains, which the query
13
+ * handles without calling to_tsquery.
14
+ */
15
+ private buildTsQuery;
16
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DedBuildingSearchRepository = void 0;
13
+ const DedBuildingSearchViewModel_1 = require("../models/DedBuildingSearchViewModel");
14
+ const DedSearchWeights_1 = require("../constants/DedSearchWeights");
15
+ const _sch_1 = require("../../schema-definitions");
16
+ const constants_1 = require("../../schema-definitions/constants");
17
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
18
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
19
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
20
+ const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
21
+ /**
22
+ * Three index-driven candidate tiers - exact identifier (GIN), full-text (GIN on the weighted
23
+ * tsvector) and trigram nearest-neighbour (GiST) - feed a scoring pass over the handful of rows they
24
+ * yield. Scoring uses ts_rank_cd and similarity(), neither of which can use an index, so the small
25
+ * candidate set is what holds the response inside the 500 ms budget.
26
+ */
27
+ const SEARCH_QUERY = `
28
+ WITH q AS (
29
+ SELECT
30
+ lower(public.unaccent($query)) AS norm,
31
+ upper(btrim($query)) AS raw,
32
+ btrim($query) AS verbatim
33
+ ),
34
+ exact AS (
35
+ SELECT
36
+ s.gid,
37
+ CASE
38
+ WHEN s.ean @> ARRAY[q.raw] THEN 'ean'
39
+ WHEN s.eic @> ARRAY[q.raw] THEN 'eic'
40
+ WHEN s.om @> ARRAY[q.raw] THEN 'om'
41
+ ELSE 'gid'
42
+ END AS matched_by,
43
+ CASE
44
+ WHEN s.ean @> ARRAY[q.raw] OR s.eic @> ARRAY[q.raw] OR s.om @> ARRAY[q.raw] THEN q.raw
45
+ ELSE s.gid
46
+ END AS matched_value
47
+ FROM ${constants_1.PG_SCHEMA}.mv_ded_building_search s
48
+ CROSS JOIN q
49
+ WHERE s.ean @> ARRAY[q.raw]
50
+ OR s.eic @> ARRAY[q.raw]
51
+ OR s.om @> ARRAY[q.raw]
52
+ OR s.gid = q.raw
53
+ OR s.gid = q.verbatim
54
+ ),
55
+ fts AS (
56
+ SELECT s.gid
57
+ FROM ${constants_1.PG_SCHEMA}.mv_ded_building_search s
58
+ WHERE $tsQuery <> '' AND s.search_document @@ to_tsquery('simple', $tsQuery)
59
+ ORDER BY ts_rank_cd($tsRank::float4[], s.search_document, to_tsquery('simple', $tsQuery)) DESC,
60
+ s.gid ASC
61
+ LIMIT $ftsCandidates
62
+ ),
63
+ fuzzy AS (
64
+ SELECT s.gid
65
+ FROM ${constants_1.PG_SCHEMA}.mv_ded_building_search s
66
+ CROSS JOIN q
67
+ WHERE NOT EXISTS (SELECT 1 FROM exact)
68
+ ORDER BY s.name_norm <-> q.norm
69
+ LIMIT $fuzzyCandidates
70
+ ),
71
+ candidate AS (
72
+ SELECT gid FROM exact
73
+ UNION
74
+ SELECT gid FROM fts
75
+ UNION
76
+ SELECT gid FROM fuzzy
77
+ ),
78
+ relevance AS (
79
+ SELECT
80
+ s.gid,
81
+ s.nazev,
82
+ s.oznaceni,
83
+ s.ej_id,
84
+ s.ej_kod,
85
+ s.ej_nazev,
86
+ s.ej_typ,
87
+ s.address_main,
88
+ s.addresses,
89
+ s.ean,
90
+ s.eic,
91
+ s.om,
92
+ s.active_points_count,
93
+ s.has_building_record,
94
+ s.name_norm,
95
+ s.address_norm,
96
+ s.geom,
97
+ (e.gid IS NOT NULL) AS is_exact,
98
+ e.matched_by AS exact_matched_by,
99
+ e.matched_value,
100
+ public.similarity(s.name_norm, q.norm) AS name_similarity,
101
+ public.similarity(s.address_norm, q.norm) AS address_similarity,
102
+ $ftsRank::double precision * COALESCE(
103
+ ts_rank_cd(
104
+ $tsRank::float4[],
105
+ s.search_document,
106
+ CASE WHEN $tsQuery = '' THEN NULL ELSE to_tsquery('simple', $tsQuery) END
107
+ ),
108
+ 0
109
+ )
110
+ + $nameTrigram::double precision * public.similarity(s.name_norm, q.norm)
111
+ + $addressTrigram::double precision * public.similarity(s.address_norm, q.norm)
112
+ + $prefixBonus::double precision * (
113
+ CASE WHEN q.norm <> '' AND starts_with(s.name_norm, q.norm) THEN 1 ELSE 0 END
114
+ ) AS relevance
115
+ FROM candidate c
116
+ INNER JOIN ${constants_1.PG_SCHEMA}.mv_ded_building_search s ON s.gid = c.gid
117
+ CROSS JOIN q
118
+ LEFT JOIN exact e ON e.gid = c.gid
119
+ ),
120
+ scored AS (
121
+ SELECT
122
+ r.gid,
123
+ r.nazev,
124
+ r.oznaceni,
125
+ r.ej_id,
126
+ r.ej_kod,
127
+ r.ej_nazev,
128
+ r.ej_typ,
129
+ r.address_main,
130
+ r.addresses,
131
+ r.ean,
132
+ r.eic,
133
+ r.om,
134
+ r.active_points_count,
135
+ r.has_building_record,
136
+ r.name_norm,
137
+ r.address_norm,
138
+ r.is_exact,
139
+ CASE
140
+ WHEN r.is_exact THEN r.exact_matched_by
141
+ WHEN r.name_similarity >= r.address_similarity THEN 'name'
142
+ ELSE 'address'
143
+ END AS matched_by,
144
+ r.matched_value,
145
+ CASE
146
+ WHEN r.is_exact THEN $exactScore::double precision
147
+ WHEN r.relevance <= 0 THEN 0
148
+ ELSE
149
+ (CASE WHEN r.has_building_record THEN 1 ELSE $missingBuildingPenalty::double precision END) * r.relevance
150
+ + $geometryBonus::double precision * (CASE WHEN r.geom IS NOT NULL THEN 1 ELSE 0 END)
151
+ + $activePointsBonus::double precision * least(r.active_points_count, 1)
152
+ END AS score,
153
+ r.geom
154
+ FROM relevance r
155
+ ),
156
+ page AS (
157
+ SELECT
158
+ gid, nazev, oznaceni, ej_id, ej_kod, ej_nazev, ej_typ, address_main, addresses, ean, eic, om,
159
+ active_points_count, has_building_record, name_norm, address_norm,
160
+ is_exact, matched_by, matched_value, score, geom
161
+ FROM scored
162
+ WHERE CASE
163
+ WHEN EXISTS (SELECT 1 FROM exact) THEN is_exact
164
+ ELSE score >= $minScore::double precision
165
+ END
166
+ ORDER BY score DESC, gid ASC
167
+ LIMIT $limit
168
+ )
169
+ SELECT
170
+ gid, nazev, oznaceni, ej_id, ej_kod, ej_nazev, ej_typ, address_main, addresses, ean, eic, om,
171
+ active_points_count, has_building_record, name_norm, address_norm,
172
+ is_exact, matched_by, matched_value, score,
173
+ public.ST_AsGeoJSON(geom)::json AS geometry,
174
+ CASE
175
+ WHEN geom IS NULL THEN NULL
176
+ ELSE ARRAY[
177
+ public.ST_XMin(geom),
178
+ public.ST_YMin(geom),
179
+ public.ST_XMax(geom),
180
+ public.ST_YMax(geom)
181
+ ]
182
+ END AS bbox,
183
+ public.ST_Y(public.ST_Centroid(geom)) AS centroid_lat,
184
+ public.ST_X(public.ST_Centroid(geom)) AS centroid_lon
185
+ FROM page
186
+ ORDER BY score DESC, gid ASC
187
+ `;
188
+ let DedBuildingSearchRepository = class DedBuildingSearchRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
189
+ constructor() {
190
+ super(DedBuildingSearchViewModel_1.DedBuildingSearchViewModel.modelName, DedBuildingSearchViewModel_1.DedBuildingSearchViewModel.tableName, DedBuildingSearchViewModel_1.DedBuildingSearchViewModel.attributeModel, {
191
+ schema: _sch_1.EnergeticsSchema.pgSchema,
192
+ });
193
+ /**
194
+ * Builds a prefix tsquery from the raw input. Splitting the normalised query on everything that
195
+ * is not alphanumeric also strips every tsquery metacharacter, so the input cannot alter the
196
+ * query structure. Returns an empty string when nothing tokenizable remains, which the query
197
+ * handles without calling to_tsquery.
198
+ */
199
+ this.buildTsQuery = (query) => {
200
+ const tokens = query
201
+ .toLowerCase()
202
+ .normalize("NFD")
203
+ .replace(/\p{Diacritic}/gu, "")
204
+ .split(/[^a-z0-9]+/)
205
+ .filter((token) => token.length > 0);
206
+ return tokens.map((token) => `${token}:*`).join(" & ");
207
+ };
208
+ }
209
+ async Search(query, limit, weights, exactScore) {
210
+ try {
211
+ const rows = await this.sequelizeModel.sequelize.query(SEARCH_QUERY, {
212
+ bind: {
213
+ query,
214
+ tsQuery: this.buildTsQuery(query),
215
+ limit,
216
+ exactScore,
217
+ ftsCandidates: DedSearchWeights_1.DED_SEARCH_FTS_CANDIDATES,
218
+ fuzzyCandidates: DedSearchWeights_1.DED_SEARCH_FUZZY_CANDIDATES,
219
+ tsRank: `{${weights.tsRank.join(",")}}`,
220
+ ftsRank: weights.ftsRank,
221
+ nameTrigram: weights.nameTrigram,
222
+ addressTrigram: weights.addressTrigram,
223
+ prefixBonus: weights.prefixBonus,
224
+ geometryBonus: weights.geometryBonus,
225
+ activePointsBonus: weights.activePointsBonus,
226
+ missingBuildingPenalty: weights.missingBuildingPenalty,
227
+ minScore: weights.minScore,
228
+ },
229
+ raw: true,
230
+ type: sequelize_1.QueryTypes.SELECT,
231
+ });
232
+ return this.parseNumericColumns(rows);
233
+ }
234
+ catch (err) {
235
+ throw new golemio_errors_1.GeneralError("Database error ~ Search DedBuildingSearchRepository", this.name, err, 500);
236
+ }
237
+ }
238
+ GetAll() {
239
+ throw new Error("Not implemented");
240
+ }
241
+ GetOne() {
242
+ throw new Error("Not implemented");
243
+ }
244
+ };
245
+ exports.DedBuildingSearchRepository = DedBuildingSearchRepository;
246
+ exports.DedBuildingSearchRepository = DedBuildingSearchRepository = __decorate([
247
+ (0, tsyringe_1.injectable)(),
248
+ __metadata("design:paramtypes", [])
249
+ ], DedBuildingSearchRepository);
250
+ //# sourceMappingURL=DedBuildingSearchRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DedBuildingSearchRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/DedBuildingSearchRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qFAAmF;AACnF,oEAA2H;AAC3H,mDAAwC;AACxC,kEAA2C;AAC3C,6EAAwE;AACxE,mEAAiE;AACjE,iEAAgE;AAChE,yFAAsF;AAGtF;;;;;GAKG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;WAoBV,qBAAS;;;;;;;;;;WAUT,qBAAS;;;;;;;;WAQT,qBAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDH,qBAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEzB,CAAC;AAGK,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,mEAAgC;IAC7E;QACI,KAAK,CACD,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,SAAS,EACpC,uDAA0B,CAAC,cAAc,EACzC;YACI,MAAM,EAAE,uBAAgB,CAA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;iBAC7B;gBACD,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,sBAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,qDAAqD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvG,CAAC;IACL,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CAkBJ,CAAA;AAvEY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,qBAAU,GAAE;;GACA,2BAA2B,CAuEvC"}
@@ -0,0 +1,8 @@
1
+ import { IAddress } from "../../schema-definitions/models/eno/interfaces/IAddress";
2
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ export declare class EnoBuildingAddressesRepository extends AbstractNumericParsingRepository {
4
+ constructor();
5
+ GetByGid(gid: string): Promise<IAddress[]>;
6
+ GetAll(): never;
7
+ GetOne(): never;
8
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EnoBuildingAddressesRepository = void 0;
13
+ const AddressModel_1 = require("../../schema-definitions/models/eno/AddressModel");
14
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
15
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
16
+ const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
17
+ let EnoBuildingAddressesRepository = class EnoBuildingAddressesRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
18
+ constructor() {
19
+ super("EnoBuildingAddressesModelData", AddressModel_1.AddressModel.TABLE_NAME, AddressModel_1.AddressModel.attributeModel, {
20
+ schema: "energetics",
21
+ });
22
+ }
23
+ async GetByGid(gid) {
24
+ try {
25
+ const rows = this.parseNumericColumns((await this.sequelizeModel.findAll({
26
+ where: { gid },
27
+ order: [
28
+ ["hlavni", "DESC"],
29
+ ["poradi", "ASC"],
30
+ ],
31
+ raw: true,
32
+ })));
33
+ const addresses = [];
34
+ const seenPopis = new Set();
35
+ for (const row of rows) {
36
+ if (row.popis === null) {
37
+ addresses.push(row);
38
+ }
39
+ else if (!seenPopis.has(row.popis)) {
40
+ seenPopis.add(row.popis);
41
+ addresses.push(row);
42
+ }
43
+ }
44
+ return addresses;
45
+ }
46
+ catch (err) {
47
+ throw new golemio_errors_1.GeneralError("Database error ~ GetByGid EnoBuildingAddressesRepository", this.name, err, 500);
48
+ }
49
+ }
50
+ GetAll() {
51
+ throw new Error("Not implemented");
52
+ }
53
+ GetOne() {
54
+ throw new Error("Not implemented");
55
+ }
56
+ };
57
+ exports.EnoBuildingAddressesRepository = EnoBuildingAddressesRepository;
58
+ exports.EnoBuildingAddressesRepository = EnoBuildingAddressesRepository = __decorate([
59
+ (0, tsyringe_1.injectable)(),
60
+ __metadata("design:paramtypes", [])
61
+ ], EnoBuildingAddressesRepository);
62
+ //# sourceMappingURL=EnoBuildingAddressesRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnoBuildingAddressesRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoBuildingAddressesRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mFAA4D;AAE5D,6EAAwE;AACxE,iEAAgE;AAChE,yFAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,mEAAgC;IAChF;QACI,KAAK,CAAC,+BAA+B,EAAE,2BAAY,CAAC,UAAU,EAAE,2BAAY,CAAC,cAAc,EAAE;YACzF,MAAM,EAAE,YAAY;SACvB,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAW;QAC7B,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,CACjC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC/B,KAAK,EAAE,EAAE,GAAG,EAAE;gBACd,KAAK,EAAE;oBACH,CAAC,QAAQ,EAAE,MAAM,CAAC;oBAClB,CAAC,QAAQ,EAAE,KAAK,CAAC;iBACpB;gBACD,GAAG,EAAE,IAAI;aACZ,CAAC,CAA0B,CAC/B,CAAC;YAEF,MAAM,SAAS,GAAe,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;YACpC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;oBACrB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC;qBAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACzB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC;YACL,CAAC;YAED,OAAO,SAAS,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,0DAA0D,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5G,CAAC;IACL,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ,CAAA;AA5CY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,qBAAU,GAAE;;GACA,8BAA8B,CA4C1C"}
@@ -0,0 +1,18 @@
1
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
2
+ import { IEnoBuildingDetailAggregate } from "./interfaces/IEnoBuildingDetailAggregate";
3
+ export declare class EnoBuildingDetailRepository extends AbstractNumericParsingRepository {
4
+ private addressesRepository;
5
+ private consumptionPointsRepository;
6
+ private distributionDevicesRepository;
7
+ private distributionPricesRepository;
8
+ private commercialDevicesRepository;
9
+ private commercialPricesRepository;
10
+ private porsennaDevicesRepository;
11
+ private porsennaConsumptionsRepository;
12
+ constructor();
13
+ GetDetail(gid: string): Promise<IEnoBuildingDetailAggregate | null>;
14
+ GetAll(): never;
15
+ GetOne(): never;
16
+ private findBuilding;
17
+ private collectIds;
18
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EnoBuildingDetailRepository = void 0;
13
+ const EnoBuildingDetailViewModel_1 = require("../models/EnoBuildingDetailViewModel");
14
+ const PpasCommercialInvoiceDeviceModel_1 = require("../../schema-definitions/models/enapo/ppas/PpasCommercialInvoiceDeviceModel");
15
+ const PpasCommercialInvoicePriceModel_1 = require("../../schema-definitions/models/enapo/ppas/PpasCommercialInvoicePriceModel");
16
+ const PpasDistributionInvoiceDeviceModel_1 = require("../../schema-definitions/models/enapo/ppas/PpasDistributionInvoiceDeviceModel");
17
+ const PpasDistributionInvoicePriceModel_1 = require("../../schema-definitions/models/enapo/ppas/PpasDistributionInvoicePriceModel");
18
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
19
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
20
+ const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
21
+ const EnoBuildingAddressesRepository_1 = require("./EnoBuildingAddressesRepository");
22
+ const EnoConsumptionPointsRepository_1 = require("./EnoConsumptionPointsRepository");
23
+ const EnoPorsennaDevicesRepository_1 = require("./EnoPorsennaDevicesRepository");
24
+ const PorsennaConsumptionsRepository_1 = require("./PorsennaConsumptionsRepository");
25
+ const PpasInvoiceChildRepository_1 = require("./PpasInvoiceChildRepository");
26
+ let EnoBuildingDetailRepository = class EnoBuildingDetailRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
27
+ constructor() {
28
+ super(EnoBuildingDetailViewModel_1.EnoBuildingDetailViewModel.modelName, EnoBuildingDetailViewModel_1.EnoBuildingDetailViewModel.tableName, EnoBuildingDetailViewModel_1.EnoBuildingDetailViewModel.attributeModel, {
29
+ schema: "energetics",
30
+ });
31
+ this.addressesRepository = new EnoBuildingAddressesRepository_1.EnoBuildingAddressesRepository();
32
+ this.consumptionPointsRepository = new EnoConsumptionPointsRepository_1.EnoConsumptionPointsRepository();
33
+ this.distributionDevicesRepository = new PpasInvoiceChildRepository_1.PpasInvoiceChildRepository("EnoPpasDistributionInvoiceDeviceModelData", PpasDistributionInvoiceDeviceModel_1.PpasDistributionInvoiceDeviceModel.TABLE_NAME, PpasDistributionInvoiceDeviceModel_1.PpasDistributionInvoiceDeviceModel.attributeModel);
34
+ this.distributionPricesRepository = new PpasInvoiceChildRepository_1.PpasInvoiceChildRepository("EnoPpasDistributionInvoicePriceModelData", PpasDistributionInvoicePriceModel_1.PpasDistributionInvoicePriceModel.TABLE_NAME, PpasDistributionInvoicePriceModel_1.PpasDistributionInvoicePriceModel.attributeModel);
35
+ this.commercialDevicesRepository = new PpasInvoiceChildRepository_1.PpasInvoiceChildRepository("EnoPpasCommercialInvoiceDeviceModelData", PpasCommercialInvoiceDeviceModel_1.PpasCommercialInvoiceDeviceModel.TABLE_NAME, PpasCommercialInvoiceDeviceModel_1.PpasCommercialInvoiceDeviceModel.attributeModel);
36
+ this.commercialPricesRepository = new PpasInvoiceChildRepository_1.PpasInvoiceChildRepository("EnoPpasCommercialInvoicePriceModelData", PpasCommercialInvoicePriceModel_1.PpasCommercialInvoicePriceModel.TABLE_NAME, PpasCommercialInvoicePriceModel_1.PpasCommercialInvoicePriceModel.attributeModel);
37
+ this.porsennaDevicesRepository = new EnoPorsennaDevicesRepository_1.EnoPorsennaDevicesRepository();
38
+ this.porsennaConsumptionsRepository = new PorsennaConsumptionsRepository_1.PorsennaConsumptionsRepository();
39
+ }
40
+ async GetDetail(gid) {
41
+ const [building, addresses, points, porsennaDevices] = await Promise.all([
42
+ this.findBuilding(gid),
43
+ this.addressesRepository.GetByGid(gid),
44
+ this.consumptionPointsRepository.GetByGid(gid),
45
+ this.porsennaDevicesRepository.GetByGid(gid),
46
+ ]);
47
+ if (building === null && addresses.length === 0 && points.length === 0 && porsennaDevices.length === 0) {
48
+ return null;
49
+ }
50
+ const distributionInvoiceIds = this.collectIds(points.map((point) => point.di_id));
51
+ const commercialInvoiceIds = this.collectIds(points.map((point) => point.ci_id));
52
+ const porsennaDeviceIds = this.collectIds(porsennaDevices.map((device) => device.device_id));
53
+ const [distributionDevices, distributionPrices, commercialDevices, commercialPrices, porsennaConsumption] = await Promise.all([
54
+ this.distributionDevicesRepository.GetByInvoiceIds(distributionInvoiceIds),
55
+ this.distributionPricesRepository.GetByInvoiceIds(distributionInvoiceIds),
56
+ this.commercialDevicesRepository.GetByInvoiceIds(commercialInvoiceIds),
57
+ this.commercialPricesRepository.GetByInvoiceIds(commercialInvoiceIds),
58
+ this.porsennaConsumptionsRepository.GetByDeviceIds(porsennaDeviceIds),
59
+ ]);
60
+ return {
61
+ gid,
62
+ building,
63
+ addresses,
64
+ points,
65
+ distributionDevices,
66
+ distributionPrices,
67
+ commercialDevices,
68
+ commercialPrices,
69
+ porsennaDevices,
70
+ porsennaConsumption,
71
+ };
72
+ }
73
+ GetAll() {
74
+ throw new Error("Not implemented");
75
+ }
76
+ GetOne() {
77
+ throw new Error("Not implemented");
78
+ }
79
+ async findBuilding(gid) {
80
+ try {
81
+ const row = (await this.sequelizeModel.findOne({
82
+ where: { gid },
83
+ raw: true,
84
+ }));
85
+ return this.parseNumericRow(row);
86
+ }
87
+ catch (err) {
88
+ throw new golemio_errors_1.GeneralError("Database error ~ GetDetail EnoBuildingDetailRepository", this.name, err, 500);
89
+ }
90
+ }
91
+ collectIds(ids) {
92
+ return [...new Set(ids.filter((id) => id !== null))];
93
+ }
94
+ };
95
+ exports.EnoBuildingDetailRepository = EnoBuildingDetailRepository;
96
+ exports.EnoBuildingDetailRepository = EnoBuildingDetailRepository = __decorate([
97
+ (0, tsyringe_1.injectable)(),
98
+ __metadata("design:paramtypes", [])
99
+ ], EnoBuildingDetailRepository);
100
+ //# sourceMappingURL=EnoBuildingDetailRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnoBuildingDetailRepository.js","sourceRoot":"","sources":["../../../src/output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"../models/interfaces/IEnoConsumptionPointView";
2
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ export declare class EnoConsumptionPointsRepository extends AbstractNumericParsingRepository {
4
+ constructor();
5
+ GetByGid(gid: string): Promise<IEnoConsumptionPointView[]>;
6
+ GetAll(): never;
7
+ GetOne(): never;
8
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EnoConsumptionPointsRepository = void 0;
13
+ const EnoConsumptionPointViewModel_1 = require("../models/EnoConsumptionPointViewModel");
14
+ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
15
+ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
16
+ const AbstractNumericParsingRepository_1 = require("./AbstractNumericParsingRepository");
17
+ let EnoConsumptionPointsRepository = class EnoConsumptionPointsRepository extends AbstractNumericParsingRepository_1.AbstractNumericParsingRepository {
18
+ constructor() {
19
+ super(EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.modelName, EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.tableName, EnoConsumptionPointViewModel_1.EnoConsumptionPointViewModel.attributeModel, {
20
+ schema: "energetics",
21
+ });
22
+ }
23
+ async GetByGid(gid) {
24
+ try {
25
+ const rows = (await this.sequelizeModel.findAll({
26
+ where: { gid },
27
+ order: [
28
+ ["commodity", "ASC"],
29
+ ["place_id", "ASC"],
30
+ ],
31
+ raw: true,
32
+ }));
33
+ return this.parseNumericColumns(rows);
34
+ }
35
+ catch (err) {
36
+ throw new golemio_errors_1.GeneralError("Database error ~ GetByGid EnoConsumptionPointsRepository", this.name, err, 500);
37
+ }
38
+ }
39
+ GetAll() {
40
+ throw new Error("Not implemented");
41
+ }
42
+ GetOne() {
43
+ throw new Error("Not implemented");
44
+ }
45
+ };
46
+ exports.EnoConsumptionPointsRepository = EnoConsumptionPointsRepository;
47
+ exports.EnoConsumptionPointsRepository = EnoConsumptionPointsRepository = __decorate([
48
+ (0, tsyringe_1.injectable)(),
49
+ __metadata("design:paramtypes", [])
50
+ ], EnoConsumptionPointsRepository);
51
+ //# sourceMappingURL=EnoConsumptionPointsRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnoConsumptionPointsRepository.js","sourceRoot":"","sources":["../../../src/output-gateway/repositories/EnoConsumptionPointsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yFAAuF;AAEvF,6EAAwE;AACxE,iEAAgE;AAChE,yFAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,mEAAgC;IAChF;QACI,KAAK,CACD,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,SAAS,EACtC,2DAA4B,CAAC,cAAc,EAC3C;YACI,MAAM,EAAE,YAAY;SACvB,CACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAW;QAC7B,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC5C,KAAK,EAAE,EAAE,GAAG,EAAE;gBACd,KAAK,EAAE;oBACH,CAAC,WAAW,EAAE,KAAK,CAAC;oBACpB,CAAC,UAAU,EAAE,KAAK,CAAC;iBACtB;gBACD,GAAG,EAAE,IAAI;aACZ,CAAC,CAA0C,CAAC;YAE7C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,6BAAY,CAAC,0DAA0D,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5G,CAAC;IACL,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ,CAAA;AApCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,qBAAU,GAAE;;GACA,8BAA8B,CAoC1C"}
@@ -0,0 +1,8 @@
1
+ import { IEnoPorsennaDeviceView } from "../models/interfaces/IEnoPorsennaDeviceView";
2
+ import { AbstractNumericParsingRepository } from "./AbstractNumericParsingRepository";
3
+ export declare class EnoPorsennaDevicesRepository extends AbstractNumericParsingRepository {
4
+ constructor();
5
+ GetByGid(gid: string): Promise<IEnoPorsennaDeviceView[]>;
6
+ GetAll(): never;
7
+ GetOne(): never;
8
+ }