@golemio/traffic-common 0.1.0-dev.856032789 → 0.1.0-dev.856907064
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/dist/integration-engine/datasources/RsdTmcOsmMappingDataStreamFactory.d.ts +4 -0
- package/dist/integration-engine/datasources/RsdTmcOsmMappingDataStreamFactory.js +25 -0
- package/dist/integration-engine/datasources/RsdTmcOsmMappingDataStreamFactory.js.map +1 -0
- package/dist/integration-engine/ioc/Di.js +3 -3
- package/dist/integration-engine/ioc/Di.js.map +1 -1
- package/dist/integration-engine/ioc/ModuleContainerToken.d.ts +1 -1
- package/dist/integration-engine/ioc/ModuleContainerToken.js +1 -1
- package/dist/integration-engine/ioc/ModuleContainerToken.js.map +1 -1
- package/dist/integration-engine/repositories/RsdTmcOsmMappingRepository.d.ts +7 -3
- package/dist/integration-engine/repositories/RsdTmcOsmMappingRepository.js +31 -19
- package/dist/integration-engine/repositories/RsdTmcOsmMappingRepository.js.map +1 -1
- package/dist/integration-engine/workers/RsdTmcOsmMappingWorker.js +1 -1
- package/dist/integration-engine/workers/RsdTmcOsmMappingWorker.js.map +1 -1
- package/dist/integration-engine/workers/tasks/RefreshRsdTmcOsmMappingDataTask.d.ts +3 -5
- package/dist/integration-engine/workers/tasks/RefreshRsdTmcOsmMappingDataTask.js +15 -15
- package/dist/integration-engine/workers/tasks/RefreshRsdTmcOsmMappingDataTask.js.map +1 -1
- package/docs/implementation_documentation.md +2 -2
- package/package.json +6 -2
- package/dist/integration-engine/datasources/RsdTmcOsmMappingDataSourceFactory.d.ts +0 -4
- package/dist/integration-engine/datasources/RsdTmcOsmMappingDataSourceFactory.js +0 -36
- package/dist/integration-engine/datasources/RsdTmcOsmMappingDataSourceFactory.js.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HTTPProtocolStrategyStreamed } from "@golemio/core/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategyStreamed";
|
|
2
|
+
export declare class RsdTmcOsmMappingDataStreamFactory {
|
|
3
|
+
getHTTPProtocolStrategyStreamed(dataUrl: string): HTTPProtocolStrategyStreamed;
|
|
4
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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.RsdTmcOsmMappingDataStreamFactory = void 0;
|
|
10
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
11
|
+
const HTTPProtocolStrategyStreamed_1 = require("@golemio/core/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategyStreamed");
|
|
12
|
+
let RsdTmcOsmMappingDataStreamFactory = class RsdTmcOsmMappingDataStreamFactory {
|
|
13
|
+
getHTTPProtocolStrategyStreamed(dataUrl) {
|
|
14
|
+
return new HTTPProtocolStrategyStreamed_1.HTTPProtocolStrategyStreamed({
|
|
15
|
+
headers: {},
|
|
16
|
+
method: "GET",
|
|
17
|
+
url: dataUrl,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
RsdTmcOsmMappingDataStreamFactory = __decorate([
|
|
22
|
+
(0, tsyringe_1.injectable)()
|
|
23
|
+
], RsdTmcOsmMappingDataStreamFactory);
|
|
24
|
+
exports.RsdTmcOsmMappingDataStreamFactory = RsdTmcOsmMappingDataStreamFactory;
|
|
25
|
+
//# sourceMappingURL=RsdTmcOsmMappingDataStreamFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RsdTmcOsmMappingDataStreamFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/RsdTmcOsmMappingDataStreamFactory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iEAAgE;AAChE,mJAAgJ;AAGhJ,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IACnC,+BAA+B,CAAC,OAAe;QAClD,OAAO,IAAI,2DAA4B,CAAC;YACpC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,OAAO;SACf,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AARY,iCAAiC;IAD7C,IAAA,qBAAU,GAAE;GACA,iCAAiC,CAQ7C;AARY,8EAAiC"}
|
|
@@ -5,7 +5,7 @@ const Di_1 = require("@golemio/core/dist/integration-engine/ioc/Di");
|
|
|
5
5
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
6
6
|
const ModuleContainerToken_1 = require("./ModuleContainerToken");
|
|
7
7
|
const RsdTmcOsmMappingRepository_1 = require("../repositories/RsdTmcOsmMappingRepository");
|
|
8
|
-
const
|
|
8
|
+
const RsdTmcOsmMappingDataStreamFactory_1 = require("../datasources/RsdTmcOsmMappingDataStreamFactory");
|
|
9
9
|
const ioc_1 = require("@golemio/core/dist/integration-engine/ioc");
|
|
10
10
|
const LteCze90PointsSjtskInAreaRepository_1 = require("../repositories/LteCze90PointsSjtskInAreaRepository");
|
|
11
11
|
//#region Initialization
|
|
@@ -13,10 +13,10 @@ const TrafficCommonContainer = Di_1.IntegrationEngineContainer.createChildContai
|
|
|
13
13
|
exports.TrafficCommonContainer = TrafficCommonContainer;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region Datasources
|
|
16
|
-
TrafficCommonContainer.register(ModuleContainerToken_1.ModuleContainerToken.
|
|
16
|
+
TrafficCommonContainer.register(ModuleContainerToken_1.ModuleContainerToken.RsdTmcOsmMappingDataSourceStrategy, {
|
|
17
17
|
useFactory: (0, tsyringe_1.instanceCachingFactory)(() => {
|
|
18
18
|
const config = Di_1.IntegrationEngineContainer.resolve(ioc_1.ContainerToken.Config);
|
|
19
|
-
return new
|
|
19
|
+
return new RsdTmcOsmMappingDataStreamFactory_1.RsdTmcOsmMappingDataStreamFactory().getHTTPProtocolStrategyStreamed(config.datasources.TrafficCommon.RsdTmcOsmMapping.url);
|
|
20
20
|
}),
|
|
21
21
|
});
|
|
22
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,qEAA0F;AAC1F,iEAAiG;AACjG,iEAA8D;AAE9D,2FAAyF;AACzF,wGAAsG;AACtG,mEAA2E;AAC3E,6GAA2G;AAE3G,wBAAwB;AACxB,MAAM,sBAAsB,GAAwB,+BAA0B,CAAC,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,qEAA0F;AAC1F,iEAAiG;AACjG,iEAA8D;AAE9D,2FAAyF;AACzF,wGAAsG;AACtG,mEAA2E;AAC3E,6GAA2G;AAE3G,wBAAwB;AACxB,MAAM,sBAAsB,GAAwB,+BAA0B,CAAC,oBAAoB,EAAE,CAAC;AAoC7F,wDAAsB;AAnC/B,YAAY;AAEZ,qBAAqB;AACrB,sBAAsB,CAAC,QAAQ,CAA+B,2CAAoB,CAAC,kCAAkC,EAAE;IACnH,UAAU,EAAE,IAAA,iCAAsB,EAA+B,GAAG,EAAE;QAClE,MAAM,MAAM,GAAmB,+BAA0B,CAAC,OAAO,CAAC,oBAAc,CAAC,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,qEAAiC,EAAE,CAAC,+BAA+B,CAC1E,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CACxD,CAAC;IACN,CAAC,CAAC;CACL,CAAC,CAAC;AACH,YAAY;AAEZ,yBAAyB;AAEzB,YAAY;AAEZ,iBAAiB;AAEjB,YAAY;AAEZ,sBAAsB;AACtB,sBAAsB,CAAC,iBAAiB,CACpC,2CAAoB,CAAC,0BAA0B,EAC/C,uDAA0B,CAC7B,CAAC,QAAQ,CACN,2CAAoB,CAAC,mCAAmC,EACxD,yEAAmC,CACtC,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModuleContainerToken = void 0;
|
|
4
4
|
const ModuleContainerToken = {
|
|
5
|
-
|
|
5
|
+
RsdTmcOsmMappingDataSourceStrategy: Symbol(),
|
|
6
6
|
RsdTmcOsmMappingRepository: Symbol(),
|
|
7
7
|
LteCze90PointsSjtskInAreaRepository: Symbol(),
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleContainerToken.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/ModuleContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG;IACzB,
|
|
1
|
+
{"version":3,"file":"ModuleContainerToken.js","sourceRoot":"","sources":["../../../src/integration-engine/ioc/ModuleContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG;IACzB,kCAAkC,EAAE,MAAM,EAAE;IAC5C,0BAA0B,EAAE,MAAM,EAAE;IACpC,mCAAmC,EAAE,MAAM,EAAE;CAChD,CAAC;AAEO,oDAAoB"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
2
3
|
import IPostgresConnector from "@golemio/core/dist/integration-engine/connectors/interfaces/IPostgresConnector";
|
|
3
|
-
import {
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers";
|
|
5
|
+
import { Readable } from "stream";
|
|
4
6
|
export declare class RsdTmcOsmMappingRepository extends PostgresModel implements IModel {
|
|
5
7
|
private connector;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
private logger;
|
|
9
|
+
constructor(connector: IPostgresConnector, logger: ILogger);
|
|
10
|
+
cleanTable(): Promise<void>;
|
|
11
|
+
streamDataIn(data: Readable): Promise<void>;
|
|
8
12
|
}
|
|
@@ -28,8 +28,9 @@ const RsdTmcOsmMappingModel_1 = require("../../schema-definitions/models/RsdTmcO
|
|
|
28
28
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
29
29
|
const ioc_1 = require("@golemio/core/dist/integration-engine/ioc");
|
|
30
30
|
const _sch_1 = require("../../schema-definitions");
|
|
31
|
+
const pg_copy_streams_1 = require("pg-copy-streams");
|
|
31
32
|
let RsdTmcOsmMappingRepository = class RsdTmcOsmMappingRepository extends models_1.PostgresModel {
|
|
32
|
-
constructor(connector) {
|
|
33
|
+
constructor(connector, logger) {
|
|
33
34
|
super("RsdTmcOsmMappingRepository", {
|
|
34
35
|
outputSequelizeAttributes: RsdTmcOsmMappingModel_1.RsdTmcOsmMappingModel.attributeModel,
|
|
35
36
|
pgTableName: _sch_1.RsdTmcOsmMappingTable.pgTableName,
|
|
@@ -41,33 +42,44 @@ let RsdTmcOsmMappingRepository = class RsdTmcOsmMappingRepository extends models
|
|
|
41
42
|
},
|
|
42
43
|
}, new golemio_validator_1.JSONSchemaValidator("RsdTmcOsmMappingValidator", RsdTmcOsmMappingModel_1.RsdTmcOsmMappingModel.jsonSchema));
|
|
43
44
|
this.connector = connector;
|
|
45
|
+
this.logger = logger;
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
cleanTable() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
yield this.sequelizeModel.destroy({
|
|
50
|
+
truncate: true,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
streamDataIn(data) {
|
|
46
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
56
|
const connection = this.connector.getConnection();
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const client = yield connection.connectionManager.getConnection({ type: "write" });
|
|
58
|
+
// copy transformed data to tmp table by stream
|
|
59
|
+
yield new Promise((resolve, reject) => {
|
|
60
|
+
const stream = client
|
|
61
|
+
.query((0, pg_copy_streams_1.from)(`COPY "${_sch_1.RsdTmcOsmMappingTable.pgSchema}".${_sch_1.RsdTmcOsmMappingTable.pgTableName}
|
|
62
|
+
FROM STDIN DELIMITER ',' CSV HEADER;`))
|
|
63
|
+
.on("error", (err) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
this.logger.error(`Copying data error (${this.name}): ${err.toString()}`);
|
|
65
|
+
yield connection.connectionManager.releaseConnection(client);
|
|
66
|
+
return reject(err);
|
|
67
|
+
}))
|
|
68
|
+
.on("finish", () => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
this.logger.info(`Done copying data (${this.name})`);
|
|
70
|
+
yield connection.connectionManager.releaseConnection(client);
|
|
71
|
+
return resolve();
|
|
72
|
+
}));
|
|
73
|
+
data.pipe(stream);
|
|
74
|
+
});
|
|
64
75
|
});
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
RsdTmcOsmMappingRepository = __decorate([
|
|
68
79
|
(0, tsyringe_1.injectable)(),
|
|
69
80
|
__param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.PostgresConnector)),
|
|
70
|
-
|
|
81
|
+
__param(1, (0, tsyringe_1.inject)(ioc_1.ContainerToken.Logger)),
|
|
82
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
71
83
|
], RsdTmcOsmMappingRepository);
|
|
72
84
|
exports.RsdTmcOsmMappingRepository = RsdTmcOsmMappingRepository;
|
|
73
85
|
//# sourceMappingURL=RsdTmcOsmMappingRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RsdTmcOsmMappingRepository.js","sourceRoot":"","sources":["../../../src/integration-engine/repositories/RsdTmcOsmMappingRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAqF;AACrF,iEAAwE;AACxE,iGAA0E;AAC1E,mFAAkF;AAClF,mEAA2E;AAE3E,
|
|
1
|
+
{"version":3,"file":"RsdTmcOsmMappingRepository.js","sourceRoot":"","sources":["../../../src/integration-engine/repositories/RsdTmcOsmMappingRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAqF;AACrF,iEAAwE;AACxE,iGAA0E;AAC1E,mFAAkF;AAClF,mEAA2E;AAE3E,mDAA6C;AAC7C,qDAAmD;AAKnD,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,sBAAa;IACzD,YACsD,SAA6B,EACxC,MAAe;QAEtD,KAAK,CACD,4BAA4B,EAC5B;YACI,yBAAyB,EAAE,6CAAqB,CAAC,cAAc;YAC/D,WAAW,EAAE,4BAAqB,CAAC,WAAW;YAC9C,QAAQ,EAAE,4BAAqB,CAAC,QAAQ;YACxC,UAAU,EAAE,YAAY;YACxB,kBAAkB,EAAE,CAAC,IAAI,CAAC;YAC1B,2BAA2B,EAAE;gBACzB,UAAU,EAAE,KAAK;aACpB;SACJ,EACD,IAAI,uCAAmB,CAAC,2BAA2B,EAAE,6CAAqB,CAAC,UAAU,CAAC,CACzF,CAAC;QAhBgD,cAAS,GAAT,SAAS,CAAoB;QACxC,WAAM,GAAN,MAAM,CAAS;IAgB1D,CAAC;IAEY,UAAU;;YACnB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC9B,QAAQ,EAAE,IAAI;aACjB,CAAC,CAAC;QACP,CAAC;KAAA;IAEY,YAAY,CAAC,IAAc;;YACpC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;YAClD,MAAM,MAAM,GAAQ,MAAM,UAAU,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAExF,+CAA+C;YAC/C,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACxC,MAAM,MAAM,GAAG,MAAM;qBAChB,KAAK,CACF,IAAA,sBAAQ,EACJ,SAAS,4BAAqB,CAAC,QAAQ,KAAK,4BAAqB,CAAC,WAAW;6DACxC,CACxC,CACJ;qBACA,EAAE,CAAC,OAAO,EAAE,CAAO,GAAQ,EAAE,EAAE;oBAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBAC1E,MAAM,UAAU,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC7D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,CAAC,CAAA,CAAC;qBACD,EAAE,CAAC,QAAQ,EAAE,GAAS,EAAE;oBACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;oBACrD,MAAM,UAAU,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC7D,OAAO,OAAO,EAAE,CAAC;gBACrB,CAAC,CAAA,CAAC,CAAC;gBACP,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAA;AArDY,0BAA0B;IADtC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,iBAAiB,CAAC,CAAA;IACxC,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,MAAM,CAAC,CAAA;;GAHzB,0BAA0B,CAqDtC;AArDY,gEAA0B"}
|
|
@@ -9,7 +9,7 @@ class RsdTmcOsmMappingWorker extends integration_engine_1.AbstractWorker {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
11
11
|
this.name = "RsdTmcOsmMapping";
|
|
12
|
-
this.registerTask(new RefreshRsdTmcOsmMappingDataTask_1.RefreshRsdTmcOsmMappingDataTask(this.getQueuePrefix(), Di_1.TrafficCommonContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.
|
|
12
|
+
this.registerTask(new RefreshRsdTmcOsmMappingDataTask_1.RefreshRsdTmcOsmMappingDataTask(this.getQueuePrefix(), Di_1.TrafficCommonContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.RsdTmcOsmMappingDataSourceStrategy), Di_1.TrafficCommonContainer.resolve(ModuleContainerToken_1.ModuleContainerToken.RsdTmcOsmMappingRepository)));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.RsdTmcOsmMappingWorker = RsdTmcOsmMappingWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RsdTmcOsmMappingWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/RsdTmcOsmMappingWorker.ts"],"names":[],"mappings":";;;AAAA,8EAAuE;AACvE,6FAA0F;AAC1F,sEAAoE;AACpE,kCAAoD;AAEpD,MAAa,sBAAuB,SAAQ,mCAAc;IAGtD;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,kBAAkB,CAAC;QAIhC,IAAI,CAAC,YAAY,CACb,IAAI,iEAA+B,CAC/B,IAAI,CAAC,cAAc,EAAE,EACrB,2BAAsB,CAAC,OAAO,CAAC,2CAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"RsdTmcOsmMappingWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/workers/RsdTmcOsmMappingWorker.ts"],"names":[],"mappings":";;;AAAA,8EAAuE;AACvE,6FAA0F;AAC1F,sEAAoE;AACpE,kCAAoD;AAEpD,MAAa,sBAAuB,SAAQ,mCAAc;IAGtD;QACI,KAAK,EAAE,CAAC;QAHF,SAAI,GAAG,kBAAkB,CAAC;QAIhC,IAAI,CAAC,YAAY,CACb,IAAI,iEAA+B,CAC/B,IAAI,CAAC,cAAc,EAAE,EACrB,2BAAsB,CAAC,OAAO,CAAC,2CAAoB,CAAC,kCAAkC,CAAC,EACvF,2BAAsB,CAAC,OAAO,CAAC,2CAAoB,CAAC,0BAA0B,CAAC,CAClF,CACJ,CAAC;IACN,CAAC;CACJ;AAbD,wDAaC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { AbstractEmptyTask,
|
|
1
|
+
import { AbstractEmptyTask, HTTPProtocolStrategyStreamed } from "@golemio/core/dist/integration-engine";
|
|
2
2
|
import { RsdTmcOsmMappingRepository } from "../../repositories/RsdTmcOsmMappingRepository";
|
|
3
3
|
export declare class RefreshRsdTmcOsmMappingDataTask extends AbstractEmptyTask {
|
|
4
|
-
private
|
|
4
|
+
private streamedStrategy;
|
|
5
5
|
private repository;
|
|
6
6
|
readonly queueName = "RsdTmsOsmMappingRefresh";
|
|
7
7
|
readonly queueTtl: number;
|
|
8
|
-
constructor(queuePrefix: string,
|
|
8
|
+
constructor(queuePrefix: string, streamedStrategy: HTTPProtocolStrategyStreamed, repository: RsdTmcOsmMappingRepository);
|
|
9
9
|
protected execute(): Promise<void>;
|
|
10
|
-
private onDataFunction;
|
|
11
|
-
private processDataStream;
|
|
12
10
|
}
|
|
@@ -13,34 +13,34 @@ exports.RefreshRsdTmcOsmMappingDataTask = void 0;
|
|
|
13
13
|
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
14
14
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
15
15
|
class RefreshRsdTmcOsmMappingDataTask extends integration_engine_1.AbstractEmptyTask {
|
|
16
|
-
constructor(queuePrefix,
|
|
16
|
+
constructor(queuePrefix, streamedStrategy, repository) {
|
|
17
17
|
super(queuePrefix);
|
|
18
|
-
this.
|
|
18
|
+
this.streamedStrategy = streamedStrategy;
|
|
19
19
|
this.repository = repository;
|
|
20
20
|
this.queueName = "RsdTmsOsmMappingRefresh";
|
|
21
21
|
this.queueTtl = 59 * 60 * 1000; // 59 minutes
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.processDataStream = (dataSourceStream, onDataFunction) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
}
|
|
23
|
+
execute() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
25
|
let dataStream;
|
|
27
26
|
try {
|
|
28
|
-
|
|
27
|
+
yield this.repository.cleanTable();
|
|
29
28
|
}
|
|
30
29
|
catch (err) {
|
|
31
|
-
throw new golemio_errors_1.CustomError("Error while
|
|
30
|
+
throw new golemio_errors_1.CustomError("Error while cleaning table.", true, this.constructor.name, 5050, err);
|
|
32
31
|
}
|
|
33
32
|
try {
|
|
34
|
-
yield
|
|
33
|
+
dataStream = yield this.streamedStrategy.getRawData();
|
|
35
34
|
}
|
|
36
35
|
catch (err) {
|
|
37
|
-
throw new golemio_errors_1.CustomError("Error while
|
|
36
|
+
throw new golemio_errors_1.CustomError("Error while getting data stream.", true, this.constructor.name, 5050, err);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
yield this.repository.streamDataIn(dataStream.data);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw new golemio_errors_1.CustomError("Error while saving data.", true, this.constructor.name, 5051, err);
|
|
38
43
|
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
execute() {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
yield this.processDataStream(this.dataSource.getAll(true), this.onDataFunction);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshRsdTmcOsmMappingDataTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/RefreshRsdTmcOsmMappingDataTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"RefreshRsdTmcOsmMappingDataTask.js","sourceRoot":"","sources":["../../../../src/integration-engine/workers/tasks/RefreshRsdTmcOsmMappingDataTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAwG;AAExG,6EAAuE;AAGvE,MAAa,+BAAgC,SAAQ,sCAAiB;IAIlE,YACI,WAAmB,EACX,gBAA8C,EAC9C,UAAsC;QAE9C,KAAK,CAAC,WAAW,CAAC,CAAC;QAHX,qBAAgB,GAAhB,gBAAgB,CAA8B;QAC9C,eAAU,GAAV,UAAU,CAA4B;QANlC,cAAS,GAAG,yBAAyB,CAAC;QACtC,aAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;IAQxD,CAAC;IAEe,OAAO;;YACnB,IAAI,UAA8B,CAAC;YAEnC,IAAI;gBACA,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;aACtC;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,4BAAW,CAAC,6BAA6B,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;aAChG;YAED,IAAI;gBACA,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC;aACzD;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,4BAAW,CAAC,kCAAkC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;aACrG;YAED,IAAI;gBACA,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;aACvD;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,4BAAW,CAAC,0BAA0B,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;aAC7F;QACL,CAAC;KAAA;CACJ;AAjCD,0EAiCC"}
|
|
@@ -30,7 +30,6 @@ Modul spravuje dopravní data využívaná ostatními moduly (konkrétně NDIC a
|
|
|
30
30
|
- název rabbitmq fronty
|
|
31
31
|
- dataplatform.RsdTmcOsmMapping.RsdTmsOsmMappingRefresh
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
### *RsdTmcOsmMappingWorker*
|
|
35
34
|
|
|
36
35
|
#### *task: RefreshRsdTmcOsmMappingDataTask*
|
|
@@ -40,6 +39,7 @@ Modul spravuje dopravní data využívaná ostatními moduly (konkrétně NDIC a
|
|
|
40
39
|
- bez parametrů
|
|
41
40
|
- datové zdroje
|
|
42
41
|
- RsdTmcOsmMapping CSV
|
|
42
|
+
- data se streamují napřímo do databáze
|
|
43
43
|
- data modely
|
|
44
44
|
- RsdTmcOsmMappingModel -> (schéma traffic) `rsd_tmc_osm_mapping`
|
|
45
45
|
|
|
@@ -50,5 +50,5 @@ Modul spravuje dopravní data využívaná ostatními moduly (konkrétně NDIC a
|
|
|
50
50
|
- tabulka
|
|
51
51
|
- `traffic.rsd_tmc_osm_mapping`
|
|
52
52
|
- retence dat
|
|
53
|
-
- task
|
|
53
|
+
- task obnoví data při každém běhu
|
|
54
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/traffic-common",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.856907064",
|
|
4
4
|
"description": "Golemio Common Traffic Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/chai-as-promised": "7.1.2",
|
|
41
41
|
"@types/mocha": "^9.1.0",
|
|
42
42
|
"@types/node": "^18.13.0",
|
|
43
|
+
"@types/pg-copy-streams": "^1.2.2",
|
|
43
44
|
"@types/sinon": "^9.0.10",
|
|
44
45
|
"@types/supertest": "^2.0.12",
|
|
45
46
|
"chai": "4.2.0",
|
|
@@ -63,5 +64,8 @@
|
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"@golemio/core": ">=1.6.5"
|
|
65
66
|
},
|
|
66
|
-
"overrides": {}
|
|
67
|
+
"overrides": {},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"pg-copy-streams": "^6.0.5"
|
|
70
|
+
}
|
|
67
71
|
}
|
|
@@ -1,36 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RsdTmcOsmMappingDataSourceFactory = void 0;
|
|
10
|
-
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
11
|
-
const _sch_1 = require("../../schema-definitions");
|
|
12
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
13
|
-
const HTTPProtocolStrategyStreamed_1 = require("@golemio/core/dist/integration-engine/datasources/protocol-strategy/HTTPProtocolStrategyStreamed");
|
|
14
|
-
let RsdTmcOsmMappingDataSourceFactory = class RsdTmcOsmMappingDataSourceFactory {
|
|
15
|
-
getDataSource(dataUrl) {
|
|
16
|
-
return new integration_engine_1.DataSourceStreamed(_sch_1.RsdTmcOsmMappingTable.name + "DataSource", new HTTPProtocolStrategyStreamed_1.HTTPProtocolStrategyStreamed({
|
|
17
|
-
headers: {},
|
|
18
|
-
method: "GET",
|
|
19
|
-
url: dataUrl,
|
|
20
|
-
}), new integration_engine_1.CSVDataTypeStrategy({
|
|
21
|
-
fastcsvParams: {
|
|
22
|
-
headers: true,
|
|
23
|
-
},
|
|
24
|
-
subscribe: (row) => ({
|
|
25
|
-
lt_start: Number(row.lt_start),
|
|
26
|
-
lt_end: Number(row.lt_end),
|
|
27
|
-
osm_path: row.osm_path,
|
|
28
|
-
}),
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
RsdTmcOsmMappingDataSourceFactory = __decorate([
|
|
33
|
-
(0, tsyringe_1.injectable)()
|
|
34
|
-
], RsdTmcOsmMappingDataSourceFactory);
|
|
35
|
-
exports.RsdTmcOsmMappingDataSourceFactory = RsdTmcOsmMappingDataSourceFactory;
|
|
36
|
-
//# sourceMappingURL=RsdTmcOsmMappingDataSourceFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RsdTmcOsmMappingDataSourceFactory.js","sourceRoot":"","sources":["../../../src/integration-engine/datasources/RsdTmcOsmMappingDataSourceFactory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8EAAgG;AAChG,mDAA6C;AAC7C,iEAAgE;AAChE,mJAAgJ;AAGhJ,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IACnC,aAAa,CAAC,OAAe;QAChC,OAAO,IAAI,uCAAkB,CACzB,4BAAqB,CAAC,IAAI,GAAG,YAAY,EACzC,IAAI,2DAA4B,CAAC;YAC7B,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,OAAO;SACf,CAAC,EACF,IAAI,wCAAmB,CAAC;YACpB,aAAa,EAAE;gBACX,OAAO,EAAE,IAAI;aAChB;YACD,SAAS,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC;gBACtB,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAC9B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;gBAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ;aACzB,CAAC;SACL,CAAC,CACL,CAAC;IACN,CAAC;CACJ,CAAA;AArBY,iCAAiC;IAD7C,IAAA,qBAAU,GAAE;GACA,iCAAiC,CAqB7C;AArBY,8EAAiC"}
|