@golemio/parkings 1.20.0-dev.1791870037 → 1.20.0-dev.1791884517
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.
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { IConfiguration } from "@golemio/core/dist/integration-engine";
|
|
2
|
-
import { IGenericFeature } from "../interfaces/IGenericFeature";
|
|
3
1
|
import { IParkomatInput } from "../../../schema-definitions/parkomats/datasources/interfaces/IParkomatInput";
|
|
4
|
-
import {
|
|
2
|
+
import { IConfiguration } from "@golemio/core/dist/integration-engine/config/abstract";
|
|
3
|
+
import { IGenericFeature } from "../interfaces/IGenericFeature";
|
|
5
4
|
export declare class ParkomatsDataSource {
|
|
6
5
|
private config;
|
|
7
|
-
private logger;
|
|
8
6
|
private readonly MAX_RETRIES;
|
|
9
|
-
|
|
10
|
-
constructor(config: IConfiguration, logger: ILogger);
|
|
7
|
+
constructor(config: IConfiguration);
|
|
11
8
|
getParkomats(params: string): Promise<Array<IGenericFeature<IParkomatInput>>>;
|
|
12
9
|
private getDatasource;
|
|
13
10
|
}
|
|
@@ -15,57 +15,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ParkomatsDataSource = void 0;
|
|
16
16
|
const _sch_1 = require("../../../schema-definitions");
|
|
17
17
|
const ParkomatInputSchema_1 = require("../../../schema-definitions/parkomats/datasources/ParkomatInputSchema");
|
|
18
|
-
const
|
|
19
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
20
|
-
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
18
|
+
const JSONDataTypeStrategy_1 = require("@golemio/core/dist/integration-engine/datasources/datatype-strategy/JSONDataTypeStrategy");
|
|
21
19
|
const HTTPFetchProtocolStrategy_1 = require("@golemio/core/dist/integration-engine/datasources/protocol-strategy/HTTPFetchProtocolStrategy");
|
|
20
|
+
const RetryDataSource_1 = require("@golemio/core/dist/integration-engine/datasources/RetryDataSource");
|
|
22
21
|
const ioc_1 = require("@golemio/core/dist/integration-engine/ioc");
|
|
23
22
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
24
|
-
const
|
|
23
|
+
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
|
|
24
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
25
25
|
let ParkomatsDataSource = exports.ParkomatsDataSource = class ParkomatsDataSource {
|
|
26
|
-
constructor(config
|
|
26
|
+
constructor(config) {
|
|
27
27
|
this.config = config;
|
|
28
|
-
this.logger = logger;
|
|
29
28
|
this.MAX_RETRIES = 3;
|
|
30
|
-
this.RETRY_DELAY_MS = 30000; // 30 second delay
|
|
31
29
|
}
|
|
32
30
|
async getParkomats(params) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (attempt === this.MAX_RETRIES) {
|
|
42
|
-
// If it's the last
|
|
43
|
-
throw new golemio_errors_1.GeneralError("Failed to fetch parkomats data after multiple attempts. " + error.message, this.constructor.name, error);
|
|
44
|
-
}
|
|
45
|
-
this.logger.warn({
|
|
46
|
-
className: this.constructor.name,
|
|
47
|
-
}, `Attempt ${attempt} failed to fetch parkomats data. Retrying in ${this.RETRY_DELAY_MS / 1000} seconds...`);
|
|
48
|
-
// sleep for a while before retrying
|
|
49
|
-
await new Promise((resolve) => setTimeout(resolve, this.RETRY_DELAY_MS));
|
|
50
|
-
}
|
|
31
|
+
try {
|
|
32
|
+
return await this.getDatasource(params).getAll();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new golemio_errors_1.GeneralError("Failed to fetch parkomats data after multiple attempts. " + error.message, this.constructor.name, error);
|
|
51
36
|
}
|
|
52
|
-
// This line should never be reached due to the loop above
|
|
53
|
-
throw new golemio_errors_1.GeneralError("Unexpected error in ParkomatsDataSource", this.constructor.name);
|
|
54
37
|
}
|
|
55
38
|
getDatasource(params) {
|
|
56
|
-
return new
|
|
39
|
+
return new RetryDataSource_1.RetryDataSource(_sch_1.Parkomats.name + "DataSource", new HTTPFetchProtocolStrategy_1.HTTPFetchProtocolStrategy({
|
|
57
40
|
headers: {
|
|
58
41
|
authorization: this.config.datasources.TSKParkomatsToken,
|
|
59
42
|
},
|
|
60
43
|
method: "GET",
|
|
61
44
|
url: this.config.datasources.TSKParkomats + "/parkingsessionshistory?" + params,
|
|
62
|
-
}), new
|
|
45
|
+
}), new JSONDataTypeStrategy_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Parkomats.name + "DataSource", ParkomatInputSchema_1.ParkomatInputSchema), this.MAX_RETRIES);
|
|
63
46
|
}
|
|
64
47
|
};
|
|
65
48
|
exports.ParkomatsDataSource = ParkomatsDataSource = __decorate([
|
|
66
49
|
(0, tsyringe_1.injectable)(),
|
|
67
50
|
__param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.Config)),
|
|
68
|
-
|
|
69
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
51
|
+
__metadata("design:paramtypes", [Object])
|
|
70
52
|
], ParkomatsDataSource);
|
|
71
53
|
//# 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;
|
|
1
|
+
{"version":3,"file":"ParkomatsDataSource.js","sourceRoot":"","sources":["../../../../src/integration-engine/datasources/parkomats/ParkomatsDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAiC;AAEjC,+GAAqF;AAErF,mIAAgI;AAChI,6IAA0I;AAC1I,uGAAoG;AACpG,mEAA2E;AAC3E,6EAAwE;AACxE,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