@golemio/chmu 1.1.1-dev.2674913750 → 1.2.0

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 (62) hide show
  1. package/dist/integration-engine/data-access/MeasurementsRepository.js +1 -1
  2. package/dist/integration-engine/data-access/MeasurementsRepository.js.map +1 -1
  3. package/dist/integration-engine/ioc/Di.js +0 -12
  4. package/dist/integration-engine/ioc/Di.js.map +1 -1
  5. package/dist/integration-engine/ioc/ModuleContainerToken.d.ts +0 -6
  6. package/dist/integration-engine/ioc/ModuleContainerToken.js +0 -8
  7. package/dist/integration-engine/ioc/ModuleContainerToken.js.map +1 -1
  8. package/dist/integration-engine/transformations/MeasurementsTransformation.js +0 -18
  9. package/dist/integration-engine/transformations/MeasurementsTransformation.js.map +1 -1
  10. package/dist/integration-engine/workers/ChmuWorker.js +0 -2
  11. package/dist/integration-engine/workers/ChmuWorker.js.map +1 -1
  12. package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js +2 -2
  13. package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js.map +1 -1
  14. package/dist/schema-definitions/definitions/interfaces/IMeasurementDto.d.ts +0 -18
  15. package/dist/schema-definitions/definitions/models/MeasurementModel.d.ts +0 -18
  16. package/dist/schema-definitions/definitions/models/MeasurementModel.js +1 -37
  17. package/dist/schema-definitions/definitions/models/MeasurementModel.js.map +1 -1
  18. package/docs/asyncapi.yaml +3 -78
  19. package/docs/implementation_documentation.md +23 -114
  20. package/package.json +4 -4
  21. package/db/migrations/postgresql/20260619120000-opendata-columns.js +0 -49
  22. package/db/migrations/postgresql/sqls/20260619120000-opendata-columns-down.sql +0 -36
  23. package/db/migrations/postgresql/sqls/20260619120000-opendata-columns-up.sql +0 -40
  24. package/dist/integration-engine/data-access/StationsRepository.d.ts +0 -8
  25. package/dist/integration-engine/data-access/StationsRepository.js +0 -57
  26. package/dist/integration-engine/data-access/StationsRepository.js.map +0 -1
  27. package/dist/integration-engine/datasources/AbstractOpendataDatasource.d.ts +0 -19
  28. package/dist/integration-engine/datasources/AbstractOpendataDatasource.js +0 -47
  29. package/dist/integration-engine/datasources/AbstractOpendataDatasource.js.map +0 -1
  30. package/dist/integration-engine/datasources/OpendataDatasource.d.ts +0 -8
  31. package/dist/integration-engine/datasources/OpendataDatasource.js +0 -37
  32. package/dist/integration-engine/datasources/OpendataDatasource.js.map +0 -1
  33. package/dist/integration-engine/datasources/OpendataHistoricalDatasource.d.ts +0 -8
  34. package/dist/integration-engine/datasources/OpendataHistoricalDatasource.js +0 -38
  35. package/dist/integration-engine/datasources/OpendataHistoricalDatasource.js.map +0 -1
  36. package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.d.ts +0 -15
  37. package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.js +0 -128
  38. package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.js.map +0 -1
  39. package/dist/integration-engine/workers/interfaces/IDownloadOpendataHistoricalMessage.d.ts +0 -10
  40. package/dist/integration-engine/workers/interfaces/IDownloadOpendataHistoricalMessage.js +0 -3
  41. package/dist/integration-engine/workers/interfaces/IDownloadOpendataHistoricalMessage.js.map +0 -1
  42. package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.d.ts +0 -8
  43. package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.js +0 -3
  44. package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.js.map +0 -1
  45. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMeasurementsTask.d.ts +0 -26
  46. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMeasurementsTask.js +0 -149
  47. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMeasurementsTask.js.map +0 -1
  48. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMessageSchema.d.ts +0 -7
  49. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMessageSchema.js +0 -40
  50. package/dist/integration-engine/workers/tasks/DownloadOpendataHistoricalMessageSchema.js.map +0 -1
  51. package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.d.ts +0 -22
  52. package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.js +0 -112
  53. package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.js.map +0 -1
  54. package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.d.ts +0 -6
  55. package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.js +0 -33
  56. package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.js.map +0 -1
  57. package/dist/schema-definitions/datasources/OpendataSchemaProvider.d.ts +0 -55
  58. package/dist/schema-definitions/datasources/OpendataSchemaProvider.js +0 -47
  59. package/dist/schema-definitions/datasources/OpendataSchemaProvider.js.map +0 -1
  60. package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.d.ts +0 -15
  61. package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.js +0 -3
  62. package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.js.map +0 -1
@@ -1,149 +0,0 @@
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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- var DownloadOpendataHistoricalMeasurementsTask_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- const StationsRepository_1 = require("../../data-access/StationsRepository");
20
- const MeasurementsRepository_1 = require("../../data-access/MeasurementsRepository");
21
- const OpendataHistoricalDatasource_1 = __importDefault(require("../../datasources/OpendataHistoricalDatasource"));
22
- const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
23
- const OpendataMeasurementsTransformation_1 = require("../../transformations/OpendataMeasurementsTransformation");
24
- const integration_engine_1 = require("@golemio/core/dist/integration-engine");
25
- const QueueManager_1 = require("@golemio/core/dist/integration-engine/queueprocessors/QueueManager");
26
- const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
27
- const luxon_1 = require("@golemio/core/dist/shared/luxon");
28
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
29
- const DownloadOpendataHistoricalMessageSchema_1 = require("./DownloadOpendataHistoricalMessageSchema");
30
- const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
31
- let DownloadOpendataHistoricalMeasurementsTask = DownloadOpendataHistoricalMeasurementsTask_1 = class DownloadOpendataHistoricalMeasurementsTask extends integration_engine_1.AbstractTask {
32
- constructor(stationsRepository, datasource, transformation, repository, logger) {
33
- super(""); // queue prefix is set by the worker
34
- this.stationsRepository = stationsRepository;
35
- this.datasource = datasource;
36
- this.transformation = transformation;
37
- this.repository = repository;
38
- this.logger = logger;
39
- this.queueName = "downloadOpendataHistoricalMeasurementsTask";
40
- this.schema = DownloadOpendataHistoricalMessageSchema_1.DownloadOpendataHistoricalMessageSchema;
41
- this.execute = async (data) => {
42
- const { from, to } = this.validateRange(data);
43
- try {
44
- if (data.station_id && data.wsi) {
45
- await this.processStation(data.station_id, data.wsi, from, to);
46
- }
47
- else {
48
- await this.generateSubtasks(from, to);
49
- }
50
- }
51
- catch (error) {
52
- if (error instanceof golemio_errors_1.AbstractGolemioError) {
53
- throw error;
54
- }
55
- throw new golemio_errors_1.GeneralError(`Unable to download chmu opendata historical measurements data.`, this.constructor.name, error);
56
- }
57
- };
58
- }
59
- async generateSubtasks(from, to) {
60
- const stations = await this.stationsRepository.getStationsWithWsi();
61
- if (stations.length === 0) {
62
- this.logger.warn(`${this.constructor.name}: no stations with WSI found - skipping. Populate chmu.stations.wsi first.`);
63
- return;
64
- }
65
- for (const station of stations) {
66
- await this.generateStationMonthSubtasks(station.station_id, station.wsi, from, to);
67
- }
68
- }
69
- async processStation(stationId, wsi, from, to) {
70
- const intervals = DownloadOpendataHistoricalMeasurementsTask_1.generateMonthIntervals(from, to);
71
- if (intervals.length === 1) {
72
- await this.processStationMeasurements(stationId, wsi, intervals[0]);
73
- }
74
- else {
75
- await this.generateStationMonthSubtasks(stationId, wsi, from, to);
76
- }
77
- }
78
- async generateStationMonthSubtasks(stationId, wsi, from, to) {
79
- const intervals = DownloadOpendataHistoricalMeasurementsTask_1.generateMonthIntervals(from, to);
80
- for (const interval of intervals) {
81
- await QueueManager_1.QueueManager.sendMessageToExchange(this.queuePrefix, this.queueName, {
82
- station_id: stationId,
83
- wsi,
84
- from: interval.from.toISO(),
85
- to: interval.to.toISO(),
86
- });
87
- }
88
- this.logger.debug(`${this.constructor.name}: dispatched ${intervals.length} month subtasks for station ${stationId}.`);
89
- }
90
- async processStationMeasurements(stationId, wsi, interval) {
91
- const rangeLabel = `${interval.from.toISO()} - ${interval.to.toISO()}`;
92
- let stationRecords;
93
- try {
94
- stationRecords = await this.datasource.getData(wsi, interval.from.toJSDate());
95
- }
96
- catch (error) {
97
- throw new golemio_errors_1.GeneralError(`${this.constructor.name}: failed to fetch data for station ${stationId} (WSI: ${wsi}, range ${rangeLabel}).`);
98
- }
99
- if (stationRecords.length === 0) {
100
- this.logger.warn(`${this.constructor.name}: no records fetched for station ${stationId} (WSI: ${wsi}), range ${rangeLabel}.`);
101
- return;
102
- }
103
- const withinRange = stationRecords.filter((r) => {
104
- const dt = luxon_1.DateTime.fromISO(r.DT, { zone: "utc" });
105
- return dt >= interval.from && dt < interval.to;
106
- });
107
- if (withinRange.length === 0) {
108
- this.logger.warn(`${this.constructor.name}: all records for station ${stationId} fall outside the requested range ${rangeLabel}.`);
109
- return;
110
- }
111
- const records = withinRange.map((r) => ({ ...r, station_id: stationId }));
112
- const transformed = await this.transformation.transform(records);
113
- await this.repository.bulkUpdate(transformed);
114
- this.logger.debug(`${this.constructor.name}: upserted ${transformed.length} measurements for station ${stationId}, range ${rangeLabel}.`);
115
- }
116
- validateRange(data) {
117
- const from = luxon_1.DateTime.fromISO(data.from, { zone: "utc" });
118
- const to = luxon_1.DateTime.fromISO(data.to, { zone: "utc" });
119
- if (to <= from) {
120
- throw new golemio_errors_1.GeneralError(`"to" (${data.to}) must be after "from" (${data.from}).`, this.constructor.name);
121
- }
122
- return { from, to };
123
- }
124
- /** Splits [from, to) into calendar-month intervals (UTC, matching DT's format); clips the first/last interval. */
125
- static generateMonthIntervals(from, to) {
126
- const intervals = [];
127
- let cursor = from;
128
- while (cursor < to) {
129
- const nextMonth = cursor.startOf("month").plus({ months: 1 });
130
- intervals.push({ from: cursor, to: luxon_1.DateTime.min(nextMonth, to) });
131
- cursor = nextMonth;
132
- }
133
- return intervals;
134
- }
135
- };
136
- DownloadOpendataHistoricalMeasurementsTask = DownloadOpendataHistoricalMeasurementsTask_1 = __decorate([
137
- (0, tsyringe_1.injectable)(),
138
- __param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.StationsRepository)),
139
- __param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OpendataHistoricalDatasource)),
140
- __param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OpendataMeasurementsTransformation)),
141
- __param(3, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsRepository)),
142
- __param(4, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
143
- __metadata("design:paramtypes", [StationsRepository_1.StationsRepository,
144
- OpendataHistoricalDatasource_1.default,
145
- OpendataMeasurementsTransformation_1.OpendataMeasurementsTransformation,
146
- MeasurementsRepository_1.MeasurementsRepository, Object])
147
- ], DownloadOpendataHistoricalMeasurementsTask);
148
- exports.default = DownloadOpendataHistoricalMeasurementsTask;
149
- //# sourceMappingURL=DownloadOpendataHistoricalMeasurementsTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadOpendataHistoricalMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadOpendataHistoricalMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6EAAwE;AACxE,qFAAgF;AAChF,kHAAwF;AACxF,yEAAoE;AACpE,iHAA4G;AAE5G,8EAAqE;AACrE,qGAAkG;AAClG,6EAA8F;AAC9F,2DAA2D;AAC3D,iEAAwE;AAExE,uGAAoG;AACpG,wEAAqE;AAQtD,IAAM,0CAA0C,kDAAhD,MAAM,0CAA2C,SAAQ,iCAAgD;IAIpH,YACqD,kBAA8C,EACpC,UAAgD,EAE3G,cAA0D,EACL,UAA0C,EACrE,MAAuB;QAEjD,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC;QAPU,uBAAkB,GAAlB,kBAAkB,CAAoB;QAC5B,eAAU,GAAV,UAAU,CAA8B;QAEnG,mBAAc,GAAd,cAAc,CAAoC;QACG,eAAU,GAAV,UAAU,CAAwB;QAC7D,WAAM,GAAN,MAAM,CAAS;QAT9C,cAAS,GAAW,4CAA4C,CAAC;QAC9D,WAAM,GAAG,iFAAuC,CAAC;QAajD,YAAO,GAAG,KAAK,EAAE,IAAwC,EAAiB,EAAE;YAClF,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAE9C,IAAI,CAAC;gBACD,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;oBAC9B,MAAM,IAAI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C,2CAAoB,CAAC,4BAA4B,CAAC,CAAA;IACzD,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,kCAAkC,CAAC,CAAA;IAE/D,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,sBAAsB,CAAC,CAAA;IACnD,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;qCALoD,uCAAkB;QAChB,sCAA4B;QAEnF,uEAAkC;QACe,+CAAsB;GATlF,0CAA0C,CAqI9D;kBArIoB,0CAA0C"}
@@ -1,7 +0,0 @@
1
- import IDownloadOpendataHistoricalMessage from "../interfaces/IDownloadOpendataHistoricalMessage";
2
- export declare class DownloadOpendataHistoricalMessageSchema implements IDownloadOpendataHistoricalMessage {
3
- from: string;
4
- to: string;
5
- station_id?: string;
6
- wsi?: string;
7
- }
@@ -1,40 +0,0 @@
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.DownloadOpendataHistoricalMessageSchema = void 0;
13
- const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
14
- const ISO8601_WITH_TIMEZONE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
15
- class DownloadOpendataHistoricalMessageSchema {
16
- }
17
- exports.DownloadOpendataHistoricalMessageSchema = DownloadOpendataHistoricalMessageSchema;
18
- __decorate([
19
- (0, class_validator_1.IsString)(),
20
- (0, class_validator_1.IsISO8601)({ strict: true }),
21
- (0, class_validator_1.Matches)(ISO8601_WITH_TIMEZONE, { message: "from must be a full ISO 8601 timestamp with a timezone (e.g. Z or +01:00)" }),
22
- __metadata("design:type", String)
23
- ], DownloadOpendataHistoricalMessageSchema.prototype, "from", void 0);
24
- __decorate([
25
- (0, class_validator_1.IsString)(),
26
- (0, class_validator_1.IsISO8601)({ strict: true }),
27
- (0, class_validator_1.Matches)(ISO8601_WITH_TIMEZONE, { message: "to must be a full ISO 8601 timestamp with a timezone (e.g. Z or +01:00)" }),
28
- __metadata("design:type", String)
29
- ], DownloadOpendataHistoricalMessageSchema.prototype, "to", void 0);
30
- __decorate([
31
- (0, class_validator_1.IsOptional)(),
32
- (0, class_validator_1.IsString)(),
33
- __metadata("design:type", String)
34
- ], DownloadOpendataHistoricalMessageSchema.prototype, "station_id", void 0);
35
- __decorate([
36
- (0, class_validator_1.IsOptional)(),
37
- (0, class_validator_1.IsString)(),
38
- __metadata("design:type", String)
39
- ], DownloadOpendataHistoricalMessageSchema.prototype, "wsi", void 0);
40
- //# sourceMappingURL=DownloadOpendataHistoricalMessageSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadOpendataHistoricalMessageSchema.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadOpendataHistoricalMessageSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAqG;AAGrG,MAAM,qBAAqB,GAAG,kEAAkE,CAAC;AAEjG,MAAa,uCAAuC;CAkBnD;AAlBD,0FAkBC;AAdG;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC3B,IAAA,yBAAO,EAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,2EAA2E,EAAE,CAAC;;qEAC3G;AAKd;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC3B,IAAA,yBAAO,EAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,yEAAyE,EAAE,CAAC;;mEAC3G;AAIZ;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2EACS;AAIpB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oEACE"}
@@ -1,22 +0,0 @@
1
- import { StationsRepository } from "../../data-access/StationsRepository";
2
- import { MeasurementsRepository } from "../../data-access/MeasurementsRepository";
3
- import OpendataDatasource from "../../datasources/OpendataDatasource";
4
- import { OpendataMeasurementsTransformation } from "../../transformations/OpendataMeasurementsTransformation";
5
- import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
6
- import { AbstractTask } from "@golemio/core/dist/integration-engine";
7
- import IDownloadOpendataMessage from "../interfaces/IDownloadOpendataMessage";
8
- import { DownloadOpendataMessageSchema } from "./DownloadOpendataMessageSchema";
9
- export default class DownloadOpendataMeasurementsTask extends AbstractTask<IDownloadOpendataMessage> {
10
- private stationsRepository;
11
- private datasource;
12
- private transformation;
13
- private repository;
14
- private logger;
15
- queueName: string;
16
- protected schema: typeof DownloadOpendataMessageSchema;
17
- constructor(stationsRepository: StationsRepository, datasource: OpendataDatasource, transformation: OpendataMeasurementsTransformation, repository: MeasurementsRepository, logger: ILogger);
18
- protected execute: (data: IDownloadOpendataMessage) => Promise<void>;
19
- private generateSubtasks;
20
- private processStationMeasurements;
21
- private validateDate;
22
- }
@@ -1,112 +0,0 @@
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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const StationsRepository_1 = require("../../data-access/StationsRepository");
19
- const MeasurementsRepository_1 = require("../../data-access/MeasurementsRepository");
20
- const OpendataDatasource_1 = __importDefault(require("../../datasources/OpendataDatasource"));
21
- const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
22
- const OpendataMeasurementsTransformation_1 = require("../../transformations/OpendataMeasurementsTransformation");
23
- const integration_engine_1 = require("@golemio/core/dist/integration-engine");
24
- const QueueManager_1 = require("@golemio/core/dist/integration-engine/queueprocessors/QueueManager");
25
- const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
26
- const luxon_1 = require("@golemio/core/dist/shared/luxon");
27
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
28
- const DownloadOpendataMessageSchema_1 = require("./DownloadOpendataMessageSchema");
29
- const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
30
- let DownloadOpendataMeasurementsTask = class DownloadOpendataMeasurementsTask extends integration_engine_1.AbstractTask {
31
- constructor(stationsRepository, datasource, transformation, repository, logger) {
32
- super(""); // queue prefix is set by the worker
33
- this.stationsRepository = stationsRepository;
34
- this.datasource = datasource;
35
- this.transformation = transformation;
36
- this.repository = repository;
37
- this.logger = logger;
38
- this.queueName = "downloadOpendataMeasurementsTask";
39
- this.schema = DownloadOpendataMessageSchema_1.DownloadOpendataMessageSchema;
40
- this.execute = async (data) => {
41
- const { date } = this.validateDate(data);
42
- try {
43
- if (data.wsi && data.station_id) {
44
- await this.processStationMeasurements(data.station_id, data.wsi, new Date(date));
45
- }
46
- else {
47
- await this.generateSubtasks(date);
48
- }
49
- }
50
- catch (error) {
51
- if (error instanceof golemio_errors_1.AbstractGolemioError) {
52
- throw error;
53
- }
54
- throw new golemio_errors_1.GeneralError(`Unable to download chmu opendata measurements data.`, this.constructor.name, error);
55
- }
56
- };
57
- }
58
- async generateSubtasks(date) {
59
- const stations = await this.stationsRepository.getStationsWithWsi();
60
- if (stations.length === 0) {
61
- this.logger.warn(`${this.constructor.name}: no stations with WSI found - skipping. Populate chmu.stations.wsi first.`);
62
- return;
63
- }
64
- for (const station of stations) {
65
- await QueueManager_1.QueueManager.sendMessageToExchange(this.queuePrefix, this.queueName, {
66
- date,
67
- station_id: station.station_id,
68
- wsi: station.wsi,
69
- });
70
- }
71
- this.logger.debug(`${this.constructor.name}: dispatched ${stations.length} subtasks for date ${date}.`);
72
- }
73
- async processStationMeasurements(stationId, wsi, date) {
74
- let stationRecords;
75
- try {
76
- stationRecords = await this.datasource.getData(wsi, date);
77
- }
78
- catch (error) {
79
- throw new golemio_errors_1.GeneralError(`${this.constructor.name}: failed to fetch data for station ${stationId} (WSI: ${wsi}).`);
80
- }
81
- if (stationRecords.length === 0) {
82
- this.logger.warn(`${this.constructor.name}: no records fetched for station ${stationId} (WSI: ${wsi}).`);
83
- return;
84
- }
85
- const records = stationRecords.map((r) => ({ ...r, station_id: stationId }));
86
- const transformed = await this.transformation.transform(records);
87
- await this.repository.bulkUpdate(transformed);
88
- this.logger.debug(`${this.constructor.name}: upserted ${transformed.length} measurements for station ${stationId}.`);
89
- }
90
- validateDate(data) {
91
- const dt = data.date ? luxon_1.DateTime.fromISO(data.date) : luxon_1.DateTime.now();
92
- const ageInDays = luxon_1.DateTime.now().startOf("day").diff(dt.startOf("day"), "days").days;
93
- if (ageInDays > 2) {
94
- throw new golemio_errors_1.GeneralError(`Date "${data.date}" is outside the 3-day retention window`, this.constructor.name);
95
- }
96
- return { date: dt.toISODate() };
97
- }
98
- };
99
- DownloadOpendataMeasurementsTask = __decorate([
100
- (0, tsyringe_1.injectable)(),
101
- __param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.StationsRepository)),
102
- __param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OpendataDatasource)),
103
- __param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.OpendataMeasurementsTransformation)),
104
- __param(3, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsRepository)),
105
- __param(4, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
106
- __metadata("design:paramtypes", [StationsRepository_1.StationsRepository,
107
- OpendataDatasource_1.default,
108
- OpendataMeasurementsTransformation_1.OpendataMeasurementsTransformation,
109
- MeasurementsRepository_1.MeasurementsRepository, Object])
110
- ], DownloadOpendataMeasurementsTask);
111
- exports.default = DownloadOpendataMeasurementsTask;
112
- //# sourceMappingURL=DownloadOpendataMeasurementsTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadOpendataMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6EAAwE;AACxE,qFAAgF;AAChF,8FAAoE;AACpE,yEAAoE;AACpE,iHAA4G;AAE5G,8EAAqE;AACrE,qGAAkG;AAClG,6EAA8F;AAC9F,2DAA2D;AAC3D,iEAAwE;AAExE,mFAAgF;AAChF,wEAAqE;AAGtD,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,iCAAsC;IAIhG,YACqD,kBAA8C,EAC9C,UAAsC,EAEvF,cAA0D,EACL,UAA0C,EACrE,MAAuB;QAEjD,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAo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AsB;GATlF,gCAAgC,CAgFpD;kBAhFoB,gCAAgC"}
@@ -1,6 +0,0 @@
1
- import IDownloadOpendataMessage from "../interfaces/IDownloadOpendataMessage";
2
- export declare class DownloadOpendataMessageSchema implements IDownloadOpendataMessage {
3
- date?: string;
4
- wsi?: string;
5
- station_id?: string;
6
- }
@@ -1,33 +0,0 @@
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.DownloadOpendataMessageSchema = void 0;
13
- const class_validator_1 = require("@golemio/core/dist/shared/class-validator");
14
- class DownloadOpendataMessageSchema {
15
- }
16
- exports.DownloadOpendataMessageSchema = DownloadOpendataMessageSchema;
17
- __decorate([
18
- (0, class_validator_1.IsOptional)(),
19
- (0, class_validator_1.IsString)(),
20
- (0, class_validator_1.IsISO8601)(),
21
- __metadata("design:type", String)
22
- ], DownloadOpendataMessageSchema.prototype, "date", void 0);
23
- __decorate([
24
- (0, class_validator_1.IsOptional)(),
25
- (0, class_validator_1.IsString)(),
26
- __metadata("design:type", String)
27
- ], DownloadOpendataMessageSchema.prototype, "wsi", void 0);
28
- __decorate([
29
- (0, class_validator_1.IsOptional)(),
30
- (0, class_validator_1.IsString)(),
31
- __metadata("design:type", String)
32
- ], DownloadOpendataMessageSchema.prototype, "station_id", void 0);
33
- //# sourceMappingURL=DownloadOpendataMessageSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DownloadOpendataMessageSchema.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadOpendataMessageSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAA4F;AAG5F,MAAa,6BAA6B;CAazC;AAbD,sEAaC;AATG;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,GAAE;;2DACE;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;0DACE;AAIb;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;iEACS"}
@@ -1,55 +0,0 @@
1
- export default class OpendataSchemaProvider {
2
- /**
3
- * Validates the raw data.data object from the API response before column mapping.
4
- * Ensures header and values are present and values rows contain only strings/numbers.
5
- */
6
- static getResponseSchema(): {
7
- type: string;
8
- required: string[];
9
- properties: {
10
- header: {
11
- type: string;
12
- };
13
- values: {
14
- type: string;
15
- items: {
16
- type: string;
17
- minItems: number;
18
- items: {
19
- type: string[];
20
- };
21
- };
22
- };
23
- };
24
- };
25
- /**
26
- * Validates the mapped IRawOpendataRecord[] after header-based column mapping.
27
- */
28
- static get(): {
29
- type: string;
30
- items: {
31
- type: string;
32
- required: string[];
33
- properties: {
34
- STATION: {
35
- type: string;
36
- };
37
- ELEMENT: {
38
- type: string;
39
- };
40
- DT: {
41
- type: string;
42
- };
43
- VAL: {
44
- type: string[];
45
- };
46
- FLAG: {
47
- type: string;
48
- };
49
- QUALITY: {
50
- type: string;
51
- };
52
- };
53
- };
54
- };
55
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class OpendataSchemaProvider {
4
- /**
5
- * Validates the raw data.data object from the API response before column mapping.
6
- * Ensures header and values are present and values rows contain only strings/numbers.
7
- */
8
- static getResponseSchema() {
9
- return {
10
- type: "object",
11
- required: ["header", "values"],
12
- properties: {
13
- header: { type: "string" },
14
- values: {
15
- type: "array",
16
- items: {
17
- type: "array",
18
- minItems: 1,
19
- items: { type: ["string", "number"] },
20
- },
21
- },
22
- },
23
- };
24
- }
25
- /**
26
- * Validates the mapped IRawOpendataRecord[] after header-based column mapping.
27
- */
28
- static get() {
29
- return {
30
- type: "array",
31
- items: {
32
- type: "object",
33
- required: ["STATION", "ELEMENT", "DT", "VAL", "FLAG", "QUALITY"],
34
- properties: {
35
- STATION: { type: "string" },
36
- ELEMENT: { type: "string" },
37
- DT: { type: "string" },
38
- VAL: { type: ["number", "string"] },
39
- FLAG: { type: "string" },
40
- QUALITY: { type: "number" },
41
- },
42
- },
43
- };
44
- }
45
- }
46
- exports.default = OpendataSchemaProvider;
47
- //# sourceMappingURL=OpendataSchemaProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpendataSchemaProvider.js","sourceRoot":"","sources":["../../../src/schema-definitions/datasources/OpendataSchemaProvider.ts"],"names":[],"mappings":";;AAAA,MAAqB,sBAAsB;IACvC;;;OAGG;IACI,MAAM,CAAC,iBAAiB;QAC3B,OAAO;YACH,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;YAC9B,UAAU,EAAE;gBACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,MAAM,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACH,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,CAAC;wBACX,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;qBACxC;iBACJ;aACJ;SACJ,CAAC;IACN,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,GAAG;QACb,OAAO;YACH,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC;gBAChE,UAAU,EAAE;oBACR,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC3B,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACtB,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;oBACnC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC9B;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AA3CD,yCA2CC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * One long-format record from the ČHMÚ opendata 10m API, after unpacking the values array.
3
- * station_id is resolved from the WSI (STATION field) by the task before transformation.
4
- *
5
- * Real API response shape: { data: { type: "DataCollection", data: { header: "...", values: [[...]] } } }
6
- * URL: https://opendata.chmi.cz/meteorology/climate/now/data/10m-{WSI}-{YYYYMMDD}.json
7
- */
8
- export default interface IInputOpendataRecord {
9
- station_id: string;
10
- ELEMENT: string;
11
- DT: string;
12
- VAL: number | "";
13
- FLAG: string;
14
- QUALITY: number;
15
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IInputOpendataRecord.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IInputOpendataRecord.js","sourceRoot":"","sources":["../../../../src/schema-definitions/datasources/interfaces/IInputOpendataRecord.ts"],"names":[],"mappings":""}