@golemio/chmu 1.1.1-dev.2644315801 → 1.1.1-dev.2647641789
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.
- package/db/migrations/postgresql/20260619120000-opendata-columns.js +49 -0
- package/db/migrations/postgresql/sqls/20260619120000-opendata-columns-down.sql +36 -0
- package/db/migrations/postgresql/sqls/20260619120000-opendata-columns-up.sql +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/integration-engine/data-access/MeasurementsRepository.js +3 -2
- package/dist/integration-engine/data-access/MeasurementsRepository.js.map +1 -1
- package/dist/integration-engine/data-access/StationsRepository.d.ts +8 -0
- package/dist/integration-engine/data-access/StationsRepository.js +57 -0
- package/dist/integration-engine/data-access/StationsRepository.js.map +1 -0
- package/dist/integration-engine/datasources/ChmuDatasource.js +1 -1
- package/dist/integration-engine/datasources/ChmuDatasource.js.map +1 -1
- package/dist/integration-engine/datasources/OpendataDatasource.d.ts +30 -0
- package/dist/integration-engine/datasources/OpendataDatasource.js +80 -0
- package/dist/integration-engine/datasources/OpendataDatasource.js.map +1 -0
- package/dist/integration-engine/ioc/Di.js +8 -0
- package/dist/integration-engine/ioc/Di.js.map +1 -1
- package/dist/integration-engine/ioc/ModuleContainerToken.d.ts +4 -0
- package/dist/integration-engine/ioc/ModuleContainerToken.js +5 -0
- package/dist/integration-engine/ioc/ModuleContainerToken.js.map +1 -1
- package/dist/integration-engine/transformations/MeasurementsTransformation.js +20 -5
- package/dist/integration-engine/transformations/MeasurementsTransformation.js.map +1 -1
- package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.d.ts +15 -0
- package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.js +128 -0
- package/dist/integration-engine/transformations/OpendataMeasurementsTransformation.js.map +1 -0
- package/dist/integration-engine/workers/ChmuWorker.js +1 -0
- package/dist/integration-engine/workers/ChmuWorker.js.map +1 -1
- package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.d.ts +8 -0
- package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.js +3 -0
- package/dist/integration-engine/workers/interfaces/IDownloadOpendataMessage.js.map +1 -0
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js +2 -2
- package/dist/integration-engine/workers/tasks/DownloadMeasurementsTask.js.map +1 -1
- package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.d.ts +22 -0
- package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.js +112 -0
- package/dist/integration-engine/workers/tasks/DownloadOpendataMeasurementsTask.js.map +1 -0
- package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.d.ts +6 -0
- package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.js +33 -0
- package/dist/integration-engine/workers/tasks/DownloadOpendataMessageSchema.js.map +1 -0
- package/dist/schema-definitions/datasources/OpendataSchemaProvider.d.ts +55 -0
- package/dist/schema-definitions/datasources/OpendataSchemaProvider.js +47 -0
- package/dist/schema-definitions/datasources/OpendataSchemaProvider.js.map +1 -0
- package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.d.ts +15 -0
- package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.js +3 -0
- package/dist/schema-definitions/datasources/interfaces/IInputOpendataRecord.js.map +1 -0
- package/dist/schema-definitions/definitions/interfaces/IMeasurementDto.d.ts +18 -0
- package/dist/schema-definitions/definitions/models/MeasurementModel.d.ts +18 -0
- package/dist/schema-definitions/definitions/models/MeasurementModel.js +37 -1
- package/dist/schema-definitions/definitions/models/MeasurementModel.js.map +1 -1
- package/docs/asyncapi.yaml +35 -3
- package/docs/implementation_documentation.md +81 -23
- package/package.json +13 -12
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OpendataMeasurementsTransformation = void 0;
|
|
10
|
+
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
|
|
11
|
+
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
12
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
13
|
+
/**
|
|
14
|
+
* Maps ČHMÚ opendata ELEMENT codes to IMeasurementDto columns.
|
|
15
|
+
* Optional transform function applies per-element unit conversion.
|
|
16
|
+
*/
|
|
17
|
+
const ELEMENT_COLUMN = {
|
|
18
|
+
T: { column: "air_temp" },
|
|
19
|
+
H: { column: "air_hum" },
|
|
20
|
+
P: { column: "air_pressure" },
|
|
21
|
+
F: { column: "wind_speed" },
|
|
22
|
+
D: { column: "wind_dir" },
|
|
23
|
+
SRA10M: { column: "precip" },
|
|
24
|
+
// SSV10M: sunshine duration in seconds over the last 10 minutes (max 600 s).
|
|
25
|
+
// DB stores sunlight in tenths of an hour (1 tenth = 6 min = 360 s), same unit as FTP SSV1H.
|
|
26
|
+
// Max per 10-min interval: 600 s / 360 ≈ 1.67 tenths.
|
|
27
|
+
SSV10M: { column: "sunlight", transform: (v) => v / 360 },
|
|
28
|
+
TMA: { column: "air_temp_max" },
|
|
29
|
+
TMI: { column: "air_temp_min" },
|
|
30
|
+
TPM: { column: "air_temp_ground" },
|
|
31
|
+
Fprum: { column: "wind_speed_avg" },
|
|
32
|
+
Dprum: { column: "wind_dir_avg" },
|
|
33
|
+
Fmax: { column: "wind_gust" },
|
|
34
|
+
Dmax: { column: "wind_gust_dir" },
|
|
35
|
+
Casmax: { column: "wind_gust_time" },
|
|
36
|
+
SCEa: { column: "snow_depth" },
|
|
37
|
+
SVHa: { column: "snow_water" },
|
|
38
|
+
RGLB10: { column: "radiation_glob" },
|
|
39
|
+
REUV10: { column: "radiation_uv" },
|
|
40
|
+
REUV25: { column: "radiation_uv" },
|
|
41
|
+
T05: { column: "soil_temp_5cm" },
|
|
42
|
+
T10: { column: "soil_temp_10cm" },
|
|
43
|
+
T20: { column: "soil_temp_20cm" },
|
|
44
|
+
T50: { column: "soil_temp_50cm" },
|
|
45
|
+
T100: { column: "soil_temp_100cm" },
|
|
46
|
+
};
|
|
47
|
+
let OpendataMeasurementsTransformation = class OpendataMeasurementsTransformation extends AbstractTransformation_1.AbstractTransformation {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.name = "OpendataMeasurementsTransformation";
|
|
51
|
+
this.transformInternal = (records) => {
|
|
52
|
+
const { station_id, DT } = records[0]; // group key — same across all records
|
|
53
|
+
const dt = luxon_1.DateTime.fromISO(DT).setZone("Europe/Prague");
|
|
54
|
+
if (!dt.isValid) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const dto = {
|
|
58
|
+
measured_at: dt.toUTC().toISO(),
|
|
59
|
+
station_id,
|
|
60
|
+
year: dt.year,
|
|
61
|
+
month: dt.month,
|
|
62
|
+
day: dt.day,
|
|
63
|
+
time: dt.toFormat("HH:mm"),
|
|
64
|
+
air_temp: null,
|
|
65
|
+
air_hum: null,
|
|
66
|
+
precip: null,
|
|
67
|
+
air_pressure: null,
|
|
68
|
+
wind_speed: null,
|
|
69
|
+
wind_dir: null,
|
|
70
|
+
sunlight: null,
|
|
71
|
+
soil_hum_0_10: null,
|
|
72
|
+
soil_hum_10_50: null,
|
|
73
|
+
soil_hum_50_100: null,
|
|
74
|
+
air_temp_max: null,
|
|
75
|
+
air_temp_min: null,
|
|
76
|
+
air_temp_ground: null,
|
|
77
|
+
wind_speed_avg: null,
|
|
78
|
+
wind_dir_avg: null,
|
|
79
|
+
wind_gust: null,
|
|
80
|
+
wind_gust_dir: null,
|
|
81
|
+
wind_gust_time: null,
|
|
82
|
+
snow_depth: null,
|
|
83
|
+
snow_water: null,
|
|
84
|
+
radiation_glob: null,
|
|
85
|
+
radiation_uv: null,
|
|
86
|
+
soil_temp_5cm: null,
|
|
87
|
+
soil_temp_10cm: null,
|
|
88
|
+
soil_temp_20cm: null,
|
|
89
|
+
soil_temp_50cm: null,
|
|
90
|
+
soil_temp_100cm: null,
|
|
91
|
+
data_source: "opendata",
|
|
92
|
+
};
|
|
93
|
+
for (const record of records) {
|
|
94
|
+
const mapping = ELEMENT_COLUMN[record.ELEMENT];
|
|
95
|
+
if (!mapping || record.VAL === "") {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
dto[mapping.column] = mapping.transform ? mapping.transform(record.VAL) : record.VAL;
|
|
99
|
+
}
|
|
100
|
+
return dto;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Pivots long-format opendata records into wide IMeasurementDto rows.
|
|
105
|
+
* Groups by (station_id, DT) and maps each ELEMENT to its DB column.
|
|
106
|
+
* DT is UTC ISO 8601; year/month/day/time are expressed in Europe/Prague local time.
|
|
107
|
+
*/
|
|
108
|
+
async transform(data) {
|
|
109
|
+
const groups = this.groupByStationAndDt(data);
|
|
110
|
+
return this.transformArray(groups).filter((dto) => dto !== null);
|
|
111
|
+
}
|
|
112
|
+
groupByStationAndDt(data) {
|
|
113
|
+
const groups = new Map();
|
|
114
|
+
for (const record of data) {
|
|
115
|
+
const key = `${record.station_id}|${record.DT}`;
|
|
116
|
+
if (!groups.has(key)) {
|
|
117
|
+
groups.set(key, []);
|
|
118
|
+
}
|
|
119
|
+
groups.get(key).push(record);
|
|
120
|
+
}
|
|
121
|
+
return Array.from(groups.values());
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.OpendataMeasurementsTransformation = OpendataMeasurementsTransformation;
|
|
125
|
+
exports.OpendataMeasurementsTransformation = OpendataMeasurementsTransformation = __decorate([
|
|
126
|
+
(0, tsyringe_1.injectable)()
|
|
127
|
+
], OpendataMeasurementsTransformation);
|
|
128
|
+
//# sourceMappingURL=OpendataMeasurementsTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpendataMeasurementsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/transformations/OpendataMeasurementsTransformation.ts"],"names":[],"mappings":";;;;;;;;;AAGA,6GAA0G;AAC1G,2DAA2D;AAC3D,iEAAgE;AAahE;;;GAGG;AACH,MAAM,cAAc,GAA6C;IAC7D,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;IACzB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;IACxB,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;IAC7B,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;IAC3B,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;IACzB,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC5B,6EAA6E;IAC7E,6FAA6F;IAC7F,sDAAsD;IACtD,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE;IACzD,GAAG,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;IAC/B,GAAG,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;IAC/B,GAAG,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;IAClC,KAAK,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE;IACnC,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;IACjC,IAAI,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;IAC7B,IAA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OAIG;IACI,KAAK,CAAC,SAAS,CAAC,IAA4B;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAA0B,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IAC7F,CAAC;IAyDO,mBAAmB,CAAC,IAA4B;QACpD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;QACzD,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxB,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;CACJ,CAAA;AAlFY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,qBAAU,GAAE;GACA,kCAAkC,CAkF9C"}
|
|
@@ -15,6 +15,7 @@ class ChmuWorker extends workers_1.AbstractWorker {
|
|
|
15
15
|
};
|
|
16
16
|
// Register tasks
|
|
17
17
|
this.registerTask(Di_1.ChmuContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.DownloadMeasurementsTask));
|
|
18
|
+
this.registerTask(Di_1.ChmuContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.DownloadOpendataMeasurementsTask));
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.ChmuWorker = ChmuWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChmuWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/ChmuWorker.ts"],"names":[],"mappings":";;;AAAA,kCAA2C;AAC3C,sEAAoE;AACpE,2EAA6F;AAC7F,uCAAwC;
|
|
1
|
+
{"version":3,"file":"ChmuWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/ChmuWorker.ts"],"names":[],"mappings":";;;AAAA,kCAA2C;AAC3C,sEAAoE;AACpE,2EAA6F;AAC7F,uCAAwC;AAIxC,MAAa,UAAW,SAAQ,wBAAc;IAG1C;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,mBAAW,CAAC;QAYtB,iBAAY,GAAG,CAAC,IAAuB,EAAQ,EAAE;YACpD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,CAAC,CAAC;QAVE,iBAAiB;QACjB,IAAI,CAAC,YAAY,CAAC,kBAAa,CAAC,OAAO,CAA2B,2CAAoB,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAClH,IAAI,CAAC,YAAY,CACb,kBAAa,CAAC,OAAO,CAAmC,2CAAoB,CAAC,gCAAgC,CAAC,CACjH,CAAC;IACN,CAAC;CAMJ;AAjBD,gCAiBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default interface IDownloadOpendataMessage {
|
|
2
|
+
/** ISO 8601 date to fetch opendata for. Defaults to today when omitted. */
|
|
3
|
+
date?: string;
|
|
4
|
+
/** WSI identifier of the station. When set together with station_id, task runs in single-station mode. */
|
|
5
|
+
wsi?: string;
|
|
6
|
+
/** Station ID from chmu.stations. Required when wsi is set. */
|
|
7
|
+
station_id?: string;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDownloadOpendataMessage.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/interfaces/IDownloadOpendataMessage.ts"],"names":[],"mappings":""}
|
|
@@ -20,12 +20,12 @@ const ChmuDatasource_1 = __importDefault(require("../../datasources/ChmuDatasour
|
|
|
20
20
|
const ModuleContainerToken_1 = require("../../ioc/ModuleContainerToken");
|
|
21
21
|
const MeasurementsTransformation_1 = require("../../transformations/MeasurementsTransformation");
|
|
22
22
|
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
23
|
-
const ContainerToken_1 = require("@golemio/core/dist/integration-engine/ioc/ContainerToken");
|
|
24
23
|
const QueueManager_1 = require("@golemio/core/dist/integration-engine/queueprocessors/QueueManager");
|
|
25
24
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
26
25
|
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
27
26
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
28
27
|
const DownloadMeasurementsMessageSchema_1 = require("./DownloadMeasurementsMessageSchema");
|
|
28
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
29
29
|
let DownloadMeasurementsTask = class DownloadMeasurementsTask extends integration_engine_1.AbstractTask {
|
|
30
30
|
constructor(datasource, transformation, repository, logger) {
|
|
31
31
|
super(""); // done in worker
|
|
@@ -88,7 +88,7 @@ DownloadMeasurementsTask = __decorate([
|
|
|
88
88
|
__param(0, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.ChmuDatasource)),
|
|
89
89
|
__param(1, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsTransformation)),
|
|
90
90
|
__param(2, (0, tsyringe_1.inject)(ModuleContainerToken_1.ModuleContainerToken.MeasurementsRepository)),
|
|
91
|
-
__param(3, (0, tsyringe_1.inject)(
|
|
91
|
+
__param(3, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
92
92
|
__metadata("design:paramtypes", [ChmuDatasource_1.default,
|
|
93
93
|
MeasurementsTransformation_1.MeasurementsTransformation,
|
|
94
94
|
MeasurementsRepository_1.MeasurementsRepository, Object])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qFAAgF;AAChF,sFAA4D;AAC5D,yEAAoE;AACpE,iGAA4F;AAE5F,8EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"DownloadMeasurementsTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/DownloadMeasurementsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qFAAgF;AAChF,sFAA4D;AAC5D,yEAAoE;AACpE,iGAA4F;AAE5F,8EAAqE;AACrE,qGAAkG;AAClG,6EAAgF;AAChF,2DAA2D;AAC3D,iEAAwE;AAGxE,2FAAwF;AACxF,wEAAqE;AAGtD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,iCAA0C;IAI5F,YACiD,UAAkC,EACtB,cAAkD,EACtD,UAA0C,EACrE,MAAuB;QAEjD,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB;QALyB,eAAU,GAAV,UAAU,CAAgB;QACd,mBAAc,GAAd,cAAc,CAA4B;QAC9C,eAAU,GAAV,UAAU,CAAwB;QAC7D,WAAM,GAAN,MAAM,CAAS;QAP9C,cAAS,GAAW,0BAA0B,CAAC;QAC5C,WAAM,GAAG,qEAAiC,CAAC;QAW3C,YAAO,GAAG,KAAK,EAAE,IAAkC,EAAiB,EAAE;YAC5E,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAE/C,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;gBAClB,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAA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5C;kBAnEoB,wBAAwB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 validateMessageData;
|
|
22
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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.validateMessageData(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
|
+
this.logger.error(error, `${this.constructor.name}: Unable to download chmu opendata measurements data.`);
|
|
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
|
+
validateMessageData(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 Error(`Date "${data.date}" is outside the 3-day retention window`);
|
|
95
|
+
}
|
|
96
|
+
return { ...data, 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
|
|
@@ -0,0 +1 @@
|
|
|
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,oCAAoC;QAPU,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,eAAU,GAAV,UAAU,CAAoB;QAE/E,mBAAc,GAAd,cAAc,CAAoC;QACG,eAAU,GAAV,UAAU,CAAwB;QAC7D,WAAM,GAAN,MAAM,CAAS;QAT9C,cAAS,GAAW,kCAAkC,CAAC;QACpD,WAAM,GAAG,6DAA6B,CAAC;QAavC,YAAO,GAAG,KAAK,EAAE,IAA8B,EAAiB,EAAE;YACxE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAEhD,IAAI,CAAC;gBACD,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;QAEpE,MAAM,SAAS,GAAG,gBAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC;QACrF,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,yCAAyC,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,EAAG,EAAE,CAAC;IAC9C,CAAC;CACJ,CAAA;AAhFoB,gCAAgC;IADpD,IAAA,qBAAU,GAAE;IAMJ,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,kBAAkB,CAAC,CAAA;IAC/C,WAAA,IAAA,iBAAM,EAAC,2CAAoB,CAAC,kBAAkB,CAAC,CAAA;IAC/C,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;QAC1B,4BAAkB;QAE/D,uEAAkC;QACe,+CAAsB;GATlF,gCAAgC,CAgFpD;kBAhFoB,gCAAgC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IInputOpendataRecord.js","sourceRoot":"","sources":["../../../../src/schema-definitions/datasources/interfaces/IInputOpendataRecord.ts"],"names":[],"mappings":""}
|
|
@@ -15,4 +15,22 @@ export interface IMeasurementDto {
|
|
|
15
15
|
soil_hum_0_10: number | null;
|
|
16
16
|
soil_hum_10_50: number | null;
|
|
17
17
|
soil_hum_50_100: number | null;
|
|
18
|
+
air_temp_max: number | null;
|
|
19
|
+
air_temp_min: number | null;
|
|
20
|
+
air_temp_ground: number | null;
|
|
21
|
+
wind_speed_avg: number | null;
|
|
22
|
+
wind_dir_avg: number | null;
|
|
23
|
+
wind_gust: number | null;
|
|
24
|
+
wind_gust_dir: number | null;
|
|
25
|
+
wind_gust_time: number | null;
|
|
26
|
+
snow_depth: number | null;
|
|
27
|
+
snow_water: number | null;
|
|
28
|
+
radiation_glob: number | null;
|
|
29
|
+
radiation_uv: number | null;
|
|
30
|
+
soil_temp_5cm: number | null;
|
|
31
|
+
soil_temp_10cm: number | null;
|
|
32
|
+
soil_temp_20cm: number | null;
|
|
33
|
+
soil_temp_50cm: number | null;
|
|
34
|
+
soil_temp_100cm: number | null;
|
|
35
|
+
data_source: string;
|
|
18
36
|
}
|
|
@@ -18,6 +18,24 @@ export declare class MeasurementModel extends Model<IMeasurementDto> implements
|
|
|
18
18
|
soil_hum_0_10: number | null;
|
|
19
19
|
soil_hum_10_50: number | null;
|
|
20
20
|
soil_hum_50_100: number | null;
|
|
21
|
+
air_temp_max: number | null;
|
|
22
|
+
air_temp_min: number | null;
|
|
23
|
+
air_temp_ground: number | null;
|
|
24
|
+
wind_speed_avg: number | null;
|
|
25
|
+
wind_dir_avg: number | null;
|
|
26
|
+
wind_gust: number | null;
|
|
27
|
+
wind_gust_dir: number | null;
|
|
28
|
+
wind_gust_time: number | null;
|
|
29
|
+
snow_depth: number | null;
|
|
30
|
+
snow_water: number | null;
|
|
31
|
+
radiation_glob: number | null;
|
|
32
|
+
radiation_uv: number | null;
|
|
33
|
+
soil_temp_5cm: number | null;
|
|
34
|
+
soil_temp_10cm: number | null;
|
|
35
|
+
soil_temp_20cm: number | null;
|
|
36
|
+
soil_temp_50cm: number | null;
|
|
37
|
+
soil_temp_100cm: number | null;
|
|
38
|
+
data_source: string;
|
|
21
39
|
static attributeModel: ModelAttributes<MeasurementModel, IMeasurementDto>;
|
|
22
40
|
static jsonSchema: JSONSchemaType<IMeasurementDto[]>;
|
|
23
41
|
}
|