@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 { ILogger } from "@golemio/core/dist/helpers";
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
- private readonly RETRY_DELAY_MS;
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 integration_engine_1 = require("@golemio/core/dist/integration-engine");
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 CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
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, logger) {
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
- const datasource = this.getDatasource(params);
34
- for (let attempt = 1; attempt <= this.MAX_RETRIES; attempt++) {
35
- try {
36
- const result = await datasource.getAll();
37
- // If successful, return the result immediately
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 integration_engine_1.DataSource(_sch_1.Parkomats.name + "DataSource", new HTTPFetchProtocolStrategy_1.HTTPFetchProtocolStrategy({
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 integration_engine_1.JSONDataTypeStrategy({ resultsPath: "" }), new golemio_validator_1.JSONSchemaValidator(_sch_1.Parkomats.name + "DataSource", ParkomatInputSchema_1.ParkomatInputSchema));
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
- __param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
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;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,KAAK,CAAC,CAAC,kBAAkB;IAKxD,CAAC;IAEG,KAAK,CAAC,YAAY,CAAC,MAAc;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,aAA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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;8BAtDY,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,CAsD/B"}
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,mFAAkF;AAClF,iEAAwE;AAIjE,IAAM,mBAAmB,iCAAzB,MAAM,mBAAmB;IAG5B,YAA2C,MAA8B;QAAtB,WAAM,GAAN,MAAM,CAAgB;QAFxD,gBAAW,GAAG,CAAC,CAAC;IAE2C,CAAC;IAEtE,KAAK,CAAC,YAAY,CAAC,MAAc;QACpC,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;SACpD;QAAC,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,6BAAY,CAClB,0DAA0D,GAAG,KAAK,CAAC,OAAO,EAC1E,IAAI,CAAC,WAAW,CAAC,IAAI,EACrB,KAAK,CACR,CAAC;SACL;IACL,CAAC;IAEO,aAAa,CAAC,MAAc;QAChC,OAAO,IAAI,iCAAe,CACtB,gBAAS,CAAC,IAAI,GAAG,YAAY,EAC7B,IAAI,qDAAyB,CAAC;YAC1B,OAAO,EAAE;gBACL,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB;aAC3D;YACD,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,GAAG,0BAA0B,GAAG,MAAM;SAClF,CAAC,EACF,IAAI,2CAAoB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,EAC7C,IAAI,uCAAmB,CAAC,gBAAS,CAAC,IAAI,GAAG,YAAY,EAAE,yCAAmB,CAAC,EAC3E,IAAI,CAAC,WAAW,CACnB,CAAC;IACN,CAAC;CACJ,CAAA;8BAhCY,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;IAII,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,MAAM,CAAC,CAAA;;GAHjC,mBAAmB,CAgC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/parkings",
3
- "version": "1.20.0-dev.1791870037",
3
+ "version": "1.20.0-dev.1791884517",
4
4
  "description": "Golemio Parkings Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",