@golemio/parkings 1.20.0-dev.1783981147 → 1.20.0-dev.1789496171
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/parkomats/ParkomatsDataSource.d.ts +6 -1
- package/dist/integration-engine/datasources/parkomats/ParkomatsDataSource.js +32 -3
- package/dist/integration-engine/datasources/parkomats/ParkomatsDataSource.js.map +1 -1
- package/docs/implementation_documentation.md +2 -1
- package/package.json +1 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { IConfiguration } from "@golemio/core/dist/integration-engine";
|
|
2
2
|
import { IGenericFeature } from "../interfaces/IGenericFeature";
|
|
3
3
|
import { IParkomatInput } from "../../../schema-definitions/parkomats/datasources/interfaces/IParkomatInput";
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers";
|
|
4
5
|
export declare class ParkomatsDataSource {
|
|
5
6
|
private config;
|
|
6
|
-
|
|
7
|
+
private logger;
|
|
8
|
+
private readonly MAX_RETRIES;
|
|
9
|
+
private readonly RETRY_DELAY_MS;
|
|
10
|
+
constructor(config: IConfiguration, logger: ILogger);
|
|
7
11
|
getParkomats(params: string): Promise<Array<IGenericFeature<IParkomatInput>>>;
|
|
12
|
+
private getDatasource;
|
|
8
13
|
}
|
|
@@ -20,23 +20,52 @@ const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
|
20
20
|
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
21
21
|
const HTTPFetchProtocolStrategy_1 = require("@golemio/core/dist/integration-engine/datasources/protocol-strategy/HTTPFetchProtocolStrategy");
|
|
22
22
|
const ioc_1 = require("@golemio/core/dist/integration-engine/ioc");
|
|
23
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
24
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
23
25
|
let ParkomatsDataSource = exports.ParkomatsDataSource = class ParkomatsDataSource {
|
|
24
|
-
constructor(config) {
|
|
26
|
+
constructor(config, logger) {
|
|
25
27
|
this.config = config;
|
|
28
|
+
this.logger = logger;
|
|
29
|
+
this.MAX_RETRIES = 3;
|
|
30
|
+
this.RETRY_DELAY_MS = 30000; // 30 second delay
|
|
26
31
|
}
|
|
27
32
|
async getParkomats(params) {
|
|
33
|
+
const datasource = this.getDatasource(params);
|
|
34
|
+
const result = await datasource.getAll();
|
|
35
|
+
for (let attempt = 1; attempt <= this.MAX_RETRIES; attempt++) {
|
|
36
|
+
try {
|
|
37
|
+
const result = await datasource.getAll();
|
|
38
|
+
// If successful, return the result immediately
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (attempt === this.MAX_RETRIES) {
|
|
43
|
+
// If it's the last
|
|
44
|
+
throw new golemio_errors_1.GeneralError("Failed to fetch parkomats data after multiple attempts. " + error.message, this.constructor.name, error);
|
|
45
|
+
}
|
|
46
|
+
this.logger.warn({
|
|
47
|
+
className: this.constructor.name,
|
|
48
|
+
}, `Attempt ${attempt} failed to fetch parkomats data. Retrying in ${this.RETRY_DELAY_MS / 1000} seconds...`);
|
|
49
|
+
// sleep for a while before retrying
|
|
50
|
+
await new Promise((resolve) => setTimeout(resolve, this.RETRY_DELAY_MS));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
getDatasource(params) {
|
|
28
56
|
return new integration_engine_1.DataSource(_sch_1.Parkomats.name + "DataSource", new HTTPFetchProtocolStrategy_1.HTTPFetchProtocolStrategy({
|
|
29
57
|
headers: {
|
|
30
58
|
authorization: this.config.datasources.TSKParkomatsToken,
|
|
31
59
|
},
|
|
32
60
|
method: "GET",
|
|
33
61
|
url: this.config.datasources.TSKParkomats + "/parkingsessionshistory?" + params,
|
|
34
|
-
}), new integration_engine_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Parkomats.name + "DataSource", ParkomatInputSchema_1.ParkomatInputSchema))
|
|
62
|
+
}), new integration_engine_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Parkomats.name + "DataSource", ParkomatInputSchema_1.ParkomatInputSchema));
|
|
35
63
|
}
|
|
36
64
|
};
|
|
37
65
|
exports.ParkomatsDataSource = ParkomatsDataSource = __decorate([
|
|
38
66
|
(0, tsyringe_1.injectable)(),
|
|
39
67
|
__param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.Config)),
|
|
40
|
-
|
|
68
|
+
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
69
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
41
70
|
], ParkomatsDataSource);
|
|
42
71
|
//# sourceMappingURL=ParkomatsDataSource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParkomatsDataSource.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/parkomats/ParkomatsDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAiC;AACjC,+GAAqF;AACrF,8EAAyG;AACzG,iEAAwE;AACxE,mFAAkF;AAGlF,6IAA0I;AAC1I,mEAA2E;
|
|
1
|
+
{"version":3,"file":"ParkomatsDataSource.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/parkomats/ParkomatsDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAiC;AACjC,+GAAqF;AACrF,8EAAyG;AACzG,iEAAwE;AACxE,mFAAkF;AAGlF,6IAA0I;AAC1I,mEAA2E;AAC3E,6EAAwE;AACxE,wEAAqE;AAG9D,IAAM,mBAAmB,iCAAzB,MAAM,mBAAmB;IAI5B,YACmC,MAA8B,EACnC,MAAuB;QADV,WAAM,GAAN,MAAM,CAAgB;QAC3B,WAAM,GAAN,MAAM,CAAS;QALpC,gBAAW,GAAG,CAAC,CAAC;QAChB,mBAAc,GAAG,K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AG,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,GAAG,0BAA0B,GAAG,MAAM;SAClF,CAAC,EACF,IAAI,yCAAoB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,EAC7C,IAAI,uCAAmB,CAAC,gBAAS,CAAC,IAAI,GAAG,YAAY,EAAE,yCAAmB,CAAC,CAC9E,CAAC;IACN,CAAC;CACJ,CAAA;8BAvDY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;IAMJ,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,MAAM,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;;GANpB,mBAAmB,CAuD/B"}
|
|
@@ -288,7 +288,8 @@ Tento zdroj je zastaralý a nespolehlivý. Může obsahovat stará a neplatná d
|
|
|
288
288
|
- parametry
|
|
289
289
|
- `from` - nastavujeme na predchozi den 00
|
|
290
290
|
- `to` - nastavujeme na dnesni den v 04
|
|
291
|
-
-
|
|
291
|
+
- poznamka stahujeme data za 28 hodin abychom o zadna data neprisli
|
|
292
|
+
- nastaveno více pokusů o stažení, z důvodů nestability API
|
|
292
293
|
- protokol: http
|
|
293
294
|
- datovy typ: json
|
|
294
295
|
- validacni schema: [parkomatInputSchema](../src/schema-definitions/parkomats/datasources/ParkomatInputSchema.ts)
|