@golemio/energetics 1.12.2-dev.2740931754 → 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 (72) hide show
  1. package/db/example/00_clear_test_data.sql +5 -0
  2. package/db/example/06_eno.sql +11 -0
  3. package/db/example/08_ded_search.sql +25 -0
  4. package/db/migrations/postgresql/20260807092000-ded-building-search.js +53 -0
  5. package/db/migrations/postgresql/sqls/20260807092000-ded-building-search-down.sql +41 -0
  6. package/db/migrations/postgresql/sqls/20260807092000-ded-building-search-up.sql +262 -0
  7. package/db/scripts/ded_gid_mapping_mock_import.sql +82 -23
  8. package/dist/integration-engine/enapo/ioc/Di.js +5 -1
  9. package/dist/integration-engine/enapo/ioc/Di.js.map +1 -1
  10. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.d.ts +2 -0
  11. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js +2 -0
  12. package/dist/integration-engine/enapo/ioc/EnapoWorkerContainerToken.js.map +1 -1
  13. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.d.ts +7 -0
  14. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js +50 -0
  15. package/dist/integration-engine/enapo/repositories/DedSearchIndexRepository.js.map +1 -0
  16. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.d.ts +7 -0
  17. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.js +3 -0
  18. package/dist/integration-engine/enapo/repositories/interfaces/IDedSearchIndexRepository.js.map +1 -0
  19. package/dist/integration-engine/enapo/workers/EnapoWorker.js +1 -0
  20. package/dist/integration-engine/enapo/workers/EnapoWorker.js.map +1 -1
  21. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.d.ts +21 -0
  22. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.js +58 -0
  23. package/dist/integration-engine/enapo/workers/task/DedSearchIndexRefreshTask.js.map +1 -0
  24. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.d.ts +13 -1
  25. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.js +25 -2
  26. package/dist/integration-engine/enapo/workers/task/EnoGeometryTask.js.map +1 -1
  27. package/dist/output-gateway/constants/DedSearchWeights.d.ts +60 -0
  28. package/dist/output-gateway/constants/DedSearchWeights.js +42 -0
  29. package/dist/output-gateway/constants/DedSearchWeights.js.map +1 -0
  30. package/dist/output-gateway/controllers/v2/EnoBuildingsController.d.ts +6 -1
  31. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js +29 -2
  32. package/dist/output-gateway/controllers/v2/EnoBuildingsController.js.map +1 -1
  33. package/dist/output-gateway/ioc/Di.js +5 -1
  34. package/dist/output-gateway/ioc/Di.js.map +1 -1
  35. package/dist/output-gateway/ioc/ModuleContainerToken.d.ts +2 -0
  36. package/dist/output-gateway/ioc/ModuleContainerToken.js +2 -0
  37. package/dist/output-gateway/ioc/ModuleContainerToken.js.map +1 -1
  38. package/dist/output-gateway/models/DedBuildingSearchViewModel.d.ts +30 -0
  39. package/dist/output-gateway/models/DedBuildingSearchViewModel.js +38 -0
  40. package/dist/output-gateway/models/DedBuildingSearchViewModel.js.map +1 -0
  41. package/dist/output-gateway/models/EnoBuildingDetailViewModel.d.ts +14 -0
  42. package/dist/output-gateway/models/EnoBuildingDetailViewModel.js +14 -0
  43. package/dist/output-gateway/models/EnoBuildingDetailViewModel.js.map +1 -1
  44. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.d.ts +24 -0
  45. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.js +3 -0
  46. package/dist/output-gateway/models/interfaces/IDedBuildingSearchView.js.map +1 -0
  47. package/dist/output-gateway/models/interfaces/IEnoBuildingDetailView.d.ts +14 -0
  48. package/dist/output-gateway/repositories/DedBuildingSearchRepository.d.ts +16 -0
  49. package/dist/output-gateway/repositories/DedBuildingSearchRepository.js +250 -0
  50. package/dist/output-gateway/repositories/DedBuildingSearchRepository.js.map +1 -0
  51. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.d.ts +14 -0
  52. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.js +3 -0
  53. package/dist/output-gateway/repositories/interfaces/IDedBuildingSearchRow.js.map +1 -0
  54. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.d.ts +50 -0
  55. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.js +3 -0
  56. package/dist/output-gateway/routers/interfaces/IDedBuildingSearchResponse.js.map +1 -0
  57. package/dist/output-gateway/routers/interfaces/IEnoBuildingDetailResponse.d.ts +23 -1
  58. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.d.ts +11 -0
  59. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.js +3 -0
  60. package/dist/output-gateway/routers/interfaces/IEnoRegistrationUnit.js.map +1 -0
  61. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.d.ts +2 -0
  62. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js +5 -0
  63. package/dist/output-gateway/routers/v2/V2EnoBuildingsRouter.js.map +1 -1
  64. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.d.ts +11 -0
  65. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.js +57 -0
  66. package/dist/output-gateway/transformations/DedBuildingSearchTransformation.js.map +1 -0
  67. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.d.ts +4 -0
  68. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js +44 -1
  69. package/dist/output-gateway/transformations/EnoBuildingDetailTransformation.js.map +1 -1
  70. package/docs/implementation_documentation.md +49 -0
  71. package/docs/openapi-output.yaml +291 -0
  72. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DedBuildingSearchViewModel = void 0;
4
+ const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
5
+ /**
6
+ * Model over the mv_ded_building_search materialized view. The search itself runs as a single raw
7
+ * query (weighted ranking is not expressible through the query builder); this model exists so the
8
+ * repository inherits the numeric column parsing and the schema binding.
9
+ * The search_document and geom columns are intentionally not declared - they are never selected as
10
+ * values, only used inside the query.
11
+ */
12
+ class DedBuildingSearchViewModel extends sequelize_1.Model {
13
+ }
14
+ exports.DedBuildingSearchViewModel = DedBuildingSearchViewModel;
15
+ DedBuildingSearchViewModel.tableName = "mv_ded_building_search";
16
+ DedBuildingSearchViewModel.modelName = "DedBuildingSearchViewModelData";
17
+ DedBuildingSearchViewModel.attributeModel = {
18
+ gid: {
19
+ primaryKey: true,
20
+ type: sequelize_1.DataTypes.TEXT,
21
+ },
22
+ nazev: sequelize_1.DataTypes.TEXT,
23
+ oznaceni: sequelize_1.DataTypes.TEXT,
24
+ ej_id: sequelize_1.DataTypes.INTEGER,
25
+ ej_kod: sequelize_1.DataTypes.TEXT,
26
+ ej_nazev: sequelize_1.DataTypes.TEXT,
27
+ ej_typ: sequelize_1.DataTypes.TEXT,
28
+ address_main: sequelize_1.DataTypes.TEXT,
29
+ addresses: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.TEXT),
30
+ ean: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.TEXT),
31
+ eic: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.TEXT),
32
+ om: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.TEXT),
33
+ active_points_count: sequelize_1.DataTypes.BIGINT,
34
+ has_building_record: sequelize_1.DataTypes.BOOLEAN,
35
+ name_norm: sequelize_1.DataTypes.TEXT,
36
+ address_norm: sequelize_1.DataTypes.TEXT,
37
+ };
38
+ //# sourceMappingURL=DedBuildingSearchViewModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DedBuildingSearchViewModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/DedBuildingSearchViewModel.ts"],"names":[],"mappings":";;;AAAA,mEAAwF;AAGxF;;;;;;GAMG;AACH,MAAa,0BAA2B,SAAQ,iBAA6B;;AAA7E,gEA0CC;AAzCiB,oCAAS,GAAG,wBAAwB,CAAC;AACrC,oCAAS,GAAG,gCAAgC,CAAC;AAmB7C,yCAAc,GAAwE;IAChG,GAAG,EAAE;QACD,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,IAAI;KACvB;IACD,KAAK,EAAE,qBAAS,CAAC,IAAI;IACrB,QAAQ,EAAE,qBAAS,CAAC,IAAI;IACxB,KAAK,EAAE,qBAAS,CAAC,OAAO;IACxB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,QAAQ,EAAE,qBAAS,CAAC,IAAI;IACxB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,YAAY,EAAE,qBAAS,CAAC,IAAI;IAC5B,SAAS,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC;IAC1C,GAAG,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC;IACpC,GAAG,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC;IACpC,EAAE,EAAE,qBAAS,CAAC,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC;IACnC,mBAAmB,EAAE,qBAAS,CAAC,MAAM;IACrC,mBAAmB,EAAE,qBAAS,CAAC,OAAO;IACtC,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,YAAY,EAAE,qBAAS,CAAC,IAAI;CAC/B,CAAC"}
@@ -31,5 +31,19 @@ export declare class EnoBuildingDetailViewModel extends Model<IEnoBuildingDetail
31
31
  kod_ochrana: string | null;
32
32
  nazev_ochrana: string | null;
33
33
  platnost_od: Date | null;
34
+ ej_id: number | null;
35
+ ej_kod: string | null;
36
+ ej_nazev: string | null;
37
+ ej_typ: string | null;
38
+ spm_id: number | null;
39
+ spm_kod: string | null;
40
+ spm_nazev: string | null;
41
+ spm_ic: string | null;
42
+ spm_dic: string | null;
43
+ spu_id: number | null;
44
+ spu_kod: string | null;
45
+ spu_nazev: string | null;
46
+ spu_ic: string | null;
47
+ spu_dic: string | null;
34
48
  static attributeModel: ModelAttributes<EnoBuildingDetailViewModel, IEnoBuildingDetailView>;
35
49
  }
@@ -39,5 +39,19 @@ EnoBuildingDetailViewModel.attributeModel = {
39
39
  kod_ochrana: sequelize_1.DataTypes.TEXT,
40
40
  nazev_ochrana: sequelize_1.DataTypes.TEXT,
41
41
  platnost_od: sequelize_1.DataTypes.DATE,
42
+ ej_id: sequelize_1.DataTypes.INTEGER,
43
+ ej_kod: sequelize_1.DataTypes.TEXT,
44
+ ej_nazev: sequelize_1.DataTypes.TEXT,
45
+ ej_typ: sequelize_1.DataTypes.TEXT,
46
+ spm_id: sequelize_1.DataTypes.INTEGER,
47
+ spm_kod: sequelize_1.DataTypes.TEXT,
48
+ spm_nazev: sequelize_1.DataTypes.TEXT,
49
+ spm_ic: sequelize_1.DataTypes.TEXT,
50
+ spm_dic: sequelize_1.DataTypes.TEXT,
51
+ spu_id: sequelize_1.DataTypes.INTEGER,
52
+ spu_kod: sequelize_1.DataTypes.TEXT,
53
+ spu_nazev: sequelize_1.DataTypes.TEXT,
54
+ spu_ic: sequelize_1.DataTypes.TEXT,
55
+ spu_dic: sequelize_1.DataTypes.TEXT,
42
56
  };
43
57
  //# sourceMappingURL=EnoBuildingDetailViewModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnoBuildingDetailViewModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/EnoBuildingDetailViewModel.ts"],"names":[],"mappings":";;;AAAA,mEAAwF;AAGxF,MAAa,0BAA2B,SAAQ,iBAA6B;;AAA7E,gEAkEC;AAjEiB,oCAAS,GAAG,yBAAyB,CAAC;AACtC,oCAAS,GAAG,gCAAgC,CAAC;AA+B7C,yCAAc,GAAwE;IAChG,GAAG,EAAE;QACD,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,qBAAS,CAAC,IAAI;KACvB;IACD,KAAK,EAAE,qBAAS,CAAC,IAAI;IACrB,KAAK,EAAE,qBAAS,CAAC,IAAI;IACrB,QAAQ,EAAE,qBAAS,CAAC,IAAI;IACxB,aAAa,EAAE,qBAAS,CAAC,IAAI;IAC7B,gBAAgB,EAAE,qBAAS,CAAC,IAAI;IAChC,aAAa,EAAE,qBAAS,CAAC,IAAI;IAC7B,mBAAmB,EAAE,qBAAS,CAAC,IAAI;IACnC,0BAA0B,EAAE,qBAAS,CAAC,IAAI;IAC1C,qBAAqB,EAAE,qBAAS,CAAC,OAAO;IACxC,yBAAyB,EAAE,qBAAS,CAAC,OAAO;IAC5C,2BAA2B,EAAE,qBAAS,CAAC,OAAO;IAC9C,gBAAgB,EAAE,qBAAS,CAAC,OAAO;IACnC,kBAAkB,EAAE,qBAAS,CAAC,OAAO;IACrC,SAAS,EAAE,qBAAS,CAAC,OAAO;IAC5B,kBAAkB,EAAE,qBAAS,CAAC,OAAO;IACrC,oBAAoB,EAAE,qBAAS,CAAC,OAAO;IACvC,oBAAoB,EAAE,qBAAS,CAAC,OAAO;IACvC,cAAc,EAAE,qBAAS,CAAC,OAAO;IACjC,KAAK,EAAE,qBAAS,CAAC,OAAO;IACxB,IAAI,EAAE,qBAAS,CAAC,OAAO;IACvB,OAAO,EAAE,qBAAS,CAAC,MAAM;IACzB,SAAS,EAAE,qBAAS,CAAC,OAAO;IAC5B,WAAW,EAAE,qBAAS,CAAC,IAAI;IAC3B,aAAa,EAAE,qBAAS,CAAC,IAAI;IAC7B,WAAW,EAAE,qBAAS,CAAC,IAAI;IAC3B,aAAa,EAAE,qBAAS,CAAC,IAAI;IAC7B,WAAW,EAAE,qBAAS,CAAC,IAAI;CAC9B,CAAC"}
1
+ {"version":3,"file":"EnoBuildingDetailViewModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/EnoBuildingDetailViewModel.ts"],"names":[],"mappings":";;;AAAA,mEAAwF;AAGxF,MAAa,0BAA2B,SAAQ,iBAA6B;;AAA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AI;IAC3B,KAAK,EAAE,qBAAS,CAAC,OAAO;IACxB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,QAAQ,EAAE,qBAAS,CAAC,IAAI;IACxB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,MAAM,EAAE,qBAAS,CAAC,OAAO;IACzB,OAAO,EAAE,qBAAS,CAAC,IAAI;IACvB,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,OAAO,EAAE,qBAAS,CAAC,IAAI;IACvB,MAAM,EAAE,qBAAS,CAAC,OAAO;IACzB,OAAO,EAAE,qBAAS,CAAC,IAAI;IACvB,SAAS,EAAE,qBAAS,CAAC,IAAI;IACzB,MAAM,EAAE,qBAAS,CAAC,IAAI;IACtB,OAAO,EAAE,qBAAS,CAAC,IAAI;CAC1B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Row of the mv_ded_building_search materialized view - one building GID with everything the DeD
3
+ * search endpoint needs: the weighted search vector, the normalised columns backing the trigram
4
+ * match, the consumption point identifiers used for exact matching and the building geometry
5
+ * (already stored in EPSG:4326).
6
+ */
7
+ export interface IDedBuildingSearchView {
8
+ gid: string;
9
+ nazev: string | null;
10
+ oznaceni: string | null;
11
+ ej_id: number | null;
12
+ ej_kod: string | null;
13
+ ej_nazev: string | null;
14
+ ej_typ: string | null;
15
+ address_main: string | null;
16
+ addresses: string[];
17
+ ean: string[];
18
+ eic: string[];
19
+ om: string[];
20
+ active_points_count: number;
21
+ has_building_record: boolean;
22
+ name_norm: string;
23
+ address_norm: string;
24
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IDedBuildingSearchView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDedBuildingSearchView.js","sourceRoot":"","sources":["../../../../src/output-gateway/models/interfaces/IDedBuildingSearchView.ts"],"names":[],"mappings":""}
@@ -27,4 +27,18 @@ export interface IEnoBuildingDetailView {
27
27
  kod_ochrana: string | null;
28
28
  nazev_ochrana: string | null;
29
29
  platnost_od: Date | null;
30
+ ej_id: number | null;
31
+ ej_kod: string | null;
32
+ ej_nazev: string | null;
33
+ ej_typ: string | null;
34
+ spm_id: number | null;
35
+ spm_kod: string | null;
36
+ spm_nazev: string | null;
37
+ spm_ic: string | null;
38
+ spm_dic: string | null;
39
+ spu_id: number | null;
40
+ spu_kod: string | null;
41
+ spu_nazev: string | null;
42
+ spu_ic: string | null;
43
+ spu_dic: string | null;
30
44
  }
@@ -0,0 +1,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;;;;;;;;WAQ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AE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;oBACvC,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,cAAc,EAAE,OAAO,CAAC,cAAc;oBACtC,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,aAAa,EAAE,OAAO,CAAC,aAAa;oBACpC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;oBAC5C,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;oBACtD,QAAQ,EAAE,OAAO,CAAC,QAAQ;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,14 @@
1
+ import { IDedBuildingSearchView } from "../../models/interfaces/IDedBuildingSearchView";
2
+ import { DedSearchMatchedBy, IDedGeoJsonGeometry } from "../../routers/interfaces/IDedBuildingSearchResponse";
3
+ /** Scored row returned by the DeD building search query. */
4
+ export interface IDedBuildingSearchRow extends IDedBuildingSearchView {
5
+ /** True when the row came from the exact identifier or GID tier, reported by the query itself. */
6
+ is_exact: boolean;
7
+ matched_by: DedSearchMatchedBy;
8
+ matched_value: string | null;
9
+ score: number;
10
+ geometry: IDedGeoJsonGeometry | null;
11
+ bbox: [number, number, number, number] | null;
12
+ centroid_lat: number | null;
13
+ centroid_lon: number | null;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IDedBuildingSearchRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDedBuildingSearchRow.js","sourceRoot":"","sources":["../../../../src/output-gateway/repositories/interfaces/IDedBuildingSearchRow.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { IEnoRegistrationUnit } from "./IEnoRegistrationUnit";
2
+ /** Which field produced the hit. Identifier and GID values come from the exact match tier. */
3
+ export type DedSearchMatchedBy = "ean" | "eic" | "om" | "gid" | "name" | "address";
4
+ /** Nested coordinate array of a GeoJSON geometry. */
5
+ export type DedGeoJsonCoordinates = number[] | DedGeoJsonCoordinates[];
6
+ export interface IDedGeoJsonGeometry {
7
+ type: string;
8
+ coordinates: DedGeoJsonCoordinates;
9
+ }
10
+ export interface IDedCentroid {
11
+ lat: number;
12
+ lon: number;
13
+ }
14
+ export interface IDedBuildingSearchResult {
15
+ gid: string;
16
+ name: string | null;
17
+ designation: string | null;
18
+ /**
19
+ * Evidenční jednotka, null when the building has no majetek record. Deliberately the same shape
20
+ * as on the building detail endpoint so a client can reuse one type across both.
21
+ */
22
+ registration_unit: IEnoRegistrationUnit | null;
23
+ /** Main address of the building (eno_adresa.hlavni), null when the building has no address. */
24
+ address: string | null;
25
+ /** Every distinct address of the building, main one first. */
26
+ addresses: string[];
27
+ matched_by: DedSearchMatchedBy;
28
+ /** The identifier that matched, present only for exact matches. */
29
+ matched_value: string | null;
30
+ score: number;
31
+ identifiers: {
32
+ ean: string[];
33
+ eic: string[];
34
+ om: string[];
35
+ };
36
+ /** Building outline in EPSG:4326, null when the building has no usable geometry. */
37
+ geometry: IDedGeoJsonGeometry | null;
38
+ /** [minLon, minLat, maxLon, maxLat] in EPSG:4326, for zooming the map. */
39
+ bbox: [number, number, number, number] | null;
40
+ centroid: IDedCentroid | null;
41
+ geometry_source: string | null;
42
+ has_building_record: boolean;
43
+ active_points_count: number;
44
+ }
45
+ export interface IDedBuildingSearchResponse {
46
+ query: string;
47
+ /** True when at least one result came from the exact identifier or GID tier. */
48
+ matched_exactly: boolean;
49
+ results: IDedBuildingSearchResult[];
50
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IDedBuildingSearchResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDedBuildingSearchResponse.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/interfaces/IDedBuildingSearchResponse.ts"],"names":[],"mappings":""}
@@ -6,6 +6,7 @@ import { IPpasCommercialInvoicePrice } from "../../../schema-definitions/models/
6
6
  import { IPpasDistributionInvoiceDevice } from "../../../schema-definitions/models/enapo/ppas/interfaces/IPpasDistributionInvoiceDevice";
7
7
  import { IPpasDistributionInvoicePrice } from "../../../schema-definitions/models/enapo/ppas/interfaces/IPpasDistributionInvoicePrice";
8
8
  import { EnapoCommodity } from "../../../schema-definitions/models/enapo/interfaces/IEnapoGidMapping";
9
+ import { IEnoRegistrationUnit } from "./IEnoRegistrationUnit";
9
10
  export type TEnoElectricityMetadata = StripPrefix<IEnoConsumptionPointView, "md_">;
10
11
  export type TEnoDistributionInvoice = StripPrefix<IEnoConsumptionPointView, "di_">;
11
12
  export type TEnoDistributionInstallation = Omit<StripPrefix<IEnoConsumptionPointView, "dinst_">, "place_id">;
@@ -97,10 +98,31 @@ export interface IEnoBuildingAddressResponse {
97
98
  hlavni: boolean | null;
98
99
  poradi: number;
99
100
  }
101
+ /** eno_budova physical attributes only; the eno_ciselnik lookups live under `property`. */
102
+ export type TEnoBuildingPhysical = Omit<IEnoBuildingDetailView, "gid" | "ej_id" | "ej_kod" | "ej_nazev" | "ej_typ" | "spm_id" | "spm_kod" | "spm_nazev" | "spm_ic" | "spm_dic" | "spu_id" | "spu_kod" | "spu_nazev" | "spu_ic" | "spu_dic">;
103
+ /** Správce (eno_ciselnik_spravce). */
104
+ export interface IEnoManager {
105
+ id: number | null;
106
+ kod: string | null;
107
+ nazev: string | null;
108
+ ic: string | null;
109
+ dic: string | null;
110
+ }
111
+ export interface IEnoBuildingProperty {
112
+ registration_unit: IEnoRegistrationUnit | null;
113
+ managers: {
114
+ /** eno_majetek.id_maj_spravce_mandatni */
115
+ mandate: IEnoManager | null;
116
+ /** eno_majetek.id_maj_spravce_ucet_jednotka */
117
+ accounting_unit: IEnoManager | null;
118
+ };
119
+ }
100
120
  export interface IEnoBuildingDetailResponse {
101
121
  gid: string;
102
122
  /** null when the GID has no eno_budova record (known only to the OM mapping or Porsenna) */
103
- building: Omit<IEnoBuildingDetailView, "gid"> | null;
123
+ building: TEnoBuildingPhysical | null;
124
+ /** ENO lookup data resolved through eno_majetek; null when the building has no majetek record */
125
+ property: IEnoBuildingProperty | null;
104
126
  addresses: IEnoBuildingAddressResponse[];
105
127
  /** null when the building is not tracked in Porsenna (e-manazer) */
106
128
  energy_management: IEnoEnergyManagement | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Evidenční jednotka (eno_ciselnik_evidencni_jednotka), resolved through the building's eno_majetek
3
+ * record. Shared by the building detail and the building search so a client can reuse one type for
4
+ * both; null on either endpoint means the building has no majetek record.
5
+ */
6
+ export interface IEnoRegistrationUnit {
7
+ id: number | null;
8
+ kod: string | null;
9
+ nazev: string | null;
10
+ typ: string | null;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IEnoRegistrationUnit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnoRegistrationUnit.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/interfaces/IEnoRegistrationUnit.ts"],"names":[],"mappings":""}
@@ -4,6 +4,8 @@ export declare class V2EnoBuildingsRouter extends AbstractRouter {
4
4
  private cacheHeaderMiddleware;
5
5
  private maxAge;
6
6
  private staleWhileRevalidate;
7
+ private searchMaxAge;
8
+ private searchStaleWhileRevalidate;
7
9
  constructor();
8
10
  protected initRoutes(): void;
9
11
  }
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.V2EnoBuildingsRouter = void 0;
13
+ const DedSearchWeights_1 = require("../../constants/DedSearchWeights");
13
14
  const Links_1 = require("../../constants/Links");
14
15
  const RouteVersion_1 = require("../../constants/RouteVersion");
15
16
  const Di_1 = require("../../ioc/Di");
@@ -24,11 +25,15 @@ let V2EnoBuildingsRouter = class V2EnoBuildingsRouter extends AbstractRouter_1.A
24
25
  super(RouteVersion_1.RouteVersion.v2, Links_1.DED_BUILDING_PATH);
25
26
  this.maxAge = 6 * 60 * 60; // 6 hours
26
27
  this.staleWhileRevalidate = 60; // 1 minute
28
+ // Suggestions must follow ingest closely, so the search is cached far more briefly than the detail.
29
+ this.searchMaxAge = 60; // 1 minute
30
+ this.searchStaleWhileRevalidate = 30; // 30 seconds
27
31
  this.controller = Di_1.OGEnergeticsContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.EnoBuildingsController);
28
32
  this.cacheHeaderMiddleware = Di_1.OGEnergeticsContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
29
33
  this.initRoutes();
30
34
  }
31
35
  initRoutes() {
36
+ this.router.get("/", (0, express_validator_1.query)("q").exists().isString().not().isArray().trim().isLength({ min: 1, max: DedSearchWeights_1.DED_SEARCH_QUERY_MAX_LENGTH }), (0, express_validator_1.query)("limit").optional().isInt({ min: 1, max: DedSearchWeights_1.DED_SEARCH_LIMIT_MAX }).toInt(), Validation_1.checkErrors, this.cacheHeaderMiddleware.getMiddleware(this.searchMaxAge, this.searchStaleWhileRevalidate), this.controller.search);
32
37
  this.router.get("/:gid", (0, express_validator_1.param)("gid").exists().isString().not().isArray(), Validation_1.checkErrors, this.cacheHeaderMiddleware.getMiddleware(this.maxAge, this.staleWhileRevalidate), this.controller.getOne);
33
38
  }
34
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"V2EnoBuildingsRouter.js","sourceRoot":"","sources":["../../../../src/output-gateway/routers/v2/V2EnoBuildingsRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAwD;AACxD,+DAA0D;AAE1D,qCAAmD;AACnD,yEAAoE;AACpE,sFAAmF;AAEnF,6EAA2E;AAC3E,+DAAuE;AACvE,mFAAoE;AACpE,iEAAgE;AAGzD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,+BAAc;IAMpD;QACI,KAAK,CAAC,2BAAY,CAAC,EAAE,EAAE,yBAAiB,CAAC,CAAC;QAJtC,WAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;QAChC,yBAAoB,GAAG,EAAE,CAAC,CAAC,WAAW;QAI1C,IAAI,CAAC,UAAU,GAAG,0BAAqB,CAAC,OAAO,CAAyB,2CAAoB,CAAC,sBAAsB,CAAC,CAAC;QACrH,IAAI,CAAC,qBAAqB,GAAG,0BAAqB,CAAC,OAAO,CAAwB,oBAAc,CAAC,qBAAqB,CAAC,CAAC;QACxH,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,OAAO,EACP,IAAA,yBAAK,EAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAChD,wBAAW,EACX,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAChF,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;AAtBY,oDAAo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AAQ,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,uCAAoB,EAAE,CAAC,CAAC,KAAK,EAAE,EAC9E,wBAAW,EACX,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,0BAA0B,CAAC,EAC5F,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,OAAO,EACP,IAAA,yBAAK,EAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAChD,wBAAW,EACX,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAChF,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;AAlCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,qBAAU,GAAE;;GACA,oBAAoB,CAkChC"}
@@ -0,0 +1,11 @@
1
+ import { IDedBuildingSearchRow } from "../repositories/interfaces/IDedBuildingSearchRow";
2
+ import { IDedBuildingSearchResult } from "../routers/interfaces/IDedBuildingSearchResponse";
3
+ import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation";
4
+ /**
5
+ * Maps a scored search row to the response shape. All coordinates arrive from PostGIS already in
6
+ * EPSG:4326, so nothing here does coordinate math.
7
+ */
8
+ export declare class DedBuildingSearchTransformation extends AbstractTransformation<IDedBuildingSearchRow, IDedBuildingSearchResult> {
9
+ name: string;
10
+ protected transformInternal: (element: IDedBuildingSearchRow) => IDedBuildingSearchResult;
11
+ }