@golemio/municipal-libraries 1.3.8 → 1.4.0

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.
Files changed (41) hide show
  1. package/db/example/01_libraries.sql +22 -22
  2. package/db/migrations/postgresql/20260521145623-migrate-to-json-api.js +45 -0
  3. package/db/migrations/postgresql/20260527131433-add-opening-hours-type.js +45 -0
  4. package/db/migrations/postgresql/sqls/20260521145623-migrate-to-json-api-down.sql +31 -0
  5. package/db/migrations/postgresql/sqls/20260521145623-migrate-to-json-api-up.sql +16 -0
  6. package/db/migrations/postgresql/sqls/20260527131433-add-opening-hours-type-down.sql +1 -0
  7. package/db/migrations/postgresql/sqls/20260527131433-add-opening-hours-type-up.sql +1 -0
  8. package/dist/integration-engine/datasources/MunicipalLibrariesDataSource.d.ts +1 -2
  9. package/dist/integration-engine/datasources/MunicipalLibrariesDataSource.js +2 -29
  10. package/dist/integration-engine/datasources/MunicipalLibrariesDataSource.js.map +1 -1
  11. package/dist/integration-engine/repositories/MunicipalLibrariesRepository.js.map +1 -1
  12. package/dist/integration-engine/transformations/MunicipalLibrariesTransformation.d.ts +3 -2
  13. package/dist/integration-engine/transformations/MunicipalLibrariesTransformation.js +24 -12
  14. package/dist/integration-engine/transformations/MunicipalLibrariesTransformation.js.map +1 -1
  15. package/dist/integration-engine/transformations/helpers/TransformationHelper.d.ts +8 -10
  16. package/dist/integration-engine/transformations/helpers/TransformationHelper.js +66 -79
  17. package/dist/integration-engine/transformations/helpers/TransformationHelper.js.map +1 -1
  18. package/dist/integration-engine/workers/schemas/UpdateDistrictSchema.d.ts +2 -2
  19. package/dist/integration-engine/workers/schemas/UpdateDistrictSchema.js +2 -2
  20. package/dist/integration-engine/workers/schemas/UpdateDistrictSchema.js.map +1 -1
  21. package/dist/output-gateway/repositories/MunicipalLibrariesRepository.js +1 -1
  22. package/dist/output-gateway/repositories/MunicipalLibrariesRepository.js.map +1 -1
  23. package/dist/schema-definitions/Libraries.d.ts +1 -1
  24. package/dist/schema-definitions/LibraryServices.d.ts +1 -1
  25. package/dist/schema-definitions/OpeningHours.d.ts +2 -1
  26. package/dist/schema-definitions/OpeningHours.js.map +1 -1
  27. package/dist/schema-definitions/datasources/MunicipalLibrariesJsonSchema.d.ts +42 -51
  28. package/dist/schema-definitions/datasources/MunicipalLibrariesJsonSchema.js +96 -146
  29. package/dist/schema-definitions/datasources/MunicipalLibrariesJsonSchema.js.map +1 -1
  30. package/dist/schema-definitions/models/LibrariesModel.d.ts +1 -1
  31. package/dist/schema-definitions/models/LibrariesModel.js +2 -2
  32. package/dist/schema-definitions/models/LibrariesModel.js.map +1 -1
  33. package/dist/schema-definitions/models/LibraryServicesModel.d.ts +1 -1
  34. package/dist/schema-definitions/models/LibraryServicesModel.js +2 -2
  35. package/dist/schema-definitions/models/LibraryServicesModel.js.map +1 -1
  36. package/dist/schema-definitions/models/OpeningHoursModel.d.ts +2 -1
  37. package/dist/schema-definitions/models/OpeningHoursModel.js +5 -3
  38. package/dist/schema-definitions/models/OpeningHoursModel.js.map +1 -1
  39. package/docs/implementation_documentation.md +8 -3
  40. package/docs/openapi.yaml +8 -4
  41. package/package.json +24 -22
@@ -11,7 +11,7 @@ OpeningHoursModel.attributeModel = {
11
11
  primaryKey: true,
12
12
  autoIncrement: true,
13
13
  },
14
- library_id: sequelize_1.DataTypes.INTEGER,
14
+ library_id: sequelize_1.DataTypes.STRING(255),
15
15
  day_of_week: sequelize_1.DataTypes.STRING(255),
16
16
  opens: sequelize_1.DataTypes.STRING(255),
17
17
  closes: sequelize_1.DataTypes.STRING(255),
@@ -19,6 +19,7 @@ OpeningHoursModel.attributeModel = {
19
19
  is_default: sequelize_1.DataTypes.BOOLEAN,
20
20
  valid_from: sequelize_1.DataTypes.DATE,
21
21
  valid_through: sequelize_1.DataTypes.DATE,
22
+ type: sequelize_1.DataTypes.STRING(255),
22
23
  };
23
24
  OpeningHoursModel.updateAttributes = Object.keys(OpeningHoursModel.attributeModel)
24
25
  .filter((att) => att !== "id")
@@ -29,7 +30,7 @@ OpeningHoursModel.jsonSchema = {
29
30
  type: "object",
30
31
  properties: {
31
32
  id: { type: "integer" },
32
- library_id: { type: "integer" },
33
+ library_id: { type: "string" },
33
34
  day_of_week: { type: "string" },
34
35
  opens: { type: "string" },
35
36
  closes: { type: "string" },
@@ -37,8 +38,9 @@ OpeningHoursModel.jsonSchema = {
37
38
  is_default: { type: "boolean" },
38
39
  valid_from: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
39
40
  valid_through: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
41
+ type: { type: "string" },
40
42
  },
41
- required: ["library_id", "day_of_week", "opens", "closes", "description", "is_default"],
43
+ required: ["library_id", "day_of_week", "opens", "closes", "description", "is_default", "type"],
42
44
  },
43
45
  };
44
46
  //# sourceMappingURL=OpeningHoursModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpeningHoursModel.js","sourceRoot":"","sources":["../../../src/schema-definitions/models/OpeningHoursModel.ts"],"names":[],"mappings":";;;AACA,mEAAwF;AAGxF,MAAa,iBAAkB,SAAQ,iBAAoB;;AAA3D,8CAiDC;AAtCiB,gCAAc,GAAsD;IAC9E,EAAE,EAAE;QACA,IAAI,EAAE,qBAAS,CAAC,OAAO;QACvB,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACtB;IACD,UAAU,EAAE,qBAAS,CAAC,OAAO;IAC7B,WAAW,EAAE,qBAAS,CAAC,MAAM,CAAC,GAAG,CAAC;IAClC,KAAK,EAAE,qBAAS,CAAC,MAAM,CAAC,GAAG,CAAC;IAC5B,MAAM,EAAE,qBAAS,CAAC,MAAM,CAAC,GAAG,CAAC;IAC7B,WAAW,EAAE,qBAAS,CAAC,MAAM,CAAC,GAAG,CAAC;IAClC,UAAU,EAAE,qBAAS,CAAC,OAAO;IAC7B,UAAU,EAAE,qBAAS,CAAC,IAAI;IAC1B,aAAa,EAAE,qBAAS,CAAC,IAAI;CAChC,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E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YAC7E,aAAa,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YAChF,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC3B;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC;KAClG;CACJ,CAAC"}
@@ -15,12 +15,11 @@ Modul slouží k ukládání a poskytování informací o městských knihovnác
15
15
  #### _open data MLP_
16
16
 
17
17
  - zdroj dat
18
- - url: [config.datasources.MunicipalLibraries](https://www.mlp.cz/cz/pobocky/?export=xml)
19
- - pozor při načtení url proběhne několik přesměrování na doplnění cookies
18
+ - url: [config.datasources.MunicipalLibraries](https://www.mlp.cz/api/v1/branches)
20
19
  - formát dat
21
20
  - protokol: http
22
21
  - datový typ: json
23
- - validační schéma: [municipalLibrariesJsonSchema](https://gitlab.com/operator-ict/golemio/code/modules/municipal-libraries/-/blob/development/src/integration-engine/datasources/MunicipalLibrariesDataSource.ts)
22
+ - validační schéma: [municipalLibrariesJsonSchema](https://gitlab.com/operator-ict/golemio/code/modules/municipal-libraries/-/blob/development/src/schema-definitions/datasources/MunicipalLibrariesJsonSchema.ts)
24
23
  - příklad [vstupních dat](https://gitlab.com/operator-ict/golemio/code/modules/municipal-libraries/-/blob/development/test/integration-engine/data/municipallibraries-datasource.json)
25
24
  - frekvence stahování
26
25
  - cron definice:
@@ -34,6 +33,12 @@ Modul slouží k ukládání a poskytování informací o městských knihovnác
34
33
 
35
34
  Při transformaci data obohacujeme o atribut `district`, která vychází z polohy dané knihovny a získává se metodou `cityDistrictsModel.getDistrict` v modulu city-district.
36
35
 
36
+ Primární klíč `libraries.id` je odvozován z URL slug dané pobočky (cesta za TLD z `website_url` bez parametrů/kotev).
37
+
38
+ Pobočky jsou filtrovány: zpracovávají se pouze záznamy s `show_in_list: true`, platnou `website_url` a nenulovými GPS souřadnicemi.
39
+
40
+ Služby (tabulka `services`) jsou odvozovány výhradně z pole `barrier_free` — pokud je `true`, je přiřazena jedna hardcodovaná služba "Bezbariérový přístup" (id = 3).
41
+
37
42
  ### _MunicipalLibrariesWorker_
38
43
 
39
44
  #### _task: RefreshDataInDBTask_
package/docs/openapi.yaml CHANGED
@@ -134,9 +134,9 @@ paths:
134
134
  in: path
135
135
  description: Identifier of the Municipal Library.
136
136
  required: true
137
- example: 5
137
+ example: ustredni-knihovna-suteren
138
138
  schema:
139
- type: number
139
+ type: string
140
140
  responses:
141
141
  "200":
142
142
  description: OK
@@ -246,8 +246,8 @@ components:
246
246
  type: string
247
247
  example: knihovna@mlp.cz
248
248
  id:
249
- type: number
250
- example: 68
249
+ type: string
250
+ example: ustredni-knihovna-suteren
251
251
  name:
252
252
  type: string
253
253
  example: Sběrný dvůr hlavního města Prahy Proboštská
@@ -279,6 +279,10 @@ components:
279
279
  type: string
280
280
  nullable: true
281
281
  example: 2022-01-01T23:00:00.000Z
282
+ type:
283
+ type: string
284
+ enum: [standard, self_service]
285
+ example: standard
282
286
  services:
283
287
  type: array
284
288
  items:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/municipal-libraries",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "Golemio Municipal Libraries Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,10 +8,12 @@
8
8
  "build": "rimraf ./dist && tspc -p ./tsconfig.build.json",
9
9
  "build-minimal": "run-s 'build -- --sourceMap false --declaration false'",
10
10
  "build-watch": "run-s 'build -- --watch --preserveWatchOutput'",
11
- "pretest": "golemio import-db-data --postgres",
12
- "test": "cross-env NODE_ENV=test mocha --exit --check-leaks --timeout 120000 -r ts-node/register -r tsconfig-paths/register -r dotenv/config --file 'test/setup.ts' 'test/**/*.test.ts'",
11
+ "prepare-db": "golemio import-db-data --postgres",
12
+ "test:only": "cross-env NODE_ENV=test mocha --exit --check-leaks --timeout 120000 -r ts-node/register -r tsconfig-paths/register -r dotenv/config --file 'test/setup.ts' 'test/**/*.test.ts'",
13
+ "test": "run-s prepare-db test:only",
13
14
  "test-debug": "run-s 'test -- --inspect-brk=9230'",
14
- "code-coverage": "nyc run-s 'test -- -r source-map-support/register'",
15
+ "coverage:only": "nyc --reporter=text --reporter=lcov npm run test:only -- -r source-map-support/register",
16
+ "code-coverage": "run-s prepare-db coverage:only",
15
17
  "migrate-db": "golemio migrate-db up --postgres",
16
18
  "generate-docs": "typedoc --out docs/typedoc src",
17
19
  "lint": "eslint \"{src,test}/**/*.ts\""
@@ -26,37 +28,37 @@
26
28
  "url": "https://gitlab.com/operator-ict/golemio/code/modules/municipal-libraries"
27
29
  },
28
30
  "engines": {
29
- "node": ">=20.0.0",
30
- "npm": ">=8.0.0"
31
+ "node": ">=24.0.0",
32
+ "npm": ">=11.0.0"
31
33
  },
32
34
  "devDependencies": {
33
35
  "@commitlint/cli": "^11.0.0",
34
36
  "@commitlint/config-conventional": "^11.0.0",
35
- "@golemio/city-districts": "1.4.0",
36
- "@golemio/cli": "1.11.0",
37
- "@golemio/core": "1.22.1",
38
- "@golemio/db-common": "1.2.0",
39
- "@golemio/eslint-config": "1.1.2",
40
- "@types/chai": "4.2.3",
41
- "@types/chai-as-promised": "7.1.2",
42
- "@types/mocha": "^9.1.0",
43
- "@types/node": "^20.12.7",
44
- "@types/sinon": "^9.0.10",
45
- "@types/supertest": "^2.0.12",
46
- "chai": "4.2.0",
47
- "chai-as-promised": "7.1.1",
37
+ "@golemio/city-districts": "1.4.5",
38
+ "@golemio/cli": "1.11.2",
39
+ "@golemio/core": "3.1.1",
40
+ "@golemio/db-common": "1.2.2",
41
+ "@golemio/eslint-config": "1.1.4",
42
+ "@types/chai": "^5.2.3",
43
+ "@types/chai-as-promised": "^8.0.2",
44
+ "@types/mocha": "^10.0.10",
45
+ "@types/node": "^24.12.4",
46
+ "@types/sinon": "^21.0.0",
47
+ "@types/supertest": "^6.0.3",
48
+ "chai": "^6.2.2",
49
+ "chai-as-promised": "^8.0.2",
48
50
  "cross-env": "^7.0.3",
49
51
  "eslint": "^8.1.1",
50
52
  "husky": "^4.3.7",
51
- "mocha": "^9.1.2",
53
+ "mocha": "^11.7.5",
52
54
  "npm-run-all": "^4.1.5",
53
55
  "nyc": "^15.1.0",
54
56
  "prettier": "^2.5.1",
55
57
  "pretty-quick": "^3.1.0",
56
58
  "rimraf": "^3.0.2",
57
- "sinon": "^9.2.3",
59
+ "sinon": "^21.0.1",
58
60
  "source-map-support": "0.5.21",
59
- "supertest": "^6.2.4",
61
+ "supertest": "^7.1.4",
60
62
  "ts-node": "^10.9.1",
61
63
  "ts-patch": "3.0.0-beta3",
62
64
  "tsconfig-paths": "^4.2.0",