@golemio/ndic 1.0.7-dev.506839341 → 1.0.8-dev.525554702
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/output-gateway/TrafficRouter.js +1 -1
- package/dist/output-gateway/TrafficRouter.js.map +1 -1
- package/dist/output-gateway/models/TrafficRestrictionsModel.d.ts +4 -3
- package/dist/output-gateway/models/TrafficRestrictionsModel.js +34 -29
- package/dist/output-gateway/models/TrafficRestrictionsModel.js.map +1 -1
- package/dist/output-gateway/transformations/OutputTrafficRestrictionsTransformation.js +11 -6
- package/dist/output-gateway/transformations/OutputTrafficRestrictionsTransformation.js.map +1 -1
- package/docs/implementation_documentation.md +157 -0
- package/docs/ndic_erdiagram.png +0 -0
- package/package.json +14 -10
|
@@ -25,7 +25,7 @@ class TrafficRouter extends BaseRouter_1.BaseRouter {
|
|
|
25
25
|
const dataFromDb = yield this.trafficRestrictionsModel.GetAll({
|
|
26
26
|
limit: req.query.limit ? +req.query.limit : undefined,
|
|
27
27
|
offset: req.query.offset ? +req.query.offset : undefined,
|
|
28
|
-
|
|
28
|
+
reqMoment: req.query.moment,
|
|
29
29
|
situationRecordType: req.query.situationRecordType,
|
|
30
30
|
});
|
|
31
31
|
if (!(dataFromDb === null || dataFromDb === void 0 ? void 0 : dataFromDb.length)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrafficRouter.js","sourceRoot":"","sources":["../../src/output-gateway/TrafficRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,mFAAoE;AACpE,6EAAuE;AACvE,mEAA6E;AAC7E,oFAAiF;AACjF,6EAAkH;AAClH,qCAAoD;AACpD,uHAAsH;AAEtH,MAAa,aAAc,SAAQ,uBAAU;IAIzC;QACI,KAAK,EAAE,CAAC;QAeL,2BAAsB,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtF,IAAI;gBACA,MAAM,UAAU,GAAG,MA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IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC;iBACtE;gBACD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,uCAAuC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACjG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aACzC;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,CAAC;aACb;QACL,CAAC,CAAA,CAAC;QA9BE,IAAI,CAAC,wBAAwB,GAAG,IAAI,iCAAwB,EAAE,CAAC;QAC/D,IAAI,CAAC,uCAAuC,GAAG,IAAI,iFAAuC,EAAE,CAAC;QAE7F,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,eAAe,EACf,CAAC,IAAA,yBAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,IAAA,yBAAK,EAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,EAC5F,uBAAU,EACV,wBAAW,EACX,IAAA,sCAAyB,EAAC,eAAe,CAAC,EAC1C,IAAA,0BAAkB,GAAE,EACpB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;IACN,CAAC;CAmBJ;AArCD,sCAqCC;AAED,MAAM,aAAa,GAAW,IAAI,aAAa,EAAE,CAAC,MAAM,CAAC;AAEhD,sCAAa"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { SequelizeModel } from "@golemio/core/dist/output-gateway/models";
|
|
2
|
+
import { ITrafficRestrictionsModel } from "../../integration-engine/transformations/TrafficRestrictionsInterface";
|
|
2
3
|
export declare class TrafficRestrictionsModel extends SequelizeModel {
|
|
3
4
|
constructor();
|
|
4
5
|
/**
|
|
5
6
|
* @param {object} [options] Options object with params
|
|
6
7
|
* @param {number} [options.limit] Limit
|
|
7
8
|
* @param {number} [options.offset] Offset
|
|
8
|
-
* @param {string} [options.
|
|
9
|
+
* @param {string} [options.reqMoment] ISO date
|
|
9
10
|
* @param {string} [options.situationRecordType] Situation Record Type
|
|
10
11
|
* @returns Array of the retrieved records
|
|
11
12
|
*/
|
|
12
13
|
GetAll: (options?: {
|
|
13
14
|
limit?: number;
|
|
14
15
|
offset?: number;
|
|
15
|
-
|
|
16
|
+
reqMoment?: string;
|
|
16
17
|
situationRecordType?: string;
|
|
17
|
-
}) => Promise<
|
|
18
|
+
}) => Promise<ITrafficRestrictionsModel[]>;
|
|
18
19
|
GetOne: (id: number) => Promise<object | null>;
|
|
19
20
|
}
|
|
@@ -13,9 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TrafficRestrictionsModel = void 0;
|
|
16
|
-
const sequelize_1 = __importDefault(require("@golemio/core/dist/shared/sequelize"));
|
|
17
16
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
18
17
|
const models_1 = require("@golemio/core/dist/output-gateway/models");
|
|
18
|
+
const database_1 = require("@golemio/core/dist/output-gateway/database");
|
|
19
|
+
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
19
20
|
const index_1 = require("../../schema-definitions/index");
|
|
20
21
|
class TrafficRestrictionsModel extends models_1.SequelizeModel {
|
|
21
22
|
constructor() {
|
|
@@ -24,41 +25,45 @@ class TrafficRestrictionsModel extends models_1.SequelizeModel {
|
|
|
24
25
|
* @param {object} [options] Options object with params
|
|
25
26
|
* @param {number} [options.limit] Limit
|
|
26
27
|
* @param {number} [options.offset] Offset
|
|
27
|
-
* @param {string} [options.
|
|
28
|
+
* @param {string} [options.reqMoment] ISO date
|
|
28
29
|
* @param {string} [options.situationRecordType] Situation Record Type
|
|
29
30
|
* @returns Array of the retrieved records
|
|
30
31
|
*/
|
|
31
32
|
this.GetAll = (options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const { limit, offset,
|
|
33
|
+
const { limit, offset, reqMoment, situationRecordType } = options;
|
|
33
34
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
// take moment from request or now
|
|
36
|
+
let queryMoment = reqMoment ? reqMoment : (0, moment_timezone_1.default)().tz("Europe/Prague").format();
|
|
37
|
+
// get rows for each `situation_record_id`,
|
|
38
|
+
// but with MAX `situation_record_version_time` for each `situation_record_id`
|
|
39
|
+
let query = `
|
|
40
|
+
SELECT *
|
|
41
|
+
FROM
|
|
42
|
+
(
|
|
43
|
+
SELECT
|
|
44
|
+
row_number() OVER (partition by situation_record_id
|
|
45
|
+
ORDER BY
|
|
46
|
+
situation_record_version_time desc) rn,
|
|
47
|
+
*
|
|
48
|
+
FROM
|
|
49
|
+
ndic_traffic_restrictions
|
|
50
|
+
)
|
|
51
|
+
a
|
|
52
|
+
WHERE rn = 1
|
|
53
|
+
AND validity_overall_start_time < '${queryMoment}'
|
|
54
|
+
AND validity_overall_end_time > '${queryMoment}'
|
|
55
|
+
`;
|
|
50
56
|
if (situationRecordType) {
|
|
51
|
-
|
|
52
|
-
situation_record_type: situationRecordType,
|
|
53
|
-
});
|
|
57
|
+
query += ` AND situation_record_type = '${situationRecordType}'`;
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
limit
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
59
|
+
if (limit) {
|
|
60
|
+
query += ` LIMIT ${limit}`;
|
|
61
|
+
}
|
|
62
|
+
if (offset) {
|
|
63
|
+
query += ` OFFSET ${offset}`;
|
|
64
|
+
}
|
|
65
|
+
const trafficRestrictionsFromDB = (yield (database_1.sequelizeConnection === null || database_1.sequelizeConnection === void 0 ? void 0 : database_1.sequelizeConnection.query(query)));
|
|
66
|
+
return trafficRestrictionsFromDB[0] || [];
|
|
62
67
|
}
|
|
63
68
|
catch (err) {
|
|
64
69
|
throw new golemio_errors_1.CustomError("Database error", true, "TrafficRestrictionsModel", 500, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrafficRestrictionsModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/TrafficRestrictionsModel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"TrafficRestrictionsModel.js","sourceRoot":"","sources":["../../../src/output-gateway/models/TrafficRestrictionsModel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6EAAuE;AACvE,qEAA0E;AAC1E,yEAAiF;AACjF,gGAA+D;AAC/D,0DAAkC;AAGlC,MAAa,wBAAyB,SAAQ,uBAAc;IACxD;QACI,KAAK,CACD,YAAI,CAAC,oBAAoB,CAAC,IAAI,EAC9B,YAAI,CAAC,oBAAoB,CAAC,WAAW,EACrC,YAAI,CAAC,oBAAoB,CAAC,yBAAyB,CACtD,CAAC;QAGN;;;;;;;WAOG;QAEI,WAAM,GAAG,CACZ,UAKI,EAAE,EAC8B,EAAE;YACtC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;YAElE,IAAI;gBACA,kCAAkC;gBAClC,IAAI,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,yBAAM,GAAE,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,CAAC;gBAEhF,2CAA2C;gBAC3C,8EAA8E;gBAE9E,IAAI,KAAK,GAAG;;;;;;;;;;;;;;iDAcyB,WAAW;+CACb,WAAW;aAC7C,CAAC;gBAEF,IAAI,mBAAmB,EAAE;oBACrB,KAAK,IAAI,iCAAiC,mBAAmB,GAAG,CAAC;iBACpE;gBAED,IAAI,KAAK,EAAE;oBACP,KAAK,IAAI,UAAU,KAAK,EAAE,CAAC;iBAC9B;gBAED,IAAI,MAAM,EAAE;oBACR,KAAK,IAAI,WAAW,MAAM,EAAE,CAAC;iBAChC;gBAED,MAAM,yBAAyB,GAAG,CAAC,MAAM,CAAA,8BAAmB,aAAnB,8BAAmB,uBAAnB,8BAAmB,CAAE,KAAK,CAAC,KAAK,CAAC,CAAA,CAAkC,CAAC;gBAE7G,OAAO,yBAAyB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAC7C;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,4BAAW,CAAC,gBAAgB,EAAE,IAAI,EAAE,0BAA0B,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aACvF;QACL,CAAC,CAAA,CAAC;QAEK,WAAM,GAAG,CAAO,EAAU,EAA0B,EAAE;YACzD,MAAM,IAAI,4BAAW,CAAC,iBAAiB,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC;QAC/E,CAAC,CAAA,CAAC;IApEF,CAAC;CAqEJ;AA5ED,4DA4EC"}
|
|
@@ -8,19 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.OutputTrafficRestrictionsTransformation = void 0;
|
|
16
|
+
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
13
17
|
const _sch_1 = require("../../schema-definitions");
|
|
14
18
|
const models_1 = require("../models");
|
|
15
19
|
class OutputTrafficRestrictionsTransformation {
|
|
16
20
|
constructor() {
|
|
17
21
|
this.transform = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// Format needed: "publicationTime": "2022-03-31T14:12:11+02:00",
|
|
23
|
+
const publicationTime = data.reduce((acc, curr) => acc.publication_time > curr.publication_time ? acc : curr).publication_time;
|
|
18
24
|
const result = {
|
|
19
25
|
modelBaseVersion: "2",
|
|
20
26
|
situationPublicationLight: {
|
|
21
27
|
lang: "cs",
|
|
22
|
-
publicationTime:
|
|
23
|
-
.publication_time,
|
|
28
|
+
publicationTime: (0, moment_timezone_1.default)(publicationTime).tz("Europe/Prague").format(),
|
|
24
29
|
publicationCreator: {
|
|
25
30
|
country: "cz",
|
|
26
31
|
nationalIdentifier: "NDIC",
|
|
@@ -94,10 +99,10 @@ class OutputTrafficRestrictionsTransformation {
|
|
|
94
99
|
continue;
|
|
95
100
|
}
|
|
96
101
|
resultRecordsArr.push({
|
|
97
|
-
situationRecordCreationTime: record.situation_record_creation_time,
|
|
98
|
-
situationRecordVersionTime: record.
|
|
99
|
-
startTime: record.validity_overall_start_time,
|
|
100
|
-
endTime: record.validity_overall_end_time,
|
|
102
|
+
situationRecordCreationTime: (0, moment_timezone_1.default)(record.situation_record_creation_time).tz("Europe/Prague").format(),
|
|
103
|
+
situationRecordVersionTime: (0, moment_timezone_1.default)(record.situation_record_version).tz("Europe/Prague").format(),
|
|
104
|
+
startTime: (0, moment_timezone_1.default)(record.validity_overall_start_time).tz("Europe/Prague").format(),
|
|
105
|
+
endTime: (0, moment_timezone_1.default)(record.validity_overall_end_time).tz("Europe/Prague").format(),
|
|
101
106
|
type: record.situation_record_type,
|
|
102
107
|
version: record.situation_record_version,
|
|
103
108
|
generalPublicComment: this.generalPublicCommentParsing(record.general_public_comment),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutputTrafficRestrictionsTransformation.js","sourceRoot":"","sources":["../../../src/output-gateway/transformations/OutputTrafficRestrictionsTransformation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OutputTrafficRestrictionsTransformation.js","sourceR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|
|
3
|
+
## Záměr
|
|
4
|
+
|
|
5
|
+
Stručný popis, k čemu modul slouží.
|
|
6
|
+
|
|
7
|
+
Pokud má modul více oblastí, každá oblast je popsána zvlášť. Dále jsem popsány vazby mezi jednotlivými oblastmi.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Vstupní data
|
|
12
|
+
|
|
13
|
+
### Data nám jsou posílána
|
|
14
|
+
|
|
15
|
+
Popis dat, jak nám jsou posíláná na input-gateway. Pokud je vystaveno více endpointů (pro různé datové sady), každý endpoint je popsán zvlášť.
|
|
16
|
+
|
|
17
|
+
#### */traffic-info / NdicTrafficInfo*
|
|
18
|
+
|
|
19
|
+
- formát dat
|
|
20
|
+
- protokol http
|
|
21
|
+
- datový typ xml
|
|
22
|
+
- [odkaz na validační schéma](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/schemas/traffic_info_schema.xsd)
|
|
23
|
+
- [příklad vstupních dat](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/test/data/traffic_info_data.xml)
|
|
24
|
+
- endpoint v input-gateway `/traffic-info`
|
|
25
|
+
- příchozí xml je na input gateway pomocí obecného middlewaru rozparsováno body parsererem z xml na json. Již předpřipravený request se dostane skrze NdicRouter do TrafficInfoController a je zvalidován oproti json schématu [link](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/src/schema-definitions/schemas/traffic_info_datasource_schema.ts)
|
|
26
|
+
- (volitelně) nastavení práv v permission-proxy
|
|
27
|
+
- zvláštní požadaky na řízení přístupu
|
|
28
|
+
- TBD
|
|
29
|
+
- transformace raw dat
|
|
30
|
+
- standardní body parser xml->json
|
|
31
|
+
- název rabbitmq fronty
|
|
32
|
+
- `dataplatform.ndic.saveTrafficInfo` - zprávy v queue obsahují přichozí data v json formátu
|
|
33
|
+
- (volitelně) odhadovaná zátěž
|
|
34
|
+
- n/a
|
|
35
|
+
|
|
36
|
+
#### */traffic-restrictions / NdicTrafficRestrictions*
|
|
37
|
+
|
|
38
|
+
- formát dat
|
|
39
|
+
- protokol http
|
|
40
|
+
- datový typ xml
|
|
41
|
+
- [odkaz na validační schéma](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/schemas/traffic_restrictions_schema.xsd)
|
|
42
|
+
- [příklad vstupních dat](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/test/data/traffic_restrictions_data.xml)
|
|
43
|
+
- endpoint v input-gateway
|
|
44
|
+
- popis endpointu /traffic-restrictions
|
|
45
|
+
- (volitelně) nastavení práv v permission-proxy
|
|
46
|
+
- zvláštní požadaky na řízení přístupu
|
|
47
|
+
- transformace raw dat
|
|
48
|
+
- body parser xml->json
|
|
49
|
+
- název rabbitmq fronty
|
|
50
|
+
- `dataplatform.ndic.saveTrafficRestrictions` - zprávy v queue obsahují přichozí data v json formátu
|
|
51
|
+
- (volitelně) odhadovaná zátěž
|
|
52
|
+
- n/a
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Zpracování dat / transformace
|
|
57
|
+
|
|
58
|
+
Popis transformace a případného obohacení dat. Zaměřeno hlavně na workery a jejich metody.
|
|
59
|
+
|
|
60
|
+
### *NdicWorker*
|
|
61
|
+
|
|
62
|
+
Worker slouží pro zpracování příchozích dat NdicTrafficInfo a NdicTrafficRestrictions.
|
|
63
|
+
|
|
64
|
+
#### *saveTrafficInfo*
|
|
65
|
+
|
|
66
|
+
- vstupní rabbitmq fronta
|
|
67
|
+
- `dataplatform.ndic.saveTrafficInfo`
|
|
68
|
+
- (volitelně) závislé fronty (do kterých jsou odesílány zprávy z metody workeru)
|
|
69
|
+
- žádné
|
|
70
|
+
- datové zdroje
|
|
71
|
+
- rsdTmcPointsModel - pro zjištění geo souřadnic
|
|
72
|
+
- transformace
|
|
73
|
+
- [odkaz na transformaci dat](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/development/src/integration-engine/transformations/TrafficInfoTransformation.ts)
|
|
74
|
+
- (volitelně) obohacení dat
|
|
75
|
+
- po tranformaci se data obohacují o geosouřadnice (např. úsek silnice), kdy data z alertCLinear části slouží jako filtrovací parametry pro lookup datasource rsdTmcPointsModel
|
|
76
|
+
- data modely
|
|
77
|
+
- `ndicTrafficInfoModel` - ukládá se do tabulky `ndic_traffic_info`
|
|
78
|
+
|
|
79
|
+
#### *saveTrafficRestrictions*
|
|
80
|
+
|
|
81
|
+
- vstupní rabbitmq fronta
|
|
82
|
+
- `dataplatform.ndic.saveTrafficRestrictions`
|
|
83
|
+
- (volitelně) závislé fronty (do kterých jsou odesílány zprávy z metody workeru)
|
|
84
|
+
- žádné
|
|
85
|
+
- datové zdroje
|
|
86
|
+
- `rsdTmcPointsModel` - pro zjištění geo souřadnic
|
|
87
|
+
- transformace
|
|
88
|
+
- [odkaz na transformaci dat](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/src/integration-engine/transformations/TrafficRestrictionsTransformation.ts)
|
|
89
|
+
- (volitelně) obohacení dat
|
|
90
|
+
- stejné jako u předešlé metody *`saveTrafficInfo`*
|
|
91
|
+
- data modely
|
|
92
|
+
- `ndicTrafficRestrictionsModel` se ukládá do tabulky ndic_traffic_restrictions
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Uložení dat
|
|
96
|
+
|
|
97
|
+
Popis ukládání dat.
|
|
98
|
+
|
|
99
|
+
### Obecné
|
|
100
|
+
|
|
101
|
+
- typ databáze
|
|
102
|
+
- PSQL
|
|
103
|
+
- datábázové schéma
|
|
104
|
+
- tabulka `ndic_traffic_info`
|
|
105
|
+
- tabulka `ndic_traffic_restrictions`
|
|
106
|
+

|
|
107
|
+
- retence dat
|
|
108
|
+
- n/a
|
|
109
|
+
|
|
110
|
+
### *ndicTrafficInfoModel*
|
|
111
|
+
|
|
112
|
+
- schéma a název tabulky / kolekce
|
|
113
|
+
- `public.ndic_traffic_info`
|
|
114
|
+
- struktura tabulky / kolekce
|
|
115
|
+
- odkaz na schéma, případně na migrační skripty
|
|
116
|
+
- schéma viz výše
|
|
117
|
+
- [odkaz na migrační skripty](https://gitlab.com/operator-ict/golemio/code/modules/schema-definitions/-/tree/development/db/postgresql-migrations)
|
|
118
|
+
- ukázka dat
|
|
119
|
+
n/a
|
|
120
|
+
|
|
121
|
+
### *ndicTrafficInfoModel*
|
|
122
|
+
|
|
123
|
+
- schéma a název tabulky / kolekce
|
|
124
|
+
- `public.ndic_traffic_restrictions`
|
|
125
|
+
- struktura tabulky / kolekce
|
|
126
|
+
- odkaz na schéma, případně na migrační skripty
|
|
127
|
+
- schéma viz výše
|
|
128
|
+
- [odkaz na migrační skripty](https://gitlab.com/operator-ict/golemio/code/modules/schema-definitions/-/tree/development/db/postgresql-migrations)
|
|
129
|
+
- [ukázka dat](https://gitlab.com/operator-ict/golemio/code/modules/ndic/-/blob/master/db/example/sql_dump.sql)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Output API
|
|
133
|
+
|
|
134
|
+
Popis output-api.
|
|
135
|
+
|
|
136
|
+
### Obecné
|
|
137
|
+
|
|
138
|
+
- API Blueprint / OpenAPI dokumentace
|
|
139
|
+
- [odkaz na dokumentaci](./openapi.yaml)
|
|
140
|
+
- veřejné / neveřejné endpointy
|
|
141
|
+
- api je neveřejné, endpoint /restrictions je přístupný pro uživatele s rolí NDIC
|
|
142
|
+
- (volitelně) ACL
|
|
143
|
+
- postman kolekce
|
|
144
|
+
- TBD
|
|
145
|
+
|
|
146
|
+
#### */restrictions*
|
|
147
|
+
|
|
148
|
+
- zdrojové tabulky
|
|
149
|
+
- `ndic_traffic_restrictions`
|
|
150
|
+
- (volitlně) nestandardní dodatečná transformace
|
|
151
|
+
- vrací pouze poslední známe stavy ( max `situation_record_version_time` ) všech dopravních situací podle klíče `situation_record_id`, které jsou platné ve vybraný čas
|
|
152
|
+
- (volitelně) nestandardní url a query parametry
|
|
153
|
+
|
|
154
|
+
| query parameter | popis |
|
|
155
|
+
| --- |---|
|
|
156
|
+
| reqMoment | datum a čas pro který zobrazit platné situace ve formátu ISO8601 |
|
|
157
|
+
| situationRecordType | filtruje podle typu situace |
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/ndic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8-dev.525554702",
|
|
4
4
|
"description": "Golemio NDIC Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test-debug": "run-s 'test --inspect-brk=9230'",
|
|
15
15
|
"code-coverage": "nyc run-s 'test -r source-map-support/register'",
|
|
16
16
|
"generate-docs": "typedoc --out docs/typedoc src",
|
|
17
|
-
"lint": "eslint
|
|
17
|
+
"lint": "eslint \"{src,test}/**/*.ts\""
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"golemio"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@commitlint/cli": "^11.0.0",
|
|
30
30
|
"@commitlint/config-conventional": "^11.0.0",
|
|
31
|
-
"@golemio/core": "1.2.
|
|
32
|
-
"@golemio/eslint-config": "^1.0
|
|
33
|
-
"@golemio/schema-definitions": "2.0.
|
|
31
|
+
"@golemio/core": "1.2.6",
|
|
32
|
+
"@golemio/eslint-config": "^1.1.0",
|
|
33
|
+
"@golemio/schema-definitions": "2.0.31",
|
|
34
34
|
"@types/body-parser-xml": "^1.1.0",
|
|
35
35
|
"@types/chai": "4.2.3",
|
|
36
36
|
"@types/chai-as-promised": "7.1.2",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"chai-as-promised": "7.1.1",
|
|
46
46
|
"cross-env": "^7.0.3",
|
|
47
47
|
"dotenv": "^8.2.0",
|
|
48
|
-
"eslint": "^
|
|
48
|
+
"eslint": "^8.1.1",
|
|
49
49
|
"husky": "^4.3.7",
|
|
50
50
|
"mocha": "^8.2.1",
|
|
51
51
|
"npm-run-all": "^4.1.5",
|
|
52
52
|
"nyc": "^15.1.0",
|
|
53
|
-
"prettier": "^2.
|
|
54
|
-
"pretty-quick": "^3.1.
|
|
53
|
+
"prettier": "^2.5.1",
|
|
54
|
+
"pretty-quick": "^3.1.3",
|
|
55
55
|
"rimraf": "^3.0.2",
|
|
56
56
|
"sinon": "^9.2.3",
|
|
57
57
|
"source-map-support": "0.5.19",
|
|
58
58
|
"supertest": "^6.0.1",
|
|
59
59
|
"ts-node": "^9.1.1",
|
|
60
|
-
"ttypescript": "^1.5.
|
|
60
|
+
"ttypescript": "^1.5.13",
|
|
61
61
|
"typedoc": "^0.21.4",
|
|
62
62
|
"typescript": "4.4.4"
|
|
63
63
|
},
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
"mpath": "^0.8.4",
|
|
76
76
|
"apicache": "1.6.3",
|
|
77
77
|
"axios": "^0.21.2",
|
|
78
|
-
"follow-redirects": "^1.14.7"
|
|
78
|
+
"follow-redirects": "^1.14.7",
|
|
79
|
+
"ansi-regex": "^5.0.1",
|
|
80
|
+
"validator": "^13.7.0",
|
|
81
|
+
"json-schema": "^0.4.0",
|
|
82
|
+
"urijs": "^1.19.10"
|
|
79
83
|
}
|
|
80
84
|
}
|