From ceab7cc7effc5d0246725f3f780d70f641b421ce Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Wed, 19 Jun 2019 15:04:59 +0200 Subject: [PATCH] refactor: tidy structure of source files Fixes #79 --- package-lock.json | 99 +++---- package.json | 20 +- .../types/config/App.ts => config/app.ts} | 8 +- .../config/Backend.ts => config/backend.ts} | 18 +- .../files/ConfigFile.ts => config/file.ts} | 8 +- .../Monitoring.ts => config/monitoring.ts} | 2 +- src/core/protocol/errors/ErrorResponse.ts | 260 ------------------ .../protocol/routes/INDEX/IndexResponse.ts | 33 --- .../routes/TYPE/UID/ThingUpdateResponse.ts | 21 -- .../BookAvailabilityResponse.ts | 22 -- .../routes/bulk/UID/BulkAddResponse.ts | 21 -- .../routes/bulk/UID/BulkDoneResponse.ts | 21 -- .../routes/feedback/FeedbackResponse.ts | 21 -- .../routes/search/MultiSearchResponse.ts | 25 -- src/core/types/PostalAddress.ts | 48 ---- src/{core/types => general}/i18n.ts | 10 +- src/{core/types/Map.ts => general/map.ts} | 0 src/{core/types => general}/namespaces.ts | 2 +- src/{core/types/Time.ts => general/time.ts} | 2 +- src/{core/types/UUID.ts => general/uuid.ts} | 2 +- src/{core/types/Guards.ts => guards.ts} | 28 +- src/{core/Classes.ts => meta.ts} | 52 ++-- src/protocol/error.ts | 56 ++++ src/protocol/errors/internal-server-error.ts | 41 +++ src/protocol/errors/method-not-allowed.ts | 30 ++ .../errors/not-found.ts} | 16 +- .../errors/parameters-not-acceptable.ts | 32 +++ .../errors/plugin-already-registered.ts | 44 +++ .../errors/plugin-registering-failed.ts | 31 +++ .../errors/request-body-too-large.ts} | 26 +- .../errors/syntax-error.ts} | 25 +- src/protocol/errors/too-many-requests.ts | 35 +++ src/protocol/errors/unsupported-media-type.ts | 30 ++ src/protocol/errors/validation.ts | 38 +++ src/{core/Route.ts => protocol/route.ts} | 36 +-- .../routes/book-availability.ts} | 32 ++- .../routes/bulk-add.ts} | 32 ++- .../routes/bulk-done.ts} | 30 +- .../routes/bulk-request.ts} | 45 ++- .../routes/feedback.ts} | 28 +- .../routes/index.ts} | 37 ++- .../routes/plugin-register.ts} | 29 +- .../routes/search-multi.ts} | 34 ++- .../routes/search.ts} | 58 +--- .../routes/thing-update.ts} | 30 +- .../search/facet.ts} | 31 ++- .../Abstract.ts => protocol/search/filter.ts} | 12 +- .../search/filters/availability.ts} | 8 +- .../search/filters/boolean.ts} | 4 +- .../search/filters/distance.ts} | 6 +- .../search/filters/value.ts} | 6 +- src/protocol/search/query.ts | 52 ++++ .../search/result.ts} | 51 +--- .../Abstract.ts => protocol/search/sort.ts} | 12 +- .../search/sorts/distance.ts} | 4 +- .../search/sorts/ducet.ts} | 4 +- .../search/sorts/price.ts} | 6 +- .../abstract/academic-degree.ts} | 10 +- .../abstract/academic-term.ts} | 10 +- .../abstract/creative-work.ts} | 30 +- .../Event.ts => things/abstract/event.ts} | 22 +- .../Place.ts => things/abstract/place.ts} | 80 +++++- .../abstract/saveable-thing.ts} | 2 +- .../abstract/thing-in-place.ts} | 8 +- .../abstract/thing-that-accepts-payments.ts} | 12 +- .../abstract/thing-that-can-be-offered.ts} | 44 +-- .../abstract/thing-with-categories.ts} | 24 +- .../Thing.ts => things/abstract/thing.ts} | 26 +- .../academic-event.ts} | 42 ++- .../things/Article.ts => things/article.ts} | 38 +-- src/{core/things/Book.ts => things/book.ts} | 20 +- .../things/Building.ts => things/building.ts} | 54 ++-- .../things/Catalog.ts => things/catalog.ts} | 38 +-- .../course-of-studies.ts} | 16 +- .../DateSeries.ts => things/date-series.ts} | 24 +- src/{core/things/Diff.ts => things/diff.ts} | 10 +- src/{core/things/Dish.ts => things/dish.ts} | 58 ++-- .../things/Favorite.ts => things/favorite.ts} | 24 +- src/{core/things/Floor.ts => things/floor.ts} | 16 +- .../things/Message.ts => things/message.ts} | 16 +- .../organization.ts} | 8 +- .../things/Person.ts => things/person.ts} | 46 ++-- .../point-of-interest.ts} | 52 ++-- src/{core/things/Room.ts => things/room.ts} | 82 +++--- .../things/Semester.ts => things/semester.ts} | 26 +- .../things/Setting.ts => things/setting.ts} | 36 +-- .../SportCourse.ts => things/sport-course.ts} | 8 +- .../StudyModule.ts => things/study-module.ts} | 22 +- .../things/Ticket.ts => things/ticket.ts} | 12 +- src/{core/things/ToDo.ts => things/todo.ts} | 20 +- src/{core/things/Tour.ts => things/tour.ts} | 28 +- src/{core/things/Video.ts => things/video.ts} | 26 +- src/{core/Translator.ts => translator.ts} | 77 +++--- test/{Guards.spec.ts => guards.spec.ts} | 12 +- test/{Routes.spec.ts => routes.spec.ts} | 6 +- test/{Schema.spec.ts => schema.spec.ts} | 0 ...{Translator.spec.ts => translator.spec.ts} | 37 ++- test/{Type.spec.ts => type.spec.ts} | 67 +++-- tslint.json | 3 +- 99 files changed, 1395 insertions(+), 1511 deletions(-) rename src/{core/types/config/App.ts => config/app.ts} (95%) rename src/{core/types/config/Backend.ts => config/backend.ts} (91%) rename src/{core/files/ConfigFile.ts => config/file.ts} (86%) rename src/{core/types/config/Monitoring.ts => config/monitoring.ts} (99%) delete mode 100644 src/core/protocol/errors/ErrorResponse.ts delete mode 100644 src/core/protocol/routes/INDEX/IndexResponse.ts delete mode 100644 src/core/protocol/routes/TYPE/UID/ThingUpdateResponse.ts delete mode 100644 src/core/protocol/routes/bookAvailability/BookAvailabilityResponse.ts delete mode 100644 src/core/protocol/routes/bulk/UID/BulkAddResponse.ts delete mode 100644 src/core/protocol/routes/bulk/UID/BulkDoneResponse.ts delete mode 100644 src/core/protocol/routes/feedback/FeedbackResponse.ts delete mode 100644 src/core/protocol/routes/search/MultiSearchResponse.ts delete mode 100644 src/core/types/PostalAddress.ts rename src/{core/types => general}/i18n.ts (99%) rename src/{core/types/Map.ts => general/map.ts} (100%) rename src/{core/types => general}/namespaces.ts (99%) rename src/{core/types/Time.ts => general/time.ts} (98%) rename src/{core/types/UUID.ts => general/uuid.ts} (96%) rename src/{core/types/Guards.ts => guards.ts} (79%) rename src/{core/Classes.ts => meta.ts} (91%) create mode 100644 src/protocol/error.ts create mode 100644 src/protocol/errors/internal-server-error.ts create mode 100644 src/protocol/errors/method-not-allowed.ts rename src/{core/protocol/routes/plugin/PluginRegisterResponse.ts => protocol/errors/not-found.ts} (59%) create mode 100644 src/protocol/errors/parameters-not-acceptable.ts create mode 100644 src/protocol/errors/plugin-already-registered.ts create mode 100644 src/protocol/errors/plugin-registering-failed.ts rename src/{core/protocol/routes/bulk/BulkResponse.ts => protocol/errors/request-body-too-large.ts} (55%) rename src/{core/types/Places.ts => protocol/errors/syntax-error.ts} (57%) create mode 100644 src/protocol/errors/too-many-requests.ts create mode 100644 src/protocol/errors/unsupported-media-type.ts create mode 100644 src/protocol/errors/validation.ts rename src/{core/Route.ts => protocol/route.ts} (69%) rename src/{core/protocol/routes/bookAvailability/BookAvailabilityRequest.ts => protocol/routes/book-availability.ts} (68%) rename src/{core/protocol/routes/bulk/UID/BulkAddRequest.ts => protocol/routes/bulk-add.ts} (65%) rename src/{core/protocol/routes/bulk/UID/BulkDoneRequest.ts => protocol/routes/bulk-done.ts} (66%) rename src/{core/protocol/routes/bulk/BulkRequest.ts => protocol/routes/bulk-request.ts} (64%) rename src/{core/protocol/routes/feedback/FeedbackRequest.ts => protocol/routes/feedback.ts} (74%) rename src/{core/protocol/routes/INDEX/IndexRequest.ts => protocol/routes/index.ts} (59%) rename src/{core/protocol/routes/plugin/PluginRegisterRequest.ts => protocol/routes/plugin-register.ts} (76%) rename src/{core/protocol/routes/search/MultiSearchRequest.ts => protocol/routes/search-multi.ts} (62%) rename src/{core/protocol/routes/search/SearchRequest.ts => protocol/routes/search.ts} (54%) rename src/{core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts => protocol/routes/thing-update.ts} (66%) rename src/{core/types/GeoInformation.ts => protocol/search/facet.ts} (62%) rename src/{core/types/filters/Abstract.ts => protocol/search/filter.ts} (80%) rename src/{core/types/filters/Availability.ts => protocol/search/filters/availability.ts} (90%) rename src/{core/types/filters/Boolean.ts => protocol/search/filters/boolean.ts} (94%) rename src/{core/types/filters/Distance.ts => protocol/search/filters/distance.ts} (93%) rename src/{core/types/filters/Value.ts => protocol/search/filters/value.ts} (91%) create mode 100644 src/protocol/search/query.ts rename src/{core/protocol/routes/search/SearchResponse.ts => protocol/search/result.ts} (62%) rename src/{core/types/sorts/Abstract.ts => protocol/search/sort.ts} (84%) rename src/{core/types/sorts/Distance.ts => protocol/search/sorts/distance.ts} (95%) rename src/{core/types/sorts/Ducet.ts => protocol/search/sorts/ducet.ts} (94%) rename src/{core/types/sorts/Price.ts => protocol/search/sorts/price.ts} (90%) rename src/{core/base/AcademicDegree.ts => things/abstract/academic-degree.ts} (94%) rename src/{core/base/AcademicTerm.ts => things/abstract/academic-term.ts} (91%) rename src/{core/base/CreativeWork.ts => things/abstract/creative-work.ts} (80%) rename src/{core/base/Event.ts => things/abstract/event.ts} (83%) rename src/{core/base/Place.ts => things/abstract/place.ts} (66%) rename src/{core/base/SaveableThing.ts => things/abstract/saveable-thing.ts} (98%) rename src/{core/base/ThingInPlace.ts => things/abstract/thing-in-place.ts} (89%) rename src/{core/base/ThingThatAcceptsPayments.ts => things/abstract/thing-that-accepts-payments.ts} (83%) rename src/{core/base/ThingThatCanBeOffered.ts => things/abstract/thing-that-can-be-offered.ts} (82%) rename src/{core/base/ThingWithCategories.ts => things/abstract/thing-with-categories.ts} (91%) rename src/{core/Thing.ts => things/abstract/thing.ts} (94%) rename src/{core/things/AcademicEvent.ts => things/academic-event.ts} (85%) rename src/{core/things/Article.ts => things/article.ts} (83%) rename src/{core/things/Book.ts => things/book.ts} (88%) rename src/{core/things/Building.ts => things/building.ts} (74%) rename src/{core/things/Catalog.ts => things/catalog.ts} (81%) rename src/{core/things/CourseOfStudies.ts => things/course-of-studies.ts} (93%) rename src/{core/things/DateSeries.ts => things/date-series.ts} (87%) rename src/{core/things/Diff.ts => things/diff.ts} (92%) rename src/{core/things/Dish.ts => things/dish.ts} (87%) rename src/{core/things/Favorite.ts => things/favorite.ts} (70%) rename src/{core/things/Floor.ts => things/floor.ts} (90%) rename src/{core/things/Message.ts => things/message.ts} (89%) rename src/{core/things/Organization.ts => things/organization.ts} (91%) rename src/{core/things/Person.ts => things/person.ts} (91%) rename src/{core/things/PointOfInterest.ts => things/point-of-interest.ts} (71%) rename src/{core/things/Room.ts => things/room.ts} (73%) rename src/{core/things/Semester.ts => things/semester.ts} (73%) rename src/{core/things/Setting.ts => things/setting.ts} (86%) rename src/{core/things/SportCourse.ts => things/sport-course.ts} (88%) rename src/{core/things/StudyModule.ts => things/study-module.ts} (92%) rename src/{core/things/Ticket.ts => things/ticket.ts} (90%) rename src/{core/things/ToDo.ts => things/todo.ts} (87%) rename src/{core/things/Tour.ts => things/tour.ts} (96%) rename src/{core/things/Video.ts => things/video.ts} (91%) rename src/{core/Translator.ts => translator.ts} (88%) rename test/{Guards.spec.ts => guards.spec.ts} (90%) rename test/{Routes.spec.ts => routes.spec.ts} (89%) rename test/{Schema.spec.ts => schema.spec.ts} (100%) rename test/{Translator.spec.ts => translator.spec.ts} (90%) rename test/{Type.spec.ts => type.spec.ts} (85%) diff --git a/package-lock.json b/package-lock.json index 9c2cfeb6..bc221926 100644 --- a/package-lock.json +++ b/package-lock.json @@ -146,9 +146,9 @@ "dev": true }, "@openstapps/configuration": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.18.0.tgz", - "integrity": "sha512-Ufi3jzCozVqCymNeaeRzuOHO2Yd5qXJ10uF4xNHk6Q4LFD9NAMMBkYbawkjmecZoNR+Llqs4AnwSxIkuEAxcxA==", + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.20.0.tgz", + "integrity": "sha512-BDgltSBmGQosJmVm1QWVvIw+GTWd0FbmCLxtuziuVdIOK520mGLhoaDrLKTEIAfNtemqxxe90J4/G9JcRiIK+w==", "dev": true, "requires": { "@types/node": "10.14.7", @@ -156,8 +156,8 @@ "@types/yaml": "1.0.2", "chalk": "2.4.2", "commander": "2.20.0", - "semver": "6.1.0", - "tslint": "5.16.0", + "semver": "6.1.1", + "tslint": "5.17.0", "tslint-eslint-rules": "5.4.0", "yaml": "1.6.0" }, @@ -169,39 +169,10 @@ "dev": true }, "semver": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.0.tgz", - "integrity": "sha512-kCqEOOHoBcFs/2Ccuk4Xarm/KiWRSLEX9CAZF8xkJ6ZPlIoTZ8V5f7J16vYLJqDbR7KrxTJpR2lqjIEm2Qx9cQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", + "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", "dev": true - }, - "tslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz", - "integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.13.0", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.29.0" - }, - "dependencies": { - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - } - } } } }, @@ -293,37 +264,37 @@ } }, "@openstapps/logger": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.2.1.tgz", - "integrity": "sha512-6+F1nxEBuNTrd3hhBxKnvkH8B84HvB/dVmoMP9Pmv2g3mL3pYJ9l2BBGaACDRA7oUCyLpbNQw+4Kf+VdyzOttw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.3.1.tgz", + "integrity": "sha512-N8S4b6yoS+txN1IduxDxOnlJzhrPKWEMnVt02ZbMjSOcD55KNqxh+VgarFTQ1g6KRkquTNCo6c9IQN0UzSIg0g==", "dev": true, "requires": { - "@types/node": "10.14.7", - "@types/nodemailer": "6.1.0", + "@types/node": "10.14.8", + "@types/nodemailer": "6.2.0", "chalk": "2.4.2", "flatted": "2.0.0", - "nodemailer": "6.1.1" + "nodemailer": "6.2.1" }, "dependencies": { "@types/node": { - "version": "10.14.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.7.tgz", - "integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A==", + "version": "10.14.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.8.tgz", + "integrity": "sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==", "dev": true }, "@types/nodemailer": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.1.0.tgz", - "integrity": "sha512-WysSJ4sGW2Aum1Cs6HFosZdlR3WUzX0XoSLsI53q77gLd4wDfE84OXffZu5/nLIjeKh4SwfTsdrKsgBL9WowMA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.2.0.tgz", + "integrity": "sha512-WGGEk/BGRLuYF3gyoTwbtKg5tCexZzb5lkTsis2k7GkAzlg4x2299/SC6Ssdj3X/5TzT1BHVc8zcFg/7KSzBLw==", "dev": true, "requires": { "@types/node": "*" } }, "nodemailer": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.1.1.tgz", - "integrity": "sha512-/x5MRIh56VyuuhLfcz+DL2SlBARpZpgQIf2A4Ao4hMb69MHSgDIMPwYmFwesGT1lkRDZ0eBSoym5+JoIZ3N+cQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.2.1.tgz", + "integrity": "sha512-TagB7iuIi9uyNgHExo8lUDq3VK5/B0BpbkcjIgNvxbtVrjNqq0DwAOTuzALPVkK76kMhTSzIgHqg8X1uklVs6g==", "dev": true } } @@ -422,9 +393,9 @@ "dev": true }, "@types/node": { - "version": "10.14.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.8.tgz", - "integrity": "sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==" + "version": "10.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.9.tgz", + "integrity": "sha512-NelG/dSahlXYtSoVPErrp06tYFrvzj8XLWmKA+X8x0W//4MqbUyZu++giUG/v0bjAT6/Qxa8IjodrfdACyb0Fg==" }, "@types/nodemailer": { "version": "4.6.5", @@ -3618,9 +3589,9 @@ } }, "ts-node": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.2.0.tgz", - "integrity": "sha512-m8XQwUurkbYqXrKqr3WHCW310utRNvV5OnRVeISeea7LoCWVcdfeB/Ntl8JYWFh+WRoUAdBgESrzKochQt7sMw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", + "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", "dev": true, "requires": { "arg": "^4.1.0", @@ -3696,9 +3667,9 @@ "dev": true }, "tsutils": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.13.0.tgz", - "integrity": "sha512-wRtEjVU8Su72sDIDoqno5Scwt8x4eaF0teKO3m4hu8K1QFPnIZMM88CLafs2tapUeWnY9SwwO3bWeOt2uauBcg==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", + "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -3761,9 +3732,9 @@ "dev": true }, "typescript": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz", - "integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", + "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 98d42a5e..e32a9a50 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "prepublishOnly": "npm ci && npm run build", "preversion": "npm run prepublishOnly", "push": "git push && git push origin \"v$npm_package_version\"", - "schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src/core lib/schema", + "schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src lib/schema", "test": "nyc mocha --require ts-node/register --require source-map-support/register --ui mocha-typescript test/*.spec.ts", "tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'" }, @@ -43,7 +43,7 @@ "dependencies": { "@types/geojson": "1.0.6", "@types/json-patch": "0.0.30", - "@types/node": "10.14.8", + "@types/node": "10.14.9", "fast-clone": "1.5.13", "http-status-codes": "1.3.2", "json-patch": "0.7.0", @@ -52,9 +52,9 @@ }, "devDependencies": { "@krlwlfrt/async-pool": "0.1.0", - "@openstapps/configuration": "0.18.0", + "@openstapps/configuration": "0.20.0", "@openstapps/core-tools": "0.6.0", - "@openstapps/logger": "0.2.1", + "@openstapps/logger": "0.3.1", "@types/chai": "4.1.7", "@types/rimraf": "2.0.2", "chai": "4.2.0", @@ -66,10 +66,10 @@ "nyc": "14.1.1", "rimraf": "2.6.3", "source-map-support": "0.5.12", - "ts-node": "8.2.0", + "ts-node": "8.3.0", "tslint": "5.17.0", "typedoc": "0.14.2", - "typescript": "3.5.1" + "typescript": "3.5.2" }, "nyc": { "check-coverage": true, @@ -79,10 +79,10 @@ "functions": 95, "branches": 85, "include": [ - "src/core/Route.ts", - "src/core/Thing.ts", - "src/core/Translator.ts", - "src/core/types/Guards.ts" + "src/protocol/route.ts", + "src/things/abstract/thing.ts", + "src/translator.ts", + "src/guards.ts" ], "exclude": [], "extension": [ diff --git a/src/core/types/config/App.ts b/src/config/app.ts similarity index 95% rename from src/core/types/config/App.ts rename to src/config/app.ts index dd4a5f0b..ae0865fa 100644 --- a/src/core/types/config/App.ts +++ b/src/config/app.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -14,8 +14,8 @@ */ // tslint:disable-next-line:no-implicit-dependencies import {Polygon} from 'geojson'; -import {SCSetting} from '../../things/Setting'; -import {SCTranslations} from '../i18n'; +import {SCTranslations} from '../general/i18n'; +import {SCSetting} from '../things/setting'; /** * An app configuration menu item @@ -149,7 +149,7 @@ export interface SCAppConfigurationStoreUrl { */ ios?: string; /** - * Microsoft Store URL + * Microsoft Store URL */ uwp?: string; } diff --git a/src/core/types/config/Backend.ts b/src/config/backend.ts similarity index 91% rename from src/core/types/config/Backend.ts rename to src/config/backend.ts index 509957c2..68632f53 100644 --- a/src/core/types/config/Backend.ts +++ b/src/config/backend.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingType} from '../../Thing'; -import {SCSearchSortType} from '../sorts/Abstract'; -import {SCUuid} from '../UUID'; -import {SCMap, SCRestrictedMap} from './../Map'; -import {SCMonitoringConfiguration} from './Monitoring'; +import {SCMap, SCRestrictedMap} from '../general/map'; +import {SCUuid} from '../general/uuid'; +import {SCSearchSortType} from '../protocol/search/sort'; +import {SCThingType} from '../things/abstract/thing'; +import {SCMonitoringConfiguration} from './monitoring'; /** * A backend configuration @@ -96,10 +96,8 @@ export type SCSearchContext = * A boosting configuration for one context */ export type SCBackendConfigurationSearchBoostingContext = - SCRestrictedMap< - SCSearchContext, - SCBackendConfigurationSearchBoostingType[] - >; + SCRestrictedMap; /** * A boosting configuration for one SCType diff --git a/src/core/files/ConfigFile.ts b/src/config/file.ts similarity index 86% rename from src/core/files/ConfigFile.ts rename to src/config/file.ts index 1e89592f..16c4bfd7 100644 --- a/src/core/files/ConfigFile.ts +++ b/src/config/file.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCAppConfiguration} from '../types/config/App'; -import {SCBackendConfiguration, SCBackendInternalConfiguration} from '../types/config/Backend'; -import {SCLicensePlate} from '../types/namespaces'; +import {SCLicensePlate} from '../general/namespaces'; +import {SCAppConfiguration} from './app'; +import {SCBackendConfiguration, SCBackendInternalConfiguration} from './backend'; /** * A configuration file that configures app and backend diff --git a/src/core/types/config/Monitoring.ts b/src/config/monitoring.ts similarity index 99% rename from src/core/types/config/Monitoring.ts rename to src/config/monitoring.ts index 424ddf22..4a4ec341 100644 --- a/src/core/types/config/Monitoring.ts +++ b/src/config/monitoring.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. diff --git a/src/core/protocol/errors/ErrorResponse.ts b/src/core/protocol/errors/ErrorResponse.ts deleted file mode 100644 index f2881378..00000000 --- a/src/core/protocol/errors/ErrorResponse.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2018-2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -import { - BAD_GATEWAY, - BAD_REQUEST, CONFLICT, INTERNAL_SERVER_ERROR, - METHOD_NOT_ALLOWED, NOT_ACCEPTABLE, NOT_FOUND, - REQUEST_TOO_LONG, - TOO_MANY_REQUESTS, - UNSUPPORTED_MEDIA_TYPE, -} from 'http-status-codes'; -import {ValidationError} from 'jsonschema'; -import {SCPluginMetaData} from '../routes/plugin/PluginRegisterRequest'; - -/** - * A generic error that can be returned by the backend if somethings fails during the processing of a request - * - * @validatable - */ -export interface SCErrorResponse extends Error { - /** - * Additional data that describes the error - */ - additionalData?: unknown; - - /** - * HTTP status code to return this error with - */ - statusCode: number; -} - -/** - * An error that can be created by the backend during the processing of a request - */ -export abstract class SCError implements SCErrorResponse { - /** - * Call stack of the error - */ - stack?: string; - - /** - * Instatiate an SCError - * - * @param name Name of the error - * @param message Message of the error - * @param statusCode HTTP status code to return this error with - * @param stack Set to true if a stack trace should be created - */ - constructor(public name: string, public message: string, public statusCode: number, stack = false) { - // generate stacktrace if needed - if (stack) { - this.stack = (new Error()).stack; - } - } -} - -/** - * An error that is returned when the validation of a request fails - */ -export class SCValidationErrorResponse extends SCError { - /** - * List of validatation errors - */ - additionalData: ValidationError[]; - - /** - * Create a SCValidationErrorResponse - * - * @param errors List of validation errors - * @param stack Set to true if a stack trace should be created - */ - constructor(errors: ValidationError[], stack?: boolean) { - super('ValidationError', 'Validation of request failed', BAD_REQUEST, stack); - this.additionalData = errors; - } -} - -/** - * An error that is returned when the content type of the request is not supported - */ -export class SCUnsupportedMediaTypeErrorResponse extends SCError { - /** - * Create a SCUnsupportedMediaTypeErrorResponse - * - * @param stack Set to true if a stack trace should be created - */ - constructor(stack?: boolean) { - super('UnsupportedMediaTypeError', 'Unsupported media type', UNSUPPORTED_MEDIA_TYPE, stack); - } -} - -/** - * An error that is returned, when the used HTTP method is not allowed on the requested route - */ -export class SCMethodNotAllowedErrorResponse extends SCError { - /** - * Create a SCMethodNotAllowedErrorResponse - * - * @param stack Set to true if a stack trace should be created - */ - constructor(stack?: boolean) { - super('MethodNotAllowedError', 'HTTP method is not allowed on this route', METHOD_NOT_ALLOWED, stack); - } -} - -/** - * An error that is returned, when the request body is too large. - */ -export class SCRequestBodyTooLargeErrorResponse extends SCError { - /** - * Create a SCRequestBodyTooLargeErrorResponse - * - * @param stack Set to true if a stack trace should be created - */ - constructor(stack?: boolean) { - super('RequestBodyTooLargeError', 'The request body is too large.', REQUEST_TOO_LONG, stack); - } -} - -/** - * An error that is returned, when to many request are submitted at once - */ -export class SCTooManyRequestsErrorResponse extends SCError { - /** - * Create a SCTooManyRequestsErrorResponse - * - * @param stack Set to true if a stack trace should be created - */ - constructor(stack?: boolean) { - super( - 'TooManyRequestsError', - 'Too many requests. You can not submit more than 5 queries an once', - TOO_MANY_REQUESTS, - stack, - ); - } -} - -/** - * An error that is returned when the requested route or resource was not found - */ -export class SCNotFoundErrorResponse extends SCError { - /** - * Create a SCNotFoundErrorResponse - * - * @param stack Set to true if a stack trace should be created - */ - constructor(stack?: boolean) { - super('NotFoundError', 'Resource not found', NOT_FOUND, stack); - } -} - -/** - * An error that is returned when the request is in the right format, but contains parameters that are invalid or not - * acceptable. - */ -export class SCParametersNotAcceptable extends SCError { - /** - * Create a ParametersNotAcceptable - * - * @param message contains more details to what you did wrong - * @param stack Set to true if a stack trace should be created - */ - constructor(message: string, stack?: boolean) { - super('ParametersNotAcceptable', message, NOT_ACCEPTABLE, stack); - } -} - -/** - * An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin - * running at the same time. - * This usually indicates that there is more than one instance a plugin running. - */ -export class SCPluginAlreadyRegisteredErrorResponse extends SCError { - /** - * Meta data of a registered plugin, which is in a conflict with the plugin we want to register. - * If the stack is disabled this is not set for security reasons - */ - additionalData?: SCPluginMetaData; - - /** - * Create a SCPluginAlreadyRegisteredError - * - * @param message Provide further information why an already registered plugin matches the one we want to register - * @param plugin Provides meta data of a registered plugin, which is in a conflict with the plugin we want to register - * @param stack Set to true if a stack trace should be created - */ - constructor(message: string, plugin: SCPluginMetaData, stack = false) { - super('SCPluginAlreadyRegisteredError', message, CONFLICT, stack); - if (stack) { - this.additionalData = plugin; - } - } -} - -/** - * An error that is returned whenever there is an unexpected error while creating a plugin - */ -export class SCPluginRegisteringFailedErrorResponse extends SCError { - /** - * Create a PluginRegisteringFailedError - * - * @param message Describes what went wrong wile registering the plugin - * @param stack Set to true if a stack trace should be created - */ - constructor(message: string, stack?: boolean) { - super('PluginRegisteringFailedError', message, INTERNAL_SERVER_ERROR, stack); - } -} - -/** - * An error that is returned whenever there is a syntax error - */ -export class SCSyntaxErrorResponse extends SCError { - /** - * Create a SyntaxError - * - * @param message Describes the syntax error - * @param stack Set to true if a stack trace should be created - */ - constructor(message: string, stack?: boolean) { - super('SyntaxError', message, BAD_REQUEST, stack); - } -} - -/** - * An error that is returned, when an internal server error occurred - */ -export class SCInternalServerErrorResponse extends SCError { - /** - * Internal error that occurred. If the stack is disabled this error is not set for security reasons - */ - additionalData?: Error; - - /** - * Create a SCInternalServerErrorResponse - * - * @param err Internal server error - * @param stack Set to true if a stack trace should be created - * and the internal server error should be displayed to the client - */ - constructor(err?: Error, stack = false) { - super('InternalServerError', 'Internal server error', BAD_GATEWAY, stack); - - if (stack) { - this.additionalData = err; - } - } -} diff --git a/src/core/protocol/routes/INDEX/IndexResponse.ts b/src/core/protocol/routes/INDEX/IndexResponse.ts deleted file mode 100644 index 948478f8..00000000 --- a/src/core/protocol/routes/INDEX/IndexResponse.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -import {SCAppConfiguration} from '../../../types/config/App'; -import {SCBackendConfiguration} from '../../../types/config/Backend'; - -/** - * A response to an index request - * - * @validatable - */ -export interface SCIndexResponse { - /** - * @see SCAppConfiguration - */ - app: SCAppConfiguration; - - /** - * @see SCBackendConfiguration - */ - backend: SCBackendConfiguration; -} diff --git a/src/core/protocol/routes/TYPE/UID/ThingUpdateResponse.ts b/src/core/protocol/routes/TYPE/UID/ThingUpdateResponse.ts deleted file mode 100644 index a8b2cc1e..00000000 --- a/src/core/protocol/routes/TYPE/UID/ThingUpdateResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -/** - * Response for an entity update request - * - * @validatable - */ -export interface SCThingUpdateResponse { -} diff --git a/src/core/protocol/routes/bookAvailability/BookAvailabilityResponse.ts b/src/core/protocol/routes/bookAvailability/BookAvailabilityResponse.ts deleted file mode 100644 index 3c9c09be..00000000 --- a/src/core/protocol/routes/bookAvailability/BookAvailabilityResponse.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../../base/ThingThatCanBeOffered'; - -/** - * List of availabilities of a book - * - * @validatable - */ -export type SCBookAvailabilityResponse = Array>; diff --git a/src/core/protocol/routes/bulk/UID/BulkAddResponse.ts b/src/core/protocol/routes/bulk/UID/BulkAddResponse.ts deleted file mode 100644 index 69df1c9e..00000000 --- a/src/core/protocol/routes/bulk/UID/BulkAddResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -/** - * Response to a request to add a thing to a bulk - * - * @validatable - */ -export interface SCBulkAddResponse { -} diff --git a/src/core/protocol/routes/bulk/UID/BulkDoneResponse.ts b/src/core/protocol/routes/bulk/UID/BulkDoneResponse.ts deleted file mode 100644 index fc8de30f..00000000 --- a/src/core/protocol/routes/bulk/UID/BulkDoneResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -/** - * Response to a request to change the state of a bulk to done - * - * @validatable - */ -export interface SCBulkDoneResponse { -} diff --git a/src/core/protocol/routes/feedback/FeedbackResponse.ts b/src/core/protocol/routes/feedback/FeedbackResponse.ts deleted file mode 100644 index a56f22d0..00000000 --- a/src/core/protocol/routes/feedback/FeedbackResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018, 2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -/** - * A response to a feedback request - * - * @validatable - */ -export interface SCFeedbackResponse { -} diff --git a/src/core/protocol/routes/search/MultiSearchResponse.ts b/src/core/protocol/routes/search/MultiSearchResponse.ts deleted file mode 100644 index 1c14a3e3..00000000 --- a/src/core/protocol/routes/search/MultiSearchResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2018-2019 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -import {SCMap} from '../../../types/Map'; -import {SCSearchResult} from './SearchResponse'; - -/** - * A multi search response - * - * This is a map of [[SCSearchResponse]]s indexed by name - * - * @validatable - */ -export type SCMultiSearchResponse = SCMap; diff --git a/src/core/types/PostalAddress.ts b/src/core/types/PostalAddress.ts deleted file mode 100644 index 5ca441f3..00000000 --- a/src/core/types/PostalAddress.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2018 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ -/** - * A postal address - */ -export interface SCPostalAddress { - /** - * Country of the address - */ - addressCountry: string; - - /** - * City of the address - */ - addressLocality: string; - - /** - * State of the address - */ - addressRegion?: string; - - /** - * Zip code of the address - */ - postalCode: string; - - /** - * Optional post box number - */ - postOfficeBoxNumber?: string; - - /** - * Street of the address - with house number! - */ - streetAddress: string; -} diff --git a/src/core/types/i18n.ts b/src/general/i18n.ts similarity index 99% rename from src/core/types/i18n.ts rename to src/general/i18n.ts index be626d5d..5b834eb9 100644 --- a/src/core/types/i18n.ts +++ b/src/general/i18n.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -29,7 +29,7 @@ export interface SCLanguage { /** * A list of possible languages in english - * + * * @see https://en.wikipedia.org/wiki/ISO_639-1 */ export type SCLanguageName = @@ -221,7 +221,7 @@ export type SCLanguageName = /** * A List of all possible Languages as ISO 639-1 Codes - * + * * @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes */ export type SCLanguageCode = @@ -691,9 +691,9 @@ export interface SCTranslations { */ type RecursivePartial = { [P in keyof T]-?: - T[P] extends Array ? Array> : + T[P] extends Array ? Array> : T[P] extends object ? RecursivePartial : - T[P]; + T[P]; }; /** diff --git a/src/core/types/Map.ts b/src/general/map.ts similarity index 100% rename from src/core/types/Map.ts rename to src/general/map.ts diff --git a/src/core/types/namespaces.ts b/src/general/namespaces.ts similarity index 99% rename from src/core/types/namespaces.ts rename to src/general/namespaces.ts index d3f02b3d..701e8082 100644 --- a/src/core/types/namespaces.ts +++ b/src/general/namespaces.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. diff --git a/src/core/types/Time.ts b/src/general/time.ts similarity index 98% rename from src/core/types/Time.ts rename to src/general/time.ts index 2905e20b..24f70c59 100644 --- a/src/core/types/Time.ts +++ b/src/general/time.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. diff --git a/src/core/types/UUID.ts b/src/general/uuid.ts similarity index 96% rename from src/core/types/UUID.ts rename to src/general/uuid.ts index 01252b95..22ad2ea4 100644 --- a/src/core/types/UUID.ts +++ b/src/general/uuid.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. diff --git a/src/core/types/Guards.ts b/src/guards.ts similarity index 79% rename from src/core/types/Guards.ts rename to src/guards.ts index b41351e5..8e9f3030 100644 --- a/src/core/types/Guards.ts +++ b/src/guards.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCBulkResponse} from '../protocol/routes/bulk/BulkResponse'; -import {SCMultiSearchResponse} from '../protocol/routes/search/MultiSearchResponse'; -import {SCSearchResponse} from '../protocol/routes/search/SearchResponse'; -import {SCThing, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCTranslations} from './i18n'; +import {SCTranslations} from './general/i18n'; +import {SCBulkResponse} from './protocol/routes/bulk-request'; +import {SCSearchResponse} from './protocol/routes/search'; +import {SCMultiSearchResponse} from './protocol/routes/search-multi'; +import {SCThing, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from './things/abstract/thing'; /** * Type guard to check if something is a SCThing @@ -102,13 +102,13 @@ export function isSearchResponse(something: unknown): something is SCSearchRespo const somethingObject = (something as { [key: string]: { [key: string]: string; }; }); return Array.isArray(somethingObject.data) - && Array.isArray(somethingObject.facets) - && typeof somethingObject.pagination !== 'undefined' - && typeof somethingObject.pagination.count === 'number' - && typeof somethingObject.pagination.offset === 'number' - && typeof somethingObject.pagination.total === 'number' - && typeof somethingObject.stats !== 'undefined' - && typeof somethingObject.stats.time === 'number'; + && Array.isArray(somethingObject.facets) + && typeof somethingObject.pagination !== 'undefined' + && typeof somethingObject.pagination.count === 'number' + && typeof somethingObject.pagination.offset === 'number' + && typeof somethingObject.pagination.total === 'number' + && typeof somethingObject.stats !== 'undefined' + && typeof somethingObject.stats.time === 'number'; } /** @@ -117,7 +117,7 @@ export function isSearchResponse(something: unknown): something is SCSearchRespo * @param something Something to check */ export function isMultiSearchResponse(something: unknown): something is SCMultiSearchResponse { - const initialValue = Object.keys(something as { [key: string]: string; }).length > 0 ? true : false; + const initialValue = Object.keys(something as { [key: string]: string; }).length > 0 ? true : false; return Object.keys(something as { [key: string]: string; }) .reduce((previousOnesAreSearchResponses, key) => { diff --git a/src/core/Classes.ts b/src/meta.ts similarity index 91% rename from src/core/Classes.ts rename to src/meta.ts index cb70933b..8b7ba031 100644 --- a/src/core/Classes.ts +++ b/src/meta.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,31 +12,31 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingType} from './Thing'; -import {SCAcademicEvent, SCAcademicEventMeta, SCAcademicEventWithoutReferences} from './things/AcademicEvent'; -import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/Article'; -import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/Book'; -import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/Building'; -import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/Catalog'; -import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/CourseOfStudies'; -import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/DateSeries'; -import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/Diff'; -import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/Dish'; -import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/Favorite'; -import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/Floor'; -import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/Message'; -import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/Organization'; -import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/Person'; -import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/PointOfInterest'; -import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/Room'; -import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/Semester'; -import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/Setting'; -import {SCSportCourse, SCSportCourseMeta, SCSportCourseWithoutReferences} from './things/SportCourse'; -import {SCStudyModule, SCStudyModuleMeta, SCStudyModuleWithoutReferences} from './things/StudyModule'; -import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/Ticket'; -import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/ToDo'; -import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/Tour'; -import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/Video'; +import {SCThingType} from './things/abstract/thing'; +import {SCAcademicEvent, SCAcademicEventMeta, SCAcademicEventWithoutReferences} from './things/academic-event'; +import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/article'; +import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book'; +import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building'; +import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog'; +import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/course-of-studies'; +import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series'; +import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff'; +import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/dish'; +import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/favorite'; +import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/floor'; +import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/message'; +import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/organization'; +import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/person'; +import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/point-of-interest'; +import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/room'; +import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/semester'; +import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/setting'; +import {SCSportCourse, SCSportCourseMeta, SCSportCourseWithoutReferences} from './things/sport-course'; +import {SCStudyModule, SCStudyModuleMeta, SCStudyModuleWithoutReferences} from './things/study-module'; +import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/ticket'; +import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/todo'; +import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/tour'; +import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/video'; /* tslint:disable:variable-name */ /** diff --git a/src/protocol/error.ts b/src/protocol/error.ts new file mode 100644 index 00000000..bd2e20f6 --- /dev/null +++ b/src/protocol/error.ts @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +/** + * A generic error that can be returned by the backend if somethings fails during the processing of a request + * + * @validatable + */ +export interface SCErrorResponse extends Error { + /** + * Additional data that describes the error + */ + additionalData?: unknown; + + /** + * HTTP status code to return this error with + */ + statusCode: number; +} + +/** + * An error that can be created by the backend during the processing of a request + */ +export abstract class SCError implements SCErrorResponse { + /** + * Call stack of the error + */ + stack?: string; + + /** + * Instatiate an SCError + * + * @param name Name of the error + * @param message Message of the error + * @param statusCode HTTP status code to return this error with + * @param stack Set to true if a stack trace should be created + */ + constructor(public name: string, public message: string, public statusCode: number, stack = false) { + // generate stacktrace if needed + if (stack) { + this.stack = (new Error()).stack; + } + } +} diff --git a/src/protocol/errors/internal-server-error.ts b/src/protocol/errors/internal-server-error.ts new file mode 100644 index 00000000..ed8bbedc --- /dev/null +++ b/src/protocol/errors/internal-server-error.ts @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {BAD_GATEWAY} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned, when an internal server error occurred + */ +export class SCInternalServerErrorResponse extends SCError { + /** + * Internal error that occurred. If the stack is disabled this error is not set for security reasons + */ + additionalData?: Error; + + /** + * Create a SCInternalServerErrorResponse + * + * @param err Internal server error + * @param stack Set to true if a stack trace should be created + * and the internal server error should be displayed to the client + */ + constructor(err?: Error, stack = false) { + super('InternalServerError', 'Internal server error', BAD_GATEWAY, stack); + + if (stack) { + this.additionalData = err; + } + } +} diff --git a/src/protocol/errors/method-not-allowed.ts b/src/protocol/errors/method-not-allowed.ts new file mode 100644 index 00000000..35397178 --- /dev/null +++ b/src/protocol/errors/method-not-allowed.ts @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {METHOD_NOT_ALLOWED} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned, when the used HTTP method is not allowed on the requested route + */ +export class SCMethodNotAllowedErrorResponse extends SCError { + /** + * Create a SCMethodNotAllowedErrorResponse + * + * @param stack Set to true if a stack trace should be created + */ + constructor(stack?: boolean) { + super('MethodNotAllowedError', 'HTTP method is not allowed on this route', METHOD_NOT_ALLOWED, stack); + } +} diff --git a/src/core/protocol/routes/plugin/PluginRegisterResponse.ts b/src/protocol/errors/not-found.ts similarity index 59% rename from src/core/protocol/routes/plugin/PluginRegisterResponse.ts rename to src/protocol/errors/not-found.ts index 7a4e43fe..154f0df2 100644 --- a/src/core/protocol/routes/plugin/PluginRegisterResponse.ts +++ b/src/protocol/errors/not-found.ts @@ -12,15 +12,19 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {NOT_FOUND} from 'http-status-codes'; +import {SCError} from '../error'; /** - * Plugin register response - * - * @validatable + * An error that is returned when the requested route or resource was not found */ -export interface SCPluginRegisterResponse { +export class SCNotFoundErrorResponse extends SCError { /** - * Whether the desired action succeeded or failed (true for success, false if an error occurred) + * Create a SCNotFoundErrorResponse + * + * @param stack Set to true if a stack trace should be created */ - success: boolean; + constructor(stack?: boolean) { + super('NotFoundError', 'Resource not found', NOT_FOUND, stack); + } } diff --git a/src/protocol/errors/parameters-not-acceptable.ts b/src/protocol/errors/parameters-not-acceptable.ts new file mode 100644 index 00000000..14a7be82 --- /dev/null +++ b/src/protocol/errors/parameters-not-acceptable.ts @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {NOT_ACCEPTABLE} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned when the request is in the right format, but contains parameters that are invalid or not + * acceptable. + */ +export class SCParametersNotAcceptable extends SCError { + /** + * Create a ParametersNotAcceptable + * + * @param message contains more details to what you did wrong + * @param stack Set to true if a stack trace should be created + */ + constructor(message: string, stack?: boolean) { + super('ParametersNotAcceptable', message, NOT_ACCEPTABLE, stack); + } +} diff --git a/src/protocol/errors/plugin-already-registered.ts b/src/protocol/errors/plugin-already-registered.ts new file mode 100644 index 00000000..ac33f741 --- /dev/null +++ b/src/protocol/errors/plugin-already-registered.ts @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {CONFLICT} from 'http-status-codes'; +import {SCError} from '../error'; +import {SCPluginMetaData} from '../routes/plugin-register'; + +/** + * An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin + * running at the same time. + * This usually indicates that there is more than one instance a plugin running. + */ +export class SCPluginAlreadyRegisteredErrorResponse extends SCError { + /** + * Meta data of a registered plugin, which is in a conflict with the plugin we want to register. + * If the stack is disabled this is not set for security reasons + */ + additionalData?: SCPluginMetaData; + + /** + * Create a SCPluginAlreadyRegisteredError + * + * @param message Provide further information why an already registered plugin matches the one we want to register + * @param plugin Provides meta data of a registered plugin, which is in a conflict with the plugin we want to register + * @param stack Set to true if a stack trace should be created + */ + constructor(message: string, plugin: SCPluginMetaData, stack = false) { + super('SCPluginAlreadyRegisteredError', message, CONFLICT, stack); + if (stack) { + this.additionalData = plugin; + } + } +} diff --git a/src/protocol/errors/plugin-registering-failed.ts b/src/protocol/errors/plugin-registering-failed.ts new file mode 100644 index 00000000..010bf27d --- /dev/null +++ b/src/protocol/errors/plugin-registering-failed.ts @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {INTERNAL_SERVER_ERROR} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned whenever there is an unexpected error while creating a plugin + */ +export class SCPluginRegisteringFailedErrorResponse extends SCError { + /** + * Create a PluginRegisteringFailedError + * + * @param message Describes what went wrong wile registering the plugin + * @param stack Set to true if a stack trace should be created + */ + constructor(message: string, stack?: boolean) { + super('PluginRegisteringFailedError', message, INTERNAL_SERVER_ERROR, stack); + } +} diff --git a/src/core/protocol/routes/bulk/BulkResponse.ts b/src/protocol/errors/request-body-too-large.ts similarity index 55% rename from src/core/protocol/routes/bulk/BulkResponse.ts rename to src/protocol/errors/request-body-too-large.ts index cf230109..a7717efe 100644 --- a/src/core/protocol/routes/bulk/BulkResponse.ts +++ b/src/protocol/errors/request-body-too-large.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,25 +12,19 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCUuid} from '../../../types/UUID'; -import {SCBulkParameters} from './BulkRequest'; +import {REQUEST_TOO_LONG} from 'http-status-codes'; +import {SCError} from '../error'; /** - * Requested Bulk from backend - * - * @validatable + * An error that is returned, when the request body is too large. */ -export interface SCBulkResponse extends SCBulkParameters { +export class SCRequestBodyTooLargeErrorResponse extends SCError { /** - * State of bulk + * Create a SCRequestBodyTooLargeErrorResponse * - * The state is `in progress` while it accepts things to be added to the bulk. - * The state is `done` once it is closed. + * @param stack Set to true if a stack trace should be created */ - state: 'in progress' | 'done'; - - /** - * Universally unique identifier of the bulk - */ - uid: SCUuid; + constructor(stack?: boolean) { + super('RequestBodyTooLargeError', 'The request body is too large.', REQUEST_TOO_LONG, stack); + } } diff --git a/src/core/types/Places.ts b/src/protocol/errors/syntax-error.ts similarity index 57% rename from src/core/types/Places.ts rename to src/protocol/errors/syntax-error.ts index 67066c41..c03c51ff 100644 --- a/src/core/types/Places.ts +++ b/src/protocol/errors/syntax-error.ts @@ -12,21 +12,20 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCBuildingWithoutReferences} from '../things/Building'; -import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest'; -import {SCRoomWithoutReferences} from '../things/Room'; +import {BAD_REQUEST} from 'http-status-codes'; +import {SCError} from '../error'; + /** - * Something that is or happens in a place - * - * !Important! - * This is not a SCThing. + * An error that is returned whenever there is a syntax error */ -export interface SCInPlace { +export class SCSyntaxErrorResponse extends SCError { /** - * Place the thing is or happens in + * Create a SyntaxError + * + * @param message Describes the syntax error + * @param stack Set to true if a stack trace should be created */ - inPlace?: - SCBuildingWithoutReferences - | SCPointOfInterestWithoutReferences - | SCRoomWithoutReferences; + constructor(message: string, stack?: boolean) { + super('SyntaxError', message, BAD_REQUEST, stack); + } } diff --git a/src/protocol/errors/too-many-requests.ts b/src/protocol/errors/too-many-requests.ts new file mode 100644 index 00000000..c1554e7b --- /dev/null +++ b/src/protocol/errors/too-many-requests.ts @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {TOO_MANY_REQUESTS} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned, when to many request are submitted at once + */ +export class SCTooManyRequestsErrorResponse extends SCError { + /** + * Create a SCTooManyRequestsErrorResponse + * + * @param stack Set to true if a stack trace should be created + */ + constructor(stack?: boolean) { + super( + 'TooManyRequestsError', + 'Too many requests. You can not submit more than 5 queries an once', + TOO_MANY_REQUESTS, + stack, + ); + } +} diff --git a/src/protocol/errors/unsupported-media-type.ts b/src/protocol/errors/unsupported-media-type.ts new file mode 100644 index 00000000..24b5886c --- /dev/null +++ b/src/protocol/errors/unsupported-media-type.ts @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {UNSUPPORTED_MEDIA_TYPE} from 'http-status-codes'; +import {SCError} from '../error'; + +/** + * An error that is returned when the content type of the request is not supported + */ +export class SCUnsupportedMediaTypeErrorResponse extends SCError { + /** + * Create a SCUnsupportedMediaTypeErrorResponse + * + * @param stack Set to true if a stack trace should be created + */ + constructor(stack?: boolean) { + super('UnsupportedMediaTypeError', 'Unsupported media type', UNSUPPORTED_MEDIA_TYPE, stack); + } +} diff --git a/src/protocol/errors/validation.ts b/src/protocol/errors/validation.ts new file mode 100644 index 00000000..f2628487 --- /dev/null +++ b/src/protocol/errors/validation.ts @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {BAD_REQUEST} from 'http-status-codes'; +import {ValidationError} from 'jsonschema'; +import {SCError} from '../error'; + +/** + * An error that is returned when the validation of a request fails + */ +export class SCValidationErrorResponse extends SCError { + /** + * List of validatation errors + */ + additionalData: ValidationError[]; + + /** + * Create a SCValidationErrorResponse + * + * @param errors List of validation errors + * @param stack Set to true if a stack trace should be created + */ + constructor(errors: ValidationError[], stack?: boolean) { + super('ValidationError', 'Validation of request failed', BAD_REQUEST, stack); + this.additionalData = errors; + } +} diff --git a/src/core/Route.ts b/src/protocol/route.ts similarity index 69% rename from src/core/Route.ts rename to src/protocol/route.ts index b1f7b997..35f30da5 100644 --- a/src/core/Route.ts +++ b/src/protocol/route.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,29 +12,17 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -/** - * Possible HTTP verbs for routes - */ -import {SCErrorResponse} from './protocol/errors/ErrorResponse'; -import {SCBookAvailabilityRequest} from './protocol/routes/bookAvailability/BookAvailabilityRequest'; -import {SCBookAvailabilityResponse} from './protocol/routes/bookAvailability/BookAvailabilityResponse'; -import {SCBulkRequest} from './protocol/routes/bulk/BulkRequest'; -import {SCBulkResponse} from './protocol/routes/bulk/BulkResponse'; -import {SCBulkAddRequest} from './protocol/routes/bulk/UID/BulkAddRequest'; -import {SCBulkAddResponse} from './protocol/routes/bulk/UID/BulkAddResponse'; -import {SCBulkDoneRequest} from './protocol/routes/bulk/UID/BulkDoneRequest'; -import {SCBulkDoneResponse} from './protocol/routes/bulk/UID/BulkDoneResponse'; -import {SCFeedbackRequest} from './protocol/routes/feedback/FeedbackRequest'; -import {SCFeedbackResponse} from './protocol/routes/feedback/FeedbackResponse'; -import {SCIndexRequest} from './protocol/routes/INDEX/IndexRequest'; -import {SCIndexResponse} from './protocol/routes/INDEX/IndexResponse'; -import {SCMultiSearchRequest} from './protocol/routes/search/MultiSearchRequest'; -import {SCMultiSearchResponse} from './protocol/routes/search/MultiSearchResponse'; -import {SCSearchRequest} from './protocol/routes/search/SearchRequest'; -import {SCSearchResponse} from './protocol/routes/search/SearchResponse'; -import {SCThingUpdateRequest} from './protocol/routes/TYPE/UID/ThingUpdateRequest'; -import {SCThingUpdateResponse} from './protocol/routes/TYPE/UID/ThingUpdateResponse'; -import {SCMap} from './types/Map'; +import {SCMap} from '../general/map'; +import {SCErrorResponse} from './error'; +import {SCIndexRequest, SCIndexResponse} from './routes'; +import {SCBookAvailabilityRequest, SCBookAvailabilityResponse} from './routes/book-availability'; +import {SCBulkAddRequest, SCBulkAddResponse} from './routes/bulk-add'; +import {SCBulkDoneRequest, SCBulkDoneResponse} from './routes/bulk-done'; +import {SCBulkRequest, SCBulkResponse} from './routes/bulk-request'; +import {SCFeedbackRequest, SCFeedbackResponse} from './routes/feedback'; +import {SCSearchRequest, SCSearchResponse} from './routes/search'; +import {SCMultiSearchRequest, SCMultiSearchResponse} from './routes/search-multi'; +import {SCThingUpdateRequest, SCThingUpdateResponse} from './routes/thing-update'; /** * Possible Verbs for HTTP requests diff --git a/src/core/protocol/routes/bookAvailability/BookAvailabilityRequest.ts b/src/protocol/routes/book-availability.ts similarity index 68% rename from src/core/protocol/routes/bookAvailability/BookAvailabilityRequest.ts rename to src/protocol/routes/book-availability.ts index 08116fb3..55f6c15a 100644 --- a/src/core/protocol/routes/bookAvailability/BookAvailabilityRequest.ts +++ b/src/protocol/routes/book-availability.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,21 +13,20 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import {SCUuid} from '../../../types/UUID'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCNotFoundErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCUuid} from '../../general/uuid'; +import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../things/abstract/thing-that-can-be-offered'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCNotFoundErrorResponse} from '../errors/not-found'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Request to check the availability of books - * + * * @validatable */ export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid; @@ -52,6 +51,13 @@ export interface SCBookAvailabilityRequestByUuid { uid: SCUuid; } +/** + * List of availabilities of a book + * + * @validatable + */ +export type SCBookAvailabilityResponse = Array>; + /** * Route for book availability * diff --git a/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts b/src/protocol/routes/bulk-add.ts similarity index 65% rename from src/core/protocol/routes/bulk/UID/BulkAddRequest.ts rename to src/protocol/routes/bulk-add.ts index 74023794..cbd80ca5 100644 --- a/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts +++ b/src/protocol/routes/bulk-add.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,25 +13,31 @@ * this program. If not, see . */ import {CREATED} from 'http-status-codes'; -import {SCThings} from '../../../../Classes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCNotFoundErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../../errors/ErrorResponse'; +import {SCThings} from '../../meta'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCNotFoundErrorResponse} from '../errors/not-found'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Request to add a thing to a bulk - * + * * @validatable */ export type SCBulkAddRequest = SCThings; +/** + * Response to a request to add a thing to a bulk + * + * @validatable + */ +export interface SCBulkAddResponse { +} + /** * Route for indexing SC things in a bulk */ diff --git a/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts b/src/protocol/routes/bulk-done.ts similarity index 66% rename from src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts rename to src/protocol/routes/bulk-done.ts index cba84ac4..56239fe2 100644 --- a/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts +++ b/src/protocol/routes/bulk-done.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,25 +13,31 @@ * this program. If not, see . */ import {NO_CONTENT} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCNotFoundErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../../errors/ErrorResponse'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCNotFoundErrorResponse} from '../errors/not-found'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Request to change the bulk state to done (close the bulk process) - * + * * @validatable */ export interface SCBulkDoneRequest { } +/** + * Response to a request to change the state of a bulk to done + * + * @validatable + */ +export interface SCBulkDoneResponse { +} + /** * Route for closing bulks */ diff --git a/src/core/protocol/routes/bulk/BulkRequest.ts b/src/protocol/routes/bulk-request.ts similarity index 64% rename from src/core/protocol/routes/bulk/BulkRequest.ts rename to src/protocol/routes/bulk-request.ts index ac4429f9..863a6b84 100644 --- a/src/core/protocol/routes/bulk/BulkRequest.ts +++ b/src/protocol/routes/bulk-request.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,17 +13,16 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import {SCThingType} from '../../../Thing'; -import {SCISO8601Date} from '../../../types/Time'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCISO8601Date} from '../../general/time'; +import {SCUuid} from '../../general/uuid'; +import {SCThingType} from '../../things/abstract/thing'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * A bulk request @@ -57,11 +56,31 @@ export interface SCBulkParameters { /** * Type of things that are indexed in this bulk. - * + * */ type: SCThingType; } +/** + * Requested Bulk from backend + * + * @validatable + */ +export interface SCBulkResponse extends SCBulkParameters { + /** + * State of bulk + * + * The state is `in progress` while it accepts things to be added to the bulk. + * The state is `done` once it is closed. + */ + state: 'in progress' | 'done'; + + /** + * Universally unique identifier of the bulk + */ + uid: SCUuid; +} + /** * Route for bulk creation */ diff --git a/src/core/protocol/routes/feedback/FeedbackRequest.ts b/src/protocol/routes/feedback.ts similarity index 74% rename from src/core/protocol/routes/feedback/FeedbackRequest.ts rename to src/protocol/routes/feedback.ts index 76099ee8..5c54a63e 100644 --- a/src/core/protocol/routes/feedback/FeedbackRequest.ts +++ b/src/protocol/routes/feedback.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,16 +13,14 @@ * this program. If not, see . */ import {NO_CONTENT} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import {SCMessage} from '../../../things/Message'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCMessage} from '../../things/message'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * User feedback @@ -36,6 +34,14 @@ export interface SCFeedbackRequest extends SCMessage { metaData: SCFeedbackRequestMetaData; } +/** + * A response to a feedback request + * + * @validatable + */ +export interface SCFeedbackResponse { +} + /** * Route for feedback submission */ diff --git a/src/core/protocol/routes/INDEX/IndexRequest.ts b/src/protocol/routes/index.ts similarity index 59% rename from src/core/protocol/routes/INDEX/IndexRequest.ts rename to src/protocol/routes/index.ts index af71eb04..42f89e10 100644 --- a/src/core/protocol/routes/INDEX/IndexRequest.ts +++ b/src/protocol/routes/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,15 +13,15 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCAppConfiguration} from '../../config/app'; +import {SCBackendConfiguration} from '../../config/backend'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Index request @@ -31,6 +31,23 @@ import { export interface SCIndexRequest { } +/** + * A response to an index request + * + * @validatable + */ +export interface SCIndexResponse { + /** + * @see SCAppConfiguration + */ + app: SCAppConfiguration; + + /** + * @see SCBackendConfiguration + */ + backend: SCBackendConfiguration; +} + /** * Route to request meta information about the deployment */ diff --git a/src/core/protocol/routes/plugin/PluginRegisterRequest.ts b/src/protocol/routes/plugin-register.ts similarity index 76% rename from src/core/protocol/routes/plugin/PluginRegisterRequest.ts rename to src/protocol/routes/plugin-register.ts index bf623fdc..23689085 100644 --- a/src/core/protocol/routes/plugin/PluginRegisterRequest.ts +++ b/src/protocol/routes/plugin-register.ts @@ -14,15 +14,14 @@ */ import {OK} from 'http-status-codes'; import {Schema} from 'jsonschema'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, SCParametersNotAcceptable, - SCPluginAlreadyRegisteredErrorResponse, - SCPluginRegisteringFailedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCParametersNotAcceptable} from '../errors/parameters-not-acceptable'; +import {SCPluginAlreadyRegisteredErrorResponse} from '../errors/plugin-already-registered'; +import {SCPluginRegisteringFailedErrorResponse} from '../errors/plugin-registering-failed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Plugin register request @@ -91,6 +90,18 @@ export interface SCPluginMetaData { route: string; } +/** + * Plugin register response + * + * @validatable + */ +export interface SCPluginRegisterResponse { + /** + * Whether the desired action succeeded or failed (true for success, false if an error occurred) + */ + success: boolean; +} + /** * Route to register plugins */ diff --git a/src/core/protocol/routes/search/MultiSearchRequest.ts b/src/protocol/routes/search-multi.ts similarity index 62% rename from src/core/protocol/routes/search/MultiSearchRequest.ts rename to src/protocol/routes/search-multi.ts index 55dd3a28..71880292 100644 --- a/src/core/protocol/routes/search/MultiSearchRequest.ts +++ b/src/protocol/routes/search-multi.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,18 +13,17 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import {SCMap} from '../../../types/Map'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCTooManyRequestsErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; -import {SCSearchQuery} from './SearchRequest'; +import {SCMap} from '../../general/map'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCTooManyRequestsErrorResponse} from '../errors/too-many-requests'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; +import {SCSearchQuery} from '../search/query'; +import {SCSearchResult} from '../search/result'; /** * A multi search request @@ -37,6 +36,15 @@ import {SCSearchQuery} from './SearchRequest'; */ export type SCMultiSearchRequest = SCMap; +/** + * A multi search response + * + * This is a map of [[SCSearchResponse]]s indexed by name + * + * @validatable + */ +export type SCMultiSearchResponse = SCMap; + /** * Route for submission of multiple search requests at once */ diff --git a/src/core/protocol/routes/search/SearchRequest.ts b/src/protocol/routes/search.ts similarity index 54% rename from src/core/protocol/routes/search/SearchRequest.ts rename to src/protocol/routes/search.ts index fe0713cb..df2ec74b 100644 --- a/src/core/protocol/routes/search/SearchRequest.ts +++ b/src/protocol/routes/search.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,18 +13,15 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; -import {SCSearchContext} from '../../../types/config/Backend'; -import {SCSearchFilter} from '../../../types/filters/Abstract'; -import {SCSearchSort} from '../../../types/sorts/Abstract'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../errors/ErrorResponse'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; +import {SCSearchQuery} from '../search/query'; +import {SCSearchResult} from '../search/result'; /** * A search request @@ -35,38 +32,11 @@ export interface SCSearchRequest extends SCSearchQuery { } /** - * A search query + * A search response + * + * @validatable */ -export interface SCSearchQuery { - /** - * The context name from where the search query was initiated - */ - context?: SCSearchContext; - - /** - * A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT') - */ - filter?: SCSearchFilter; - - /** - * Number of things to skip in result set (paging) - */ - from?: number; - - /** - * A term to search for - */ - query?: string; - - /** - * Number of things to have in the result set (paging) - */ - size?: number; - - /** - * A list of sorting parameters to order the result set by - */ - sort?: SCSearchSort[]; +export interface SCSearchResponse extends SCSearchResult { } /** diff --git a/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts b/src/protocol/routes/thing-update.ts similarity index 66% rename from src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts rename to src/protocol/routes/thing-update.ts index 8886d971..fc83537e 100644 --- a/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts +++ b/src/protocol/routes/thing-update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,17 +13,15 @@ * this program. If not, see . */ import {OK} from 'http-status-codes'; -import {SCThings} from '../../../../Classes'; -import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; -import { - SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, - SCNotFoundErrorResponse, - SCRequestBodyTooLargeErrorResponse, - SCSyntaxErrorResponse, - SCUnsupportedMediaTypeErrorResponse, - SCValidationErrorResponse, -} from '../../../errors/ErrorResponse'; +import {SCThings} from '../../meta'; +import {SCInternalServerErrorResponse} from '../errors/internal-server-error'; +import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed'; +import {SCNotFoundErrorResponse} from '../errors/not-found'; +import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large'; +import {SCSyntaxErrorResponse} from '../errors/syntax-error'; +import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type'; +import {SCValidationErrorResponse} from '../errors/validation'; +import {SCAbstractRoute, SCRouteHttpVerbs} from '../route'; /** * Request to update an existing thing @@ -32,6 +30,14 @@ import { */ export type SCThingUpdateRequest = SCThings; +/** + * Response for an entity update request + * + * @validatable + */ +export interface SCThingUpdateResponse { +} + /** * Route for updating existing things */ diff --git a/src/core/types/GeoInformation.ts b/src/protocol/search/facet.ts similarity index 62% rename from src/core/types/GeoInformation.ts rename to src/protocol/search/facet.ts index 9dfc228a..2da9034b 100644 --- a/src/core/types/GeoInformation.ts +++ b/src/protocol/search/facet.ts @@ -12,19 +12,34 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -// tslint:disable-next-line:no-implicit-dependencies -import {Point, Polygon} from 'geojson'; +import {SCThingsField} from '../../meta'; /** - * Positional information + * A search facet */ -export interface SCGeoInformation { +export interface SCFacet { /** - * Center point of a place + * Buckets for the aggregation */ - point: Point; + buckets: SCFacetBucket[]; + /** - * Shape of a place + * Field of the aggregation */ - polygon?: Polygon; + field: SCThingsField; +} + +/** + * A bucket of a facet + */ +export interface SCFacetBucket { + /** + * Count of matching search results + */ + count: number; + + /** + * Key of a bucket + */ + key: string; } diff --git a/src/core/types/filters/Abstract.ts b/src/protocol/search/filter.ts similarity index 80% rename from src/core/types/filters/Abstract.ts rename to src/protocol/search/filter.ts index e90df0fc..82beb884 100644 --- a/src/core/types/filters/Abstract.ts +++ b/src/protocol/search/filter.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,14 +12,14 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCMap} from '../Map'; +import {SCMap} from '../../general/map'; /** * All available filter types */ -import {SCSearchAvailabilityFilter} from './Availability'; -import {SCSearchBooleanFilter} from './Boolean'; -import {SCSearchDistanceFilter} from './Distance'; -import {SCSearchValueFilter} from './Value'; +import {SCSearchAvailabilityFilter} from './filters/availability'; +import {SCSearchBooleanFilter} from './filters/boolean'; +import {SCSearchDistanceFilter} from './filters/distance'; +import {SCSearchValueFilter} from './filters/value'; /** * Filter instruction types diff --git a/src/core/types/filters/Availability.ts b/src/protocol/search/filters/availability.ts similarity index 90% rename from src/core/types/filters/Availability.ts rename to src/protocol/search/filters/availability.ts index 557538e2..0c5145f8 100644 --- a/src/core/types/filters/Availability.ts +++ b/src/protocol/search/filters/availability.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingsField} from '../../Classes'; -import {SCISO8601Date} from '../Time'; -import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; +import {SCISO8601Date} from '../../../general/time'; +import {SCThingsField} from '../../../meta'; +import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter'; /** * An availability filter diff --git a/src/core/types/filters/Boolean.ts b/src/protocol/search/filters/boolean.ts similarity index 94% rename from src/core/types/filters/Boolean.ts rename to src/protocol/search/filters/boolean.ts index 341201a5..46303449 100644 --- a/src/core/types/filters/Boolean.ts +++ b/src/protocol/search/filters/boolean.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter} from './Abstract'; +import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter} from '../filter'; /** * A boolean filter diff --git a/src/core/types/filters/Distance.ts b/src/protocol/search/filters/distance.ts similarity index 93% rename from src/core/types/filters/Distance.ts rename to src/protocol/search/filters/distance.ts index 6bc32f37..de237aba 100644 --- a/src/core/types/filters/Distance.ts +++ b/src/protocol/search/filters/distance.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -14,8 +14,8 @@ */ // tslint:disable-next-line:no-implicit-dependencies import {Position} from 'geojson'; -import {SCThingsField} from '../../Classes'; -import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; +import {SCThingsField} from '../../../meta'; +import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter'; /** * A distance filter diff --git a/src/core/types/filters/Value.ts b/src/protocol/search/filters/value.ts similarity index 91% rename from src/core/types/filters/Value.ts rename to src/protocol/search/filters/value.ts index 564dabc2..9fae2ca6 100644 --- a/src/core/types/filters/Value.ts +++ b/src/protocol/search/filters/value.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingsField} from '../../Classes'; -import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; +import {SCThingsField} from '../../../meta'; +import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter'; /** * Filters for documents that match the value on the given field diff --git a/src/protocol/search/query.ts b/src/protocol/search/query.ts new file mode 100644 index 00000000..ce30e75f --- /dev/null +++ b/src/protocol/search/query.ts @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {SCSearchContext} from '../../config/backend'; +import {SCSearchFilter} from './filter'; +import {SCSearchSort} from './sort'; + +/** + * A search query + */ +export interface SCSearchQuery { + /** + * The context name from where the search query was initiated + */ + context?: SCSearchContext; + + /** + * A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT') + */ + filter?: SCSearchFilter; + + /** + * Number of things to skip in result set (paging) + */ + from?: number; + + /** + * A term to search for + */ + query?: string; + + /** + * Number of things to have in the result set (paging) + */ + size?: number; + + /** + * A list of sorting parameters to order the result set by + */ + sort?: SCSearchSort[]; +} diff --git a/src/core/protocol/routes/search/SearchResponse.ts b/src/protocol/search/result.ts similarity index 62% rename from src/core/protocol/routes/search/SearchResponse.ts rename to src/protocol/search/result.ts index 8b72e378..2fc6a663 100644 --- a/src/core/protocol/routes/search/SearchResponse.ts +++ b/src/protocol/search/result.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,15 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThings, SCThingsField} from '../../../Classes'; - -/** - * A search response - * - * @validatable - */ -export interface SCSearchResponse extends SCSearchResult { -} +import {SCThings} from '../../meta'; +import {SCFacet} from './facet'; /** * A search response @@ -39,48 +32,18 @@ export interface SCSearchResult { /** * Pagination information */ - pagination: SCSearchResponsePagination; + pagination: SCSearchResultPagination; /** * Stats of the search engine */ - stats: SCSearchResponseSearchEngineStats; -} - -/** - * A search facet - */ -export interface SCFacet { - /** - * Buckets for the aggregation - */ - buckets: SCFacetBucket[]; - - /** - * Field of the aggregation - */ - field: SCThingsField; -} - -/** - * A bucket of a facet - */ -export interface SCFacetBucket { - /** - * Count of matching search results - */ - count: number; - - /** - * Key of a bucket - */ - key: string; + stats: SCSearchResultSearchEngineStats; } /** * Stores information about Pagination */ -export interface SCSearchResponsePagination { +export interface SCSearchResultPagination { /** * Count of given data. Same as data.length */ @@ -100,7 +63,7 @@ export interface SCSearchResponsePagination { /** * Statistics of search engine */ -export interface SCSearchResponseSearchEngineStats { +export interface SCSearchResultSearchEngineStats { /** * Response time of the search engine in ms */ diff --git a/src/core/types/sorts/Abstract.ts b/src/protocol/search/sort.ts similarity index 84% rename from src/core/types/sorts/Abstract.ts rename to src/protocol/search/sort.ts index a12474c6..fadbfe76 100644 --- a/src/core/types/sorts/Abstract.ts +++ b/src/protocol/search/sort.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingsField} from '../../Classes'; -import {SCMap} from '../Map'; -import {SCDistanceSort} from './Distance'; -import {SCDucetSort} from './Ducet'; -import {SCPriceSort} from './Price'; +import {SCMap} from '../../general/map'; +import {SCThingsField} from '../../meta'; +import {SCDistanceSort} from './sorts/distance'; +import {SCDucetSort} from './sorts/ducet'; +import {SCPriceSort} from './sorts/price'; /** * Abstract sort instruction diff --git a/src/core/types/sorts/Distance.ts b/src/protocol/search/sorts/distance.ts similarity index 95% rename from src/core/types/sorts/Distance.ts rename to src/protocol/search/sorts/distance.ts index 0dd7547f..d082e6b8 100644 --- a/src/core/types/sorts/Distance.ts +++ b/src/protocol/search/sorts/distance.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -14,7 +14,7 @@ */ // tslint:disable-next-line:no-implicit-dependencies import {Position} from 'geojson'; -import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; +import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort'; /** * Sort instruction to sort by distance diff --git a/src/core/types/sorts/Ducet.ts b/src/protocol/search/sorts/ducet.ts similarity index 94% rename from src/core/types/sorts/Ducet.ts rename to src/protocol/search/sorts/ducet.ts index ab378901..3f985c73 100644 --- a/src/core/types/sorts/Ducet.ts +++ b/src/protocol/search/sorts/ducet.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; +import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort'; /** * Sort instruction for ducet sort diff --git a/src/core/types/sorts/Price.ts b/src/protocol/search/sorts/price.ts similarity index 90% rename from src/core/types/sorts/Price.ts rename to src/protocol/search/sorts/price.ts index 846b9653..1ba3ae43 100644 --- a/src/core/types/sorts/Price.ts +++ b/src/protocol/search/sorts/price.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCSportCoursePriceGroup} from '../../things/DateSeries'; -import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; +import {SCSportCoursePriceGroup} from '../../../things/date-series'; +import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort'; /** * Sort instruction to sort by price diff --git a/src/core/base/AcademicDegree.ts b/src/things/abstract/academic-degree.ts similarity index 94% rename from src/core/base/AcademicDegree.ts rename to src/things/abstract/academic-degree.ts index ac822e6a..75ca8b3b 100644 --- a/src/core/base/AcademicDegree.ts +++ b/src/things/abstract/academic-degree.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +import {SCMetaTranslations} from '../../general/i18n'; +import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing'; /** * An academic degree without references @@ -28,7 +28,7 @@ export interface SCAcademicDegreeWithoutReferences /** * The achievable academic degree with academic field specification * (eg. Master of Science) - * + * * @keyword */ academicDegreewithField: string; @@ -36,7 +36,7 @@ export interface SCAcademicDegreeWithoutReferences /** * The achievable academic degree with academic field specification * shorted (eg. M.Sc.). - * + * * @keyword */ academicDegreewithFieldShort: string; diff --git a/src/core/base/AcademicTerm.ts b/src/things/abstract/academic-term.ts similarity index 91% rename from src/core/base/AcademicTerm.ts rename to src/things/abstract/academic-term.ts index f2e592ec..d46322d5 100644 --- a/src/core/base/AcademicTerm.ts +++ b/src/things/abstract/academic-term.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; +import {SCMetaTranslations} from '../../general/i18n'; +import {SCISO8601Date} from '../../general/time'; +import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing'; /** * An academic term without references @@ -23,7 +23,7 @@ export interface SCAcademicTermWithoutReferences extends SCThingWithoutReferences { /** * Short name of the academic term, using the given pattern - * + * * @aggregatable * @keyword */ diff --git a/src/core/base/CreativeWork.ts b/src/things/abstract/creative-work.ts similarity index 80% rename from src/core/base/CreativeWork.ts rename to src/things/abstract/creative-work.ts index 5493413a..d0265224 100644 --- a/src/core/base/CreativeWork.ts +++ b/src/things/abstract/creative-work.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,18 +12,18 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing'; -import {SCOrganizationWithoutReferences} from '../things/Organization'; -import {SCPersonWithoutReferences} from '../things/Person'; -import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; +import {SCLanguage, SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCISO8601Date} from '../../general/time'; +import {SCOrganizationWithoutReferences} from '../organization'; +import {SCPersonWithoutReferences} from '../person'; +import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, -} from './ThingThatCanBeOffered'; +} from './thing-that-can-be-offered'; /** * A creative work without references @@ -42,7 +42,7 @@ export interface SCCreativeWorkWithoutReferences /** * Keywords of the creative work - * + * * @aggregatable * @keyword */ @@ -82,7 +82,7 @@ export interface SCCreativeWorkTranslatableProperties extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties { /** * Translation of the keywords of the creative work - * + * * @keyword */ keywords?: string[]; @@ -98,8 +98,8 @@ export class SCCreativeWorkMeta */ fieldTranslations = { de: { - ... SCThingMeta.getInstance().fieldTranslations.de, - ... SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de, + ...SCThingMeta.getInstance().fieldTranslations.de, + ...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de, authors: 'Authoren', datePublished: 'Veröffentlichungsdatum', inLanguages: 'verfügbare Übersetzungen', @@ -107,8 +107,8 @@ export class SCCreativeWorkMeta publishers: 'Verleger', }, en: { - ... SCThingMeta.getInstance().fieldTranslations.en, - ... SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en, + ...SCThingMeta.getInstance().fieldTranslations.en, + ...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en, authors: 'authors', datePublished: 'release date', inLanguages: 'available Languages', @@ -123,11 +123,11 @@ export class SCCreativeWorkMeta fieldValueTranslations = { de: { ...SCThingMeta.getInstance().fieldValueTranslations.de, - ... SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en, + ...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en, }, en: { ...SCThingMeta.getInstance().fieldValueTranslations.en, - ... SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en, + ...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en, }, }; } diff --git a/src/core/base/Event.ts b/src/things/abstract/event.ts similarity index 83% rename from src/core/base/Event.ts rename to src/things/abstract/event.ts index 9a14c555..5e3fd896 100644 --- a/src/core/base/Event.ts +++ b/src/things/abstract/event.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,12 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing'; -import {SCCatalogWithoutReferences} from '../things/Catalog'; -import {SCPersonWithoutReferences} from '../things/Person'; -import {SCSemesterWithoutReferences} from '../things/Semester'; -import {SCMetaTranslations} from '../types/i18n'; -import {SCCreativeWorkWithoutReferences} from './CreativeWork'; +import {SCMetaTranslations} from '../../general/i18n'; +import {SCCatalogWithoutReferences} from '../catalog'; +import {SCPersonWithoutReferences} from '../person'; +import {SCSemesterWithoutReferences} from '../semester'; +import {SCCreativeWorkWithoutReferences} from './creative-work'; +import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing'; /** * An event without references @@ -28,7 +28,7 @@ export interface SCEventWithoutReferences * Maximum number of participants of the event * * A maximum number of people that can participate in the event. - * + * * @integer */ maximumParticipants?: number; @@ -37,7 +37,7 @@ export interface SCEventWithoutReferences * Remaining attendee capacity of the event * * This number represents the remaining open spots. - * + * * @integer */ remainingAttendeeCapacity?: number; @@ -86,7 +86,7 @@ export class SCEventMeta */ fieldTranslations = { de: { - ... SCThingMeta.getInstance().fieldTranslations.de, + ...SCThingMeta.getInstance().fieldTranslations.de, academicTerms: 'Semester', catalogs: 'Verzeichnis', creativeWorks: 'begleitende Werke', @@ -96,7 +96,7 @@ export class SCEventMeta remainingAttendeeCapacity: 'verfügbare Anzahl an Teilnehmern', }, en: { - ... SCThingMeta.getInstance().fieldTranslations.en, + ...SCThingMeta.getInstance().fieldTranslations.en, academicTerms: 'academic terms', catalogs: 'catalogs', creativeWorks: 'related material', diff --git a/src/core/base/Place.ts b/src/things/abstract/place.ts similarity index 66% rename from src/core/base/Place.ts rename to src/things/abstract/place.ts index 4ea8153c..bd6f17c4 100644 --- a/src/core/base/Place.ts +++ b/src/things/abstract/place.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,10 +12,62 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing'; -import {SCGeoInformation} from '../types/GeoInformation'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCPostalAddress} from '../types/PostalAddress'; +// tslint:disable-next-line:no-implicit-dependencies +import {Point, Polygon} from 'geojson'; +import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCBuildingWithoutReferences} from '../building'; +import {SCPointOfInterestWithoutReferences} from '../point-of-interest'; +import {SCRoomWithoutReferences} from '../room'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; + +/** + * Positional information + */ +export interface SCGeoInformation { + /** + * Center point of a place + */ + point: Point; + /** + * Shape of a place + */ + polygon?: Polygon; +} + +/** + * A postal address + */ +export interface SCPostalAddress { + /** + * Country of the address + */ + addressCountry: string; + + /** + * City of the address + */ + addressLocality: string; + + /** + * State of the address + */ + addressRegion?: string; + + /** + * Zip code of the address + */ + postalCode: string; + + /** + * Optional post box number + */ + postOfficeBoxNumber?: string; + + /** + * Street of the address - with house number! + */ + streetAddress: string; +} /** * A place without references @@ -37,7 +89,7 @@ export interface SCPlaceWithoutReferences /** * Opening hours of the place - * + * * @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification * @keyword */ @@ -106,3 +158,19 @@ export class SCPlaceWithoutReferencesMeta }, }; } + +/** + * Something that is or happens in a place + * + * !Important! + * This is not a SCThing. + */ +export interface SCInPlace { + /** + * Place the thing is or happens in + */ + inPlace?: + SCBuildingWithoutReferences + | SCPointOfInterestWithoutReferences + | SCRoomWithoutReferences; +} diff --git a/src/core/base/SaveableThing.ts b/src/things/abstract/saveable-thing.ts similarity index 98% rename from src/core/base/SaveableThing.ts rename to src/things/abstract/saveable-thing.ts index 09735fa0..41c28dbe 100644 --- a/src/core/base/SaveableThing.ts +++ b/src/things/abstract/saveable-thing.ts @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from '../Thing'; +import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing'; /** * An encapsulation of the data (e.g. a thing) that is saved, which provides additional information. diff --git a/src/core/base/ThingInPlace.ts b/src/things/abstract/thing-in-place.ts similarity index 89% rename from src/core/base/ThingInPlace.ts rename to src/things/abstract/thing-in-place.ts index e78549e9..c51d0a85 100644 --- a/src/core/base/ThingInPlace.ts +++ b/src/things/abstract/thing-in-place.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; -import {SCInPlace} from '../types/Places'; +import {SCMetaTranslations} from '../../general/i18n'; +import {SCInPlace} from './place'; +import {SCThing, SCThingMeta} from './thing'; /** * A thing that is or happens in a place diff --git a/src/core/base/ThingThatAcceptsPayments.ts b/src/things/abstract/thing-that-accepts-payments.ts similarity index 83% rename from src/core/base/ThingThatAcceptsPayments.ts rename to src/things/abstract/thing-that-accepts-payments.ts index fca6591c..58f087a4 100644 --- a/src/core/base/ThingThatAcceptsPayments.ts +++ b/src/things/abstract/thing-that-accepts-payments.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +import {SCMetaTranslations} from '../../general/i18n'; +import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing'; /** * Types of payment that are accepted at a place. @@ -52,11 +52,11 @@ export class SCThingThatAcceptsPaymentsWithoutReferencesMeta */ fieldTranslations = { de: { - ... SCThingMeta.getInstance().fieldTranslations.de, + ...SCThingMeta.getInstance().fieldTranslations.de, paymentsAccepted: 'Bezahlmethoden', }, en: { - ... SCThingMeta.getInstance().fieldTranslations.en, + ...SCThingMeta.getInstance().fieldTranslations.en, paymentsAccepted: 'accepted payment methods', }, }; @@ -66,7 +66,7 @@ export class SCThingThatAcceptsPaymentsWithoutReferencesMeta */ fieldValueTranslations = { de: { - ... SCThingMeta.getInstance().fieldValueTranslations.de, + ...SCThingMeta.getInstance().fieldValueTranslations.de, paymentsAccepted: { 'cafeteria card': 'Mensakarte', 'cash': 'Bar', diff --git a/src/core/base/ThingThatCanBeOffered.ts b/src/things/abstract/thing-that-can-be-offered.ts similarity index 82% rename from src/core/base/ThingThatCanBeOffered.ts rename to src/things/abstract/thing-that-can-be-offered.ts index 8836876a..5912db3d 100644 --- a/src/core/base/ThingThatCanBeOffered.ts +++ b/src/things/abstract/thing-that-can-be-offered.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,12 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing'; -import {SCOrganizationWithoutReferences} from '../things/Organization'; -import {SCPersonWithoutReferences} from '../things/Person'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCInPlace} from '../types/Places'; -import {SCISO8601Date} from '../types/Time'; +import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCISO8601Date} from '../../general/time'; +import {SCOrganizationWithoutReferences} from '../organization'; +import {SCPersonWithoutReferences} from '../person'; +import {SCInPlace} from './place'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; /** * Default price without distinction @@ -25,7 +25,7 @@ import {SCISO8601Date} from '../types/Time'; export interface SCPriceGroup { /** * Default price of the thing - * + * * @sortable price * @float */ @@ -39,7 +39,7 @@ export interface SCAcademicPriceGroup extends SCPriceGroup { /** * Price for employees - * + * * @sortable price * @float */ @@ -47,7 +47,7 @@ export interface SCAcademicPriceGroup /** * Price for guests - * + * * @sortable price * @float */ @@ -55,7 +55,7 @@ export interface SCAcademicPriceGroup /** * Price for students - * + * * @sortable price * @float */ @@ -127,7 +127,7 @@ export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties { /** * Availability of an offer - * + * * @keyword */ 'offers[].availability'?: string; @@ -152,8 +152,8 @@ export type SCThingThatCanBeOfferedAvailability = /** * Meta information about a thing without references that accepts payments */ -export class SCThingThatCanBeOfferedMeta implements - SCMetaTranslations> { +export class SCThingThatCanBeOfferedMeta + implements SCMetaTranslations> { /** * Instance @@ -165,11 +165,11 @@ export class SCThingThatCanBeOfferedMeta implements */ fieldTranslations = { de: { - ... SCThingMeta.getInstance().fieldTranslations.de, + ...SCThingMeta.getInstance().fieldTranslations.de, offers: 'Angebote', }, en: { - ... SCThingMeta.getInstance().fieldTranslations.en, + ...SCThingMeta.getInstance().fieldTranslations.en, offers: 'offers', }, }; @@ -177,12 +177,12 @@ export class SCThingThatCanBeOfferedMeta implements /** * Translations of values of fields */ - fieldValueTranslations = { + fieldValueTranslations = { de: { - ... SCThingMeta.getInstance().fieldValueTranslations.de, + ...SCThingMeta.getInstance().fieldValueTranslations.de, }, en: { - ... SCThingMeta.getInstance().fieldValueTranslations.en, + ...SCThingMeta.getInstance().fieldValueTranslations.en, }, }; @@ -196,7 +196,9 @@ export class SCThingThatCanBeOfferedMeta implements } return SCThingThatCanBeOfferedMeta._instance - .get(this.name) as SCThingThatCanBeOfferedMeta; + .get(this.name) as SCThingThatCanBeOfferedMeta; + } + + protected constructor() { } - protected constructor() {} } diff --git a/src/core/base/ThingWithCategories.ts b/src/things/abstract/thing-with-categories.ts similarity index 91% rename from src/core/base/ThingWithCategories.ts rename to src/things/abstract/thing-with-categories.ts index aa97c08a..0b75f3bf 100644 --- a/src/core/base/ThingWithCategories.ts +++ b/src/things/abstract/thing-with-categories.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCMap} from '../types/Map'; +import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCMap} from '../../general/map'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; /** * A thing without references with categories @@ -26,7 +26,7 @@ export interface SCThingWithCategoriesWithoutReferences public static getInstance(): SCThingWithCategoriesWithoutReferencesMeta { if (!SCThingWithCategoriesWithoutReferencesMeta._instance.has(this.name)) { SCThingWithCategoriesWithoutReferencesMeta._instance - .set(this.name, new SCThingWithCategoriesWithoutReferencesMeta()); + .set(this.name, new SCThingWithCategoriesWithoutReferencesMeta()); } return SCThingWithCategoriesWithoutReferencesMeta._instance - .get(this.name) as SCThingWithCategoriesWithoutReferencesMeta; + .get(this.name) as SCThingWithCategoriesWithoutReferencesMeta; } protected constructor() { diff --git a/src/core/Thing.ts b/src/things/abstract/thing.ts similarity index 94% rename from src/core/Thing.ts rename to src/things/abstract/thing.ts index b0045074..26369fdf 100644 --- a/src/core/Thing.ts +++ b/src/things/abstract/thing.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCOrganizationWithoutReferences} from './things/Organization'; -import {SCPersonWithoutReferences} from './things/Person'; -import {SCMetaTranslations, SCTranslations} from './types/i18n'; -import {SCISO8601Date} from './types/Time'; -import {SCUuid} from './types/UUID'; +import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCISO8601Date} from '../../general/time'; +import {SCUuid} from '../../general/uuid'; +import {SCOrganizationWithoutReferences} from '../organization'; +import {SCPersonWithoutReferences} from '../person'; /** * Types a thing can be @@ -54,7 +54,7 @@ export enum SCThingType { export interface SCThingWithoutReferences { /** * Alternate names of the thing - * + * * @keyword */ alternateNames?: string[]; @@ -67,7 +67,7 @@ export interface SCThingWithoutReferences { description?: string; /** * URL of an image of the thing - * + * * @keyword */ image?: string; @@ -87,7 +87,7 @@ export interface SCThingWithoutReferences { translations?: SCTranslations; /** * Type of the thing - * + * * @sortable ducet * @aggregatable */ @@ -153,7 +153,7 @@ export interface SCThingRemoteOrigin extends SCThingOrigin { /** * Name of the origin - * + * * @text */ name: string; @@ -212,13 +212,13 @@ export interface SCThingUserOrigin extends SCThingOrigin { export interface SCThingTranslatableProperties { /** * Translation of the description of the thing - * + * * @text */ description?: string; /** * Translation of the name of the thing - * + * * @text */ name?: string; @@ -234,7 +234,7 @@ export interface SCThingTranslatableProperties { export interface SCThingTranslatablePropertyOrigin { /** * Translation of the name of the origin - * + * * @text */ name: string; diff --git a/src/core/things/AcademicEvent.ts b/src/things/academic-event.ts similarity index 85% rename from src/core/things/AcademicEvent.ts rename to src/things/academic-event.ts index 7644abed..2005400e 100644 --- a/src/core/things/AcademicEvent.ts +++ b/src/things/academic-event.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,16 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; /** * An academic event without references @@ -31,7 +31,7 @@ export interface SCAcademicEventWithoutReferences SCThingWithCategoriesWithoutReferences { /** * Majors of the academic event that this event belongs to - * + * * @aggregatable * @keyword */ @@ -39,7 +39,7 @@ export interface SCAcademicEventWithoutReferences /** * Original unmapped category from the source of the academic event - * + * * @keyword */ originalCategory?: string; @@ -101,14 +101,14 @@ export interface SCAcademicEventTranslatableProperties extends SCThingWithCategoriesTranslatableProperties { /** * Translations of the majors of the academic event that this event belongs to - * + * * @keyword */ majors?: string[]; /** * Translation of the original unmapped category from the source of the academic event - * + * * @keyword */ originalCategory?: string; @@ -126,19 +126,15 @@ export class SCAcademicEventMeta fieldTranslations = { de: { ...SCEventMeta.getInstance().fieldTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCAcademicEventCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, majors: 'Hauptfächer', originalCategory: 'ursprüngliche Kategorie', }, en: { ...SCEventMeta.getInstance().fieldTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCAcademicEventCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, majors: 'majors', originalCategory: 'original category', }, @@ -150,10 +146,8 @@ export class SCAcademicEventMeta fieldValueTranslations = { de: { ...SCEventMeta.getInstance().fieldValueTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCAcademicEventCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'colloquium': 'Kolloquium', 'course': 'Kurs', @@ -174,10 +168,8 @@ export class SCAcademicEventMeta }, en: { ...SCEventMeta.getInstance().fieldValueTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCAcademicEventCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.AcademicEvent, }, }; diff --git a/src/core/things/Article.ts b/src/things/article.ts similarity index 83% rename from src/core/things/Article.ts rename to src/things/article.ts index c71441b4..4839fcd6 100644 --- a/src/core/things/Article.ts +++ b/src/things/article.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,21 +12,21 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; import { SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, -} from '../base/CreativeWork'; +} from './abstract/creative-work'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; /** * An article without references @@ -36,7 +36,7 @@ export interface SCArticleWithoutReferences SCThingWithCategoriesWithoutReferences { /** * Article itself as markdown - * + * * @text */ articleBody: string; @@ -84,7 +84,7 @@ export interface SCArticleTranslatableProperties extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { /** * Translation of the article itself as markdown - * + * * @text */ articleBody?: string[]; @@ -102,19 +102,15 @@ export class SCArticleMeta de: { ...SCCreativeWorkMeta.getInstance().fieldTranslations .de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCArticleCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, articleBody: 'Artikelinhalt', }, en: { ...SCCreativeWorkMeta.getInstance().fieldTranslations .en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCArticleCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, articleBody: 'article body', }, }; @@ -126,10 +122,8 @@ export class SCArticleMeta de: { ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCArticleCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'unipedia': 'Unipedia', }, @@ -138,10 +132,8 @@ export class SCArticleMeta en: { ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCArticleCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Article, }, }; diff --git a/src/core/things/Book.ts b/src/things/book.ts similarity index 88% rename from src/core/things/Book.ts rename to src/things/book.ts index eae5afb4..5c19b4cd 100644 --- a/src/core/things/Book.ts +++ b/src/things/book.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,16 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; import { SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, -} from '../base/CreativeWork'; -import {SCThingWithCategoriesTranslatableProperties} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCPersonWithoutReferences} from './Person'; +} from './abstract/creative-work'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCThingWithCategoriesTranslatableProperties} from './abstract/thing-with-categories'; +import {SCPersonWithoutReferences} from './person'; /** * A book without references @@ -30,21 +30,21 @@ export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences { /** * Edition of a book - * + * * @keyword */ bookEdition?: string; /** * ISBN of a book - * + * * @keyword */ isbn: string; /** * Number of pages of a book - * + * * @integer */ numberOfPages?: number; @@ -91,7 +91,7 @@ export interface SCBookTranslatableFields extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { /** * Translation of an edition of a book - * + * * @keyword */ bookEdition?: string; diff --git a/src/core/things/Building.ts b/src/things/building.ts similarity index 74% rename from src/core/things/Building.ts rename to src/things/building.ts index fdd79ae6..26f188b7 100644 --- a/src/core/things/Building.ts +++ b/src/things/building.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,21 +12,21 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; import { SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta, SCPlaceWithoutReferencesTranslatableProperties, -} from '../base/Place'; +} from './abstract/place'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; export type SCBuildingCategories = 'cafe' @@ -43,7 +43,7 @@ export interface SCBuildingWithoutReferences SCPlaceWithoutReferences { /** * Categories of a building - * + * * @sortable ducet * @aggregatable */ @@ -51,7 +51,7 @@ export interface SCBuildingWithoutReferences /** * List of floor names of the place - * + * * @keyword */ floors?: string[]; @@ -106,23 +106,15 @@ export class SCBuildingMeta */ fieldTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCBuildingCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, floors: 'Etagen', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCBuildingCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, floors: 'floors', }, }; @@ -132,13 +124,9 @@ export class SCBuildingMeta */ fieldValueTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCBuildingCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'cafe': 'Café', 'canteen': 'Kantine', @@ -152,13 +140,9 @@ export class SCBuildingMeta type: 'Gebäude', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCBuildingCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Building, }, }; diff --git a/src/core/things/Catalog.ts b/src/things/catalog.ts similarity index 81% rename from src/core/things/Catalog.ts rename to src/things/catalog.ts index 603308cd..bd0a6d53 100644 --- a/src/core/things/Catalog.ts +++ b/src/things/catalog.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,16 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCAcademicTermWithoutReferences} from './abstract/academic-term'; +import {SCThing, SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThing, SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; /** * A catalog without references @@ -32,7 +32,7 @@ export interface SCCatalogWithoutReferences * Level of the catalog (0 for 'root catalog', 1 for its subcatalog, 2 for its subcatalog etc.) * * Needed for keeping order in catalog inheritance array. - * + * * @integer */ level: number; @@ -46,7 +46,7 @@ export interface SCCatalogWithoutReferences /** * A catalog * - * @validatable + * @validatable * @indexable */ export interface SCCatalog @@ -88,20 +88,16 @@ export class SCCatalogMeta */ fieldTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCCatalogCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, academicTerm: 'Semester', level: 'Ebene', superCatalog: 'übergeordnetes Verzeichniss', superCatalogs: 'übergeordnete Verzeichnisse', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCCatalogCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, academicTerm: 'academic term', level: 'level', superCatalog: 'parent catalog', @@ -114,20 +110,16 @@ export class SCCatalogMeta */ fieldValueTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCCatalogCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'university events': 'Universitätsveranstaltung', }, type: 'Verzeichnis', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCCatalogCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Catalog, }, }; diff --git a/src/core/things/CourseOfStudies.ts b/src/things/course-of-studies.ts similarity index 93% rename from src/core/things/CourseOfStudies.ts rename to src/things/course-of-studies.ts index cb8b26dc..a05bd0e6 100644 --- a/src/core/things/CourseOfStudies.ts +++ b/src/things/course-of-studies.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,18 +12,18 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCAcademicDegree, SCAcademicDegreeMeta, SCAcademicDegreeWithoutReferences} from '../base/AcademicDegree'; +import {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCAcademicDegree, SCAcademicDegreeMeta, SCAcademicDegreeWithoutReferences} from './abstract/academic-degree'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, -} from '../base/ThingThatCanBeOffered'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCDateSeriesWithoutReferences} from './DateSeries'; -import {SCOrganizationWithoutReferences} from './Organization'; +} from './abstract/thing-that-can-be-offered'; +import {SCDateSeriesWithoutReferences} from './date-series'; +import {SCOrganizationWithoutReferences} from './organization'; /** * A course of studies without references @@ -38,7 +38,7 @@ export interface SCCourseOfStudiesWithoutReferences /** * Actual major of the course of studies (eg. physics) - * + * * @keyword */ major: string; diff --git a/src/core/things/DateSeries.ts b/src/things/date-series.ts similarity index 87% rename from src/core/things/DateSeries.ts rename to src/things/date-series.ts index b7c13e04..83c08553 100644 --- a/src/core/things/DateSeries.ts +++ b/src/things/date-series.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,20 +12,20 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCISO8601Date, SCISO8601Duration} from '../general/time'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, + SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, -} from '../base/ThingThatCanBeOffered'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCISO8601Date, SCISO8601Duration} from '../types/Time'; -import {SCThingThatCanBeOfferedMeta} from './../base/ThingThatCanBeOffered'; -import {SCAcademicEventWithoutReferences} from './AcademicEvent'; -import {SCPersonWithoutReferences} from './Person'; -import {SCSportCourseWithoutReferences} from './SportCourse'; +} from './abstract/thing-that-can-be-offered'; +import {SCAcademicEventWithoutReferences} from './academic-event'; +import {SCPersonWithoutReferences} from './person'; +import {SCSportCourseWithoutReferences} from './sport-course'; /** * Price groups for sport courses @@ -34,7 +34,7 @@ export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup { /** * Price for alumnis - * + * * @float */ alumni?: number; @@ -62,7 +62,7 @@ export interface SCDateSeriesWithoutReferences /** * Frequency of the date series - * + * * @keyword */ frequency: string; diff --git a/src/core/things/Diff.ts b/src/things/diff.ts similarity index 92% rename from src/core/things/Diff.ts rename to src/things/diff.ts index a0657cc9..a7ea1bcf 100644 --- a/src/core/things/Diff.ts +++ b/src/things/diff.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,10 +13,10 @@ * this program. If not, see . */ import * as jsonpatch from 'json-patch'; -import {SCThingsWithoutDiff} from '../Classes'; -import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; +import {SCMetaTranslations} from '../general/i18n'; +import {SCISO8601Date} from '../general/time'; +import {SCThingsWithoutDiff} from '../meta'; +import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing'; /** * A diff without references diff --git a/src/core/things/Dish.ts b/src/things/dish.ts similarity index 87% rename from src/core/things/Dish.ts rename to src/things/dish.ts index dfc0d386..5c26de99 100644 --- a/src/core/things/Dish.ts +++ b/src/things/dish.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,22 +12,22 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, + SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, -} from '../base/ThingThatCanBeOffered'; +} from './abstract/thing-that-can-be-offered'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCThingThatCanBeOfferedMeta} from './../base/ThingThatCanBeOffered'; +} from './abstract/thing-with-categories'; /** * A dish without references @@ -37,14 +37,14 @@ export interface SCDishWithoutReferences SCThingWithCategoriesWithoutReferences { /** * Additives of the dish - * + * * @keyword */ additives?: string[]; /** * Category of the dish - * + * * @sortable ducet * @aggregatable */ @@ -110,14 +110,14 @@ export interface SCDishTranslatableProperties export interface SCDishCharacteristic { /** * URL of an image of the characteristic - * + * * @keyword */ image?: string; /** * Name of the characteristic - * + * * @text */ name: string; @@ -142,49 +142,49 @@ export type SCDishCategories = export interface SCNutritionInformation { /** * Number of calories contained (in kcal) - * + * * @float */ calories?: number; /** * Content of carbohydrates (in grams) - * + * * @float */ carbohydrateContent?: number; /** * Content of fat (in grams) - * + * * @float */ fatContent?: number; /** * Content of proteins (in grams) - * + * * @float */ proteinContent?: number; /** * Content of salt (in grams) - * + * * @float */ saltContent?: number; /** * Content of saturated fat (in grams) - * + * * @float */ saturatedFatContent?: number; /** * Content of sugar (in grams) - * + * * @float */ sugarContent?: number; @@ -201,10 +201,8 @@ export class SCDishMeta */ fieldTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCDishCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, ...SCThingThatCanBeOfferedMeta.getInstance() .fieldTranslations.de, additives: 'Zusatzstoffe', @@ -213,10 +211,8 @@ export class SCDishMeta nutrition: 'Nährwertangaben', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCDishCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, ...SCThingThatCanBeOfferedMeta.getInstance() .fieldTranslations.en, additives: 'additives', @@ -231,10 +227,8 @@ export class SCDishMeta */ fieldValueTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCDishCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, ...SCThingThatCanBeOfferedMeta.getInstance() .fieldValueTranslations.de, categories: { @@ -248,10 +242,8 @@ export class SCDishMeta type: 'Essen', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCDishCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, ...SCThingThatCanBeOfferedMeta.getInstance() .fieldValueTranslations.en, type: SCThingType.Dish, diff --git a/src/core/things/Favorite.ts b/src/things/favorite.ts similarity index 70% rename from src/core/things/Favorite.ts rename to src/things/favorite.ts index e4c5ea1a..1f2688be 100644 --- a/src/core/things/Favorite.ts +++ b/src/things/favorite.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,17 +12,17 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCSaveableThing, SCSaveableThingWithoutReferences} from '../base/SaveableThing'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCAcademicEventWithoutReferences} from './AcademicEvent'; -import {SCArticleWithoutReferences} from './Article'; -import {SCBookWithoutReferences} from './Book'; -import {SCBuildingWithoutReferences} from './Building'; -import {SCPersonWithoutReferences} from './Person'; -import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; -import {SCRoomWithoutReferences} from './Room'; -import {SCSportCourseWithoutReferences} from './SportCourse'; -import {SCToDoWithoutReferences} from './ToDo'; +import {SCSaveableThing, SCSaveableThingWithoutReferences} from './abstract/saveable-thing'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCAcademicEventWithoutReferences} from './academic-event'; +import {SCArticleWithoutReferences} from './article'; +import {SCBookWithoutReferences} from './book'; +import {SCBuildingWithoutReferences} from './building'; +import {SCPersonWithoutReferences} from './person'; +import {SCPointOfInterestWithoutReferences} from './point-of-interest'; +import {SCRoomWithoutReferences} from './room'; +import {SCSportCourseWithoutReferences} from './sport-course'; +import {SCToDoWithoutReferences} from './todo'; /** * Types that can be made a favorite (added as a favorite) diff --git a/src/core/things/Floor.ts b/src/things/floor.ts similarity index 90% rename from src/core/things/Floor.ts rename to src/things/floor.ts index d388626a..cc2050a6 100644 --- a/src/core/things/Floor.ts +++ b/src/things/floor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -14,11 +14,11 @@ */ // tslint:disable-next-line:no-implicit-dependencies import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson'; -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; -import {SCThingMeta, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; -import {SCRoomWithoutReferences} from './Room'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCThingMeta, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; +import {SCPointOfInterestWithoutReferences} from './point-of-interest'; +import {SCRoomWithoutReferences} from './room'; /** * A floor without references @@ -27,7 +27,7 @@ export interface SCFloorWithoutReferences extends SCThingWithoutReferences { /** * Floor name in the place it is in e.g. "first floor", "ground floor". This doesn't reference the building name. - * + * * @text */ floorName: string; @@ -96,7 +96,7 @@ export interface SCFloorTranslatableProperties extends SCThingTranslatableProperties { /** * Translation of the floor name - * + * * @text */ floorName?: string; diff --git a/src/core/things/Message.ts b/src/things/message.ts similarity index 89% rename from src/core/things/Message.ts rename to src/things/message.ts index 8ede249b..decc4d81 100644 --- a/src/core/things/Message.ts +++ b/src/things/message.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,16 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCISO8601Date} from '../general/time'; import { SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, -} from '../base/CreativeWork'; -import {SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; +} from './abstract/creative-work'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered'; /** * A message without references @@ -40,7 +40,7 @@ export interface SCMessageWithoutReferences /** * Message itself - * + * * @text */ messageBody: string; @@ -90,7 +90,7 @@ export interface SCMessageTranslatableProperties extends SCCreativeWorkTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties { /** * Message itself - * + * * @text */ messageBody?: string; diff --git a/src/core/things/Organization.ts b/src/things/organization.ts similarity index 91% rename from src/core/things/Organization.ts rename to src/things/organization.ts index 05d484ca..d1718a51 100644 --- a/src/core/things/Organization.ts +++ b/src/things/organization.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; -import {SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +import {SCMetaTranslations} from '../general/i18n'; +import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; /** * An organization without references diff --git a/src/core/things/Person.ts b/src/things/person.ts similarity index 91% rename from src/core/things/Person.ts rename to src/things/person.ts index 736bbafe..c6076214 100644 --- a/src/core/things/Person.ts +++ b/src/things/person.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,13 +12,13 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations, SCNationality} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; -import {SCBuildingWithoutReferences} from './Building'; -import {SCOrganizationWithoutReferences} from './Organization'; -import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; -import {SCRoomWithoutReferences} from './Room'; +import {SCMetaTranslations, SCNationality} from '../general/i18n'; +import {SCISO8601Date} from '../general/time'; +import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing'; +import {SCBuildingWithoutReferences} from './building'; +import {SCOrganizationWithoutReferences} from './organization'; +import {SCPointOfInterestWithoutReferences} from './point-of-interest'; +import {SCRoomWithoutReferences} from './room'; /** * A person without references @@ -27,7 +27,7 @@ export interface SCPersonWithoutReferences extends SCThingWithoutReferences { /** * Additional first names of the person. - * + * * @keyword */ additionalName?: string; @@ -41,21 +41,21 @@ export interface SCPersonWithoutReferences * The private email address of the person. * * @TJS-format email - * + * * @keyword */ email?: string; /** * The family name of the person. - * + * * @keyword */ familyName: string; /** * The private fax number of the person. - * + * * @keyword */ faxNumber?: string; @@ -67,35 +67,35 @@ export interface SCPersonWithoutReferences /** * The first name of the person. - * + * * @keyword */ givenName: string; /** * Honorific prefix of the person. - * + * * @keyword */ honorificPrefix?: string; /** * Honorific suffix of the person. - * + * * @keyword */ honorificSuffix?: string; /** * Titles of jobs that the person has. - * + * * @keyword */ jobTitles?: string[]; /** * The complete name of the person combining all the parts of the name into one. - * + * * @text */ name: string; @@ -107,7 +107,7 @@ export interface SCPersonWithoutReferences /** * The private telephone number of the person. - * + * * @keyword */ telephone?: string; @@ -231,35 +231,35 @@ export interface SCContactPoint { /** * E-mail at the work location - * + * * @keyword */ email?: string; /** * Fax number at the work location - * + * * @keyword */ faxNumber?: string; /** * Times available for contacting at the work location - * + * * @keyword */ hoursAvailable?: string; /** * Contact number at the work location - * + * * @keyword */ telephone?: string; /** * URL at the work location - * + * * @keyword */ url?: string; diff --git a/src/core/things/PointOfInterest.ts b/src/things/point-of-interest.ts similarity index 71% rename from src/core/things/PointOfInterest.ts rename to src/things/point-of-interest.ts index fdaccb35..6cdddfeb 100644 --- a/src/core/things/PointOfInterest.ts +++ b/src/things/point-of-interest.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,17 +12,17 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place'; -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; /** * A point of interest without references @@ -82,24 +82,16 @@ export class SCPointOfInterestMeta */ fieldTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCPointOfInterestCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.de, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, ...SCThingInPlaceMeta.getInstance().fieldTranslations .de, }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCPointOfInterestCategories, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, ...SCThingInPlaceMeta.getInstance().fieldTranslations .en, }, @@ -110,13 +102,9 @@ export class SCPointOfInterestMeta */ fieldValueTranslations = { de: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCPointOfInterestCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.de, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'card charger': 'Kartenaufwerter', 'computer': 'Computer', @@ -127,13 +115,9 @@ export class SCPointOfInterestMeta type: 'Sonderziel', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCPointOfInterestCategories, - SCThingWithCategoriesSpecificValues - >().fieldValueTranslations.en, - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.PointOfInterest, }, }; diff --git a/src/core/things/Room.ts b/src/things/room.ts similarity index 73% rename from src/core/things/Room.ts rename to src/things/room.ts index 4de2461a..9953cc25 100644 --- a/src/core/things/Room.ts +++ b/src/things/room.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,24 +12,24 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place'; -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCMap} from '../general/map'; +import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place'; + +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; import { SCThingThatAcceptsPayments, SCThingThatAcceptsPaymentsWithoutReferences, SCThingThatAcceptsPaymentsWithoutReferencesMeta, -} from '../base/ThingThatAcceptsPayments'; +} from './abstract/thing-that-accepts-payments'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; - -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCMap} from '../types/Map'; +} from './abstract/thing-with-categories'; /** * Categories of a room @@ -57,7 +57,7 @@ export interface SCRoomWithoutReferences SCThingWithCategoriesWithoutReferences { /** * The name of the floor in which the room is in. - * + * * @text */ floorName?: string; @@ -109,7 +109,7 @@ export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValues { /** * Category specific opening hours of the room - * + * * @keyword */ openingHours?: string; @@ -126,32 +126,22 @@ export class SCRoomMeta */ fieldTranslations = { de: { - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.de, - ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance< - SCThingThatAcceptsPaymentsWithoutReferencesMeta - >().fieldTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCRoomCategories, - SCRoomSpecificValues - >().fieldTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, + ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance() + .fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, ...SCThingInPlaceMeta.getInstance().fieldTranslations .de, floorName: 'Etagenbezeichnung', inventory: 'Bestand', }, en: { - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldTranslations.en, - ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance< - SCThingThatAcceptsPaymentsWithoutReferencesMeta - >().fieldTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCRoomCategories, - SCRoomSpecificValues - >().fieldTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, + ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance() + .fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, ...SCThingInPlaceMeta.getInstance().fieldTranslations .en, floorName: 'floor name', @@ -164,16 +154,11 @@ export class SCRoomMeta */ fieldValueTranslations = { de: { - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.de, - ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance< - SCThingThatAcceptsPaymentsWithoutReferencesMeta - >().fieldValueTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCRoomCategories, - SCRoomSpecificValues - >().fieldValueTranslations.de, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance() + .fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, ...SCThingInPlaceMeta.getInstance() .fieldValueTranslations.de, categories: { @@ -194,16 +179,11 @@ export class SCRoomMeta type: 'Raum', }, en: { - ...SCPlaceWithoutReferencesMeta.getInstance< - SCPlaceWithoutReferencesMeta - >().fieldValueTranslations.en, - ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance< - SCThingThatAcceptsPaymentsWithoutReferencesMeta - >().fieldValueTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - SCRoomCategories, - SCRoomSpecificValues - >().fieldValueTranslations.en, + ...SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance() + .fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, ...SCThingInPlaceMeta.getInstance() .fieldValueTranslations.en, type: SCThingType.Room, diff --git a/src/core/things/Semester.ts b/src/things/semester.ts similarity index 73% rename from src/core/things/Semester.ts rename to src/things/semester.ts index ca12aef3..9545c5e3 100644 --- a/src/core/things/Semester.ts +++ b/src/things/semester.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,13 +12,13 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations} from '../general/i18n'; import { SCAcademicTerm, SCAcademicTermWithoutReferences, SCAcademicTermWithoutReferencesMeta, -} from '../base/AcademicTerm'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +} from './abstract/academic-term'; +import {SCThingMeta, SCThingType} from './abstract/thing'; /** * A semester without references @@ -64,9 +64,7 @@ export class SCSemesterMeta */ fieldTranslations = { de: { - ...SCAcademicTermWithoutReferencesMeta.getInstance< - SCAcademicTermWithoutReferencesMeta - >().fieldTranslations.de, + ...SCAcademicTermWithoutReferencesMeta.getInstance().fieldTranslations.de, acronym: 'Abkürzung', endDate: 'Ende', eventsEndDate: 'Vorlesungsschluss', @@ -74,9 +72,7 @@ export class SCSemesterMeta startDate: 'Beginn', }, en: { - ...SCAcademicTermWithoutReferencesMeta.getInstance< - SCAcademicTermWithoutReferencesMeta - >().fieldTranslations.en, + ...SCAcademicTermWithoutReferencesMeta.getInstance().fieldTranslations.en, acronym: 'acronym', endDate: 'end date', eventsEndDate: 'semester ending', @@ -90,15 +86,13 @@ export class SCSemesterMeta */ fieldValueTranslations = { de: { - ...SCAcademicTermWithoutReferencesMeta.getInstance< - SCAcademicTermWithoutReferencesMeta - >().fieldValueTranslations.de, + ...SCAcademicTermWithoutReferencesMeta.getInstance() + .fieldValueTranslations.de, type: 'Semester', }, en: { - ...SCAcademicTermWithoutReferencesMeta.getInstance< - SCAcademicTermWithoutReferencesMeta - >().fieldValueTranslations.en, + ...SCAcademicTermWithoutReferencesMeta.getInstance() + .fieldValueTranslations.en, type: SCThingType.Semester, }, }; diff --git a/src/core/things/Setting.ts b/src/things/setting.ts similarity index 86% rename from src/core/things/Setting.ts rename to src/things/setting.ts index b1e3b2e6..b45e2ac8 100644 --- a/src/core/things/Setting.ts +++ b/src/things/setting.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,15 +12,15 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCThing, SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThing, SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; +} from './abstract/thing-with-categories'; /** * A setting without references @@ -41,7 +41,7 @@ export interface SCSettingWithoutReferences inputType: SCSettingInputType; /** * The order number this setting should show up in its category list - * + * * @integer */ order: number; @@ -118,7 +118,7 @@ export type SCSettingValues = SCSettingValue[]; export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties { /** * The translations of the possible values of a setting - * + * * @keyword */ values?: string[]; @@ -133,10 +133,8 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, defaultValue: 'Standard Wert', inputType: 'Eingabetyp', order: 'Position', @@ -144,10 +142,8 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, defaultValue: 'default value', inputType: 'input type', order: 'position', @@ -161,10 +157,8 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { credentials: 'Anmeldedaten', others: 'Andere', @@ -181,10 +175,8 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Setting, }, }; diff --git a/src/core/things/SportCourse.ts b/src/things/sport-course.ts similarity index 88% rename from src/core/things/SportCourse.ts rename to src/things/sport-course.ts index 2f0efce8..471072ee 100644 --- a/src/core/things/SportCourse.ts +++ b/src/things/sport-course.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +import {SCMetaTranslations} from '../general/i18n'; +import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event'; +import {SCThingMeta, SCThingType} from './abstract/thing'; /** * A sport course without references diff --git a/src/core/things/StudyModule.ts b/src/things/study-module.ts similarity index 92% rename from src/core/things/StudyModule.ts rename to src/things/study-module.ts index 7c6ef9eb..2a272a99 100644 --- a/src/core/things/StudyModule.ts +++ b/src/things/study-module.ts @@ -12,19 +12,19 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCMap} from '../general/map'; +import {SCThingMeta, SCThingType} from './abstract/thing'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, + SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, -} from '../base/ThingThatCanBeOffered'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCMap} from '../types/Map'; -import {SCThingThatCanBeOfferedMeta} from './../base/ThingThatCanBeOffered'; -import {SCAcademicEventWithoutReferences} from './AcademicEvent'; -import {SCOrganizationWithoutReferences} from './Organization'; -import {SCPersonWithoutReferences} from './Person'; +} from './abstract/thing-that-can-be-offered'; +import {SCAcademicEventWithoutReferences} from './academic-event'; +import {SCOrganizationWithoutReferences} from './organization'; +import {SCPersonWithoutReferences} from './person'; /** * A study module without references @@ -34,7 +34,7 @@ export interface SCStudyModuleWithoutReferences /** * ECTS points (European Credit Transfer System) - * + * * @float */ ects: number; @@ -46,7 +46,7 @@ export interface SCStudyModuleWithoutReferences /** * Majors that this study module is meant for - * + * * @keyword */ majors: string[]; @@ -116,7 +116,7 @@ export interface SCStudyModuleTranslatableProperties extends SCThingThatCanBeOfferedTranslatableProperties { /** * Translations of the majors that this study module is meant for - * + * * @keyword */ majors?: string[]; diff --git a/src/core/things/Ticket.ts b/src/things/ticket.ts similarity index 90% rename from src/core/things/Ticket.ts rename to src/things/ticket.ts index c34d11a6..a2a60b2c 100644 --- a/src/core/things/Ticket.ts +++ b/src/things/ticket.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,10 +12,10 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; -import {SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; -import {SCISO8601Duration} from '../types/Time'; +import {SCMetaTranslations} from '../general/i18n'; +import {SCISO8601Duration} from '../general/time'; +import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing'; +import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place'; /** * A ticket without references @@ -29,7 +29,7 @@ export interface SCTicketWithoutReferences /** * Waiting number of the ticket - * + * * @keyword */ currentTicketNumber: string; diff --git a/src/core/things/ToDo.ts b/src/things/todo.ts similarity index 87% rename from src/core/things/ToDo.ts rename to src/things/todo.ts index 9aab87be..0bd981b5 100644 --- a/src/core/things/ToDo.ts +++ b/src/things/todo.ts @@ -12,16 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCISO8601Date} from '../general/time'; +import {SCThing, SCThingMeta, SCThingType} from './abstract/thing'; import { SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, -} from '../base/ThingWithCategories'; -import {SCThing, SCThingMeta, SCThingType} from '../Thing'; -import {SCMetaTranslations, SCTranslations} from '../types/i18n'; -import {SCISO8601Date} from '../types/Time'; +} from './abstract/thing-with-categories'; /** * A "to do" without references @@ -86,19 +86,15 @@ export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, done: 'Erledigt', dueDate: 'Fälligkeitsdatum', priority: 'Priorität', }, en: { - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance< - string, - SCThingWithCategoriesSpecificValues - >().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, done: 'done', dueDate: 'due date', priority: 'priority', diff --git a/src/core/things/Tour.ts b/src/things/tour.ts similarity index 96% rename from src/core/things/Tour.ts rename to src/things/tour.ts index 100fcd1b..adbd71b4 100644 --- a/src/core/things/Tour.ts +++ b/src/things/tour.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing'; -import {SCMetaTranslations} from '../types/i18n'; +import {SCMetaTranslations} from '../general/i18n'; +import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing'; /** * A tour without references @@ -22,21 +22,21 @@ export interface SCTourWithoutReferences extends SCThingWithoutReferences { /** * Init script for the tour - * + * * @text */ init?: string; /** * Steps of a tour - * + * * @keyword */ steps: SCTourStep[]; /** * Type of a tour - * + * * @keyword */ type: SCThingType.Tour; @@ -107,7 +107,7 @@ export type SCTourStep = export interface SCTourStepLocation { /** * Location to go to - * + * * @keyword */ location: string; @@ -129,7 +129,7 @@ export interface SCTourStepTooltip { /** * Element that the tooltip shall be pointing at or a list of elements to try in the specified order - * + * * @keyword */ element: string | string[]; @@ -146,14 +146,14 @@ export interface SCTourStepTooltip { /** * Text that the tooltip shall contain - * + * * @text */ text: string; /** * How often it shall be retried - * + * * @integer */ tries?: number; @@ -190,7 +190,7 @@ export interface SCTourStepMenu { export interface SCTourResolvedElement { /** * Element name - * + * * @keyword */ element: string; @@ -202,7 +202,7 @@ export interface SCTourResolvedElement { export interface SCTourResolvedEvent { /** * Event name - * + * * @keyword */ event: string; @@ -224,7 +224,7 @@ export interface SCTourResolvedLocation { export interface SCTourResolvedLocationTypeIs { /** * Specific location name - * + * * @keyword */ is: string; @@ -236,7 +236,7 @@ export interface SCTourResolvedLocationTypeIs { export interface SCTourResolvedLocationTypeMatch { /** * Regex location name - * + * * @keyword */ match: string; diff --git a/src/core/things/Video.ts b/src/things/video.ts similarity index 91% rename from src/core/things/Video.ts rename to src/things/video.ts index 4631a506..5140e537 100644 --- a/src/core/things/Video.ts +++ b/src/things/video.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018, 2019 StApps + * Copyright (C) 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkWithoutReferences} from '../base/CreativeWork'; -import {SCThingMeta, SCThingType} from '../Thing'; -import {SCLanguage, SCMetaTranslations} from '../types/i18n'; -import {SCISO8601Duration} from '../types/Time'; -import {SCPersonWithoutReferences} from './Person'; +import {SCLanguage, SCMetaTranslations} from '../general/i18n'; +import {SCISO8601Duration} from '../general/time'; +import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkWithoutReferences} from './abstract/creative-work'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import {SCPersonWithoutReferences} from './person'; /** * A video without references @@ -35,7 +35,7 @@ export interface SCVideoWithoutReferences /** * URLs to a thumbnails for the Video - * + * * @keyword */ thumbnails?: string[]; @@ -47,7 +47,7 @@ export interface SCVideoWithoutReferences /** * A Transcript of the Video - * + * * @text */ transcript?: string; @@ -61,7 +61,7 @@ export interface SCVideoWithoutReferences export interface SCVideoSource { /** * Pixel Height of the Video - * + * * @integer */ height?: number; @@ -73,21 +73,21 @@ export interface SCVideoSource { /** * Size of the Video File in bytes - * + * * @integer */ size?: number; /** * URL to the Video File - * + * * @keyword */ url: string; /** * Pixel Width of the Video - * + * * @integer */ width?: number; @@ -106,7 +106,7 @@ export interface SCVideoTrack { /** * URL to the Track File - * + * * @keyword */ url: string; diff --git a/src/core/Translator.ts b/src/translator.ts similarity index 88% rename from src/core/Translator.ts rename to src/translator.ts index 4340a4cc..b810a0cd 100644 --- a/src/core/Translator.ts +++ b/src/translator.ts @@ -12,14 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCClasses} from './Classes'; -import {SCThing, SCThingType} from './Thing'; - -import {isThing} from './types/Guards'; -import {SCTranslations} from './types/i18n'; - import clone = require('fast-clone'); import {Defined, OCType} from 'ts-optchain'; +import {SCTranslations} from './general/i18n'; +import {isThing} from './guards'; +import {SCClasses} from './meta'; +import {SCThing, SCThingType} from './things/abstract/thing'; // tslint:disable:no-any const standardCacheSize = 200; @@ -33,7 +31,6 @@ export class SCThingTranslator { * Property representing the translators target language */ private _language: keyof SCTranslations; - /** * Property representing the translators base language * This means every translation is given for this language @@ -45,7 +42,7 @@ export class SCThingTranslator { */ private readonly metaClasses: typeof SCClasses; - /** + /** * @example * // returns translator instance for german * new SCThingTranslator('de'); @@ -115,17 +112,17 @@ export class SCThingTranslator { // Assigns every property in fieldTranslations to the known base language translation if (typeof metaClass.fieldTranslations.en !== 'undefined') { Object.keys(metaClass.fieldTranslations.en) - .forEach((key) => { - (fieldTranslations as any)[key] = metaClass.fieldTranslations.en[key]; - }); + .forEach((key) => { + (fieldTranslations as any)[key] = metaClass.fieldTranslations.en[key]; + }); } // Assigns every property in fieldTranslations to the known translation in given language if (typeof metaClass.fieldTranslations[language] !== 'undefined') { Object.keys(metaClass.fieldTranslations[language]) - .forEach((key) => { - (fieldTranslations as any)[key] = metaClass.fieldTranslations[language][key]; - }); + .forEach((key) => { + (fieldTranslations as any)[key] = metaClass.fieldTranslations[language][key]; + }); } return fieldTranslations; @@ -161,19 +158,19 @@ export class SCThingTranslator { } if (typeof metaClass.fieldValueTranslations[language] !== 'undefined') { Object.keys(metaClass.fieldValueTranslations[language]) - .forEach((key) => { - if (metaClass.fieldValueTranslations[language][key] instanceof Object) { - // Assigns known translations of subproperties to property in given language (e.g. categories) - Object.keys((instance as any)[key]) - .forEach((subKey) => { - (instance as any)[key][subKey] = - metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]]; - }); - } else { - // Assigns property to known translation of fieldValueTranslations in given language - (instance as any)[key] = metaClass.fieldValueTranslations[language][key]; - } - }); + .forEach((key) => { + if (metaClass.fieldValueTranslations[language][key] instanceof Object) { + // Assigns known translations of subproperties to property in given language (e.g. categories) + Object.keys((instance as any)[key]) + .forEach((subKey) => { + (instance as any)[key][subKey] = + metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]]; + }); + } else { + // Assigns property to known translation of fieldValueTranslations in given language + (instance as any)[key] = metaClass.fieldValueTranslations[language][key]; + } + }); } return instance; @@ -241,14 +238,14 @@ export class SCThingTranslator { let nextInstance = instance; // Recursively call this function on all nested SCThings, arrays and objects Object.keys(nextInstance) - .forEach((key) => { - if ( - isThing((nextInstance as any)[key]) || - nextInstance[key] instanceof Array || - nextInstance[key] instanceof Object) { + .forEach((key) => { + if ( + isThing((nextInstance as any)[key]) || + nextInstance[key] instanceof Array || + nextInstance[key] instanceof Object) { nextInstance[key] = this.translateWholeThingDestructively(nextInstance[key], targetLanguage); - } - }); + } + }); // Spread variable translations given by the connector into thing if (typeof nextInstance.translations !== 'undefined') { @@ -265,7 +262,7 @@ export class SCThingTranslator { } /** - * LRUCache class + * LRUCache class * Small last recently used cache intended to get used by SCThingTranslator */ class LRUCache { @@ -279,7 +276,7 @@ class LRUCache { */ private readonly maxEntries: number; - /** + /** * @example * // returns LRUCache instance with a maximum capacity of 500 * new LRUCache(500); @@ -308,7 +305,7 @@ class LRUCache { /** * Get content from cache by key or by another objects uid * - * @param somethingOrKey The key which maps to the cached content or an object for which content has been cached + * @param somethingOrKey The key which maps to the cached content or an object for which content has been cached * @returns If available the content connected to the key or somethingOrKey.uid property */ public get(somethingOrKey: string | U): T | undefined { @@ -341,7 +338,7 @@ class LRUCache { if (this.entries.size >= this.maxEntries) { // LRU behavior const keyToDelete = this.entries.keys() - .next().value; + .next().value; this.entries.delete(keyToDelete); } this.entries.set(key, content); @@ -349,10 +346,10 @@ class LRUCache { /** * Place content in cache by another objects uid - * + * * @param something The object that should be cached under something.uid */ public putObject(something: U) { - this.put(something.uid, (something as any) as T); + this.put(something.uid, (something as any) as T); } } diff --git a/test/Guards.spec.ts b/test/guards.spec.ts similarity index 90% rename from test/Guards.spec.ts rename to test/guards.spec.ts index 90df6e9f..13cbb67c 100644 --- a/test/Guards.spec.ts +++ b/test/guards.spec.ts @@ -14,18 +14,18 @@ */ import {expect} from 'chai'; import {slow, suite, test, timeout} from 'mocha-typescript'; -import {SCBulkResponse} from '../src/core/protocol/routes/bulk/BulkResponse'; -import {SCMultiSearchResponse} from '../src/core/protocol/routes/search/MultiSearchResponse'; -import {SCSearchResponse} from '../src/core/protocol/routes/search/SearchResponse'; -import {SCThingOriginType, SCThingType} from '../src/core/Thing'; -import {SCDish} from '../src/core/things/Dish'; +import {SCBulkResponse} from '../src/protocol/routes/bulk-request'; +import {SCMultiSearchResponse} from '../src/protocol/routes/search-multi'; +import {SCSearchResponse} from '../src/protocol/routes/search'; +import {SCThingOriginType, SCThingType} from '../src/things/abstract/thing'; +import {SCDish} from '../src/things/dish'; import { isBulkResponse, isMultiSearchResponse, isSearchResponse, isThing, isThingWithTranslations, -} from '../src/core/types/Guards'; +} from '../src/guards'; @suite(timeout(10000), slow(5000)) export class GuardsSpec { diff --git a/test/Routes.spec.ts b/test/routes.spec.ts similarity index 89% rename from test/Routes.spec.ts rename to test/routes.spec.ts index d5cdd929..abc114f9 100644 --- a/test/Routes.spec.ts +++ b/test/routes.spec.ts @@ -14,9 +14,9 @@ */ import {expect} from 'chai'; import {slow, suite, test, timeout} from 'mocha-typescript'; -import {SCBulkRoute} from '../src/core/protocol/routes/bulk/BulkRequest'; -import {SCBulkAddRoute} from '../src/core/protocol/routes/bulk/UID/BulkAddRequest'; -import {SCThingUpdateRoute} from '../src/core/protocol/routes/TYPE/UID/ThingUpdateRequest'; +import {SCBulkRoute} from '../src/protocol/routes/bulk-request'; +import {SCBulkAddRoute} from '../src/protocol/routes/bulk-add'; +import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update'; @suite(timeout(10000), slow(5000)) export class RoutesSpec { diff --git a/test/Schema.spec.ts b/test/schema.spec.ts similarity index 100% rename from test/Schema.spec.ts rename to test/schema.spec.ts diff --git a/test/Translator.spec.ts b/test/translator.spec.ts similarity index 90% rename from test/Translator.spec.ts rename to test/translator.spec.ts index 9a34698f..f42935f5 100644 --- a/test/Translator.spec.ts +++ b/test/translator.spec.ts @@ -15,15 +15,14 @@ import {expect} from 'chai'; import clone = require('fast-clone'); import {slow, suite, test, timeout} from 'mocha-typescript'; - -import {SCThingOriginType, SCThingType} from '../src/core/Thing'; -import {SCBuildingWithoutReferences} from '../src/core/things/Building'; -import {SCDish, SCDishMeta} from '../src/core/things/Dish'; -import {SCThingTranslator} from '../src/core/Translator'; +import {SCThingOriginType, SCThingType} from '../src/things/abstract/thing'; +import {SCBuildingWithoutReferences} from '../src/things/building'; +import {SCDish, SCDishMeta} from '../src/things/dish'; +import {SCThingTranslator} from '../src/translator'; const building: SCBuildingWithoutReferences = { address: { - addressCountry : 'base-address.addressCountry', + addressCountry: 'base-address.addressCountry', addressLocality: 'base-address.addressLocality', postalCode: 'base-address.postalCode', streetAddress: 'base-address.streetAddress', @@ -40,7 +39,7 @@ const building: SCBuildingWithoutReferences = { translations: { de: { address: { - addressCountry : 'de-address.addressCountry', + addressCountry: 'de-address.addressCountry', addressLocality: 'de-address.addressLocality', postalCode: 'de-address.postalCode', streetAddress: 'de-address.streetAddress', @@ -60,15 +59,15 @@ const dish: SCDish = { name: 'base-dish-name', offers: [ { - availability: 'in stock', - inPlace: building, - prices: { - default: 23.42, - }, - provider: { - name: 'base-provider', - type: SCThingType.Organization, - uid: '540862f3-ea30-5b8f-8678-56b4dc217141', + availability: 'in stock', + inPlace: building, + prices: { + default: 23.42, + }, + provider: { + name: 'base-provider', + type: SCThingType.Organization, + uid: '540862f3-ea30-5b8f-8678-56b4dc217141', }, }, ], @@ -110,7 +109,7 @@ export class TranslationSpecInplace { @test public directArrayOfString() { expect(translator.translate(dish).characteristics()).to.deep - .equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]); + .equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]); } @test @@ -161,7 +160,7 @@ export class TranslationSpecInplace { @test public directArrayOfStringSubscriptFallback() { expect(translatorWithFallback.translate(dish).characteristics[1]()) - .to.deep.equal({name: 'base-characteristic1'}); + .to.deep.equal({name: 'base-characteristic1'}); } @test @@ -187,7 +186,7 @@ export class TranslationSpecInplace { @test public nestedMetaArrayOfStringFallback() { expect(translatorWithFallback.translate(dish).offers[0].inPlace.categories()) - .to.deep.equal(['office', 'education']); + .to.deep.equal(['office', 'education']); } @test diff --git a/test/Type.spec.ts b/test/type.spec.ts similarity index 85% rename from test/Type.spec.ts rename to test/type.spec.ts index 972ab96f..97d381e5 100644 --- a/test/Type.spec.ts +++ b/test/type.spec.ts @@ -1,29 +1,46 @@ +/* + * Copyright (C) 2019 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ import {assert, Has, IsAny, IsNever, NotHas} from 'conditional-type-checks'; -import {SCThing, SCThingWithoutReferences} from '../src/core/Thing'; -import {SCAcademicEvent, SCAcademicEventWithoutReferences} from '../src/core/things/AcademicEvent'; -import {SCArticle, SCArticleWithoutReferences} from '../src/core/things/Article'; -import {SCBook, SCBookWithoutReferences} from '../src/core/things/Book'; -import {SCBuilding, SCBuildingWithoutReferences} from '../src/core/things/Building'; -import {SCCatalog, SCCatalogWithoutReferences} from '../src/core/things/Catalog'; -import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/core/things/CourseOfStudies'; -import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/core/things/DateSeries'; -import {SCDiff, SCDiffWithoutReferences} from '../src/core/things/Diff'; -import {SCDish, SCDishWithoutReferences} from '../src/core/things/Dish'; -import {SCFavorite, SCFavoriteWithoutReferences} from '../src/core/things/Favorite'; -import {SCFloor, SCFloorWithoutReferences} from '../src/core/things/Floor'; -import {SCMessage, SCMessageWithoutReferences} from '../src/core/things/Message'; -import {SCOrganization, SCOrganizationWithoutReferences} from '../src/core/things/Organization'; -import {SCPerson, SCPersonWithoutReferences} from '../src/core/things/Person'; -import {SCPointOfInterest, SCPointOfInterestWithoutReferences} from '../src/core/things/PointOfInterest'; -import {SCRoom, SCRoomWithoutReferences} from '../src/core/things/Room'; -import {SCSemester, SCSemesterWithoutReferences} from '../src/core/things/Semester'; -import {SCSetting, SCSettingWithoutReferences} from '../src/core/things/Setting'; -import {SCSportCourse, SCSportCourseWithoutReferences} from '../src/core/things/SportCourse'; -import {SCStudyModule, SCStudyModuleWithoutReferences} from '../src/core/things/StudyModule'; -import {SCTicket, SCTicketWithoutReferences} from '../src/core/things/Ticket'; -import {SCToDo, SCToDoWithoutReferences} from '../src/core/things/ToDo'; -import {SCTour, SCTourWithoutReferences} from '../src/core/things/Tour'; -import {SCVideo, SCVideoWithoutReferences} from '../src/core/things/Video'; +import {SCThing, SCThingWithoutReferences} from '../src/things/abstract/thing'; +import {SCAcademicEvent, SCAcademicEventWithoutReferences} from '../src/things/academic-event'; +import {SCArticle, SCArticleWithoutReferences} from '../src/things/article'; +import {SCBook, SCBookWithoutReferences} from '../src/things/book'; +import {SCBuilding, SCBuildingWithoutReferences} from '../src/things/building'; +import {SCCatalog, SCCatalogWithoutReferences} from '../src/things/catalog'; +import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/things/course-of-studies'; +import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/things/date-series'; +import {SCDiff, SCDiffWithoutReferences} from '../src/things/diff'; +import {SCDish, SCDishWithoutReferences} from '../src/things/dish'; +import {SCFavorite, SCFavoriteWithoutReferences} from '../src/things/favorite'; +import {SCFloor, SCFloorWithoutReferences} from '../src/things/floor'; +import {SCMessage, SCMessageWithoutReferences} from '../src/things/message'; +import {SCOrganization, SCOrganizationWithoutReferences} from '../src/things/organization'; +import {SCPerson, SCPersonWithoutReferences} from '../src/things/person'; +import {SCPointOfInterest, SCPointOfInterestWithoutReferences} from '../src/things/point-of-interest'; +import {SCRoom, SCRoomWithoutReferences} from '../src/things/room'; +import {SCSemester, SCSemesterWithoutReferences} from '../src/things/semester'; +import {SCSetting, SCSettingWithoutReferences} from '../src/things/setting'; +import {SCSportCourse, SCSportCourseWithoutReferences} from '../src/things/sport-course'; +import {SCStudyModule, SCStudyModuleWithoutReferences} from '../src/things/study-module'; +import {SCTicket, SCTicketWithoutReferences} from '../src/things/ticket'; +import {SCToDo, SCToDoWithoutReferences} from '../src/things/todo'; +import {SCTour, SCTourWithoutReferences} from '../src/things/tour'; +import {SCVideo, SCVideoWithoutReferences} from '../src/things/video'; + +// tslint:disable:no-any +// tslint:disable:completed-docs /** * Check if E extends T diff --git a/tslint.json b/tslint.json index 21085561..900794ab 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,6 @@ { "extends": "./node_modules/@openstapps/configuration/tslint.json", "rules": { - "no-empty-interface": false, - "file-name-casing": [false, "camel-case"] + "no-empty-interface": false } }