@golemio/pid 2.1.4 → 2.1.5-dev.431823764
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/example/__truncate_tables.sql +1 -0
- package/db/example/ropidvymi_example.sql +12 -12
- package/db/migrations/postgresql/20211213120726-ropidvymi-refactoring.js +53 -0
- package/db/migrations/postgresql/package.json +3 -0
- package/db/migrations/postgresql/sqls/20211213120726-ropidvymi-refactoring-down.sql +45 -0
- package/db/migrations/postgresql/sqls/20211213120726-ropidvymi-refactoring-up.sql +54 -0
- package/db/migrations/postgresql/sqls/package.json +3 -0
- package/dist/integration-engine/queueDefinitions.js +13 -3
- package/dist/integration-engine/queueDefinitions.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSMetadataModel.d.ts +2 -36
- package/dist/integration-engine/ropid-gtfs/RopidGTFSMetadataModel.js +18 -321
- package/dist/integration-engine/ropid-gtfs/RopidGTFSMetadataModel.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSWorker.js +13 -12
- package/dist/integration-engine/ropid-gtfs/RopidGTFSWorker.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/RopidVYMIEventsTransformation.d.ts +11 -11
- package/dist/integration-engine/ropid-vymi/RopidVYMIEventsTransformation.js +45 -39
- package/dist/integration-engine/ropid-vymi/RopidVYMIEventsTransformation.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/RopidVYMIWorker.d.ts +15 -2
- package/dist/integration-engine/ropid-vymi/RopidVYMIWorker.js +115 -17
- package/dist/integration-engine/ropid-vymi/RopidVYMIWorker.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsModel.d.ts +0 -16
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsModel.js +2 -46
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsModel.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsRoutesModel.d.ts +0 -14
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsRoutesModel.js +2 -48
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsRoutesModel.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsStopsModel.d.ts +0 -13
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsStopsModel.js +2 -50
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIEventsStopsModel.js.map +1 -1
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIMetadataModel.d.ts +8 -0
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIMetadataModel.js +44 -0
- package/dist/integration-engine/ropid-vymi/models/RopidVYMIMetadataModel.js.map +1 -0
- package/dist/integration-engine/ropid-vymi/models/index.d.ts +1 -0
- package/dist/integration-engine/ropid-vymi/models/index.js +1 -0
- package/dist/integration-engine/ropid-vymi/models/index.js.map +1 -1
- package/dist/integration-engine/shared/RopidMetadataModel.d.ts +29 -0
- package/dist/integration-engine/shared/RopidMetadataModel.js +261 -0
- package/dist/integration-engine/shared/RopidMetadataModel.js.map +1 -0
- package/dist/integration-engine/shared/index.d.ts +1 -0
- package/dist/integration-engine/shared/index.js +14 -0
- package/dist/integration-engine/shared/index.js.map +1 -0
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js +1 -1
- package/dist/output-gateway/pid/models/PIDDepartureBoardsModel.js.map +1 -1
- package/dist/output-gateway/pid/models/RopidVYMIEventsStopsModel.js +2 -3
- package/dist/output-gateway/pid/models/RopidVYMIEventsStopsModel.js.map +1 -1
- package/dist/schema-definitions/ropid-gtfs/index.d.ts +2 -604
- package/dist/schema-definitions/ropid-gtfs/index.js +3 -24
- package/dist/schema-definitions/ropid-gtfs/index.js.map +1 -1
- package/dist/schema-definitions/ropid-vymi/RopidVYMIOutputSchemas.d.ts +135 -126
- package/dist/schema-definitions/ropid-vymi/RopidVYMIOutputSchemas.js +138 -129
- package/dist/schema-definitions/ropid-vymi/RopidVYMIOutputSchemas.js.map +1 -1
- package/dist/schema-definitions/ropid-vymi/RopidVYMISDMA.js +24 -23
- package/dist/schema-definitions/ropid-vymi/RopidVYMISDMA.js.map +1 -1
- package/dist/schema-definitions/ropid-vymi/index.d.ts +2 -181
- package/dist/schema-definitions/ropid-vymi/index.js +7 -0
- package/dist/schema-definitions/ropid-vymi/index.js.map +1 -1
- package/dist/schema-definitions/shared/index.d.ts +15 -0
- package/dist/schema-definitions/shared/index.js +29 -0
- package/dist/schema-definitions/shared/index.js.map +1 -0
- package/package.json +83 -83
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { BaseTransformation, ITransformation } from "@golemio/core/dist/integration-engine/transformations";
|
|
2
2
|
import { IRopidVYMIEvent, IRopidVYMIEventOutput, IRopidVYMIEventRouteOutput, IRopidVYMIEventStopOutput } from "../../schema-definitions/ropid-vymi";
|
|
3
|
-
interface
|
|
3
|
+
interface ITransformElementOutput {
|
|
4
4
|
event: IRopidVYMIEventOutput;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
routes: IRopidVYMIEventRouteOutput[];
|
|
6
|
+
stops: IRopidVYMIEventStopOutput[];
|
|
7
|
+
}
|
|
8
|
+
interface ITransformedData extends Omit<ITransformElementOutput, "event"> {
|
|
9
|
+
events: IRopidVYMIEventOutput[];
|
|
7
10
|
}
|
|
8
11
|
export declare class RopidVYMIEventsTransformation extends BaseTransformation implements ITransformation {
|
|
9
12
|
name: string;
|
|
10
13
|
constructor();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private composeTransformRoutes;
|
|
17
|
-
private composeTransformStops;
|
|
18
|
-
private convertHTMLFragmentToPlainText;
|
|
14
|
+
transform: (data: IRopidVYMIEvent[]) => Promise<ITransformedData>;
|
|
15
|
+
protected transformElement: (event: IRopidVYMIEvent) => ITransformElementOutput;
|
|
16
|
+
private transformRoutes;
|
|
17
|
+
private transformStops;
|
|
18
|
+
private outputPlainText;
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -16,46 +16,52 @@ const ropid_vymi_1 = require("../../schema-definitions/ropid-vymi");
|
|
|
16
16
|
class RopidVYMIEventsTransformation extends transformations_1.BaseTransformation {
|
|
17
17
|
constructor() {
|
|
18
18
|
super();
|
|
19
|
-
/**
|
|
20
|
-
* Overrides BaseTransformation::transform
|
|
21
|
-
*/
|
|
22
19
|
this.transform = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
state: parseInt(data["@stav"], 10),
|
|
28
|
-
pa_01: data["@pa_01"],
|
|
29
|
-
pa_02: data["@pa_02"],
|
|
30
|
-
pa_03: data["@pa_03"],
|
|
31
|
-
pa_04: data["@pa_04"],
|
|
32
|
-
record_type: parseInt(data["@typ_zaznamu"], 10),
|
|
33
|
-
event_type: data["@typ_udalost"] ? parseInt(data["@typ_udalost"], 10) : null,
|
|
34
|
-
channels: parseInt(data["@kanaly"], 10),
|
|
35
|
-
title: data["@nazev"],
|
|
36
|
-
time_from: data["@cas_od"],
|
|
37
|
-
time_to_type: parseInt(data["@typ_do"], 10),
|
|
38
|
-
time_to: (_a = data["@cas_do"]) !== null && _a !== void 0 ? _a : null,
|
|
39
|
-
expiration_date: (_b = data["@zobrazit_do"]) !== null && _b !== void 0 ? _b : null,
|
|
40
|
-
transportation_type: parseInt(data["@druh_dopr"], 10),
|
|
41
|
-
priority: data["@priorita"] ? parseInt(data["@priorita"], 10) : null,
|
|
42
|
-
cause: (_c = data["@duvod"]) !== null && _c !== void 0 ? _c : null,
|
|
43
|
-
link: (_d = data["@link"]) !== null && _d !== void 0 ? _d : null,
|
|
44
|
-
ropid_action: (_e = data["@opatr_ropid"]) !== null && _e !== void 0 ? _e : null,
|
|
45
|
-
dpp_action: (_f = data["@opatr_dpp"]) !== null && _f !== void 0 ? _f : null,
|
|
46
|
-
description: (_g = data["@popis"]) !== null && _g !== void 0 ? _g : null,
|
|
20
|
+
let output = {
|
|
21
|
+
events: [],
|
|
22
|
+
routes: [],
|
|
23
|
+
stops: [],
|
|
47
24
|
};
|
|
25
|
+
for (const eventData of data) {
|
|
26
|
+
const { event, routes, stops } = this.transformElement(eventData);
|
|
27
|
+
output.events.push(event);
|
|
28
|
+
output.routes.push(...routes);
|
|
29
|
+
output.stops.push(...stops);
|
|
30
|
+
}
|
|
31
|
+
return output;
|
|
32
|
+
});
|
|
33
|
+
this.transformElement = (event) => {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
35
|
return {
|
|
49
|
-
event
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
event: {
|
|
37
|
+
vymi_id: parseInt(event["@id"], 10),
|
|
38
|
+
vymi_id_dtb: parseInt(event["@id_dtb"], 10),
|
|
39
|
+
state: parseInt(event["@stav"], 10),
|
|
40
|
+
pa_01: event["@pa_01"],
|
|
41
|
+
pa_02: event["@pa_02"],
|
|
42
|
+
pa_03: event["@pa_03"],
|
|
43
|
+
pa_04: event["@pa_04"],
|
|
44
|
+
record_type: parseInt(event["@typ_zaznamu"], 10),
|
|
45
|
+
event_type: event["@typ_udalost"] ? parseInt(event["@typ_udalost"], 10) : null,
|
|
46
|
+
channels: parseInt(event["@kanaly"], 10),
|
|
47
|
+
title: event["@nazev"],
|
|
48
|
+
time_from: event["@cas_od"],
|
|
49
|
+
time_to_type: parseInt(event["@typ_do"], 10),
|
|
50
|
+
time_to: (_a = event["@cas_do"]) !== null && _a !== void 0 ? _a : null,
|
|
51
|
+
expiration_date: (_b = event["@zobrazit_do"]) !== null && _b !== void 0 ? _b : null,
|
|
52
|
+
transportation_type: parseInt(event["@druh_dopr"], 10),
|
|
53
|
+
priority: event["@priorita"] ? parseInt(event["@priorita"], 10) : null,
|
|
54
|
+
cause: (_c = event["@duvod"]) !== null && _c !== void 0 ? _c : null,
|
|
55
|
+
link: (_d = event["@link"]) !== null && _d !== void 0 ? _d : null,
|
|
56
|
+
ropid_action: (_e = event["@opatr_ropid"]) !== null && _e !== void 0 ? _e : null,
|
|
57
|
+
dpp_action: (_f = event["@opatr_dpp"]) !== null && _f !== void 0 ? _f : null,
|
|
58
|
+
description: (_g = event["@popis"]) !== null && _g !== void 0 ? _g : null,
|
|
59
|
+
},
|
|
60
|
+
routes: this.transformRoutes(parseInt(event["@id"], 10), event["linky-zmena"]),
|
|
61
|
+
stops: this.transformStops(parseInt(event["@id"], 10), event["zastavky-zmena"]),
|
|
52
62
|
};
|
|
53
|
-
});
|
|
54
|
-
this.transformElement = () => {
|
|
55
|
-
// Nothing to do.
|
|
56
|
-
return;
|
|
57
63
|
};
|
|
58
|
-
this.
|
|
64
|
+
this.transformRoutes = (eventId, routes = []) => {
|
|
59
65
|
return routes.map((route) => {
|
|
60
66
|
var _a, _b;
|
|
61
67
|
return ({
|
|
@@ -68,11 +74,11 @@ class RopidVYMIEventsTransformation extends transformations_1.BaseTransformation
|
|
|
68
74
|
route_type: parseInt(route["@linka_typ"], 10),
|
|
69
75
|
valid_from: (_a = route["@plati_od"]) !== null && _a !== void 0 ? _a : null,
|
|
70
76
|
valid_to: (_b = route["@plati_do"]) !== null && _b !== void 0 ? _b : null,
|
|
71
|
-
text: this.
|
|
77
|
+
text: this.outputPlainText(route["#text"]),
|
|
72
78
|
});
|
|
73
79
|
});
|
|
74
80
|
};
|
|
75
|
-
this.
|
|
81
|
+
this.transformStops = (eventId, stops = []) => {
|
|
76
82
|
return stops.map((stop) => {
|
|
77
83
|
var _a, _b;
|
|
78
84
|
return ({
|
|
@@ -85,11 +91,11 @@ class RopidVYMIEventsTransformation extends transformations_1.BaseTransformation
|
|
|
85
91
|
stop_type: parseInt(stop["@zast_typ"], 10),
|
|
86
92
|
valid_from: (_a = stop["@plati_od"]) !== null && _a !== void 0 ? _a : null,
|
|
87
93
|
valid_to: (_b = stop["@plati_do"]) !== null && _b !== void 0 ? _b : null,
|
|
88
|
-
text: this.
|
|
94
|
+
text: this.outputPlainText(stop["#text"]),
|
|
89
95
|
});
|
|
90
96
|
});
|
|
91
97
|
};
|
|
92
|
-
this.
|
|
98
|
+
this.outputPlainText = (html) => {
|
|
93
99
|
return jsdom_1.JSDOM.fragment(html).textContent || null;
|
|
94
100
|
};
|
|
95
101
|
this.name = ropid_vymi_1.RopidVYMI.events.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopidVYMIEventsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/ropid-vymi/RopidVYMIEventsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8B;AAC9B,2FAA4G;AAC5G,oEAQyB;
|
|
1
|
+
{"version":3,"file":"RopidVYMIEventsTransformation.js","sourceRoot":"","sources":["../../../src/integration-engine/ropid-vymi/RopidVYMIEventsTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8B;AAC9B,2FAA4G;AAC5G,oEAQyB;AAYzB,MAAa,6BAA8B,SAAQ,oCAAkB;IAGjE;QACI,KAAK,EAAE,CAAC;QAII,cAAS,GAAG,CAAO,IAAuB,EAA6B,EAAE;YACrF,IAAI,MAAM,GAAqB;gBAC3B,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,EAAE;aACZ,CAAC;YAEF,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC1B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;gBAClE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;gBAC9B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;aAC/B;YAED,OAAO,MAAM,CAAC;QAClB,CAAC,CAAA,CAAC;QAEiB,qBAAgB,GAAG,CAAC,KAAsB,EAA2B,EAAE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AI,CAAC;IACtC,CAAC;CAmFJ;AAzFD,sEAyFC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { BaseWorker } from "@golemio/core/dist/integration-engine/workers";
|
|
2
3
|
declare class RopidVYMIWorker extends BaseWorker {
|
|
3
4
|
private readonly datasource;
|
|
@@ -5,10 +6,22 @@ declare class RopidVYMIWorker extends BaseWorker {
|
|
|
5
6
|
private readonly modelVYMIEvents;
|
|
6
7
|
private readonly modelVYMIEventsRoutes;
|
|
7
8
|
private readonly modelVYMIEventsStops;
|
|
9
|
+
private readonly modelVYMIMeta;
|
|
10
|
+
private readonly queuePrefix;
|
|
8
11
|
constructor();
|
|
9
12
|
/**
|
|
10
|
-
* Worker method -
|
|
13
|
+
* Worker method - check for new events
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
checkForNewEvents: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Worker method - fetch and process events
|
|
18
|
+
*/
|
|
19
|
+
fetchAndProcessEvents: (msg: {
|
|
20
|
+
content: Buffer;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
private prepareAndTransformEvents;
|
|
23
|
+
private prepareAndSaveEvents;
|
|
24
|
+
private getAllEvents;
|
|
25
|
+
private createDigest;
|
|
13
26
|
}
|
|
14
27
|
export { RopidVYMIWorker };
|
|
@@ -13,14 +13,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RopidVYMIWorker = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
16
17
|
const JSONStream_1 = __importDefault(require("JSONStream"));
|
|
17
18
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
19
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
18
20
|
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
19
21
|
const datasources_1 = require("@golemio/core/dist/integration-engine/datasources");
|
|
20
|
-
const
|
|
22
|
+
const helpers_1 = require("@golemio/core/dist/integration-engine/helpers");
|
|
21
23
|
const config_1 = require("@golemio/core/dist/integration-engine/config");
|
|
22
24
|
const ropid_vymi_1 = require("../../schema-definitions/ropid-vymi");
|
|
25
|
+
const shared_1 = require("../shared");
|
|
23
26
|
const models_1 = require("./models");
|
|
27
|
+
const RopidVYMIMetadataModel_1 = require("./models/RopidVYMIMetadataModel");
|
|
24
28
|
const RopidVYMIEventsTransformation_1 = require("./RopidVYMIEventsTransformation");
|
|
25
29
|
var RopidVYMIApiOutputLevel;
|
|
26
30
|
(function (RopidVYMIApiOutputLevel) {
|
|
@@ -32,28 +36,120 @@ class RopidVYMIWorker extends workers_1.BaseWorker {
|
|
|
32
36
|
constructor() {
|
|
33
37
|
super();
|
|
34
38
|
/**
|
|
35
|
-
* Worker method -
|
|
39
|
+
* Worker method - check for new events
|
|
36
40
|
*/
|
|
37
|
-
this.
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
yield this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
this.checkForNewEvents = () => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const lastDigest = yield this.modelVYMIMeta.getDigest(RopidVYMIMetadataModel_1.DatasetEnum.EVENTS);
|
|
43
|
+
const { digest, data } = yield this.getAllEvents();
|
|
44
|
+
if (digest !== lastDigest) {
|
|
45
|
+
yield this.sendMessageToExchange("workers." + this.queuePrefix + ".fetchAndProcessEvents", JSON.stringify({ digest, data }));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Worker method - fetch and process events
|
|
50
|
+
*/
|
|
51
|
+
this.fetchAndProcessEvents = (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
let content = undefined;
|
|
53
|
+
try {
|
|
54
|
+
content = JSON.parse(msg.content.toString());
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// Noop
|
|
58
|
+
}
|
|
59
|
+
if (!content || !content.data || !content.digest) {
|
|
60
|
+
helpers_1.log.warn(`[${this.constructor.name}] fetchAndProcessEvents() Invalid content. Fetching data again`);
|
|
61
|
+
content = yield this.getAllEvents();
|
|
62
|
+
}
|
|
63
|
+
const dbLastModified = yield this.modelVYMIMeta.getLastModified(RopidVYMIMetadataModel_1.DatasetEnum.EVENTS);
|
|
64
|
+
const version = dbLastModified.version + 1;
|
|
65
|
+
yield this.modelVYMIMeta.save({
|
|
66
|
+
dataset: RopidVYMIMetadataModel_1.DatasetEnum.EVENTS,
|
|
67
|
+
key: shared_1.MetaDatasetInfoKeyEnum.LAST_MODIFIED,
|
|
68
|
+
type: shared_1.MetaTypeEnum.DATASET_INFO,
|
|
69
|
+
value: new Date().toISOString(),
|
|
70
|
+
version,
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
const { events, routes, stops } = yield this.prepareAndTransformEvents(content.data, version);
|
|
74
|
+
yield Promise.all([
|
|
75
|
+
this.prepareAndSaveEvents("events", this.modelVYMIEvents, events, version),
|
|
76
|
+
this.prepareAndSaveEvents("eventsRoutes", this.modelVYMIEventsRoutes, routes, version),
|
|
77
|
+
this.prepareAndSaveEvents("eventsStops", this.modelVYMIEventsStops, stops, version),
|
|
78
|
+
]);
|
|
79
|
+
yield this.modelVYMIMeta.checkSavedRows(RopidVYMIMetadataModel_1.DatasetEnum.EVENTS, version);
|
|
80
|
+
yield this.modelVYMIMeta.replaceTmpTables(RopidVYMIMetadataModel_1.DatasetEnum.EVENTS, version);
|
|
81
|
+
// Save current digest
|
|
82
|
+
yield this.modelVYMIMeta.save({
|
|
83
|
+
dataset: RopidVYMIMetadataModel_1.DatasetEnum.EVENTS,
|
|
84
|
+
key: shared_1.MetaDatasetInfoKeyEnum.DIGEST,
|
|
85
|
+
type: shared_1.MetaTypeEnum.DATASET_INFO,
|
|
86
|
+
value: content.digest,
|
|
87
|
+
version,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
helpers_1.log.error(err);
|
|
92
|
+
yield this.modelVYMIMeta.rollbackFailedSaving(RopidVYMIMetadataModel_1.DatasetEnum.EVENTS, version);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.prepareAndTransformEvents = (data, version) => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const { events, routes, stops } = yield this.transformation.transform(data);
|
|
97
|
+
const baseMetaInputData = {
|
|
98
|
+
dataset: RopidVYMIMetadataModel_1.DatasetEnum.EVENTS,
|
|
99
|
+
type: shared_1.MetaTypeEnum.TABLE_TOTAL_COUNT,
|
|
100
|
+
version,
|
|
101
|
+
};
|
|
102
|
+
yield Promise.all([
|
|
103
|
+
this.modelVYMIMeta.save(Object.assign({ key: "events", value: events.length }, baseMetaInputData)),
|
|
104
|
+
this.modelVYMIMeta.save(Object.assign({ key: "eventsRoutes", value: routes.length }, baseMetaInputData)),
|
|
105
|
+
this.modelVYMIMeta.save(Object.assign({ key: "eventsStops", value: stops.length }, baseMetaInputData)),
|
|
106
|
+
]);
|
|
107
|
+
return {
|
|
108
|
+
events,
|
|
109
|
+
routes,
|
|
110
|
+
stops,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
this.prepareAndSaveEvents = (key, model, transformedData, version) => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
yield model.truncate(true);
|
|
115
|
+
yield model.save(transformedData, true);
|
|
116
|
+
yield this.modelVYMIMeta.save({
|
|
117
|
+
dataset: RopidVYMIMetadataModel_1.DatasetEnum.EVENTS,
|
|
118
|
+
key,
|
|
119
|
+
type: shared_1.MetaTypeEnum.STATE,
|
|
120
|
+
value: shared_1.MetaStateEnum.SAVED,
|
|
121
|
+
version,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
this.getAllEvents = () => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
try {
|
|
126
|
+
let data = [], digest = "";
|
|
127
|
+
yield this.processDataStream(this.datasource.getAll(true), (events) => __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
data = events;
|
|
129
|
+
digest = this.createDigest(JSON.stringify(data));
|
|
130
|
+
}));
|
|
131
|
+
return {
|
|
132
|
+
data,
|
|
133
|
+
digest,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
helpers_1.log.error(err);
|
|
138
|
+
if (err instanceof golemio_errors_1.CustomError) {
|
|
139
|
+
throw err;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new golemio_errors_1.CustomError("Error while getting data", true, this.constructor.name, undefined, err);
|
|
49
143
|
}
|
|
50
|
-
|
|
51
|
-
}));
|
|
144
|
+
}
|
|
52
145
|
});
|
|
146
|
+
this.createDigest = (data) => {
|
|
147
|
+
return crypto_1.default.createHash("sha1").update(data).digest("hex");
|
|
148
|
+
};
|
|
53
149
|
this.datasource = new datasources_1.DataSourceStreamed(ropid_vymi_1.RopidVYMI.events.name + "DataSource", new datasources_1.HTTPProtocolStrategyStreamed({
|
|
54
150
|
headers: config_1.config.datasources.RopidVYMIApiHeaders,
|
|
55
151
|
method: "GET",
|
|
56
|
-
timeout:
|
|
152
|
+
timeout: 30000,
|
|
57
153
|
url: `${config_1.config.datasources.RopidVYMIApiUrl}?level=${RopidVYMIApiOutputLevel.Standard}`,
|
|
58
154
|
}).setStreamTransformer(JSONStream_1.default.parse("vymi-report.vymi-list.*")), new datasources_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(ropid_vymi_1.RopidVYMI.events.name + "DataSource", ropid_vymi_1.RopidVYMI.events.datasourceJsonSchema));
|
|
59
155
|
this.transformation = new RopidVYMIEventsTransformation_1.RopidVYMIEventsTransformation();
|
|
@@ -61,6 +157,8 @@ class RopidVYMIWorker extends workers_1.BaseWorker {
|
|
|
61
157
|
this.modelVYMIEvents = new models_1.RopidVYMIEventsModel();
|
|
62
158
|
this.modelVYMIEventsRoutes = new models_1.RopidVYMIEventsRoutesModel();
|
|
63
159
|
this.modelVYMIEventsStops = new models_1.RopidVYMIEventsStopsModel();
|
|
160
|
+
this.modelVYMIMeta = new models_1.RopidVYMIMetadataModel();
|
|
161
|
+
this.queuePrefix = config_1.config.RABBIT_EXCHANGE_NAME + "." + ropid_vymi_1.RopidVYMI.name.toLowerCase();
|
|
64
162
|
}
|
|
65
163
|
}
|
|
66
164
|
exports.RopidVYMIWorker = RopidVYMIWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopidVYMIWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/ropid-vymi/RopidVYMIWorker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAoC;AACpC,mFAAkF;AAClF,2EAA2E;AAC3E,mFAI2D;
|
|
1
|
+
{"version":3,"file":"RopidVYMIWorker.js","sourceRoot":"","sources":["../../../src/integration-engine/ropid-vymi/RopidVYMIWorker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4C;AAC5C,4DAAoC;AACpC,mFAAkF;AAClF,6EAAuE;AACvE,2EAA2E;AAC3E,mFAI2D;AAE3D,2EAAoE;AACpE,yEAAsE;AACtE,oEAA6D;AAC7D,sCAAiF;AACjF,qCAA+H;AAC/H,4EAA8D;AAC9D,mFAAgF;AAOhF,IAAK,uBAIJ;AAJD,WAAK,uBAAuB;IACxB,uEAAS,CAAA;IACT,6EAAY,CAAA;IACZ,6EAAY,CAAA;AAChB,CAAC,EAJI,uBAAuB,KAAvB,uBAAuB,QAI3B;AAED,MAAM,eAAgB,SAAQ,oBAAU;IASpC;QACI,KAAK,EAAE,CAAC;QAyBZ;;WAEG;QACI,sBAAiB,GAAG,GAAwB,EAAE;YACjD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC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AC,EACpE,IAAI,kCAAoB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,EAC7C,IAAI,uCAAmB,CAAC,sBAAS,CAAC,MAAM,CAAC,IAAI,GAAG,YAAY,EAAE,sBAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,CACvG,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,IAAI,6DAA6B,EAAE,CAAC;QAE1D,kBAAkB;QAClB,IAAI,CAAC,eAAe,GAAG,IAAI,6BAAoB,EAAE,CAAC;QAClD,IAAI,CAAC,qBAAqB,GAAG,IAAI,mCAA0B,EAAE,CAAC;QAC9D,IAAI,CAAC,oBAAoB,GAAG,IAAI,kCAAyB,EAAE,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAI,+BAAsB,EAAE,CAAC;QAElD,IAAI,CAAC,WAAW,GAAG,eAAM,CAAC,oBAAoB,GAAG,GAAG,GAAG,sBAAS,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACxF,CAAC;CA+IJ;AAEQ,0CAAe"}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import { JSONSchemaValidator } from "@golemio/core/dist/shared/golemio-validator";
|
|
2
|
-
import Sequelize, { Transaction } from "@golemio/core/dist/shared/sequelize";
|
|
3
1
|
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
4
|
-
import { IRopidVYMIEventOutput } from "../../../schema-definitions/ropid-vymi";
|
|
5
|
-
interface ISaveEventOutput {
|
|
6
|
-
eventId: number;
|
|
7
|
-
}
|
|
8
2
|
/**
|
|
9
3
|
* Custom Postgres model for Ropid VYMI Events
|
|
10
4
|
*/
|
|
11
5
|
export declare class RopidVYMIEventsModel extends PostgresModel implements IModel {
|
|
12
|
-
name: string;
|
|
13
|
-
protected sequelizeModel: Sequelize.ModelCtor<any>;
|
|
14
|
-
protected validator: JSONSchemaValidator;
|
|
15
6
|
constructor();
|
|
16
|
-
truncateEvents: (transaction: Transaction) => Promise<void>;
|
|
17
|
-
saveEvent: (data: IRopidVYMIEventOutput, transaction: Transaction) => Promise<ISaveEventOutput>;
|
|
18
|
-
GetAll: (options: {
|
|
19
|
-
includeStops: boolean;
|
|
20
|
-
stopsToInclude: any;
|
|
21
|
-
}) => Promise<any>;
|
|
22
7
|
}
|
|
23
|
-
export {};
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RopidVYMIEventsModel = void 0;
|
|
13
|
-
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
14
4
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
|
-
const helpers_1 = require("@golemio/core/dist/integration-engine/helpers");
|
|
16
5
|
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
17
6
|
const ropid_vymi_1 = require("../../../schema-definitions/ropid-vymi");
|
|
18
7
|
/**
|
|
@@ -21,45 +10,12 @@ const ropid_vymi_1 = require("../../../schema-definitions/ropid-vymi");
|
|
|
21
10
|
class RopidVYMIEventsModel extends models_1.PostgresModel {
|
|
22
11
|
constructor() {
|
|
23
12
|
super(ropid_vymi_1.RopidVYMI.events.name + "Model", {
|
|
13
|
+
hasTmpTable: true,
|
|
24
14
|
outputSequelizeAttributes: ropid_vymi_1.RopidVYMI.events.outputSequelizeAttributes,
|
|
25
15
|
pgTableName: ropid_vymi_1.RopidVYMI.events.pgTableName,
|
|
26
16
|
pgSchema: ropid_vymi_1.RopidVYMI.pgSchema,
|
|
27
|
-
savingType: "
|
|
17
|
+
savingType: "insertOnly",
|
|
28
18
|
}, new golemio_validator_1.JSONSchemaValidator(ropid_vymi_1.RopidVYMI.events.name + "ModelValidator", ropid_vymi_1.RopidVYMI.events.outputJsonSchema));
|
|
29
|
-
this.truncateEvents = (transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
try {
|
|
31
|
-
yield this.sequelizeModel.truncate({ cascade: true, transaction });
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
helpers_1.log.error(err);
|
|
35
|
-
yield transaction.rollback();
|
|
36
|
-
throw new golemio_errors_1.CustomError("Error while truncating database.", true, this.name, 4001, err);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
this.saveEvent = (data, transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
try {
|
|
41
|
-
yield this.validator.Validate(data);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
throw new golemio_errors_1.CustomError("Error while validating data.", true, this.name, 4005, err);
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const [res] = yield this.sequelizeModel.upsert(data, { transaction });
|
|
48
|
-
return { eventId: res.id };
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
helpers_1.log.error(err);
|
|
52
|
-
yield transaction.rollback();
|
|
53
|
-
throw new golemio_errors_1.CustomError("Error while saving to database.", true, this.name, 4001, err);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
this.GetAll = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return this.sequelizeModel.findAll({
|
|
58
|
-
// include: {
|
|
59
|
-
// }
|
|
60
|
-
raw: true,
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
19
|
}
|
|
64
20
|
}
|
|
65
21
|
exports.RopidVYMIEventsModel = RopidVYMIEventsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopidVYMIEventsModel.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-vymi/models/RopidVYMIEventsModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RopidVYMIEventsModel.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-vymi/models/RopidVYMIEventsModel.ts"],"names":[],"mappings":";;;AAAA,mFAAkF;AAClF,yEAAqF;AACrF,uEAA4C;AAE5C;;GAEG;AACH,MAAa,oBAAqB,SAAQ,sBAAa;IACnD;QACI,KAAK,CACD,sBAAS,CAAC,MAAM,CAAC,IAAI,GAAG,OAAO,EAC/B;YACI,WAAW,EAAE,IAAI;YACjB,yBAAyB,EAAE,sBAAS,CAAC,MAAM,CAAC,yBAAyB;YACrE,WAAW,EAAE,sBAAS,CAAC,MAAM,CAAC,WAAW;YACzC,QAAQ,EAAE,sBAAS,CAAC,QAAQ;YAC5B,UAAU,EAAE,YAAY;SAC3B,EACD,IAAI,uCAAmB,CAAC,sBAAS,CAAC,MAAM,CAAC,IAAI,GAAG,gBAAgB,EAAE,sBAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACvG,CAAC;IACN,CAAC;CACJ;AAdD,oDAcC"}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import { JSONSchemaValidator } from "@golemio/core/dist/shared/golemio-validator";
|
|
2
|
-
import Sequelize, { Transaction } from "@golemio/core/dist/shared/sequelize";
|
|
3
1
|
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
4
|
-
import { IRopidVYMIEventRouteOutput } from "../../../schema-definitions/ropid-vymi";
|
|
5
2
|
/**
|
|
6
3
|
* Custom Postgres model for Ropid VYMI Events Routes
|
|
7
4
|
*/
|
|
8
5
|
export declare class RopidVYMIEventsRoutesModel extends PostgresModel implements IModel {
|
|
9
|
-
name: string;
|
|
10
|
-
protected sequelizeModel: Sequelize.ModelCtor<any>;
|
|
11
|
-
protected validator: JSONSchemaValidator;
|
|
12
|
-
private ropidGTFSRoutesModel;
|
|
13
6
|
constructor();
|
|
14
|
-
saveRoute: (data: IRopidVYMIEventRouteOutput, transaction: Transaction) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Find GTFS route id based on route short name
|
|
17
|
-
* @example B -> L992
|
|
18
|
-
* @example 231 -> L231
|
|
19
|
-
*/
|
|
20
|
-
private findGTFSRouteId;
|
|
21
7
|
}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RopidVYMIEventsRoutesModel = void 0;
|
|
13
|
-
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
14
4
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
15
|
-
const connectors_1 = require("@golemio/core/dist/integration-engine/connectors");
|
|
16
|
-
const helpers_1 = require("@golemio/core/dist/integration-engine/helpers");
|
|
17
5
|
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
18
|
-
const ropid_gtfs_1 = require("../../../schema-definitions/ropid-gtfs");
|
|
19
6
|
const ropid_vymi_1 = require("../../../schema-definitions/ropid-vymi");
|
|
20
7
|
/**
|
|
21
8
|
* Custom Postgres model for Ropid VYMI Events Routes
|
|
@@ -23,45 +10,12 @@ const ropid_vymi_1 = require("../../../schema-definitions/ropid-vymi");
|
|
|
23
10
|
class RopidVYMIEventsRoutesModel extends models_1.PostgresModel {
|
|
24
11
|
constructor() {
|
|
25
12
|
super(ropid_vymi_1.RopidVYMI.eventsRoutes.name + "Model", {
|
|
13
|
+
hasTmpTable: true,
|
|
26
14
|
outputSequelizeAttributes: ropid_vymi_1.RopidVYMI.eventsRoutes.outputSequelizeAttributes,
|
|
27
15
|
pgTableName: ropid_vymi_1.RopidVYMI.eventsRoutes.pgTableName,
|
|
28
16
|
pgSchema: ropid_vymi_1.RopidVYMI.pgSchema,
|
|
29
|
-
savingType: "
|
|
17
|
+
savingType: "insertOnly",
|
|
30
18
|
}, new golemio_validator_1.JSONSchemaValidator(ropid_vymi_1.RopidVYMI.eventsRoutes.name + "ModelValidator", ropid_vymi_1.RopidVYMI.eventsRoutes.outputJsonSchema));
|
|
31
|
-
this.saveRoute = (data, transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
data.gtfs_route_id = yield this.findGTFSRouteId(data.name);
|
|
33
|
-
try {
|
|
34
|
-
yield this.validator.Validate(data);
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
throw new golemio_errors_1.CustomError("Error while validating data.", true, this.name, 4005, err);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
yield this.sequelizeModel.upsert(data, { transaction, returning: false });
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
helpers_1.log.error(err);
|
|
44
|
-
yield transaction.rollback();
|
|
45
|
-
throw new golemio_errors_1.CustomError("Error while saving to database.", true, this.name, 4001, err);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Find GTFS route id based on route short name
|
|
50
|
-
* @example B -> L992
|
|
51
|
-
* @example 231 -> L231
|
|
52
|
-
*/
|
|
53
|
-
this.findGTFSRouteId = (routeShortName) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a;
|
|
55
|
-
const record = yield this.ropidGTFSRoutesModel.findOne({
|
|
56
|
-
attributes: ["route_id"],
|
|
57
|
-
where: {
|
|
58
|
-
route_short_name: routeShortName,
|
|
59
|
-
},
|
|
60
|
-
raw: true,
|
|
61
|
-
});
|
|
62
|
-
return (_a = record === null || record === void 0 ? void 0 : record.route_id) !== null && _a !== void 0 ? _a : null;
|
|
63
|
-
});
|
|
64
|
-
this.ropidGTFSRoutesModel = connectors_1.PostgresConnector.getConnection().define(ropid_gtfs_1.RopidGTFS.routes.pgTableName, ropid_gtfs_1.RopidGTFS.routes.outputSequelizeAttributes, { timestamps: false, schema: ropid_gtfs_1.RopidGTFS.pgSchema });
|
|
65
19
|
}
|
|
66
20
|
}
|
|
67
21
|
exports.RopidVYMIEventsRoutesModel = RopidVYMIEventsRoutesModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopidVYMIEventsRoutesModel.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-vymi/models/RopidVYMIEventsRoutesModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RopidVYMIEventsRoutesModel.js","sourceRoot":"","sources":["../../../../src/integration-engine/ropid-vymi/models/RopidVYMIEventsRoutesModel.ts"],"names":[],"mappings":";;;AAAA,mFAAkF;AAClF,yEAAqF;AACrF,uEAA4C;AAE5C;;GAEG;AACH,MAAa,0BAA2B,SAAQ,sBAAa;IACzD;QACI,KAAK,CACD,sBAAS,CAAC,YAAY,CAAC,IAAI,GAAG,OAAO,EACrC;YACI,WAAW,EAAE,IAAI;YACjB,yBAAyB,EAAE,sBAAS,CAAC,YAAY,CAAC,yBAAyB;YAC3E,WAAW,EAAE,sBAAS,CAAC,YAAY,CAAC,WAAW;YAC/C,QAAQ,EAAE,sBAAS,CAAC,QAAQ;YAC5B,UAAU,EAAE,YAAY;SAC3B,EACD,IAAI,uCAAmB,CAAC,sBAAS,CAAC,YAAY,CAAC,IAAI,GAAG,gBAAgB,EAAE,sBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,CACnH,CAAC;IACN,CAAC;CACJ;AAdD,gEAcC"}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { JSONSchemaValidator } from "@golemio/core/dist/shared/golemio-validator";
|
|
2
|
-
import Sequelize, { Transaction } from "@golemio/core/dist/shared/sequelize";
|
|
3
1
|
import { IModel, PostgresModel } from "@golemio/core/dist/integration-engine/models";
|
|
4
|
-
import { IRopidVYMIEventStopOutput } from "../../../schema-definitions/ropid-vymi";
|
|
5
2
|
/**
|
|
6
3
|
* Custom Postgres model for Ropid VYMI Events Stops
|
|
7
4
|
*/
|
|
8
5
|
export declare class RopidVYMIEventsStopsModel extends PostgresModel implements IModel {
|
|
9
|
-
name: string;
|
|
10
|
-
protected sequelizeModel: Sequelize.ModelCtor<any>;
|
|
11
|
-
protected validator: JSONSchemaValidator;
|
|
12
|
-
private ropidGTFSTripsModel;
|
|
13
6
|
constructor();
|
|
14
|
-
saveStop: (data: IRopidVYMIEventStopOutput, transaction: Transaction) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Find GTFS stop id based on asw stop id (node number, stop number)
|
|
17
|
-
* @example 145/3 -> U!45Z3P
|
|
18
|
-
*/
|
|
19
|
-
private findGTFSStopId;
|
|
20
7
|
}
|