Compare commits

..

86 Commits

Author SHA1 Message Date
Jovan Krunić
961103c4e8 0.20.0 2019-06-11 16:21:37 +02:00
Rainer Killinger
771c417db8 docs: extend discription of getInstance() 2019-06-05 13:07:07 +00:00
Rainer Killinger
f847a2aa0c fix: add translations for every SCThing
fix: add field translations for  basic interfaces

fix: add translations for Message, Ticket & Video

fix: add translations for AcademicEvent, Article, Book and Building

fix: add translations

fix: add translations for Dish, Floor, Person and Room

fix: finalize  known translations

fix: add translations for setting

fix: add empty translations for fieldValues

style: applied tslint rules

fix: add missing fieldValueTranslations

fix: remove illegal nested translations
2019-06-05 12:31:48 +00:00
Wieland Schöbl
78b64bae08 fix: rename properties floor and message so that they are not identical to SCThingTypes 2019-05-29 14:02:27 +02:00
Jovan Krunić
e3ea846470 refactor: unify plugin conflict errors
Closes #58
2019-05-17 14:15:11 +02:00
Jovan Krunić
3f10129356 docs: update changelog 2019-05-17 12:34:01 +02:00
Jovan Krunić
68c5fcacbb 0.19.0 2019-05-17 12:33:37 +02:00
Karl-Philipp Wulfert
56d43bb59a build: update dependencies 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
2ad314eda6 docs: correct copyright years 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
f2a86fb6bd test: add tests to ensure consistency of model 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
198f48add4 test: adjust tests 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
5e29203e3d test: make sure to write report 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
ca72c20bd0 fix: adjust model to remove references from things without references
Fixes #69
2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
da0507ee34 fix: add thing without references, split thing
References #69
2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
1a73208c6f style: correct indentation and format in Thing.ts 2019-05-17 08:50:20 +00:00
Karl-Philipp Wulfert
1d6a2b7841 fix: remove references from origins
References #69
2019-05-17 08:50:20 +00:00
Jovan Krunić
e3d3d022c7 test: add test files for plugin routes 2019-05-16 17:05:25 +02:00
Jovan Krunić
bff6079f60 refactor: add plugin meta data interface
Closes #67
2019-05-16 17:05:24 +02:00
Jovan Krunić
bac09ffebc refactor: unify use of the image field
Closes #44
2019-05-15 14:22:35 +02:00
Karl-Philipp Wulfert
1c5a931e09 docs: update changelog 2019-05-14 14:42:41 +02:00
Karl-Philipp Wulfert
e8da621558 0.18.0 2019-05-14 14:42:35 +02:00
Rainer Killinger
6f12fbda94 test: add tests concerning the translators cache 2019-05-13 15:04:31 +02:00
Rainer Killinger
cf83692e71 refactor: simpify translator class functions 2019-05-13 15:04:31 +02:00
Jovan Krunić
27417e80e1 build: replace missing package
Closes #65
2019-05-09 17:15:03 +02:00
Sebastian Lange
bab675b806 refactor: remodel settings inputType
Flatten inputType to fit new core translation

Closes #59
2019-04-29 12:48:43 +02:00
Rainer Killinger
d3790adbd8 feat: add study module interface 2019-04-17 14:50:25 +02:00
Karl-Philipp Wulfert
d8aa023b28 docs: update changelog 2019-04-16 14:25:36 +02:00
Karl-Philipp Wulfert
4217e237fb 0.17.0 2019-04-16 14:25:33 +02:00
Karl-Philipp Wulfert
c7e2584472 build: adjust build script and add contributors 2019-04-16 14:09:29 +02:00
Karl-Philipp Wulfert
e30e04384f build: update dependencies 2019-04-16 14:08:16 +02:00
Karl-Philipp Wulfert
6fb9ccb821 docs: update changelog 2019-04-15 17:41:51 +02:00
Karl-Philipp Wulfert
9fb0a7c885 0.16.0 2019-04-15 17:41:48 +02:00
Karl-Philipp Wulfert
b5e0b76c24 build: exclude docs from package
Fixes #56
2019-04-15 15:51:25 +02:00
Karl-Philipp Wulfert
a2f44762f9 docs: update changelog 2019-04-09 17:14:55 +02:00
Karl-Philipp Wulfert
d46abbe29b 0.15.0 2019-04-09 17:14:52 +02:00
Rainer Killinger
4986042428 fix: change SCThingMeta getInstance() return value 2019-04-09 14:08:07 +00:00
Michel Jonathan Schmitz
3242411768 feat: provide context based search 2019-04-09 13:47:53 +00:00
Karl-Philipp Wulfert
37e5f6c490 build: update dependencies
Fixes #53
2019-04-09 12:36:22 +02:00
Karl-Philipp Wulfert
623ed613a9 fix: resolve issues with things that can be offered
Fixes #41
2019-04-04 13:47:30 +02:00
Karl-Philipp Wulfert
fd994e2c08 docs: update changelog 2019-04-03 16:23:56 +02:00
Karl-Philipp Wulfert
8dc40dbb00 0.14.0 2019-04-03 16:23:53 +02:00
Wieland Schöbl
c4e30c5fdd docs: add blank line before @param 2019-04-03 15:49:34 +02:00
Wieland Schöbl
81887315f8 feat: add model for plugin register route 2019-04-03 15:17:01 +02:00
Karl-Philipp Wulfert
55687daca9 docs: update changelog 2019-04-02 17:14:45 +02:00
Karl-Philipp Wulfert
2bf65a9086 0.13.0 2019-04-02 17:14:41 +02:00
Karl-Philipp Wulfert
d9347ece05 build: remove extraneous dependency 2019-04-02 16:52:32 +02:00
Karl-Philipp Wulfert
acdca2f554 test: add test for isThing guard 2019-04-02 16:24:40 +02:00
Karl-Philipp Wulfert
67868e9eb8 fix: correct isThing guard 2019-04-02 16:24:27 +02:00
Karl-Philipp Wulfert
bc00f62117 test: appropriately rename schema spec 2019-04-02 16:24:03 +02:00
Karl-Philipp Wulfert
75e833d841 refactor: adjust type to new requirements 2019-04-02 15:47:20 +02:00
Karl-Philipp Wulfert
a97805172c ci: allow audit stage to fail 2019-04-02 15:38:59 +02:00
Karl-Philipp Wulfert
c8bda2eae7 feat: add conditional "maps" for associated types
Fixes #50
2019-04-02 15:37:10 +02:00
Karl-Philipp Wulfert
1e9f36c4be refactor: apply structure to favorites and saveable things 2019-04-02 15:36:14 +02:00
Karl-Philipp Wulfert
6da9d73477 build: update dependencies 2019-04-02 15:34:38 +02:00
Rainer Killinger
bbe4fcac42 fix: update tslint dependencies 2019-04-01 14:10:14 +02:00
Jovan Krunić
5d1e79d487 feat: provide sample JSON files with the package
Closes #46
2019-03-21 17:34:28 +01:00
Jovan Krunić
7532a9bb62 test: use different UIDs for different things 2019-03-21 16:15:10 +01:00
Jovan Krunić
a4db76ec36 docs: update changelog 2019-03-14 10:16:50 +01:00
Jovan Krunić
2ff10692d5 0.12.0 2019-03-14 10:15:50 +01:00
Sebastian Lange
7c7f2726aa refactor: remodel buckets in SCFacet 2019-03-13 09:38:31 +01:00
Rainer Killinger
0679690a18 test: add nyc coverage report 2019-03-12 10:05:18 +01:00
Rainer Killinger
186ce89b91 test: add unit test for translation 2019-03-12 10:05:14 +01:00
Rainer Killinger
62975b9ded refactor: change meta class structure to include types.
Introduce requiredness of translations via implemented interface.
2019-02-28 10:51:37 +00:00
Rainer Killinger
90e3d22399 feat: add SCThingTranslator class. move functionality accordingly 2019-02-28 10:51:37 +00:00
Michel Jonathan Schmitz
797e5ca9de refactor: moved default price into SCPriceGroup 2019-02-27 13:59:14 +01:00
Karl-Philipp Wulfert
86d9696f58 build: ensure that correct dependencies are installed 2019-02-25 15:09:03 +00:00
Karl-Philipp Wulfert
94f528bb92 docs: explain how to update related projects
Fixes #37
2019-02-25 15:09:02 +00:00
Jovan Krunić
9a49442902 fix: add todo to SCThingsWithoutDiff and SCClasses
Closes #39
2019-02-25 11:52:51 +00:00
Karl-Philipp Wulfert
21a5986e3f docs: adjust documentation generation
Fixes #25
2019-02-22 11:01:30 +00:00
Michel Jonathan Schmitz
d2eeaeffd8 refactor: move location from the dish to its offers 2019-02-22 10:02:11 +01:00
Karl-Philipp Wulfert
ac08d226e9 docs: update changelog 2019-02-21 17:08:50 +01:00
Karl-Philipp Wulfert
c7462237eb 0.11.0 2019-02-21 17:08:43 +01:00
Wieland Schöbl
b5bd09e40b feat: add maxRequestBodySize in backend configuration 2019-02-21 15:16:37 +00:00
Michel Jonathan Schmitz
8f66abbb73 refactor: use the SCMap more consistently 2019-02-20 11:04:55 +01:00
Jovan Krunić
a0ab72e597 feat: add laboratory and computer as room categories
Closes #33
2019-02-18 12:23:13 +00:00
Karl-Philipp Wulfert
b4229aac35 docs: update changelog 2019-02-18 12:47:37 +01:00
Karl-Philipp Wulfert
824e841dad 0.10.0 2019-02-18 12:47:32 +01:00
Wieland Schöbl
bc3a0f6d11 feat: add model for requestBodyTooLargeError 2019-02-18 12:21:31 +01:00
Karl-Philipp Wulfert
a09aae5d5d docs: update changelog 2019-02-14 13:21:51 +01:00
Karl-Philipp Wulfert
c5c59412f4 0.9.0 2019-02-14 13:21:47 +01:00
Anselm Stordeur
85b62544bf build: update dependencies to fix security issues 2019-02-14 12:08:11 +01:00
Wieland Schöbl
e2ff4f4ec6 refactor: use constructor for checking error type in SCRoute
change SCRouteHttpVerbs from type to enum
2019-02-13 16:43:07 +01:00
Karl-Philipp Wulfert
f9c357fccf docs: update changelog 2019-02-13 14:25:47 +01:00
Karl-Philipp Wulfert
6618f91ab6 0.8.0 2019-02-13 14:25:43 +01:00
Wieland Schöbl
c7ab47397e feat: add config for maximum queries 2019-02-13 11:57:14 +01:00
Karl-Philipp Wulfert
d3f1e0ff99 docs: update changelog 2019-02-13 11:48:28 +01:00
132 changed files with 106575 additions and 1812 deletions

View File

@@ -1,4 +1,3 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org
root = true
@@ -7,11 +6,10 @@ root = true
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = false

29
.gitignore vendored
View File

@@ -20,7 +20,7 @@ coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
@@ -29,14 +29,14 @@ bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
@@ -57,6 +57,29 @@ typings/
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
#DynamoDB Local files
.dynamodb/
########## end of https://github.com/github/gitignore/blob/master/Node.gitignore
# ignore ide files
.idea
.vscode

View File

@@ -28,6 +28,16 @@ audit:
stage: test
script:
- npm audit
allow_failure: true
except:
- schedules
scheduled-audit:
stage: test
script:
- npm audit
only:
- schedules
test:
dependencies:
@@ -38,6 +48,7 @@ test:
artifacts:
paths:
- report
- coverage
pages:
stage: deploy

View File

@@ -1,12 +1,12 @@
# Ignore all files/folders by default
# See https://stackoverflow.com/a/29932318
/*
# Execept this files/folders
!docs
# Except these files/folders
!lib
lib/tsconfig.tsbuildinfo
!LICENSE
!package.json
!package-lock.json
!README.md
!src
!test/resources/

View File

@@ -1,3 +1,121 @@
# [0.19.0](https://gitlab.com/openstapps/core/compare/v0.18.0...v0.19.0) (2019-05-17)
### Bug Fixes
* add thing without references, split thing ([da0507e](https://gitlab.com/openstapps/core/commit/da0507e)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
* adjust model to remove references from things without references ([ca72c20](https://gitlab.com/openstapps/core/commit/ca72c20)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
* remove references from origins ([1d6a2b7](https://gitlab.com/openstapps/core/commit/1d6a2b7)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
# [0.18.0](https://gitlab.com/openstapps/core/compare/v0.17.0...v0.18.0) (2019-05-14)
### Features
* add study module interface ([d3790ad](https://gitlab.com/openstapps/core/commit/d3790ad))
# [0.17.0](https://gitlab.com/openstapps/core/compare/v0.16.0...v0.17.0) (2019-04-16)
# [0.16.0](https://gitlab.com/openstapps/core/compare/v0.15.0...v0.16.0) (2019-04-15)
# [0.15.0](https://gitlab.com/openstapps/core/compare/v0.14.0...v0.15.0) (2019-04-09)
### Bug Fixes
* change SCThingMeta getInstance() return value ([4986042](https://gitlab.com/openstapps/core/commit/4986042))
* resolve issues with things that can be offered ([623ed61](https://gitlab.com/openstapps/core/commit/623ed61)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
### Features
* provide context based search ([3242411](https://gitlab.com/openstapps/core/commit/3242411))
# [0.14.0](https://gitlab.com/openstapps/core/compare/v0.13.0...v0.14.0) (2019-04-03)
### Features
* add model for plugin register route ([8188731](https://gitlab.com/openstapps/core/commit/8188731))
# [0.13.0](https://gitlab.com/openstapps/core/compare/v0.12.0...v0.13.0) (2019-04-02)
### Bug Fixes
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9))
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fca))
### Features
* add conditional "maps" for associated types ([c8bda2e](https://gitlab.com/openstapps/core/commit/c8bda2e)), closes [#50](https://gitlab.com/openstapps/core/issues/50)
* provide sample JSON files with the package ([5d1e79d](https://gitlab.com/openstapps/core/commit/5d1e79d)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
# [0.12.0](https://gitlab.com/openstapps/core/compare/v0.11.0...v0.12.0) (2019-03-14)
### Bug Fixes
* add todo to SCThingsWithoutDiff and SCClasses ([9a49442](https://gitlab.com/openstapps/core/commit/9a49442)), closes [#39](https://gitlab.com/openstapps/core/issues/39)
### Features
* add SCThingTranslator class. move functionality accordingly ([90e3d22](https://gitlab.com/openstapps/core/commit/90e3d22))
# [0.11.0](https://gitlab.com/openstapps/core/compare/v0.10.0...v0.11.0) (2019-02-21)
### Features
* add laboratory and computer as room categories ([a0ab72e](https://gitlab.com/openstapps/core/commit/a0ab72e)), closes [#33](https://gitlab.com/openstapps/core/issues/33)
* add maxRequestBodySize in backend configuration ([b5bd09e](https://gitlab.com/openstapps/core/commit/b5bd09e))
# [0.10.0](https://gitlab.com/openstapps/core/compare/v0.9.0...v0.10.0) (2019-02-18)
### Features
* add model for requestBodyTooLargeError ([bc3a0f6](https://gitlab.com/openstapps/core/commit/bc3a0f6))
# [0.9.0](https://gitlab.com/openstapps/core/compare/v0.8.0...v0.9.0) (2019-02-14)
# [0.8.0](https://gitlab.com/openstapps/core/compare/v0.7.0...v0.8.0) (2019-02-13)
### Features
* add config for maximum queries ([c7ab473](https://gitlab.com/openstapps/core/commit/c7ab473))
# [0.7.0](https://gitlab.com/openstapps/core/compare/v0.6.0...v0.7.0) (2019-02-13)
# [0.6.0](https://gitlab.com/openstapps/core/compare/v0.5.0...v0.6.0) (2019-02-07)

View File

@@ -2,6 +2,32 @@
Please see the appropriate general group contributing guides in [project-management](https://gitlab.com/openstapps/projectmanagement/tree/master/project-docs/workflow).
## Updating and releasing related projects
Following semantic versioning patches to the core should not break existing usage.
### API
Every minor and major version of the core needs a corresponding version of the [API](https://openstapps.gitlab.io/api) to be used in the app and connectors.
Because the API is an integral part of the App and Node.js-based connectors this should be done for every new minor and major release of the core.
### Backend
The [backend](https://openstapps.gitlab.io/backend) uses the core to validate requests and responses. With the use of the [core tools](https://openstapps.gitlab.io/core-tools) it uses the core to set up the database according to the model.
Like for the API there should be a new release of the backend for every minor and major release of the core.
### Core tools
The [core tools](https://openstapps.gitlab.io/core-tools) are more or less not dependent on a specific core version and should normally not need adjustments for new core versions as long the structure of the code in the core stays the same.
### App and connectors
[App](https://openstapps.gitlab.io/app) and connectors use the API to communicate with the backend. To ensure compatibility the version of the used core must be the same as the one that is used in the used API.
App and connectors should be updated regularly to new releases of the core but not as important like API and backend. Since the app is just a view for the data stored in the backend it is not necessary to be up to date with the newest core immediately and the connectors are developed independently by every school and up to their responsibility.
## Additional coding style
### Extract inline type definitions

2539
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.7.0",
"version": "0.20.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -14,51 +14,82 @@
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"build": "npm run tslint && npm run compile && npm run pack && npm run schema && npm run documentation",
"build": "npm run tslint && npm run compile && npm run pack && npm run schema",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
"check-configuration": "openstapps-configuration",
"compile": "tsc",
"documentation": "typedoc --includeDeclarations --excludeExternals --mode modules --out docs src",
"compile": "rimraf lib && tsc",
"documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib",
"pack": "openstapps-core-tools pack",
"prepublishOnly": "npm run build",
"prepublishOnly": "npm ci && npm run build",
"schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src/core lib/schema",
"test": "mocha --require ts-node/register --ui mocha-typescript test/*.spec.ts",
"test": "nyc mocha --require ts-node/register --require source-map-support/register --ui mocha-typescript test/*.spec.ts",
"tslint": "tslint 'src/**/*.ts'"
},
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com",
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
"contributors": [
"Anselm Stordeur <anselmstordeur@gmail.com>",
"Jovan Krunic <jovan.krunic@gmail.com>",
"Jovan Krunić <jovan.krunic@gmail.com>",
"Andreas Lehmann",
"Sebastian Lange",
"Rainer Killinger",
"Imran Hossain"
"Imran Hossain",
"Michel Jonathan Schmitz",
"Wieland Schöbl"
],
"dependencies": {
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/node": "10.14.6",
"fast-clone": "1.5.13",
"json-patch": "0.7.0",
"jsonschema": "1.2.4"
"jsonschema": "1.2.4",
"ts-optchain": "0.1.3"
},
"devDependencies": {
"@openstapps/configuration": "0.5.0",
"@openstapps/core-tools": "0.2.0",
"@openstapps/logger": "0.0.3",
"@krlwlfrt/async-pool": "0.1.0",
"@openstapps/configuration": "0.14.0",
"@openstapps/core-tools": "0.6.0",
"@openstapps/logger": "0.1.0",
"@types/chai": "4.1.7",
"@types/humanize-string": "1.0.0",
"@types/node": "10.12.18",
"@types/rimraf": "2.0.2",
"async-pool-native": "0.1.0",
"chai": "4.2.0",
"commander": "2.19.0",
"conventional-changelog-cli": "2.0.11",
"humanize-string": "1.0.2",
"mocha": "5.2.0",
"commander": "2.20.0",
"conventional-changelog-cli": "2.0.21",
"mocha": "6.1.4",
"mocha-typescript": "1.1.17",
"nyc": "14.1.1",
"rimraf": "2.6.3",
"ts-node": "7.0.1",
"tslint": "5.12.0",
"typedoc": "0.14.0",
"typescript": "3.2.2"
"source-map-support": "0.5.12",
"ts-node": "8.1.0",
"tslint": "5.16.0",
"typedoc": "0.14.2",
"typescript": "3.4.5"
},
"nyc": {
"check-coverage": true,
"per-file": true,
"lines": 95,
"statements": 95,
"functions": 95,
"branches": 85,
"include": [
"src/core/Route.ts",
"src/core/Thing.ts",
"src/core/Translator.ts"
],
"exclude": [],
"extension": [
".ts"
],
"reporter": [
"html",
"text-summary"
],
"all": true
},
"openstappsConfiguration": {
"hasCli": false,
"standardBuild": false,
"standardDocumentation": false
}
}

100109
reflection.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,55 +12,62 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicEvent, SCAcademicEventMeta} from './things/AcademicEvent';
import {SCArticle, SCArticleMeta} from './things/Article';
import {SCBook, SCBookMeta} from './things/Book';
import {SCBuilding, SCBuildingMeta} from './things/Building';
import {SCCatalog, SCCatalogMeta} from './things/Catalog';
import {SCDateSeries, SCDateSeriesMeta} from './things/DateSeries';
import {SCDiff, SCDiffMeta} from './things/Diff';
import {SCDish, SCDishMeta} from './things/Dish';
import {SCFavorite, SCFavoriteMeta} from './things/Favorite';
import {SCFloor, SCFloorMeta} from './things/Floor';
import {SCMessage, SCMessageMeta} from './things/Message';
import {SCOrganization, SCOrganizationMeta} from './things/Organization';
import {SCPerson, SCPersonMeta} from './things/Person';
import {SCPointOfInterest, SCPointOfInterestMeta} from './things/PointOfInterest';
import {SCRoom, SCRoomMeta} from './things/Room';
import {SCSemester, SCSemesterMeta} from './things/Semester';
import {SCSetting, SCSettingMeta} from './things/Setting';
import {SCSportCourse, SCSportCourseMeta} from './things/SportCourse';
import {SCTicket, SCTicketMeta} from './things/Ticket';
import {SCTour, SCTourMeta} from './things/Tour';
import {SCVideo, SCVideoMeta} from './things/Video';
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';
/* tslint:disable:variable-name */
/**
* A map of things, from type to meta data
*/
export const SCClasses = {
export const SCClasses: { [K in SCThingType]: any } = {
/* tslint:enable */
'academic event': SCAcademicEventMeta,
article: SCArticleMeta,
book: SCBookMeta,
building: SCBuildingMeta,
catalog: SCCatalogMeta,
'article': SCArticleMeta,
'book': SCBookMeta,
'building': SCBuildingMeta,
'catalog': SCCatalogMeta,
'course of studies': SCCourseOfStudiesMeta,
'date series': SCDateSeriesMeta,
diff: SCDiffMeta,
dish: SCDishMeta,
favorite: SCFavoriteMeta,
floor: SCFloorMeta,
message: SCMessageMeta,
organization: SCOrganizationMeta,
person: SCPersonMeta,
'diff': SCDiffMeta,
'dish': SCDishMeta,
'favorite': SCFavoriteMeta,
'floor': SCFloorMeta,
'message': SCMessageMeta,
'organization': SCOrganizationMeta,
'person': SCPersonMeta,
'point of interest': SCPointOfInterestMeta,
room: SCRoomMeta,
'room': SCRoomMeta,
'semester': SCSemesterMeta,
setting: SCSettingMeta,
'setting': SCSettingMeta,
'sport course': SCSportCourseMeta,
ticket: SCTicketMeta,
tour: SCTourMeta,
video: SCVideoMeta,
'study module': SCStudyModuleMeta,
'ticket': SCTicketMeta,
'todo': SCToDoMeta,
'tour': SCTourMeta,
'video': SCVideoMeta,
};
export type SCThingsWithoutDiff =
@@ -69,6 +76,7 @@ export type SCThingsWithoutDiff =
| SCBook
| SCBuilding
| SCCatalog
| SCCourseOfStudies
| SCDateSeries
| SCDish
| SCFavorite
@@ -81,7 +89,9 @@ export type SCThingsWithoutDiff =
| SCSemester
| SCSetting
| SCSportCourse
| SCStudyModule
| SCTicket
| SCToDo
| SCTour
| SCVideo;
@@ -96,3 +106,63 @@ export type SCThings =
* A field of a thing
*/
export type SCThingsField = keyof SCThings | string;
/**
* Thing without references for a thing
*/
export type SCAssociatedThingWithoutReferences<THING extends SCThings> =
THING extends SCAcademicEvent ? SCAcademicEventWithoutReferences :
THING extends SCArticle ? SCArticleWithoutReferences :
THING extends SCBook ? SCBookWithoutReferences :
THING extends SCBuilding ? SCBuildingWithoutReferences :
THING extends SCCatalog ? SCCatalogWithoutReferences :
THING extends SCCourseOfStudies ? SCCourseOfStudiesWithoutReferences :
THING extends SCDateSeries ? SCDateSeriesWithoutReferences :
THING extends SCDiff ? SCDiffWithoutReferences :
THING extends SCDish ? SCDishWithoutReferences :
THING extends SCFavorite ? SCFavoriteWithoutReferences :
THING extends SCFloor ? SCFloorWithoutReferences :
THING extends SCMessage ? SCMessageWithoutReferences :
THING extends SCOrganization ? SCOrganizationWithoutReferences :
THING extends SCPerson ? SCPersonWithoutReferences :
THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences :
THING extends SCRoom ? SCRoomWithoutReferences :
THING extends SCSemester ? SCSemesterWithoutReferences :
THING extends SCSetting ? SCSettingWithoutReferences :
THING extends SCSportCourse ? SCSportCourseWithoutReferences :
THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
THING extends SCTicket ? SCTicketWithoutReferences :
THING extends SCToDo ? SCToDoWithoutReferences :
THING extends SCTour ? SCTourWithoutReferences :
THING extends SCVideo ? SCVideoWithoutReferences :
never;
/**
* Thing for a thing without references
*/
export type SCAssociatedThing<THING extends SCThings> =
THING extends SCAcademicEventWithoutReferences ? SCAcademicEvent :
THING extends SCArticleWithoutReferences ? SCArticle :
THING extends SCBookWithoutReferences ? SCBook :
THING extends SCBuildingWithoutReferences ? SCBuilding :
THING extends SCCatalogWithoutReferences ? SCCatalog :
THING extends SCCourseOfStudiesWithoutReferences ? SCCourseOfStudies :
THING extends SCDateSeriesWithoutReferences ? SCDateSeries :
THING extends SCDiffWithoutReferences ? SCDiff :
THING extends SCDishWithoutReferences ? SCDish :
THING extends SCFavoriteWithoutReferences ? SCFavorite :
THING extends SCFloorWithoutReferences ? SCFloor :
THING extends SCMessageWithoutReferences ? SCMessage :
THING extends SCOrganizationWithoutReferences ? SCOrganization :
THING extends SCPersonWithoutReferences ? SCPerson :
THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest :
THING extends SCRoomWithoutReferences ? SCRoom :
THING extends SCSemesterWithoutReferences ? SCSemester :
THING extends SCSettingWithoutReferences ? SCSetting :
THING extends SCSportCourseWithoutReferences ? SCSportCourse :
THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
THING extends SCTicketWithoutReferences ? SCTicket :
THING extends SCToDoWithoutReferences ? SCToDo :
THING extends SCTourWithoutReferences ? SCTour :
THING extends SCVideoWithoutReferences ? SCVideo :
never;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -15,6 +15,7 @@
/**
* 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';
@@ -35,7 +36,19 @@ import {SCThingUpdateRequest} from './protocol/routes/TYPE/UID/ThingUpdateReques
import {SCThingUpdateResponse} from './protocol/routes/TYPE/UID/ThingUpdateResponse';
import {SCMap} from './types/Map';
export type SCRouteHttpVerbs = 'GET' | 'POST' | 'PUT';
/**
* Possible Verbs for HTTP requests
*/
export enum SCRouteHttpVerbs {
GET = 'GET',
POST = 'POST',
PUT = 'PUT',
}
/**
* The constructor of an error response
*/
export type SCErrorResponseConstructor = new (...args: any) => SCErrorResponse;
/**
* A description of a route
@@ -44,7 +57,7 @@ export interface SCRoute {
/**
* A map of names of possible errors that can be returned by the route with their appropriate status codes
*/
errorNames: string[];
errorNames: SCErrorResponseConstructor[];
/**
* HTTP verb to use to request the route
@@ -81,10 +94,8 @@ export interface SCRoute {
* An abstract route
*/
export abstract class SCAbstractRoute implements SCRoute {
errorNames = [
'SCErrorResponse',
];
method: SCRouteHttpVerbs = 'GET';
errorNames: SCErrorResponseConstructor[] = [];
method: SCRouteHttpVerbs = SCRouteHttpVerbs.GET;
obligatoryParameters?: SCMap<string>;
requestBodyName = 'any';
responseBodyName = 'any';

View File

@@ -12,11 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingsField} from './Classes';
import {SCOrganization} from './things/Organization';
import {SCPerson} from './things/Person';
import {isThingWithTranslations} from './types/Guards';
import {SCTranslations} from './types/i18n';
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';
@@ -43,6 +41,7 @@ export enum SCThingType {
Semester = 'semester',
Setting = 'setting',
SportCourse = 'sport course',
StudyModule = 'study module',
Ticket = 'ticket',
ToDo = 'todo',
Tour = 'tour',
@@ -50,9 +49,9 @@ export enum SCThingType {
}
/**
* A thing
* A thing without references
*/
export interface SCThing {
export interface SCThingWithoutReferences {
/**
* Alternate names of the thing
*/
@@ -64,7 +63,7 @@ export interface SCThing {
*/
description?: string;
/**
* Image of the thing
* URL of an image of the thing
*/
image?: string;
/**
@@ -73,10 +72,6 @@ export interface SCThing {
* @minLength 1
*/
name: string;
/**
* Origin of the thing
*/
origin: SCThingRemoteOrigin | SCThingUserOrigin;
/**
* Translations of specific values of the object
*
@@ -97,6 +92,16 @@ export interface SCThing {
url?: string;
}
/**
* A thing
*/
export interface SCThing extends SCThingWithoutReferences {
/**
* Origin of the thing
*/
origin: SCThingRemoteOrigin | SCThingUserOrigin;
}
/**
* Possible types of an origin
*/
@@ -114,7 +119,7 @@ export interface SCThingOrigin {
*
* e.g. restaurant of a dish
*/
maintainer?: SCPerson | SCOrganization;
maintainer?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
/**
* When the thing was modified last in the origin
@@ -151,7 +156,7 @@ export interface SCThingRemoteOrigin extends SCThingOrigin {
*
* e.g. an organizer for an event
*/
responsibleEntity?: SCPerson | SCOrganization;
responsibleEntity?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
/**
* Type of the origin
@@ -189,117 +194,6 @@ export interface SCThingUserOrigin extends SCThingOrigin {
updated?: SCISO8601Date;
}
/**
* Meta information about things
*/
export class SCThingMeta {
/**
* Translations of fields
*/
static fieldTranslations: any = {
de: {
alternateNames: 'alternative Namen',
description: 'Beschreibung',
image: 'Bild',
name: 'Name',
translations: 'Übersetzungen',
type: 'Typ',
uid: 'Identifikation',
url: 'URL',
},
en: {
alternateNames: 'alternate names',
description: 'description',
uid: 'identification',
},
};
/**
* Translations of values of fields
*/
static fieldValueTranslations: any = {
de: {
type: {
AcademicTerm: 'Studienabschnitt',
Article: 'Artikel',
Book: 'Buch',
Catalog: 'Katalog',
Date: 'Termin',
Diff: 'Unterschied',
Dish: 'Essen',
Event: 'Veranstaltung',
Favorite: 'Favorit',
FloorPlan: 'Etagenplan',
Message: 'Nachricht',
Offer: 'Angebot',
Organization: 'Organisation',
Person: 'Person',
Place: 'Ort',
Setting: 'Einstellung',
Thing: 'Ding',
Ticket: 'Ticket',
Tour: 'Tour',
Video: 'Video',
},
},
};
/**
* Get field translation
*
* @param {keyof SCTranslations<T extends SCThing>} language Language to get field translation for
* @param {keyof T} field Field to get translation for
* @returns {string} Translated field or field itself
*/
static getFieldTranslation<T extends SCThing>(language: keyof SCTranslations<T>,
field: SCThingsField): string {
if (typeof this.fieldTranslations[language] !== 'undefined'
&& typeof this.fieldTranslations[language][field] !== 'undefined') {
return this.fieldTranslations[language][field];
}
return field as string;
}
/**
* Get field value translation
*
* @param {keyof SCTranslations<T>} language Language to get value translation for
* @param {string} field Field to get value translation for
* @param {T} thing SCThing to get value translation for
* @returns {string} Translated value or value itself
*/
static getFieldValueTranslation<T extends SCThing>(language: keyof SCTranslations<T>,
field: SCThingsField,
thing: T): string {
let translations: SCTranslations<SCThingTranslatableProperties>;
if (isThingWithTranslations(thing)) {
translations = thing.translations;
const languageTranslations: SCThingTranslatableProperties | undefined = translations[language];
if (typeof languageTranslations !== 'undefined') {
if (typeof (languageTranslations as any)[field] !== 'undefined') {
return (languageTranslations as any)[field];
}
}
}
// get translation from meta object
if (typeof this.fieldValueTranslations[language] !== 'undefined'
&& typeof this.fieldValueTranslations[language][field] !== 'undefined'
&& typeof (thing as any)[field] !== 'undefined'
&& typeof this.fieldValueTranslations[language][field][(thing as any)[field]]) {
return this.fieldValueTranslations[language][field][(thing as any)[field]];
}
// fallback to value itself
return (thing as any)[field];
}
}
/**
* Translatable properties of things
*/
@@ -327,3 +221,66 @@ export interface SCThingTranslatablePropertyOrigin {
*/
name: string;
}
/**
* Meta information about things
*/
export class SCThingMeta implements SCMetaTranslations<SCThing> {
/**
* Set type definiton for singleton instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
fieldTranslations = {
de: {
alternateNames: 'alternative Namen',
description: 'Beschreibung',
image: 'Bild',
name: 'Name',
origin: 'Ursprung',
translations: 'Übersetzungen',
type: 'Typ',
uid: 'Identifikation',
url: 'URL',
},
en: {
alternateNames: 'alternate names',
description: 'description',
image: 'image',
name: 'name',
origin: 'origin',
translations: 'translations',
type: 'type',
uid: 'identification',
url: 'URL',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
type: 'Ding',
},
en: {
type: 'Thing',
},
};
/**
* Function to retrieve typed singleton instance
*/
public static getInstance<T extends SCThingMeta>(): T {
if (!this._instance.has(this.name)) {
this._instance.set(this.name, new this());
}
return this._instance.get(this.name) as T;
}
protected constructor() {
}
}

341
src/core/Translator.ts Normal file
View File

@@ -0,0 +1,341 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
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';
/**
* SCThingTranslator class
*/
export class SCThingTranslator {
/**
* Property representing the translators target language
*/
private _language: keyof SCTranslations<SCThing>;
/**
* Property representing the translators base language
* This means every translation is given for this language
*/
private cache: LRUCache<SCThing>;
/**
* Property providing a mapping from a SCThingType to its known own meta class
*/
private metaClasses: typeof SCClasses;
/**
* @constructor
* @example
* // returns translator instance for german
* new SCThingTranslator('de');
*/
constructor(language: keyof SCTranslations<SCThing>, cacheCapacity: number = 200) {
this.cache = new LRUCache(cacheCapacity);
this._language = language;
this.metaClasses = SCClasses;
}
/**
* Getter for language property
*/
get language(): keyof SCTranslations<SCThing> {
return this._language;
}
/**
* Setter for language property. Also flushes translation cache
*
* @param language The language the translator instance will use from now on
*/
set language(language: keyof SCTranslations<SCThing>) {
if (language !== this._language) {
this.cache.flush();
}
this._language = language;
}
/**
* Get field value translation recursively
*
* @param data The intermediate object / primitive returned by the Proxys get() method
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
*/
private deeptranslate<T>(data?: T): OCType<T> {
const proxy = new Proxy(
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
{
get: (target, key) => {
const obj: any = target();
return this.deeptranslate(obj[key]);
},
},
);
return proxy;
}
/**
* Applies only known field translations of the given SCThings meta class to an instance
*
* @param thingType The type of thing that will be translated
* @param language The language the thing property values are translated to
* @returns The thing with all known meta values translated
*/
private getAllMetaFieldTranslations<T extends SCThing>(thingType: SCThingType,
language: keyof SCTranslations<T>): object | undefined {
const fieldTranslations = {};
const metaClass = this.getMetaClassInstance(thingType);
if (typeof metaClass === 'undefined') {
return undefined;
}
// 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];
});
}
// 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];
});
}
return fieldTranslations;
}
/**
* Returns meta class needed for translations given a SCThingType
*
* @param thingType
* @returns An instance of the metaclass
*/
private getMetaClassInstance(thingType: SCThingType): any {
if (thingType in this.metaClasses) {
return new (this.metaClasses as any)[thingType]();
}
return undefined;
}
/**
* Applies known field value translations of the given SCThings meta class to an instance
* Translated values overwrite current values inplace (destructive)
*
* @param language The language the thing is translated to
* @param thing The thing that will be translated
* @returns The thing with translated meta field values
*/
private replaceAvailableMetaFieldValueTranslations(instance: any,
language: keyof SCTranslations<any>): any {
const metaClass = this.getMetaClassInstance(instance.type);
if (typeof metaClass === 'undefined') {
return instance;
}
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];
}
});
}
return instance;
}
/**
* Get field value translation recursively
* @example
* const dish: SCDish = {...};
* translator.translate(dish).offers[0].inPlace.categories[1]());
* // or
* const dishTranslatedAccess = translator.translate(dish);
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
* // undoing the OCType<T>
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
* @param data Top level object that gets passed through the recursion
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
*/
public translate<T extends SCThing>(data: T): OCType<T> {
return new Proxy(
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
{
get: (target, key) => {
const obj: any = target();
const objTranslatedFromCache = this.cache.get(data);
if (typeof objTranslatedFromCache !== 'undefined') {
return this.deeptranslate((objTranslatedFromCache as any)[key]);
}
const objTranslated = this.translateWholeThingDestructively(clone(obj));
this.cache.putObject(objTranslated);
return this.deeptranslate(objTranslated[key]);
},
},
);
}
/**
* Given a SCThingType this function returns an object with the same basic structure as the corresponding SCThing
* All the values will be set to the known translations of the property/key name
* @example
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
* @param language The language the object is translated to
* @param thingType
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
*/
public translatedPropertyNames<T extends SCThing>(thing: T,
language?: keyof SCTranslations<T>): T | undefined {
const targetLanguage = (language) ? language : this.language;
// return {...{}, ...this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T};
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
}
/**
* Recursively translates the given object in-place
* Translated values overwrite current values (destructive)
*
* @param language The language the thing is translated to
* @param thing The thing that will be translated
* @returns The thing translated
*/
public translateWholeThingDestructively(instance: any,
language?: keyof SCTranslations<any>): any {
const targetLanguage = (language) ? language : this.language;
// Recursively call this function on all nested SCThings, arrays and objects
Object.keys(instance).forEach((key) => {
if (
isThing((instance as any)[key]) ||
instance[key] instanceof Array ||
instance[key] instanceof Object) {
instance[key] = this.translateWholeThingDestructively(instance[key], targetLanguage);
}
});
// Spread variable translations given by the connector into thing
if (typeof instance.translations !== 'undefined') {
if (typeof instance.translations![targetLanguage] !== 'undefined') {
instance = {...instance, ...instance.translations![targetLanguage]} as typeof instance;
}
}
// Spread known translations from meta classes into (partly) translated thing
this.replaceAvailableMetaFieldValueTranslations(instance, targetLanguage);
return instance;
}
}
/**
* LRUCache class
* Small last recently used cache intended to get used by SCThingTranslator
*/
class LRUCache<T> {
/**
* Map property that manages cached content
*/
private entries: Map<string, T> = new Map<string, T>();
/**
* Property representing cache maximum capacity
*/
private maxEntries: number;
/**
* @constructor
* @example
* // returns LRUCache instance with a maximum capacity of 500
* new LRUCache(500);
*/
constructor(maxEntries: number) {
this.maxEntries = maxEntries;
}
/**
* Flushes cache / removes all entries
*/
public flush() {
this.entries.clear();
}
/**
* Get content from cache by key
*/
public get(somethingOrKey: string): T | undefined;
/**
* Get content from cache by another objects uid
*/
public get<U extends SCThing>(something: U): T | undefined;
/**
* 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
* @returns If available the content connected to the key or somethingOrKey.uid property
*/
public get<U extends SCThing>(somethingOrKey: string | U): T | undefined {
let key: string;
if (typeof somethingOrKey === 'string') {
key = somethingOrKey;
} else if (isThing(somethingOrKey)) {
key = somethingOrKey.uid;
} else {
throw new Error(`Passed argument ${somethingOrKey} cannot be key in LRUCache`);
}
const entry = this.entries.get(key);
if (entry) {
// LRU behavior
this.entries.delete(key);
this.entries.set(key, entry);
}
return entry;
}
/**
* Place content in cache by key
*
* @param key The key for which content should be cached
* @param content The content that should be cached
*/
public put(key: string, content: T) {
if (this.entries.size >= this.maxEntries) {
// LRU behavior
const keyToDelete = this.entries.keys().next().value;
this.entries.delete(keyToDelete);
}
this.entries.set(key, content);
}
/**
* Place content in cache by another objects uid
*
* @param something The object that should be cached under something.uid
*/
public putObject<U extends SCThing>(something: U) {
this.put(something.uid, (something as any) as T);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,47 +12,69 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
import {SCThingMeta} from '../Thing';
import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* An academic degree without references
*/
export interface SCAcademicDegreeWithoutReferences extends SCThing {
export interface SCAcademicDegreeWithoutReferences
extends SCThingWithoutReferences {
/**
* The achievable academic degree
*/
academicDegree: SCGermanAcademicDegree;
/**
* The achievable academic degree with academic field specification
* The achievable academic degree with academic field specification
* (eg. Master of Science)
*/
academicDegreewithField: string;
/**
* The achievable academic degree with academic field specification
* The achievable academic degree with academic field specification
* shorted (eg. M.Sc.).
*/
academicDegreewithFieldShort: string;
}
export interface SCAcademicDegree extends SCAcademicDegreeWithoutReferences {
/**
* An academic degree
*/
export interface SCAcademicDegree
extends SCAcademicDegreeWithoutReferences, SCThing {
// noop
}
export class SCAcademicDegreeMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
/**
* Meta information about academic degrees
*/
export class SCAcademicDegreeMeta
extends SCThingMeta implements SCMetaTranslations<SCAcademicDegree> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
academicDegree: 'Hochschulgrad',
academicDegreewithField: 'Abschlussbezeichnungen',
academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
academicDegree: 'academic degree',
academicDegreewithField: 'acedemic degree and discipline',
academicDegreewithFieldShort: 'acedemic degree and discipline (short)',
},
};
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
academicDegree: {
'bachelor': 'Bachelor',
'diploma': 'Diplom',
@@ -64,17 +86,21 @@ export class SCAcademicDegreeMeta extends SCThingMeta {
'state examination': 'Staatsexamen',
},
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}
/**
* Types of (german) academic degrees
*/
export type SCGermanAcademicDegree = 'bachelor' |
'diploma' |
'doctor' |
'licentiate' |
'magister' |
'master' |
'master pupil' |
'state examination' ;
export type SCGermanAcademicDegree =
'bachelor'
| 'diploma'
| 'doctor'
| 'licentiate'
| 'magister'
| 'master'
| 'master pupil'
| 'state examination' ;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,13 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/**
* An academic term without references
*/
export interface SCAcademicTermWithoutReferences extends SCThing {
export interface SCAcademicTermWithoutReferences
extends SCThingWithoutReferences {
/**
* Short name of the academic term, using the given pattern
*/
@@ -44,3 +46,51 @@ export interface SCAcademicTermWithoutReferences extends SCThing {
*/
startDate: SCISO8601Date;
}
/**
* An academic term
*/
export interface SCAcademicTerm
extends SCAcademicTermWithoutReferences, SCThing {
// noop
}
/**
* Meta information about academic terms
*/
export class SCAcademicTermWithoutReferencesMeta
extends SCThingMeta implements SCMetaTranslations<SCThing> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
acronym: 'Akronym',
endDate: 'Enddatum',
eventsEndDate: 'Enddatum der Veranstaltungen',
eventsStartDate: 'Startdatum der Veranstaltungen',
startDate: 'Startdatum',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
acronym: 'acronym',
endDate: 'end date',
eventsEndDate: 'end date of events',
eventsStartDate: 'start date of events',
startDate: 'start date',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,21 +12,24 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing';
import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCLanguage, SCTranslations} from '../types/i18n';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from './ThingThatCanBeOffered';
/**
* A creative work without references
*/
export interface SCCreativeWorkWithoutReferences extends SCThing {
export interface SCCreativeWorkWithoutReferences
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* Date the creative work was published
*/
@@ -51,7 +54,8 @@ export interface SCCreativeWorkWithoutReferences extends SCThing {
/**
* A creative work
*/
export interface SCCreativeWork extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
export interface SCCreativeWork
extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* Authors of the creative work
*/
@@ -78,3 +82,47 @@ export interface SCCreativeWorkTranslatableProperties
*/
keywords?: string[];
}
/**
* Meta information about creative works
*/
export class SCCreativeWorkMeta
extends SCThingMeta implements SCMetaTranslations<SCCreativeWork> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
... SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
authors: 'Authoren',
datePublished: 'Veröffentlichungsdatum',
inLanguages: 'verfügbare Übersetzungen',
keywords: 'Schlagwörter',
publishers: 'Verleger',
},
en: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
... SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
authors: 'authors',
datePublished: 'release date',
inLanguages: 'available Languages',
keywords: 'keywords',
publishers: 'publishers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
... SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
... SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,16 +12,18 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
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';
/**
* An event without references
*/
export interface SCEventWithoutReferences extends SCThing {
export interface SCEventWithoutReferences
extends SCThingWithoutReferences {
/**
* Maximum number of participants of the event
*
@@ -40,7 +42,8 @@ export interface SCEventWithoutReferences extends SCThing {
/**
* An event
*/
export interface SCEvent extends SCEventWithoutReferences {
export interface SCEvent
extends SCEventWithoutReferences, SCThing {
/**
* Academic terms that an event belongs to, e.g. semester(s).
*/
@@ -68,3 +71,47 @@ export interface SCEvent extends SCEventWithoutReferences {
*/
performers?: SCPersonWithoutReferences[];
}
/**
* Meta information about events
*/
export class SCEventMeta
extends SCThingMeta implements SCMetaTranslations<SCEvent> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
academicTerms: 'Semester',
catalogs: 'Verzeichnis',
creativeWorks: 'begleitende Werke',
maximumParticipants: 'maximale Anzahl an Teilnehmern',
organizers: 'Origanisatoren',
performers: 'Vortragende',
remainingAttendeeCapacity: 'verfügbare Anzahl an Teilnehmern',
},
en: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
academicTerms: 'academic terms',
catalogs: 'catalogs',
creativeWorks: 'related material',
maximumParticipants: 'maximum participants',
organizers: 'organizers',
performers: 'performers',
remainingAttendeeCapacity: 'remaining attendee capacity',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,14 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing';
import {SCGeoInformation} from '../types/GeoInformation';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCPostalAddress} from '../types/PostalAddress';
/**
* A place without references
*/
export interface SCPlaceWithoutReferences extends SCThing {
export interface SCPlaceWithoutReferences
extends SCThingWithoutReferences {
/**
* Address of the place
*/
@@ -38,4 +40,64 @@ export interface SCPlaceWithoutReferences extends SCThing {
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
*/
openingHours?: string;
/**
* Translated fields of a place
*/
translations?: SCTranslations<SCPlaceWithoutReferencesTranslatableProperties>;
}
/**
* A place
*/
export interface SCPlace
extends SCPlaceWithoutReferences, SCThing {
/**
* Translated fields of a place
*/
translations?: SCTranslations<SCPlaceWithoutReferencesTranslatableProperties>;
}
/**
* Translatable properties of a place without references
*/
export interface SCPlaceWithoutReferencesTranslatableProperties
extends SCThingTranslatableProperties {
address?: SCPostalAddress;
}
/**
* Meta information about creative works
*/
export class SCPlaceWithoutReferencesMeta
extends SCThingMeta implements SCMetaTranslations<SCPlaceWithoutReferences> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
address: 'Adresse',
geo: 'Geoinformation',
openingHours: 'Öffnungszeiten',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
address: 'address',
geo: 'geographic information',
openingHours: 'opening hours',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -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,25 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingUserOrigin} from '../Thing';
import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from '../Thing';
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThing<T extends SCThing> extends SCThing {
export interface SCSaveableThingWithoutReferences
extends SCThingWithoutReferences {
// noop
}
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThing<T extends SCThingWithoutReferences>
extends SCSaveableThingWithoutReferences, SCThing {
/**
* The contained data
*/
data: T;
/**
* Type of the origin
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,20 +12,46 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
import {SCThing, SCThingMeta} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
import {SCInPlace} from '../types/Places';
/**
* A thing that is or happens in a place
*/
export interface SCThingInPlace extends SCThing {
/**
* Place the thing is or happens in
*/
inPlace?:
SCBuildingWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
export interface SCThingInPlace
extends SCThing, SCInPlace {
// noop
}
/**
* Meta information about thing in a place
*/
export class SCThingInPlaceMeta
extends SCThingMeta implements SCMetaTranslations<SCThingInPlace> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
inPlace: 'Ort',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
inPlace: 'location',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,22 +12,69 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing} from '../Thing';
import {SCThing, SCThingMeta, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* Types of payment that are accepted at a place.
*/
export type SCThingThatAcceptsPaymentsAcceptedPayments =
'Cash'
| 'Credit'
| 'Cafeteria Card';
'cash'
| 'credit'
| 'cafeteria card';
/**
* A place without references that accepts payments
* A thing without references that accepts payments
*/
export interface SCThingThatAcceptsPaymentsWithoutReferences extends SCThing {
export interface SCThingThatAcceptsPaymentsWithoutReferences
extends SCThingWithoutReferences {
/**
* Accepted payments of the place
*/
paymentsAccepted?: SCThingThatAcceptsPaymentsAcceptedPayments[];
}
/**
* A thing that accepts payments
*/
export interface SCThingThatAcceptsPayments
extends SCThingThatAcceptsPaymentsWithoutReferences, SCThing {
// noop
}
/**
* Meta information about a thing without references that accepts payments
*/
export class SCThingThatAcceptsPaymentsWithoutReferencesMeta
extends SCThingMeta implements SCMetaTranslations<SCThingThatAcceptsPaymentsWithoutReferences> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
paymentsAccepted: 'Bezahlmethoden',
},
en: {
... SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
paymentsAccepted: 'accepted payment methods',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
paymentsAccepted: {
'cafeteria card': 'Mensakarte',
'cash': 'Bar',
'credit': 'Kreditkarte',
},
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,26 +12,28 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing';
import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCInPlace} from '../types/Places';
import {SCISO8601Date} from '../types/Time';
/**
* A map from group name to price
* Default price without distinction
*/
export interface SCPriceGroup {
[s: string]: number | undefined;
/**
* Default price of the thing
*/
default: number;
}
/**
* Price distinctions for academic context
*/
export interface SCAcademicPriceGroup extends SCPriceGroup {
export interface SCAcademicPriceGroup
extends SCPriceGroup {
/**
* Price for employees
*/
@@ -49,9 +51,21 @@ export interface SCAcademicPriceGroup extends SCPriceGroup {
}
/**
* A thing without references that has a price tag
* A thing without references that can be offered
*/
export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing {
export interface SCThingThatCanBeOfferedWithoutReferences
extends SCThingWithoutReferences {
/**
* Translations of a thing that can be offered
*/
translations?: SCTranslations<SCThingThatCanBeOfferedTranslatableProperties>;
}
/**
* A thing that can be offered
*/
export interface SCThingThatCanBeOffered<T extends SCPriceGroup>
extends SCThing, SCThingThatCanBeOfferedWithoutReferences {
/**
* List of offers for that thing
*/
@@ -66,7 +80,8 @@ export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing
/**
* Offer of a thing
*/
export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> {
export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup>
extends SCInPlace {
/**
* Availability of an offer
*/
@@ -82,15 +97,10 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> {
*/
availabilityStarts?: SCISO8601Date;
/**
* Default price of the thing
*/
price: number;
/**
* List of prices that are distinct for specific groups
*/
prices?: T;
prices: T;
/**
* Provider of an offer
@@ -101,7 +111,8 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> {
/**
* Translatable properties of a thing that can be offered
*/
export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties {
export interface SCThingThatCanBeOfferedTranslatableProperties
extends SCThingTranslatableProperties {
/**
* Availability of an offer
*/
@@ -109,20 +120,61 @@ export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTr
}
/**
* Possible things a provider can be
* Entity responsible for the offer
*/
export type SCThingThatCanBeOfferedProvider =
SCBuildingWithoutReferences
| SCOrganizationWithoutReferences
| SCPersonWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
| SCPersonWithoutReferences;
/**
* Availability of an Offer
*/
export type SCThingThatCanBeOfferedAvailability =
'in stock'
| 'in stock'
| 'out of stock'
| 'online only'
| 'limited availability';
/**
* Meta information about a thing without references that accepts payments
*/
export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup> implements
SCMetaTranslations<SCThingThatCanBeOffered<T>> {
protected static _instance: any;
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingMeta.getInstance().fieldTranslations.de,
offers: 'Angebote',
},
en: {
... SCThingMeta.getInstance().fieldTranslations.en,
offers: 'offers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
... SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T extends SCPriceGroup>(): SCThingThatCanBeOfferedMeta<T> {
return this._instance || (this._instance = new this<T>());
}
protected constructor() {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCMap} from '../types/Map';
/**
@@ -22,9 +22,8 @@ import {SCMap} from '../types/Map';
* !!! BEWARE !!!
* `T` should be a union type - e.g. `T = 'foo' | 'bar' | 'foobar';`
*/
export interface SCThingWithCategoriesWithoutReferences<T,
U extends SCThingWithCategoriesSpecificValues>
extends SCThing {
export interface SCThingWithCategoriesWithoutReferences<T, U extends SCThingWithCategoriesSpecificValues>
extends SCThingWithoutReferences {
/**
* Categories of a thing with categories
*/
@@ -43,10 +42,22 @@ export interface SCThingWithCategoriesWithoutReferences<T,
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
}
/**
* A thing with categories
*/
export interface SCThingWithCategories<T, U extends SCThingWithCategoriesSpecificValues>
extends SCThing, SCThingWithCategoriesWithoutReferences<T, U> {
/**
* Translated fields of a thing with categories
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
}
/**
* Translatable properties of a thing with categories
*/
export interface SCThingWithCategoriesTranslatableProperties extends SCThingTranslatableProperties {
export interface SCThingWithCategoriesTranslatableProperties
extends SCThingTranslatableProperties {
/**
* translations of the categories of a thing with categories
*/
@@ -70,7 +81,7 @@ export interface SCThingWithCategoriesSpecificValues {
description?: string;
/**
* Category specific image of a thing
* URL of a category specific image of a thing
*/
image?: string;
@@ -84,3 +95,51 @@ export interface SCThingWithCategoriesSpecificValues {
*/
url?: string;
}
/**
* Meta information about a thing without references that accepts payments
* It intentionally does not extend the SCThingMeta implementation to be able to include generics.
*/
export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
protected static _instance: any;
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
categories: 'Kategorien',
categorySpecificValues: 'besondere Kategorien',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
categories: 'categories',
categorySpecificValues: 'category with specific values',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> {
return this._instance || (this._instance = new this<T, U>());
}
protected constructor() {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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
@@ -42,6 +43,7 @@ export abstract class SCError implements SCErrorResponse {
/**
* 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
@@ -66,6 +68,7 @@ export class SCValidationErrorResponse extends SCError {
/**
* Create a SCValidationErrorResponse
*
* @param errors List of validation errors
* @param stack Set to true if a stack trace should be created
*/
@@ -81,6 +84,7 @@ export class SCValidationErrorResponse extends SCError {
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
* Create a SCUnsupportedMediaTypeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -94,6 +98,7 @@ export class SCUnsupportedMediaTypeErrorResponse extends SCError {
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
* Create a SCMethodNotAllowedErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -101,12 +106,26 @@ export class SCMethodNotAllowedErrorResponse extends SCError {
}
}
/**
* 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.', 413, 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) {
@@ -120,6 +139,7 @@ export class SCTooManyRequestsErrorResponse extends SCError {
export class SCNotFoundErrorResponse extends SCError {
/**
* Create a SCNotFoundErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -127,12 +147,71 @@ export class SCNotFoundErrorResponse extends SCError {
}
}
/**
* 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, 406, 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?: boolean) {
super('SCPluginAlreadyRegisteredError', message, 409, 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, 500, 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
*/
@@ -152,8 +231,9 @@ export class SCInternalServerErrorResponse extends SCError {
/**
* Create a SCInternalServerErrorResponse
*
* @param err Internal server error
* @param stack Set to true if a stack trace should be created
* @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?: boolean) {

View File

@@ -12,7 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../errors/ErrorResponse';
/**
* Index request
@@ -29,13 +37,14 @@ export class SCIndexRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCIndexRequest';
this.responseBodyName = 'SCIndexResponse';
this.statusCodeSuccess = 200;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -13,7 +13,16 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThings} from '../../../../Classes';
import {SCAbstractRoute} from '../../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../../errors/ErrorResponse';
/**
* Request to update an existing thing
@@ -29,14 +38,15 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCNotFoundErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'PUT';
this.method = SCRouteHttpVerbs.PUT;
this.obligatoryParameters = {
TYPE: 'SCThingTypes',
UID: 'SCUuid',

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -12,8 +12,17 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {SCUuid} from '../../../types/UUID';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../errors/ErrorResponse';
/**
* Request to check the availability of books
@@ -60,14 +69,15 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCNotFoundErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBookAvailabilityRequest';
this.responseBodyName = 'SCBookAvailabilityResponse';
this.statusCodeSuccess = 200;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -12,9 +12,17 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {SCThingType} from '../../../Thing';
import {SCISO8601Date} from '../../../types/Time';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../errors/ErrorResponse';
/**
* A bulk request
@@ -60,13 +68,14 @@ export class SCBulkRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBulkRequest';
this.responseBodyName = 'SCBulkResponse';
this.statusCodeSuccess = 200;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -13,7 +13,16 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThings} from '../../../../Classes';
import {SCAbstractRoute} from '../../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../../errors/ErrorResponse';
/**
* Request to add a thing to a bulk
@@ -28,14 +37,15 @@ export class SCBulkAddRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCNotFoundErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.obligatoryParameters = {
UID: 'SCUuid',
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -12,7 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../../errors/ErrorResponse';
/**
* Request to change the bulk state to done (close the bulk process)
@@ -28,14 +37,15 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCNotFoundErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.obligatoryParameters = {
UID: 'SCUuid',
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -12,8 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {SCMessage} from '../../../things/Message';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
} from '../../errors/ErrorResponse';
/**
* User feedback
@@ -34,13 +42,14 @@ export class SCFeedbackRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCFeedbackRequest';
this.responseBodyName = 'SCFeedbackResponse';
this.statusCodeSuccess = 204;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -0,0 +1,114 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
import {Schema} from 'jsonschema';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse, SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
} from '../../errors/ErrorResponse';
/**
* Plugin register request
*
* @validatable
*/
export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove;
/**
* Plugin request for adding a plugin registration to the backend
*/
export interface SCPluginAdd {
/**
* The desired action, so whether the plugin should be added or removed
*/
action: 'add';
/**
* Plugin information needed for its registration
*/
plugin: SCPluginMetaData;
}
/**
* Plugin request for removing a plugin registration from the backend
*/
export interface SCPluginRemove {
/**
* The desired action, so whether the plugin should be added or removed
*/
action: 'remove';
/**
* The route of the plugin you want to remove
*/
route: string;
}
/**
* Plugin meta data - contains needed information for a plugin registration
*/
export interface SCPluginMetaData {
/**
* The address of the plugin, to which the backend routes the requests
*/
address: string;
/**
* The name of the plugin (for debugging purposes, to more easily identify conflicts)
*/
name: string;
/**
* How the requests of the plugin looks like, a JSON schema for validation
*/
requestSchema: Schema;
/**
* How the responses of the plugin looks like, a JSON schema for validation
*/
responseSchema: Schema;
/**
* The desired route, for example /feedback.
*/
route: string;
}
/**
* Route to register plugins
*/
export class SCPluginRegisterRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
];
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCPluginRegisterRequest';
this.responseBodyName = 'SCPluginRegisterResponse';
this.statusCodeSuccess = 200;
this.urlFragment = '/plugin/register';
}
}

View File

@@ -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.
@@ -12,12 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* A thing that has translations
* Plugin register response
*
* @validatable
*/
export interface SCThingWithTranslations extends SCThing {
translations: SCTranslations<SCThingTranslatableProperties>;
export interface SCPluginRegisterResponse {
/**
* Whether the desired action succeeded or failed (true for success, false if an error occurred)
*/
success: boolean;
}

View File

@@ -12,7 +12,17 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
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';
/**
@@ -24,9 +34,7 @@ import {SCSearchQuery} from './SearchRequest';
*
* @validatable
*/
export interface SCMultiSearchRequest {
[k: string]: SCSearchQuery;
}
export type SCMultiSearchRequest = SCMap<SCSearchQuery>;
/**
* Route for submission of multiple search requests at once
@@ -35,14 +43,15 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCSyntaxError',
'SCTooManyRequestsErrorResponse',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCTooManyRequestsErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCMultiSearchRequest';
this.responseBodyName = 'SCMultiSearchResponse';
this.statusCodeSuccess = 200;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMap} from '../../../types/Map';
import {SCSearchResult} from './SearchResponse';
/**
@@ -21,6 +22,4 @@ import {SCSearchResult} from './SearchResponse';
*
* @validatable
*/
export interface SCMultiSearchResponse {
[k: string]: SCSearchResult;
}
export type SCMultiSearchResponse = SCMap<SCSearchResult>;

View File

@@ -12,9 +12,18 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
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';
/**
* A search request
@@ -29,7 +38,12 @@ export interface SCSearchRequest extends SCSearchQuery {
*/
export interface SCSearchQuery {
/**
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
* 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;
@@ -61,13 +75,14 @@ export class SCSearchRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
'SCInternalServerErrorResponse',
'SCMethodNotAllowedErrorResponse',
'SCSyntaxError',
'SCUnsupportedMediaTypeErrorResponse',
'SCValidationErrorResponse',
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
SCUnsupportedMediaTypeErrorResponse,
SCValidationErrorResponse,
];
this.method = 'POST';
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCSearchRequest';
this.responseBodyName = 'SCSearchResponse';
this.statusCodeSuccess = 200;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -13,7 +13,6 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThings, SCThingsField} from '../../../Classes';
import {SCMap} from '../../../types/Map';
/**
* A search response
@@ -53,9 +52,9 @@ export interface SCSearchResult {
*/
export interface SCFacet {
/**
* Values for the aggregation
* Buckets for the aggregation
*/
buckets: Array<SCMap<number>>;
buckets: SCFacetBucket[];
/**
* Field of the aggregation
@@ -63,6 +62,21 @@ export interface SCFacet {
field: SCThingsField;
}
/**
* A bucket of a facet
*/
export interface SCFacetBucket {
/**
* Count of matching search results
*/
count: number;
/**
* Key of a bucket
*/
key: string;
}
/**
* Stores information about Pagination
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,22 +12,23 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCEvent, SCEventWithoutReferences} from '../base/Event';
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* An academic event without references
*/
export interface SCAcademicEventWithoutReferences
extends SCEventWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
/**
* Majors of the academic event that this event belongs to
*/
@@ -54,7 +55,9 @@ export interface SCAcademicEventWithoutReferences
*
* @validatable
*/
export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferences {
export interface SCAcademicEvent
extends SCEvent, SCAcademicEventWithoutReferences,
SCThingWithCategories<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated fields of an academic event
*/
@@ -66,18 +69,6 @@ export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferenc
type: SCThingType.AcademicEvent;
}
/**
* Event meta data
*/
export class SCAcademicEventMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
de: {
type: 'Event',
},
};
}
/**
* Categories of academic events
*/
@@ -86,6 +77,7 @@ export type SCAcademicEventCategories =
| 'seminar'
| 'integrated course'
| 'written exam'
| 'oral exam'
| 'tutorial'
| 'project'
| 'colloquium'
@@ -111,3 +103,72 @@ export interface SCAcademicEventTranslatableProperties
*/
originalCategory?: string;
}
/**
* Meta information about academic events
*/
export class SCAcademicEventMeta
extends SCThingMeta
implements SCMetaTranslations<SCAcademicEvent> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
majors: 'Hauptfächer',
originalCategory: 'ursprüngliche Kategorie',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
majors: 'majors',
originalCategory: 'original category',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
categories: {
'colloquium': 'Kolloquium',
'course': 'Kurs',
'excursion': 'Exkursion',
'integrated course': '',
'introductory class': 'Einführungsveranstaltung',
'lecture': 'Vorlesung',
'oral exam': 'mündliche Prüfung',
'practicum': 'Praktikum',
'practicum introduction': 'Einführungspraktikum',
'project': 'Projekt',
'seminar': 'Seminar',
'special': 'Sonderveranstalltung',
'tutorial': 'Tutorium',
'written exam': 'Schriftilche Prüfung',
},
type: 'akademische Veranstaltung',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
type: SCThingType.AcademicEvent,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -14,24 +14,26 @@
*/
import {
SCCreativeWork,
SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* An article without references
*/
export interface SCArticleWithoutReferences
extends SCCreativeWorkWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCArticleCategories,
SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
/**
* Article itself as markdown
*/
@@ -53,7 +55,9 @@ export interface SCArticleWithoutReferences
*
* @validatable
*/
export interface SCArticle extends SCCreativeWork, SCArticleWithoutReferences {
export interface SCArticle
extends SCCreativeWork, SCArticleWithoutReferences,
SCThingWithCategories<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated fields of an article
*/
@@ -65,19 +69,6 @@ export interface SCArticle extends SCCreativeWork, SCArticleWithoutReferences {
type: SCThingType.Article;
}
/**
* Meta information about an article
*/
export class SCArticleMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
de: {
articleBody: 'Artikeltext',
categories: 'Kategorien',
},
};
}
/**
* Categories of articles
*/
@@ -93,3 +84,60 @@ export interface SCArticleTranslatableProperties
*/
articleBody?: string[];
}
/**
* Meta information about an article
*/
export class SCArticleMeta
extends SCThingMeta implements SCMetaTranslations<SCArticle> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCArticleCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
articleBody: 'Artikelinhalt',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCArticleCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
articleBody: 'article body',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCArticleCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
categories: {
'unipedia': 'Unipedia',
},
type: 'Artikel',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCArticleCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
type: SCThingType.Article,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -14,18 +14,20 @@
*/
import {
SCCreativeWork,
SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork';
import {SCThingWithCategoriesTranslatableProperties} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCPersonWithoutReferences} from './Person';
/**
* A book without references
*/
export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences {
export interface SCBookWithoutReferences
extends SCCreativeWorkWithoutReferences {
/**
* Edition of a book
*/
@@ -57,7 +59,8 @@ export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences
*
* @validatable
*/
export interface SCBook extends SCCreativeWork, SCBookWithoutReferences {
export interface SCBook
extends SCCreativeWork, SCBookWithoutReferences {
/**
* Authors of the creative work
*/
@@ -74,20 +77,6 @@ export interface SCBook extends SCCreativeWork, SCBookWithoutReferences {
type: SCThingType.Book;
}
/**
* Meta information about a book
*/
export class SCBookMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
de: {
bookEdition: 'Edition',
isbn: 'ISBN',
numberOfPages: 'Seitenanzahl',
},
};
}
/**
* Translatable properties of a book
*/
@@ -98,3 +87,44 @@ export interface SCBookTranslatableFields
*/
bookEdition?: string;
}
/**
* Meta information about a book
*/
export class SCBookMeta extends SCThingMeta implements SCMetaTranslations<SCBook> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
bookEdition: 'Buchausgabe',
isbn: 'ISBN',
numberOfPages: 'Seitenzahl',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
bookEdition: 'book edition',
isbn: 'ISBN',
numberOfPages: 'number of pages',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
type: 'Buch',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
type: SCThingType.Book,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,14 +12,21 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCPlaceWithoutReferences} from '../base/Place';
import {
SCPlace,
SCPlaceWithoutReferences,
SCPlaceWithoutReferencesMeta,
SCPlaceWithoutReferencesTranslatableProperties,
} from '../base/Place';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
export type SCBuildingCategories =
'cafe'
@@ -32,8 +39,7 @@ export type SCBuildingCategories =
| 'restroom';
export interface SCBuildingWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>,
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
SCPlaceWithoutReferences {
/**
* Categories of a building
@@ -48,7 +54,7 @@ export interface SCBuildingWithoutReferences
/**
* Translated fields of a building
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
translations?: SCTranslations<SCBuildingTranslatableProperties>;
/**
* Type of the building
@@ -61,20 +67,69 @@ export interface SCBuildingWithoutReferences
*
* @validatable
*/
export interface SCBuilding extends SCBuildingWithoutReferences {
export interface SCBuilding
extends SCBuildingWithoutReferences, SCPlace,
SCThingWithCategories<SCBuildingCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated fields of a building
*/
translations?: SCTranslations<SCBuildingTranslatableProperties>;
/**
* Type of the building
*/
type: SCThingType.Building;
}
export interface SCBuildingTranslatableProperties
extends SCPlaceWithoutReferencesTranslatableProperties, SCThingWithCategoriesTranslatableProperties {
floors?: string[];
}
/**
* Meta information about a place
*/
export class SCBuildingMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
export class SCBuildingMeta
extends SCThingMeta
implements SCMetaTranslations<SCBuilding> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCBuildingCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.de,
floors: 'Etagen',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCBuildingCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.en,
floors: 'floors',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCBuildingCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.de,
categories: {
'cafe': 'Café',
'canteen': 'Kantine',
@@ -85,6 +140,17 @@ export class SCBuildingMeta extends SCThingMeta {
'restroom': 'Toilette',
'student canteen': 'Mensa',
},
type: 'Gebäude',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCBuildingCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.en,
type: SCThingType.Building,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -13,15 +13,21 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm';
import {SCThingWithCategoriesSpecificValues, SCThingWithCategoriesWithoutReferences} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* A catalog without references
*/
export interface SCCatalogWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCCatalogCategories,
SCThingWithCategoriesSpecificValues> {
extends SCThingWithCategoriesWithoutReferences<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
/**
* Level of the catalog (0 for 'root catalog', 1 for its subcatalog, 2 for its subcatalog etc.)
*
@@ -40,7 +46,9 @@ export interface SCCatalogWithoutReferences
*
* @validatable
*/
export interface SCCatalog extends SCCatalogWithoutReferences {
export interface SCCatalog
extends SCCatalogWithoutReferences, SCThing,
SCThingWithCategories<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
/**
* Academic term that a catalog belongs to (e.g. semester)
*/
@@ -56,6 +64,11 @@ export interface SCCatalog extends SCCatalogWithoutReferences {
*/
superCatalogs?: SCCatalogWithoutReferences[];
/**
* Translated fields of a catalog
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of a catalog
*/
@@ -65,7 +78,56 @@ export interface SCCatalog extends SCCatalogWithoutReferences {
/**
* Catalog meta data
*/
export class SCCatalogMeta extends SCThingMeta {
export class SCCatalogMeta
extends SCThingMeta implements SCMetaTranslations<SCCatalog> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCCatalogCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
academicTerm: 'Semester',
level: 'Ebene',
superCatalog: 'übergeordnetes Verzeichniss',
superCatalogs: 'übergeordnete Verzeichnisse',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCCatalogCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
academicTerm: 'academic term',
level: 'level',
superCatalog: 'parent catalog',
superCatalogs: 'parent catalogs',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCCatalogCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
categories: {
'university events': 'Universitätsveranstaltung',
},
type: 'Verzeichnis',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCCatalogCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
type: SCThingType.Catalog,
},
};
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,21 +12,24 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicDegree} from '../base/AcademicDegree';
import {SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {SCAcademicDegree, SCAcademicDegreeMeta, SCAcademicDegreeWithoutReferences} from '../base/AcademicDegree';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage, SCTranslations} from '../types/i18n';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCDateSeriesWithoutReferences} from './DateSeries';
import {SCOrganization} from './Organization';
import {SCOrganizationWithoutReferences} from './Organization';
/**
* A course of studies without references
*/
export interface SCCourseOfStudiesWithoutReferences extends
SCAcademicDegree,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
export interface SCCourseOfStudiesWithoutReferences
extends SCAcademicDegreeWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* The main language in which the course of studies
* is beeing offered
@@ -64,71 +67,126 @@ export interface SCCourseOfStudiesWithoutReferences extends
*
* @validatable
*/
export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
export interface SCCourseOfStudies
extends SCCourseOfStudiesWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>, SCAcademicDegree {
/**
* The department that manages the course of studies
*/
department: SCOrganization;
department: SCOrganizationWithoutReferences;
/**
* The secretary that administers requests and
* The secretary that administers requests and
* questions concerning the course of studies
*/
secretary: SCOrganization;
secretary: SCOrganizationWithoutReferences;
/**
* Dates at which the course of studies is planned to start
*/
startDates?: SCDateSeriesWithoutReferences[];
/**
* Translated fields of a course of studies
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
/**
* Type of the course of studies
*/
type: SCThingType.CourseOfStudies;
}
/**
* Translatable properties of a course of studies
*/
export interface SCCourseOfStudiesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
extends SCThingThatCanBeOfferedTranslatableProperties {
// noop
}
/**
* course of studies meta data
* Meta information about a course of studies
*/
export class SCCourseOfStudiesMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
export class SCCourseOfStudiesMeta
extends SCThingMeta
implements SCMetaTranslations<SCCourseOfStudies> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
academicDegree: 'Hochschulabschluss',
...SCAcademicDegreeMeta.getInstance<SCAcademicDegreeMeta>()
.fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
department: 'Fachbereich',
mainLanguage: 'Unterrichtssprache',
major: 'Studienfach',
modes: 'Studiengangsarten',
mode: 'Studiengangsart',
secretary: 'Sekretariat',
startDates: 'Startdatum',
timeMode: 'Zeitmodell',
},
en: {
...SCAcademicDegreeMeta.getInstance<SCAcademicDegreeMeta>()
.fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
department: 'department',
mainLanguage: 'main language',
major: 'major',
mode: 'mode',
secretary: 'secretary',
startDates: 'start dates',
timeMode: 'time mode',
},
};
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
modes: {
combination: 'Kombinationsstudiengang',
dual: 'Dualer Studiengang',
'double-degree': 'Doppelstudium',
dual: 'duales Studium',
standard: 'Studium',
},
timeMode: {
fulltime: 'Vollzeitstudiengang',
parttime: 'Teilzeitstudiengang',
},
type: 'Studiengang',
},
en: {
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en,
modes: {
combination: 'combination course of studies',
'double-degree': 'double degree course of studies',
dual: 'dual course of studies',
standard: 'course of studies',
},
timeMode: {
fulltime: 'full-time',
parttime: 'part-time',
},
type: SCThingType.CourseOfStudies,
},
};
}
/**
* Types of (german) course of studies modes
*/
export type SCCourseOfStudiesMode = 'combination' |
'dual' |
'double-degree' |
'standard' ;
export type SCCourseOfStudiesMode = 'combination'
| 'dual'
| 'double-degree'
| 'standard' ;
/**
* Types of (german) course of studies time modes
*/
export type SCCourseOfStudiesTimeMode = 'fulltime' |
'parttime' ;
export type SCCourseOfStudiesTimeMode = 'fulltime'
| 'parttime' ;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,15 +12,17 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
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';
@@ -28,18 +30,19 @@ import {SCSportCourseWithoutReferences} from './SportCourse';
/**
* Price groups for sport courses
*/
export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup {
export interface SCSportCoursePriceGroup
extends SCAcademicPriceGroup {
/**
* Price for alumnis
*/
alumni: number;
alumni?: number;
}
/**
* A date without references
*/
export interface SCDateSeriesWithoutReferences
extends SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
extends SCThingThatCanBeOfferedWithoutReferences {
/**
* Dates of the date series that are initially planned to be held
*/
@@ -76,7 +79,10 @@ export interface SCDateSeriesWithoutReferences
*
* @validatable
*/
export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPlace {
export interface SCDateSeries
extends SCDateSeriesWithoutReferences,
SCThingInPlace,
SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
/**
* Event to which the date series belongs
*/
@@ -100,15 +106,58 @@ export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPl
}
/**
* Date series meta data
* Meta information about a date series
*/
export class SCDateSeriesMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
export class SCDateSeriesMeta
extends SCThingMeta
implements SCMetaTranslations<SCDateSeries> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldTranslations.de,
dates: 'Einzeltermine',
duration: 'Dauer',
frequency: 'Wiederholung',
event: 'Event',
exceptions: 'Ausnahmen',
frequency: 'Frequenz',
performers: 'Vortragende',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldTranslations.en,
dates: 'dates',
duration: 'duration',
event: 'event',
exceptions: 'exceptions',
frequency: 'frequency',
performers: 'performers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldValueTranslations.de,
type: 'Terminserie',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.DateSeries,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -14,13 +14,15 @@
*/
import * as jsonpatch from 'json-patch';
import {SCThingsWithoutDiff} from '../Classes';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/**
* A diff without references
*/
export interface SCDiffWithoutReferences extends SCThing {
export interface SCDiffWithoutReferences
extends SCThingWithoutReferences {
/**
* Action of the diff
*/
@@ -47,7 +49,8 @@ export interface SCDiffWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCDiff extends SCDiffWithoutReferences {
export interface SCDiff
extends SCDiffWithoutReferences, SCThing {
/**
* Original object the diff was generated on
*/
@@ -60,15 +63,46 @@ export interface SCDiff extends SCDiffWithoutReferences {
}
/**
* Diff meta data
* Meta information about a diff
*/
export class SCDiffMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
export class SCDiffMeta
extends SCThingMeta
implements SCMetaTranslations<SCDiff> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
action: 'Aktion',
changes: 'Änderungen',
dateCreated: 'Erstellungsdatum',
object: 'Objekt',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
action: 'action',
changes: 'changes',
dateCreated: 'date created',
object: 'object',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance().fieldValueTranslations.de,
action: {
'changed': 'geändert',
'removed': 'gelöscht',
},
type: 'Unterschied',
},
en: {
...SCThingMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Diff,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,27 +12,29 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCThingThatCanBeOfferedMeta} from './../base/ThingThatCanBeOffered';
/**
* A dish without references
*/
export interface SCDishWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCDishCategories,
SCThingWithCategoriesSpecificValues>,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
extends SCThingThatCanBeOfferedWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCDishCategories, SCThingWithCategoriesSpecificValues> {
/**
* Additives of the dish
*/
@@ -69,7 +71,9 @@ export interface SCDishWithoutReferences
*
* @validatable
*/
export interface SCDish extends SCDishWithoutReferences, SCThingInPlace {
export interface SCDish
extends SCDishWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>,
SCThingWithCategories<SCDishCategories, SCThingWithCategoriesSpecificValues> {
/**
* Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish)
*/
@@ -88,18 +92,10 @@ export interface SCDish extends SCDishWithoutReferences, SCThingInPlace {
export interface SCDishTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
}
/**
* Dish meta data
*/
export class SCDishMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
de: {
categories: 'Kategorien',
},
};
/**
* Characteristics of the dish
*/
characteristics?: SCDishCharacteristic[];
}
/**
@@ -107,7 +103,7 @@ export class SCDishMeta extends SCThingMeta {
*/
export interface SCDishCharacteristic {
/**
* URL to the image of the characteristic
* URL of an image of the characteristic
*/
image?: string;
@@ -121,7 +117,7 @@ export interface SCDishCharacteristic {
* A list of categories for dishes
*/
export type SCDishCategories =
'appetizer'
| 'appetizer'
| 'salad'
| 'main dish'
| 'dessert'
@@ -169,3 +165,72 @@ export interface SCNutritionInformation {
*/
sugarContent?: number;
}
/**
* Meta information about a dish
*/
export class SCDishMeta
extends SCThingMeta
implements SCMetaTranslations<SCDish> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCDishCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
additives: 'Zusatzstoffe',
characteristics: 'Merkmale',
dishAddOns: 'Beilagen',
nutrition: 'Nährwertangaben',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCDishCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.en,
additives: 'additives',
characteristics: 'characteristics',
dishAddOns: 'side dishes',
nutrition: 'nutrition information',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCDishCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
categories: {
appetizer: 'Vorspeise',
dessert: 'Nachtisch',
'main dish': 'Hauptgericht',
salad: 'Salat',
'side dish': 'Beilage',
soup: 'Suppe',
},
type: 'Essen',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCDishCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.Dish,
},
};
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCSaveableThing} from '../base/SaveableThing';
import {SCSaveableThing, SCSaveableThingWithoutReferences} from '../base/SaveableThing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCAcademicEventWithoutReferences} from './AcademicEvent';
import {SCArticleWithoutReferences} from './Article';
@@ -37,12 +37,21 @@ export type SCFavoriteDataTypes = SCAcademicEventWithoutReferences
| SCSportCourseWithoutReferences
| SCToDoWithoutReferences;
/**
* A favorite without references
*/
export interface SCFavoriteWithoutReferences
extends SCSaveableThingWithoutReferences {
// noop
}
/**
* A favorite
*
* @validatable
*/
export interface SCFavorite extends SCSaveableThing<SCFavoriteDataTypes> {
export interface SCFavorite
extends SCSaveableThing<SCFavoriteDataTypes>, SCFavoriteWithoutReferences {
/**
* Type of a favorite
*/
@@ -52,5 +61,6 @@ export interface SCFavorite extends SCSaveableThing<SCFavoriteDataTypes> {
/**
* Meta information about a favorite
*/
export class SCFavoriteMeta extends SCThingMeta {
export class SCFavoriteMeta
extends SCThingMeta {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -13,16 +13,17 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson';
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
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';
/**
* A floor without references
*/
export interface SCFloorWithoutReferences extends SCThing {
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.
*/
@@ -49,7 +50,8 @@ export interface SCFloorWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace {
export interface SCFloor
extends SCFloorWithoutReferences, SCThingInPlace {
/**
* Translated fields of a floor
*/
@@ -61,12 +63,6 @@ export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace {
type: SCThingType.Floor;
}
/**
* Meta information about a floor
*/
export class SCFloorMeta extends SCThingMeta {
}
/**
* A feature collection
*/
@@ -92,9 +88,51 @@ export interface SCFloorFeatureWithPlace<T extends GeometryObject, P = any>
/**
* Translatable properties of a floor
*/
export interface SCFloorTranslatableProperties extends SCThingTranslatableProperties {
export interface SCFloorTranslatableProperties
extends SCThingTranslatableProperties {
/**
* Translation of the floor name
*/
floorName?: string;
}
/**
* Meta information about floors
*/
export class SCFloorMeta
extends SCThingMeta
implements SCMetaTranslations<SCFloor> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
floorName: 'Etagenbezeichnung',
plan: 'Grundriss',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
floorName: 'floor name',
plan: 'plan',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.de,
type: 'Etage',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
type: SCThingType.Floor,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -14,18 +14,20 @@
*/
import {
SCCreativeWork,
SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork';
import {SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/**
* A message without references
*/
export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferences {
export interface SCMessageWithoutReferences
extends SCCreativeWorkWithoutReferences {
/**
* Audience of the message
*/
@@ -39,7 +41,7 @@ export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferen
/**
* Message itself
*/
message: string;
messageBody: string;
/**
* Translated fields of a message
@@ -57,7 +59,8 @@ export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferen
*
* @validatable
*/
export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences {
export interface SCMessage
extends SCCreativeWork, SCMessageWithoutReferences {
/**
* Translated fields of a message
*/
@@ -69,12 +72,6 @@ export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences {
type: SCThingType.Message;
}
/**
* Meta information about a message
*/
export class SCMessageMeta extends SCThingMeta {
}
/**
* Audiences for messages
*/
@@ -91,5 +88,53 @@ export interface SCMessageTranslatableProperties
/**
* Message itself
*/
message?: string;
messageBody?: string;
}
/**
* Meta information about messages
*/
export class SCMessageMeta
extends SCThingMeta
implements SCMetaTranslations<SCMessage> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
audiences: 'Zielgruppen',
dateCreated: 'Erstellungsdatum',
messageBody: 'Nachrichteninhalt',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
audiences: 'audiences',
dateCreated: 'date created',
messageBody: 'message body',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
audiences: {
'employees': 'Angestellte',
'guests': 'Gäste',
'students': 'Studenten',
},
type: 'Nachricht',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
type: SCThingType.Message,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,13 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* An organization without references
*/
export interface SCOrganizationWithoutReferences extends SCThing {
export interface SCOrganizationWithoutReferences
extends SCThingWithoutReferences {
/**
* Type of an organization
*/
@@ -30,7 +32,8 @@ export interface SCOrganizationWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCOrganization extends SCOrganizationWithoutReferences, SCThingInPlace {
export interface SCOrganization
extends SCOrganizationWithoutReferences, SCThingInPlace {
/**
* Type of an organization
*/
@@ -40,5 +43,31 @@ export interface SCOrganization extends SCOrganizationWithoutReferences, SCThing
/**
* Meta information about an organization
*/
export class SCOrganizationMeta extends SCThingMeta {
export class SCOrganizationMeta
extends SCThingMeta implements SCMetaTranslations<SCOrganization> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.de,
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldValueTranslations.de,
type: 'Einrichtung',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldValueTranslations.en,
type: SCThingType.Organization,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCNationality} from '../types/i18n';
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';
@@ -23,7 +23,8 @@ import {SCRoomWithoutReferences} from './Room';
/**
* A person without references
*/
export interface SCPersonWithoutReferences extends SCThing {
export interface SCPersonWithoutReferences
extends SCThingWithoutReferences {
/**
* Additional first names of the person.
*/
@@ -102,7 +103,8 @@ export interface SCPersonWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCPerson extends SCPersonWithoutReferences {
export interface SCPerson
extends SCPersonWithoutReferences, SCThing {
/**
* Organization the person works for
*/
@@ -129,7 +131,70 @@ export interface SCPerson extends SCPersonWithoutReferences {
/**
* Meta information about a person
*/
export class SCPersonMeta extends SCThingMeta {
export class SCPersonMeta
extends SCThingMeta
implements SCMetaTranslations<SCPerson> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
additionalName: 'Zusatzname',
affiliations: 'Zugehörigkeiten',
birthDate: 'Geburtsdatum',
email: 'E-Mail',
familyName: 'Nachname',
faxNumber: 'Faxnummer',
gender: 'Geschlecht',
givenName: 'Vorname',
homeLocations: 'Heimatstandorte',
honorificPrefix: 'Ehrentitel',
honorificSuffix: 'Ehrentitel (Suffix)',
jobTitles: 'Berufsbezeichnungen',
nationality: 'Staatsangehörigkeit',
telephone: 'Telefonnummer',
workLocations: 'Arbeitsorte',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
additionalName: 'additional name',
affiliations: 'affiliations',
birthDate: 'birth date',
email: 'email',
familyName: 'family name',
faxNumber: 'fax',
gender: 'gender',
givenName: 'given name',
homeLocations: 'home locations',
honorificPrefix: 'honorific title',
honorificSuffix: 'honorific title (suffix)',
jobTitles: 'job titles',
nationality: 'nationality',
telephone: 'telephone',
workLocations: 'work locations',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
gender: {
'female': 'weiblich',
'inter': 'divers',
'male': 'männlich',
'undefined': 'undefiniert',
},
type: 'Person',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
type: SCThingType.Person,
},
};
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,22 +12,23 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCPlaceWithoutReferences} from '../base/Place';
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* A point of interest without references
*/
export interface SCPointOfInterestWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>,
extends SCThingWithCategoriesWithoutReferences<SCPointOfInterestCategories, SCThingWithCategoriesSpecificValues>,
SCPlaceWithoutReferences {
/**
* Translated properties of a point of interest
@@ -45,7 +46,9 @@ export interface SCPointOfInterestWithoutReferences
*
* @validatable
*/
export interface SCPointOfInterest extends SCPointOfInterestWithoutReferences, SCThingInPlace {
export interface SCPointOfInterest
extends SCPointOfInterestWithoutReferences, SCThingInPlace, SCPlace,
SCThingWithCategories<SCPointOfInterestCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated properties of a point of interest
*/
@@ -68,7 +71,69 @@ export type SCPointOfInterestCategories =
| 'disabled access';
/**
* Meta data of a point of interest
* Meta information about points of interest
*/
export class SCPointOfInterestMeta extends SCThingMeta {
export class SCPointOfInterestMeta
extends SCThingMeta
implements SCMetaTranslations<SCPointOfInterest> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.de,
categories: {
'card charger': 'Kartenaufwerter',
'computer': 'Computer',
'disabled access': 'barrierefreier Zugang',
'printer': 'Drucker',
'validator': 'Validierer',
},
type: 'Sonderziel',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.en,
type: SCThingType.PointOfInterest,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,16 +12,23 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCPlaceWithoutReferences} from '../base/Place';
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThingThatAcceptsPaymentsWithoutReferences} from '../base/ThingThatAcceptsPayments';
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {
SCThingThatAcceptsPayments,
SCThingThatAcceptsPaymentsWithoutReferences,
SCThingThatAcceptsPaymentsWithoutReferencesMeta,
} from '../base/ThingThatAcceptsPayments';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCMap} from '../types/Map';
/**
@@ -29,15 +36,17 @@ import {SCMap} from '../types/Map';
*/
export type SCRoomCategories =
'cafe'
| 'canteen'
| 'computer'
| 'education'
| 'laboratory'
| 'learn'
| 'library'
| 'lounge'
| 'office'
| 'restaurant'
| 'canteen'
| 'student canteen'
| 'restroom'
| 'lounge'
| 'student canteen'
| 'student union';
/**
@@ -49,7 +58,7 @@ export interface SCRoomWithoutReferences
/**
* The name of the floor in which the room is in.
*/
floor?: string;
floorName?: string;
/**
* The inventory of the place/room as a list of items and their quantity.
@@ -74,7 +83,9 @@ export interface SCRoomWithoutReferences
*
* @validatable
*/
export interface SCRoom extends SCRoomWithoutReferences, SCThingInPlace {
export interface SCRoom
extends SCRoomWithoutReferences, SCThingInPlace, SCThingThatAcceptsPayments, SCPlace,
SCThingWithCategories<SCRoomCategories, SCRoomSpecificValues> {
/**
* Translations of specific values of the object
*
@@ -91,7 +102,8 @@ export interface SCRoom extends SCRoomWithoutReferences, SCThingInPlace {
/**
* Category specific values of a room
*/
export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValues {
export interface SCRoomSpecificValues
extends SCThingWithCategoriesSpecificValues {
/**
* Category specific opening hours of the room
*/
@@ -101,14 +113,70 @@ export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValue
/**
* Meta information about a place
*/
export class SCRoomMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
export class SCRoomMeta
extends SCThingMeta
implements SCMetaTranslations<SCRoom> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.de,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<
SCThingThatAcceptsPaymentsWithoutReferencesMeta
>().fieldTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCRoomCategories,
SCRoomSpecificValues
>().fieldTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
floorName: 'Etagenbezeichnung',
inventory: 'Bestand',
},
en: {
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldTranslations.en,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<
SCThingThatAcceptsPaymentsWithoutReferencesMeta
>().fieldTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCRoomCategories,
SCRoomSpecificValues
>().fieldTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
floorName: 'floor name',
inventory: 'inventory',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.de,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<
SCThingThatAcceptsPaymentsWithoutReferencesMeta
>().fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCRoomCategories,
SCRoomSpecificValues
>().fieldValueTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.de,
categories: {
'cafe': 'Café',
'canteen': 'Kantine',
'computer': 'PC-Pool',
'education': 'Bildung',
'laboratory': 'Labor',
'learn': 'Lernen',
'library': 'Bibliothek',
'lounge': 'Lounge',
@@ -118,6 +186,22 @@ export class SCRoomMeta extends SCThingMeta {
'student canteen': 'Mensa',
'student union': 'Studentenvereinigung',
},
type: 'Raum',
},
en: {
...SCPlaceWithoutReferencesMeta.getInstance<
SCPlaceWithoutReferencesMeta
>().fieldValueTranslations.en,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<
SCThingThatAcceptsPaymentsWithoutReferencesMeta
>().fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCRoomCategories,
SCRoomSpecificValues
>().fieldValueTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
type: SCThingType.Room,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,13 +12,19 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm';
import {
SCAcademicTerm,
SCAcademicTermWithoutReferences,
SCAcademicTermWithoutReferencesMeta,
} from '../base/AcademicTerm';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* A semester without references
*/
export interface SCSemesterWithoutReferences extends SCAcademicTermWithoutReferences {
export interface SCSemesterWithoutReferences
extends SCAcademicTermWithoutReferences {
/**
* The short name of the semester, using the given pattern.
*
@@ -37,7 +43,8 @@ export interface SCSemesterWithoutReferences extends SCAcademicTermWithoutRefere
*
* @validatable
*/
export interface SCSemester extends SCSemesterWithoutReferences {
export interface SCSemester
extends SCSemesterWithoutReferences, SCAcademicTerm {
/**
* Type of the semester
*/
@@ -45,17 +52,52 @@ export interface SCSemester extends SCSemesterWithoutReferences {
}
/**
* Semester meta data
* Meta information about a semester
*/
export class SCSemesterMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
export class SCSemesterMeta
extends SCThingMeta
implements SCMetaTranslations<SCSemester> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCAcademicTermWithoutReferencesMeta.getInstance<
SCAcademicTermWithoutReferencesMeta
>().fieldTranslations.de,
acronym: 'Abkürzung',
endDate: 'Ende',
eventsEndDate: 'Vorlesungsschluss',
eventsStartDate: 'Vorlesungsbeginn',
startDate: 'Beginn',
},
en: {
...SCAcademicTermWithoutReferencesMeta.getInstance<
SCAcademicTermWithoutReferencesMeta
>().fieldTranslations.en,
acronym: 'acronym',
endDate: 'end date',
eventsEndDate: 'semester ending',
eventsStartDate: 'semester beginning',
startDate: 'start date',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCAcademicTermWithoutReferencesMeta.getInstance<
SCAcademicTermWithoutReferencesMeta
>().fieldValueTranslations.de,
type: 'Semester',
},
en: {
...SCAcademicTermWithoutReferencesMeta.getInstance<
SCAcademicTermWithoutReferencesMeta
>().fieldValueTranslations.en,
type: SCThingType.Semester,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -13,25 +13,32 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
export type SCSettingCategories = string;
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* A setting without references
*/
export interface SCSettingWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
/**
* The type of input/value this setting is carrying
* Categories of a setting
*/
input: SCSettingInputType;
categories: SCSettingCategories[];
/**
* The default value of a setting
*/
defaultValue: SCSettingValue | SCSettingValues;
/**
* The input type of this setting
*/
inputType: SCSettingInputType;
/**
* The order number this setting should show up in its category list
*/
@@ -44,23 +51,48 @@ export interface SCSettingWithoutReferences
* The type of this model
*/
type: SCThingType.Setting;
/**
* The key of a value of a setting
*/
value?: SCSettingValue | SCSettingValues;
/**
* The possible values of a setting
*/
values?: SCSettingValues;
}
/**
* A list of categories for settings
*/
export type SCSettingCategories =
'profile'
| 'privacy'
| 'credentials'
| 'others';
/**
* The types of input/value a setting object can carry
*/
export type SCSettingInputType = SCSettingSingleChoice
| SCSettingMultipleChoice
| SCSettingNumber
| SCSettingText
| SCSettingPassword;
export enum SCSettingInputType {
SingleChoice = 'single choice',
MultipleChoice = 'multiple choice',
Number = 'number',
Text = 'text',
Password = 'password',
}
/**
* A setting with references
*
* @validatable
*/
export interface SCSetting extends SCSettingWithoutReferences {
export interface SCSetting
extends SCSettingWithoutReferences, SCThing,
SCThingWithCategories<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated fields of a setting
*/
translations?: SCTranslations<SCSettingValueTranslatableProperties>;
/**
* The type of this model
*/
@@ -68,65 +100,87 @@ export interface SCSetting extends SCSettingWithoutReferences {
}
/**
* Input type with single choice as value
* The type a value of a setting can have
*/
export interface SCSettingSingleChoice {
defaultValue: SCSettingValue;
inputType: 'singleChoice';
value?: SCSettingValue;
values: SCSettingValue[];
}
/**
* Input type with multiple choice as value
*/
export interface SCSettingMultipleChoice {
defaultValue: SCSettingValue[];
inputType: 'multipleChoice';
value?: SCSettingValue[];
values: SCSettingValue[];
}
export type SCSettingValue = string | number | boolean;
/**
* Input type with number as value
* The type of multiple values a setting can have
*/
export interface SCSettingNumber {
defaultValue: number;
inputType: 'number';
value?: number;
}
/**
* Input type with text as value
*/
export interface SCSettingText {
defaultValue: string;
inputType: 'text';
value?: string;
}
/**
* Input type with secret text (eq. password) as value
*/
export interface SCSettingPassword {
defaultValue: string;
inputType: 'password';
value?: string;
}
export type SCSettingValues = SCSettingValue[];
/**
* Translatable properties of a setting
*/
export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
/**
* The translations of the possible values of a setting
*/
values?: string[];
}
/**
* Meta information about a setting
* Meta information about settings
*/
export class SCSettingMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCSetting> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCSettingCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
defaultValue: 'Standard Wert',
inputType: 'Eingabetyp',
order: 'Position',
value: 'Wert',
values: 'Werte',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCSettingCategories,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
defaultValue: 'default value',
inputType: 'input type',
order: 'position',
value: 'value',
values: 'values',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCSettingCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.de,
categories: {
credentials: 'Anmeldedaten',
others: 'Andere',
privacy: 'Privatsphäre',
profile: 'Profil',
},
inputType: {
'multiple choice': 'mehrfach Auswahl',
number: 'Zahl',
password: 'Passwort',
'single choice': 'einfache Auswahl',
text: 'Text',
},
type: 'Einstellung',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
SCSettingCategories,
SCThingWithCategoriesSpecificValues
>().fieldValueTranslations.en,
type: SCThingType.Setting,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,13 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCEvent, SCEventWithoutReferences} from '../base/Event';
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* A sport course without references
*/
export interface SCSportCourseWithoutReferences extends SCEventWithoutReferences {
export interface SCSportCourseWithoutReferences
extends SCEventWithoutReferences {
/**
* Type of a sport course
*/
@@ -30,7 +32,8 @@ export interface SCSportCourseWithoutReferences extends SCEventWithoutReferences
*
* @validatable
*/
export interface SCSportCourse extends SCEvent, SCSportCourseWithoutReferences {
export interface SCSportCourse
extends SCEvent, SCSportCourseWithoutReferences {
/**
* Type of a sport course
*/
@@ -38,13 +41,34 @@ export interface SCSportCourse extends SCEvent, SCSportCourseWithoutReferences {
}
/**
* Sport course meta data
* Meta information about a sport course
*/
export class SCSportCourseMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
export class SCSportCourseMeta
extends SCThingMeta
implements SCMetaTranslations<SCSportCourse> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.de,
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.de,
type: 'Sportkurs',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.en,
type: SCThingType.SportCourse,
},
};
}

View File

@@ -0,0 +1,196 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
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';
/**
* A study module without references
*/
export interface SCStudyModuleWithoutReferences
extends SCThingThatCanBeOfferedWithoutReferences {
/**
* ECTS points (European Credit Transfer System)
*/
ects: number;
/**
* The language in which the study module is offered
*/
language: SCLanguage;
/**
* Majors that this study module is meant for
*/
majors: string[];
/**
* Represents the modules necessity for each given major (of the major property)
*/
necessity: SCMap<SCStudyModuleNecessity>;
/**
* Translated fields of a study module
*/
translations?: SCTranslations<SCStudyModuleTranslatableProperties>;
/**
* Type of the study module
*/
type: SCThingType.StudyModule;
}
/**
* A study module
*
* @validatable
*/
export interface SCStudyModule
extends SCStudyModuleWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* Academic events that make up a study module
*/
academicEvents: SCAcademicEventWithoutReferences[];
/**
* The faculty that manages and curates the study module
*/
faculty: SCOrganizationWithoutReferences;
/**
* Study modules needed for each others fulfillment
*/
partnerModules?: SCStudyModuleWithoutReferences[];
/**
* Study modules required beforehand
*/
requiredModules?: SCStudyModuleWithoutReferences[];
/**
* The secretary that administers requests and
* questions concerning the study module by eg. students
*/
secretary: SCOrganizationWithoutReferences | SCPersonWithoutReferences;
/**
* Translated fields of a study module
*/
translations?: SCTranslations<SCStudyModuleTranslatableProperties>;
/**
* Type of the study module
*/
type: SCThingType.StudyModule;
}
export interface SCStudyModuleTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
/**
* Translations of the majors that this study module is meant for
*/
majors?: string[];
/**
* Translations of the modules necessity for each given major (of the major property)
*/
necessity: SCMap<SCStudyModuleNecessity>;
}
/**
* Represents a modules necessity (in a major) as it may be required, optional or
* is in a pool of n optional modules were m out of them have to be taken/completed.
* Hence the elective option.
*/
export enum SCStudyModuleNecessity {
Required = 'required',
Elective = 'elective',
Optional = 'optional',
}
/**
* Study module meta data
*/
export class SCStudyModuleMeta
extends SCThingMeta
implements SCMetaTranslations<SCStudyModule> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
academicEvents: 'Veranstaltungen',
ects: 'ECTS-Punkte',
faculty: 'Fachbereich',
language: 'Unterrichtssprache',
majors: 'Fachrichtungen',
necessity: 'Erforderlichkeit',
partnerModules: 'Partnermodule',
requiredModules: 'Benötigte Module',
secretary: 'Sekretariat',
},
en: {
...SCThingMeta.getInstance().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.en,
academicEvents: 'academic events',
ects: 'ECTS points',
faculty: 'faculty',
language: 'teaching language',
majors: 'majors',
necessity: 'necessity',
partnerModules: 'partner modules',
requiredModules: 'required modules',
secretary: 'secretary',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
necessity: {
'elective': 'Wahlfach',
'optional': 'optional',
'required': 'benötigt',
},
type: 'Studiengangmodul',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.StudyModule,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,14 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
import {SCISO8601Duration} from '../types/Time';
/**
* A ticket without references
*/
export interface SCTicketWithoutReferences extends SCThing {
export interface SCTicketWithoutReferences
extends SCThingWithoutReferences {
/**
* Approximate wait time
*/
@@ -46,7 +48,8 @@ export interface SCTicketWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace {
export interface SCTicket
extends SCTicketWithoutReferences, SCThingInPlace {
/**
* Type of a ticket
*/
@@ -56,11 +59,42 @@ export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace {
/**
* Meta information about a ticket
*/
export class SCTicketMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
export class SCTicketMeta
extends SCThingMeta
implements SCMetaTranslations<SCTicket> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
approxWaitingTime: 'ungefähre Wartezeit',
currentTicketNumber: 'aktuelle Ticketnummer',
serviceType: 'Service Kategorie',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
approxWaitingTime: 'approximate waiting time',
currentTicketNumber: 'current ticket number',
serviceType: 'type of service',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.de,
type: 'Ticket',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
type: SCThingType.Ticket,
},
};
}

View File

@@ -12,8 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingWithCategoriesSpecificValues, SCThingWithCategoriesWithoutReferences} from '../base/ThingWithCategories';
import {SCThingType} from '../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';
/**
@@ -47,7 +54,17 @@ export interface SCToDoWithoutReferences
*
* @validatable
*/
export interface SCToDo extends SCToDoWithoutReferences {
export interface SCToDo
extends SCToDoWithoutReferences, SCThing, SCThingWithCategories<string, SCThingWithCategoriesSpecificValues> {
/**
* Translated fields of a thing with categories
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of the "to do"
*/
type: SCThingType.ToDo;
}
/**
@@ -58,3 +75,48 @@ export enum SCToDoPriority {
NORMAL = 2,
HIGH = 5,
}
/**
* Meta information about todo
*/
export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations<SCToDo> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
string,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.de,
done: 'Erledigt',
dueDate: 'Fälligkeitsdatum',
priority: 'Priorität',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<
string,
SCThingWithCategoriesSpecificValues
>().fieldTranslations.en,
done: 'done',
dueDate: 'due date',
priority: 'priority',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'ToDo',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.ToDo,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,12 +12,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* A tour without references
*/
export interface SCTourWithoutReferences extends SCThing {
export interface SCTourWithoutReferences
extends SCThingWithoutReferences {
/**
* Init script for the tour
*/
@@ -39,7 +41,8 @@ export interface SCTourWithoutReferences extends SCThing {
*
* @validatable
*/
export interface SCTour extends SCTourWithoutReferences {
export interface SCTour
extends SCTourWithoutReferences, SCThing {
/**
* Type of a tour
*/
@@ -49,7 +52,38 @@ export interface SCTour extends SCTourWithoutReferences {
/**
* Meta information about a tour
*/
export class SCTourMeta extends SCThingMeta {
export class SCTourMeta
extends SCThingMeta
implements SCMetaTranslations<SCTour> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
init: 'Initiales Skript',
steps: 'Schritte',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
init: 'initial script',
steps: 'steps',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
type: 'Tour',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
type: SCThingType.Tour,
},
};
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,16 +12,17 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCCreativeWork, SCCreativeWorkWithoutReferences} from '../base/CreativeWork';
import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkWithoutReferences} from '../base/CreativeWork';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage} from '../types/i18n';
import {SCLanguage, SCMetaTranslations} from '../types/i18n';
import {SCISO8601Duration} from '../types/Time';
import {SCPersonWithoutReferences} from './Person';
/**
* A video without references
*/
export interface SCVideoWithoutReferences extends SCCreativeWorkWithoutReferences {
export interface SCVideoWithoutReferences
extends SCCreativeWorkWithoutReferences {
/**
* The Duration of the Video
*/
@@ -102,7 +103,8 @@ export interface SCVideoTrack {
*
* @validatable
*/
export interface SCVideo extends SCCreativeWork, SCVideoWithoutReferences {
export interface SCVideo
extends SCCreativeWork, SCVideoWithoutReferences {
/**
* Persons acting in the Video
*/
@@ -114,19 +116,51 @@ export interface SCVideo extends SCCreativeWork, SCVideoWithoutReferences {
type: SCThingType.Video;
}
export class SCVideoMeta extends SCThingMeta {
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
/**
* Meta information about a video
*/
export class SCVideoMeta
extends SCThingMeta
implements SCMetaTranslations<SCVideo> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
actors: 'Darsteller',
duration: 'Länge',
height: 'Höhe',
language: 'Sprache',
size: 'Größe',
duration: 'Dauer',
sources: 'Quellen',
transcript: 'Abschrift',
thumbnails: 'Vorschaubilder',
tracks: 'Spuren',
transcript: 'Transkript',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
actors: 'actors',
duration: 'duration',
sources: 'sources',
thumbnails: 'thumbnails',
tracks: 'tracks',
transcript: 'transcript',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
type: 'Video',
width: 'Breite',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
type: SCThingType.Video,
},
};
}
@@ -145,7 +179,7 @@ export type SCVideoMimeType =
* Video Track Types
*/
export type SCVideoTrackTypes =
'captions'
'closed captions'
| 'chapters'
| 'description'
| 'metadata'

View File

@@ -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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,25 +12,39 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingWithTranslations} from '../base/ThingWithTranslations';
import {SCBulkResponse} from '../protocol/routes/bulk/BulkResponse';
import {SCMultiSearchResponse} from '../protocol/routes/search/MultiSearchResponse';
import {SCSearchResponse} from '../protocol/routes/search/SearchResponse';
import {SCThing} from '../Thing';
import {SCThing, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from '../Thing';
import {SCTranslations} from './i18n';
/**
* Type guard to check if something is a SCThing
*
* @param something Something to check
*/
export function isThing(something: any): something is SCThing {
return (
typeof something === 'object'
&& typeof something.type === 'string'
&& Object.values(SCThingType).indexOf(something.type) >= 0
);
}
/**
* Type guard to check if translations exist
*
* @param {SCThing} thing Thing to check
* @param thing Thing to check
*/
export function isThingWithTranslations(thing: SCThing): thing is SCThingWithTranslations {
export function isThingWithTranslations(thing: SCThingWithoutReferences)
: thing is SCThingWithoutReferences & { translations: SCTranslations<SCThingTranslatableProperties> } {
return typeof thing.translations !== 'undefined';
}
/**
* Type guard to check if something is a bulk response
*
* @param {any} something Something to check
* @param something Something to check
*/
export function isBulkResponse(something: any): something is SCBulkResponse {
return typeof something.expiration === 'string'
@@ -43,7 +57,7 @@ export function isBulkResponse(something: any): something is SCBulkResponse {
/**
* Type guard to check if something is a search response
*
* @param {any} something Something to check
* @param something Something to check
*/
export function isSearchResponse(something: any): something is SCSearchResponse {
return Array.isArray(something.data)
@@ -59,11 +73,10 @@ export function isSearchResponse(something: any): something is SCSearchResponse
/**
* Type guard to check if something is a multi search response
*
*
* @param something Something to check
*/
export function isMultiSearchResponse(something: any): something is SCMultiSearchResponse {
return Object.keys(something).reduce((previousOnesAreSearchResponses, key) => {
return previousOnesAreSearchResponses && isSearchResponse(something[key]);
}, true);
}, true as boolean);
}

View File

@@ -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.
@@ -15,10 +15,10 @@
/**
* Capsulation for a map with a string as key with values of type `T`
*
*
* !!! BEWARE !!!
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
*
*
* @typeparam T Can be any type.
*/
export interface SCMap<T> {
@@ -27,3 +27,20 @@ export interface SCMap<T> {
*/
[key: string]: T;
}
/**
* Restricted map with keys, limited to values of `U`, and corresponding values of type `T`
*
* !!! BEWARE !!!
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
* Also note, that this is a type not an interface
*
* @typeparam U Must be a type the `in` operator can be applied to and contains only strings or numbers
* @typeparam T Can be any type
*/
export type SCRestrictedMap<U extends string | number, T> = {
/**
* One value for each key
*/
[key in U]: T
};

32
src/core/types/Places.ts Normal file
View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
/**
* 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;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -15,7 +15,7 @@
import {SCThingType} from '../../Thing';
import {SCSearchSortType} from '../sorts/Abstract';
import {SCUuid} from '../UUID';
import {SCMap} from './../Map';
import {SCMap, SCRestrictedMap} from './../Map';
import {SCMonitoringConfiguration} from './Monitoring';
/**
@@ -30,6 +30,16 @@ export interface SCBackendConfiguration {
*/
hiddenTypes: SCThingType[];
/**
* Maximum number of queries, that can be used in MultiSearchRoute
*/
maxMultiSearchRouteQueries: number;
/**
* Maximum body size for requests
*/
maxRequestBodySize: number;
/**
* Name of university
*/
@@ -62,7 +72,7 @@ export interface SCBackendConfigurationSortableField {
/**
* A list of SC types on which this field exists
*
*
* If no type is given it is assumed it exists on every type
*/
onlyOnTypes?: SCThingType[];
@@ -75,22 +85,26 @@ export interface SCBackendConfigurationSortableField {
}
/**
* Values of a field that should be boosted by the given factors
* Possible context names to be used by the search request
*/
export interface SCBackendConfigurationSearchBoostingValues {
export type SCSearchContext =
| 'default'
| 'dining'
| 'place';
/**
* Value of the field that should be boosted by the given number
*
* For example `"SS 2019": 2`
*/
[valueOfField: string]: number;
}
/**
* A boosting configuration for one context
*/
export type SCBackendConfigurationSearchBoostingContext =
SCRestrictedMap<
SCSearchContext,
SCBackendConfigurationSearchBoostingType[]
>;
/**
* A boosting configuration for one SCType
*/
export interface SCBackendConfigurationSearchBoosting {
export interface SCBackendConfigurationSearchBoostingType {
/**
* The factor of which the scores matching this type should be multiplied by
@@ -98,11 +112,15 @@ export interface SCBackendConfigurationSearchBoosting {
factor: number;
/**
* Outer-Map:
* Fields of this type that should be boosted if they match a given value
*
* For nest fields you can use the `.` as a separator. For example `academicTerms.acronym`
*
* Inner-map:
* Value of the field that should be boosted by the given number
* For example `"SS 2019": 2`
*/
fields?: SCMap<SCBackendConfigurationSearchBoostingValues>;
fields?: SCMap<SCMap<number>>;
/**
* Type of things the factor should be applied to
@@ -142,7 +160,7 @@ export interface SCBackendInternalConfiguration {
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
* set of results
*/
boostings: SCBackendConfigurationSearchBoosting[];
boostings: SCBackendConfigurationSearchBoostingContext;
/**
* Configuration of the database
@@ -158,14 +176,10 @@ export interface SCBackendInternalConfiguration {
/**
* Configuration of the database
*/
export interface SCBackendConfigurationDatabaseConfiguration {
export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<any> {
/**
* Name of the database used by the backend
*/
name: string;
/**
* Allow additional configuration for the database
*/
[key: string]: any;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMap} from '../Map';
/**
* All available filter types
*/
@@ -47,9 +48,7 @@ export interface SCSearchAbstractFilter<T extends SCSearchAbstractFilterArgument
/**
* Arguments for the filter instruction
*/
export interface SCSearchAbstractFilterArguments {
[key: string]: any;
}
export type SCSearchAbstractFilterArguments = SCMap<any>;
/**
* Available filter instructions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -17,7 +17,7 @@
*/
export interface SCLanguage {
/**
* The Alpha-2 Code of the Language
* The two letter ISO 639-1 Code of the Language
*/
code: SCLanguageCode;
@@ -28,8 +28,8 @@ export interface SCLanguage {
}
/**
* A list of possible languages
*
* A list of possible languages in english
*
* @see https://en.wikipedia.org/wiki/ISO_639-1
*/
export type SCLanguageName =
@@ -220,7 +220,9 @@ export type SCLanguageName =
| 'zulu';
/**
* A List of all possible Languages as Alpha-2 Codes
* 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 =
'aa'
@@ -668,7 +670,7 @@ export type SCNationality =
/**
* Translations for specific languages
*
* @see https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
* @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
export interface SCTranslations<T> {
/**
@@ -681,3 +683,37 @@ export interface SCTranslations<T> {
*/
en?: T;
}
/**
* Type to represent requiredness of translation properties.
* Will be changed from RecursivePartial to RecursiveRequired in the future.
* (Source: https://stackoverflow.com/a/51365037)
*/
type RecursivePartial<T> = {
[P in keyof T]-?:
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
T[P] extends object ? RecursivePartial<T[P]> :
T[P];
};
/**
* Type to recursively map keys in <T> to a string value (used for translation)
*/
type SCRequiredTranslationKeys<T> = {
[key in keyof RecursivePartial<T>]: string;
};
/**
* Type that allows mapping from available keys of SCTranslations to SCRequiredTranslationKeys
*/
type SCRequiredTranslation<T> = {
[key in keyof SCTranslations<T>]: SCRequiredTranslationKeys<T>;
};
/**
* Interface to be implemented by all Meta classes
*/
export interface SCMetaTranslations<T> {
fieldTranslations: SCRequiredTranslation<T>;
fieldValueTranslations: any;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* 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.
@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingsField} from '../../Classes';
import {SCMap} from '../Map';
import {SCDistanceSort} from './Distance';
import {SCDucetSort} from './Ducet';
import {SCPriceSort} from './Price';
@@ -40,12 +41,7 @@ export interface SCSearchAbstractSort<T extends SCSearchAbstractSortArguments> {
/**
* Map of arguments for the sort instruction
*/
export interface SCSearchAbstractSortArguments {
/**
* Index signature for additional arguments
*/
[key: string]: any;
export interface SCSearchAbstractSortArguments extends SCMap<any> {
/**
* Field to sort by
*/

View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
import {validateFiles, writeReport} from '@openstapps/core-tools/lib/validate';
import {Logger} from '@openstapps/logger';
import {expect} from 'chai';
import {mkdirSync} from 'fs';
import {slow, suite, test, timeout} from 'mocha-typescript';
import {join, resolve} from 'path';
const logger = new Logger();
process.on('unhandledRejection', (err) => {
logger.error('UNHANDLED REJECTION', err.stack);
process.exit(1);
});
@suite(timeout(10000), slow(5000))
export class ValidateTestFiles {
@test
async validateTestFiles() {
const errorsPerFile = await validateFiles(resolve('lib', 'schema'), resolve('test', 'resources'));
let unexpected = false;
Object.keys(errorsPerFile).forEach((file) => {
unexpected = unexpected || errorsPerFile[file].some((error) => !error.expected);
});
expect(unexpected).to.be.equal(false);
mkdirSync('report', {
recursive: true,
});
await writeReport(join('report', 'index.html'), errorsPerFile);
}
}

57
test/Guards.spec.ts Normal file
View File

@@ -0,0 +1,57 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
import {expect} from 'chai';
import {slow, suite, test, timeout} from 'mocha-typescript';
import {SCThingOriginType, SCThingType} from '../src/core/Thing';
import {SCDish} from '../src/core/things/Dish';
import {isThing} from '../src/core/types/Guards';
@suite(timeout(10000), slow(5000))
export class GuardsSpec {
@test
public isThing() {
const notADish = {
categories: [
'appetizer',
],
name: 'foo',
origin: {
created: '',
type: SCThingOriginType.User,
},
type: 'foobar',
uid: 'bar',
};
const dish: SCDish = {
categories: [
'appetizer',
],
name: 'foo',
origin: {
created: '',
type: SCThingOriginType.User,
},
type: SCThingType.Dish,
uid: 'bar',
};
expect(isThing('foo')).to.be.equal(false);
expect(isThing(notADish)).to.be.equal(false);
expect(isThing(dish)).to.be.equal(true);
}
}

283
test/Schema.spec.ts Normal file
View File

@@ -0,0 +1,283 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
import {getProjectReflection} from '@openstapps/core-tools/lib/common';
import {validateFiles, writeReport} from '@openstapps/core-tools/lib/validate';
import {Logger} from '@openstapps/logger';
import {fail} from 'assert';
import {expect} from 'chai';
import {mkdirSync} from 'fs';
import {slow, suite, test, timeout} from 'mocha-typescript';
import {join, resolve} from 'path';
import {DeclarationReflection, ProjectReflection} from 'typedoc';
import {ArrayType, IntrinsicType, ReferenceType, StringLiteralType, Type, UnionType} from 'typedoc/dist/lib/models';
process.on('unhandledRejection', (err) => {
Logger.error('UNHANDLED REJECTION', err.stack);
process.exit(1);
});
/**
* Check if type is a union type
*
* @param type Type to check
*/
function isUnionType(type: Type): type is UnionType {
return type.type === 'union';
}
/**
* Check if a type is reference type
*
* @param type Type to check
*/
function isReferenceType(type: Type): type is ReferenceType {
return type.type === 'reference';
}
/**
* Check if a type is an array type
*
* @param type Type to check
*/
function isArrayType(type: Type): type is ArrayType {
return type.type === 'array';
}
/**
* Check if a type is an intrinsic type
*
* @param type Type to check
*/
function isIntrinsicType(type: Type): type is IntrinsicType {
return type.type === 'intrinsic';
}
/**
* Check if a type is a string literal type
*
* @param type Type to check
*/
function isStringLiteralType(type: Type): type is StringLiteralType {
return type.type === 'stringLiteral';
}
/**
* Get extended types of a declaration reflection
* @param thingReflection Reflection of the thing
* @param objects Map of reflections by name
*/
function getExtendedTypes(thingReflection: DeclarationReflection,
objects: { [name: string]: DeclarationReflection }): string[] {
const extendedTypes: string[] = [];
if (Array.isArray(thingReflection.extendedTypes)) {
const typesToCheck = thingReflection.extendedTypes.slice();
while (typesToCheck.length > 0) {
const extendedType = typesToCheck.splice(0, 1)[0];
extendedTypes.push((extendedType as unknown as ReferenceType).name);
const extendedObject = objects[(extendedType as unknown as ReferenceType).name];
if (typeof extendedObject !== 'undefined') {
if (Array.isArray(extendedObject.extendedTypes)) {
typesToCheck.push.apply(typesToCheck, extendedObject.extendedTypes);
}
}
}
}
return extendedTypes;
}
@suite(timeout(10000), slow(5000))
export class SchemaSpec {
static objects: { [name: string]: DeclarationReflection } = {};
static reflection: ProjectReflection;
static thingNames: string[];
static before() {
SchemaSpec.reflection = getProjectReflection(resolve(__dirname, '..', 'src'));
if (Array.isArray(SchemaSpec.reflection.children)) {
for (const module of SchemaSpec.reflection.children) {
if (Array.isArray(module.children)) {
for (const object of module.children) {
SchemaSpec.objects[object.name] = object;
}
}
}
}
const thingsReflection = SchemaSpec.objects.SCThingsWithoutDiff;
// tslint:disable-next-line:no-unused-expression
expect(thingsReflection).not.to.be.undefined;
// tslint:disable-next-line:no-unused-expression
expect(isUnionType(thingsReflection.type!)).to.be.true;
(thingsReflection.type! as UnionType).types.push({
'id': 0,
'name': 'SCDiff',
'type': 'reference',
} as unknown as ReferenceType);
// tslint:disable-next-line:no-unused-expression
expect((thingsReflection.type! as UnionType).types.every(isReferenceType)).to.be.true;
SchemaSpec.thingNames = (thingsReflection.type! as UnionType).types.map((type) => {
return (type as ReferenceType).name;
});
}
@test
'all things have an origin'() {
for (const thingName of SchemaSpec.thingNames) {
const thingReflection = SchemaSpec.objects[`${thingName}`];
let originFound = false;
if (Array.isArray(thingReflection.children)) {
for (const property of thingReflection.children) {
if (property.name === 'origin') {
originFound = true;
break;
}
}
}
// tslint:disable-next-line:no-unused-expression
expect(originFound).to.be.equal(true, `'${thingName}' must have property 'origin'.`);
}
}
@test
'does not have duplicate names'() {
const names: string[] = [];
if (Array.isArray(SchemaSpec.reflection.children)) {
for (const module of SchemaSpec.reflection.children) {
if (Array.isArray(module.children)) {
for (const object of module.children) {
expect(names).not.to.contain(object.name);
names.push(object.name);
}
}
}
}
}
@test
'no property is an SCThing'() {
for (const thingName of SchemaSpec.thingNames) {
const thingReflection = SchemaSpec.objects[`${thingName}`];
if (Array.isArray(thingReflection.children)) {
for (const property of thingReflection.children) {
if (typeof property.type === 'undefined') {
Logger.error(thingName, property.name);
continue;
}
const type = property.type!;
if (isIntrinsicType(type)) {
continue;
} else if (isArrayType(type)) {
const elementType = type.elementType;
if (isIntrinsicType(elementType)) {
continue;
} else if (isReferenceType(elementType)) {
expect(SchemaSpec.thingNames).not.to.contain(
elementType.name,
`Array property '${property.name}' on type '${thingName}' has element type '${elementType.name}'.`,
);
} else {
// tslint:disable-next-line:max-line-length
fail(`'${thingName}'#'${property.name}' element type '${elementType.type}' is not handled by this test!`);
}
} else if (isReferenceType(type)) {
expect(SchemaSpec.thingNames).not.to.contain(
type.name,
`Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`,
);
} else if (isUnionType(type)) {
for (const nestedType of type.types) {
if (isIntrinsicType(nestedType) || isStringLiteralType(nestedType)) {
continue;
} else if (isReferenceType(nestedType)) {
expect(SchemaSpec.thingNames).not.to.contain(
nestedType.name,
`Union property '${property.name}' on type '${thingName}' contains type '${nestedType.name}'.`,
);
} else {
// tslint:disable-next-line:max-line-length
fail(`'${thingName}'#'${property.name}' union type '${nestedType.type}' is not handled by this test!`);
}
}
} else {
// tslint:disable-next-line:max-line-length
fail(`'${thingName}'#'${property.name}' with type '${type.type}' is not handled by this test!`);
}
}
}
}
}
@test
'things extend SCThing'() {
for (const thingName of SchemaSpec.thingNames) {
const thingReflection = SchemaSpec.objects[`${thingName}`];
expect(getExtendedTypes(thingReflection, SchemaSpec.objects)).to.contain(
'SCThing',
`'${thingName}' neither extends 'SCThing' transitively nor directly.`,
);
}
}
@test
'things without references do not extend SCThing'() {
for (const thingName of SchemaSpec.thingNames) {
const thingWithoutReferencesReflection = SchemaSpec.objects[`${thingName}WithoutReferences`];
expect(getExtendedTypes(thingWithoutReferencesReflection, SchemaSpec.objects)).not.to.contain(
'SCThing',
`'${thingName}WithoutReferences' extends 'SCThing' either transitively or directly.`,
);
}
}
@test
async 'validate against test files'() {
const errorsPerFile = await validateFiles(resolve('lib', 'schema'), resolve('test', 'resources'));
let unexpected = false;
Object.keys(errorsPerFile).forEach((file) => {
unexpected = unexpected || errorsPerFile[file].some((error) => !error.expected);
});
mkdirSync('report', {
recursive: true,
});
await writeReport(join('report', 'index.html'), errorsPerFile);
expect(unexpected).to.be.equal(false);
}
}

253
test/Translator.spec.ts Normal file
View File

@@ -0,0 +1,253 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
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';
const building: SCBuildingWithoutReferences = {
address: {
addressCountry : 'base-address.addressCountry',
addressLocality: 'base-address.addressLocality',
postalCode: 'base-address.postalCode',
streetAddress: 'base-address.streetAddress',
},
categories: ['office', 'education'],
floors: ['base-floor0', 'base-floor1'],
geo: {
point: {
coordinates: [12.0, 13.0],
type: 'Point',
},
},
name: 'base-space-name',
translations: {
de: {
address: {
addressCountry : 'de-address.addressCountry',
addressLocality: 'de-address.addressLocality',
postalCode: 'de-address.postalCode',
streetAddress: 'de-address.streetAddress',
},
floors: ['de-floor0', 'de-floor1'],
name: 'de-space-name',
},
},
type: SCThingType.Building,
uid: '540862f3-ea30-5b8f-8678-56b4dc217140',
};
const dish: SCDish = {
categories: ['main dish', 'dessert'],
characteristics: [{name: 'base-characteristic0'}, {name: 'base-characteristic1'}],
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',
},
},
],
origin: {
indexed: '1970-01-01T00:00:00.000Z',
name: 'dish-connector',
type: SCThingOriginType.Remote,
},
translations: {
de: {
characteristics: [{name: 'de-characteristic0'}, {name: 'de-characteristic1'}],
name: 'de-dish-name',
},
},
type: SCThingType.Dish,
uid: '540862f3-ea30-5b8f-8678-56b4dc217140',
};
const translator = new SCThingTranslator('de');
// tslint:disable-next-line:no-eval
const languageNonExistant = eval("'jp'");
// this will simulate a translator always utilizing the base language translations
const translatorWithFallback = new SCThingTranslator(languageNonExistant);
// tslint:disable:member-ordering TranslationSpecInplace
@suite(timeout(10000), slow(5000))
export class TranslationSpecInplace {
@test
public directStringLiteralType() {
expect(translator.translate(dish).type()).to.equal('Essen');
}
@test
public directStringProperty() {
expect(translator.translate(dish).name()).to.equal('de-dish-name');
}
@test
public directArrayOfString() {
expect(translator.translate(dish).characteristics()).to.deep
.equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]);
}
@test
public directArrayOfStringSubscript() {
expect(translator.translate(dish).characteristics[1]()).to.deep.equal({name: 'de-characteristic1'});
}
@test
public directMetaArrayOfString() {
expect(translator.translate(dish).categories()).to.deep.equal(['Hauptgericht', 'Nachtisch']);
}
@test
public directMetaArrayOfStringSubscript() {
expect(translator.translate(dish).categories[1]()).to.equal('Nachtisch');
}
@test
public nestedStringLiteralType() {
expect(translator.translate(dish).offers[0].inPlace.type()).to.equal('Gebäude');
}
@test
public nestedStringProperty() {
expect(translator.translate(dish).offers[0].inPlace.name()).to.equal('de-space-name');
}
@test
public nestedMetaArrayOfString() {
expect(translator.translate(dish).offers[0].inPlace.categories()).to.deep.equal(['Büro', 'Bildung']);
}
@test
public nestedMetaArrayOfStringSubscript() {
expect(translator.translate(dish).offers[0].inPlace.categories[1]()).to.equal('Bildung');
}
@test
public directStringLiteralTypeFallback() {
expect(translatorWithFallback.translate(dish).type()).to.equal('dish');
}
@test
public directStringPropertyFallback() {
expect(translatorWithFallback.translate(dish).name()).to.equal('base-dish-name');
}
@test
public directArrayOfStringSubscriptFallback() {
expect(translatorWithFallback.translate(dish).characteristics[1]())
.to.deep.equal({name: 'base-characteristic1'});
}
@test
public directMetaArrayOfStringFallback() {
expect(translatorWithFallback.translate(dish).categories()).to.deep.equal(['main dish', 'dessert']);
}
@test
public directMetaArrayOfStringSubscriptFallback() {
expect(translatorWithFallback.translate(dish).categories[1]()).to.equal('dessert');
}
@test
public nestedStringLiteralTypeFallback() {
expect(translatorWithFallback.translate(dish).offers[0].inPlace.type()).to.equal('building');
}
@test
public nestedStringPropertyFallback() {
expect(translatorWithFallback.translate(dish).offers[0].inPlace.name()).to.equal('base-space-name');
}
@test
public nestedMetaArrayOfStringFallback() {
expect(translatorWithFallback.translate(dish).offers[0].inPlace.categories())
.to.deep.equal(['office', 'education']);
}
@test
public nestedMetaArrayOfStringSubscriptFallback() {
expect(translatorWithFallback.translate(dish).offers[0].inPlace.categories[1]()).to.equal('education');
}
@test
public directStringLiteralTypeUndefined() {
// tslint:disable-next-line:no-eval
const undefinedThing = eval('(x) => undefined;');
expect(translator.translate(undefinedThing())('defaultValue')).to.equal('defaultValue');
expect(translator.translate(dish).name('defaultValue')).to.not.equal('defaultValue');
}
@test
public nestedMetaArrayOfStringSubscriptUndefined() {
expect(translator.translate(dish).offers[0].inPlace.categories[1234]('printer')).to.equal('printer');
expect(translator.translate(dish).offers[0].inPlace.categories[1]('printer')).to.not.equal('printer');
}
@test
public changingTranslatorLanguageFlushesItsLRUCache() {
const translatorDE = new SCThingTranslator('de');
expect(translatorDE.translate(dish).name()).to.equal('de-dish-name');
translatorDE.language = 'en';
expect(translatorDE.translate(dish).name()).to.equal('base-dish-name');
}
@test
public forceTranslatorLRUCacheToOverflow() {
const translatorDE = new SCThingTranslator('de');
// Make sure to add more elements to the translator cache than the maximum cache capacity. See Translator.ts
for (let i = 0; i < 201; i++) {
const anotherDish = Object.assign({}, dish);
anotherDish.uid = String(i);
expect(translatorDE.translate(anotherDish).name()).to.equal('de-dish-name');
}
}
}
// tslint:disable:member-ordering no-eval no-unused-expression TranslationSpec
@suite(timeout(10000), slow(5000))
export class MetaTranslationSpec {
@test
public consistencyWithMetaClass() {
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, 'en');
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
}
@test
public thingWithoutMetaClass() {
const dishCopy = clone(dish);
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
// this will assign a non existant SCThingType to dishCopy
dishCopy.type = typeNonExistant();
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy);
expect(dishMetaTranslationsDE).to.be.undefined;
}
}

View File

@@ -3,7 +3,7 @@
"instance": {
"type": "academic event",
"description": "Fortsetzung der Algebra I: Galoistheorie mit Anwendungen, ausgewählte Spezialthemen.",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "681a59a1-23c2-5d78-861a-8c86a3abf2b9",
"name": "Algebra II",
"categories": [
"lecture"
@@ -20,28 +20,18 @@
"startDate": "2018-04-01",
"endDate": "2018-09-30",
"eventsStartDate": "2018-04-09",
"eventsEndDate": "2018-07-13",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"eventsEndDate": "2018-07-13"
}
],
"performers": [
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "7f8ce700-2679-51a5-86b5-3dfba85a33ff",
"givenName": "Peter",
"familyName": "Bürgisser",
"gender": "male",
"honorificPrefix": "Prof. Dr.",
"name": "Peter Bürgisser",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Peter Bürgisser"
}
],
"majors": [
@@ -59,28 +49,18 @@
"maintainer": {
"type": "organization",
"name": "tubIT",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"uid": "25f76840-db89-5da2-a8a2-75992f637613"
},
"modified": "2018-09-01T10:00:00Z",
"originalId": "foo bar",
"responsibleEntity": {
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "7f8ce700-2679-51a5-86b5-3dfba85a33ff",
"givenName": "Peter",
"familyName": "Bürgisser",
"gender": "male",
"honorificPrefix": "Prof. Dr.",
"name": "Peter Bürgisser",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Peter Bürgisser"
}
}
},

View File

@@ -3,7 +3,7 @@
"instance": {
"type": "academic event",
"description": "Grundlagen, algebraische Grundbegriffe, Vektorräume, lineare Abbildungen und Gleichungen, Determinanten",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "b17eb963-42b5-5861-adce-2b7b2607ef0a",
"name": "Lineare Algebra I für Mathematiker",
"categories": [
"lecture"
@@ -20,28 +20,18 @@
"startDate": "2018-04-01",
"endDate": "2018-09-30",
"eventsStartDate": "2018-04-09",
"eventsEndDate": "2018-07-13",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"eventsEndDate": "2018-07-13"
}
],
"performers": [
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "fc8b10cf-10c0-5b92-b16e-92ff734676da",
"givenName": "Jörg",
"familyName": "Liesen",
"gender": "male",
"honorificPrefix": "Prof. Dr.",
"name": "Jörg Liesen",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Jörg Liesen"
}
],
"catalogs": [
@@ -53,12 +43,7 @@
"categories": [
"university events"
],
"name": "Mathematik: Lehrveranstaltungen für andere Fachrichtungen (Service)",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Mathematik: Lehrveranstaltungen für andere Fachrichtungen (Service)"
}
],
"majors": [

View File

@@ -1,9 +1,9 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "academic event",
"description": "Die Übung hat 2 SWS und wird auf 2 Gruppen verteilt.",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "7e2b64b0-925d-5f63-b464-a6e3e9492411",
"name": "Algebra II",
"categories": [
"tutorial"
@@ -20,40 +20,25 @@
"startDate": "2018-04-01",
"endDate": "2018-09-30",
"eventsStartDate": "2018-04-09",
"eventsEndDate": "2018-07-13",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"eventsEndDate": "2018-07-13"
}
],
"performers": [
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "97be73c0-5319-579a-a393-c4eeeacae58b",
"givenName": "Paul",
"familyName": "Breiding",
"gender": "male",
"name": "Paul Breiding",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Paul Breiding"
},
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "0db9b55a-4c27-5faf-9bf0-4b564be45a08",
"givenName": "Pierre",
"familyName": "Lairez",
"gender": "male",
"name": "Pierre Lairez",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Pierre Lairez"
}
],
"catalogs": [
@@ -64,12 +49,7 @@
"categories": [
"university events"
],
"name": "Mathematik: Grundstudiums-Veranstaltungen (Diplom, Bachelor)",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Mathematik: Grundstudiums-Veranstaltungen (Diplom, Bachelor)"
},
{
"uid": "5a1f4f51-2498-5af1-91cb-c939673cc69c",
@@ -79,12 +59,7 @@
"categories": [
"university events"
],
"name": "Mathematik: Lehrveranstaltungen für andere Fachrichtungen (Service)",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Mathematik: Lehrveranstaltungen für andere Fachrichtungen (Service)"
}
],
"majors": [

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"instance": {
"uid": "8d8bd89c-8429-5f81-b754-15a5be55e593",
"type": "article",
"categories": [
"unipedia"

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"instance": {
"uid": "4f772b29-0b28-53a4-a8b9-206d9b425962",
"type": "article",
"categories": [
"unipedia"

View File

@@ -1,34 +1,24 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "book",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "a0520263-29ae-5357-a3ce-ba1902d121e0",
"name": "Kundenorientierung durch Quality Function Deployment: Systematisches Entwickeln von Produkten und Dienstleistungen",
"authors": [
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "10dfe386-71b4-554a-beb1-2d38561e42f8",
"name": "Jutta Saatweber",
"givenName": "Jutta",
"familyName": "Saatweber",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"familyName": "Saatweber"
}
],
"datePublished": "2007-08-01",
"publishers": [
{
"type": "organization",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"name": "Symposion Publishing",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"uid": "28df2bb9-c854-5898-b9d5-1abbd3524804",
"name": "Symposion Publishing"
}
],
"inLanguages": [

View File

@@ -1,21 +1,16 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "book",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "db47f7f4-7699-5a37-afcc-24beaa998d36",
"name": "Minimal Book",
"authors": [
{
"type": "person",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "10dfe386-71b4-554a-beb1-2d38561e42f8",
"name": "Jutta Saatweber",
"givenName": "Jutta",
"familyName": "Saatweber",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"familyName": "Saatweber"
}
],
"datePublished": "2007-08-01",

View File

@@ -1,6 +1,6 @@
{
"errorNames": [],
"instance": {
"instance": {
"geo": {
"point": {
"type": "Point",
@@ -150,7 +150,7 @@
"alternateNames": [
"MA"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "edfaba58-254f-5da0-82d6-3b46a76c48ce",
"categories": [
"education"
],

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "64bb29ed-21e5-50c7-9d7c-1dc4741001b9",
"instance": {
"uid": "c8dc1f7f-9e3e-5b1f-8c38-084f46413b87",
"type": "catalog",
"level": 1,
"categories": [
@@ -17,12 +17,7 @@
"WiSe 2017/18"
],
"startDate": "2017-10-01",
"endDate": "2018-03-31",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"endDate": "2018-03-31"
},
"superCatalog": {
"type": "catalog",
@@ -31,12 +26,7 @@
"university events"
],
"uid": "a7404d36-282d-546e-bfa5-6c7b25ba7838",
"name": "Vorlesungsverzeichnis WS 2017/18",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Vorlesungsverzeichnis WS 2017/18"
},
"superCatalogs": [
{
@@ -46,12 +36,7 @@
"university events"
],
"uid": "a7404d36-282d-546e-bfa5-6c7b25ba7838",
"name": "Vorlesungsverzeichnis WS 2017/18",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Vorlesungsverzeichnis WS 2017/18"
}
],
"origin": {

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "5a1f4f51-2498-5af1-91cb-c939673cc69c",
"instance": {
"uid": "5a8bc725-8658-528f-b515-5f7cd6987169",
"type": "catalog",
"level": 3,
"description": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
@@ -18,12 +18,7 @@
"WiSe 2017/18"
],
"startDate": "2017-10-01",
"endDate": "2018-03-31",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"endDate": "2018-03-31"
},
"superCatalog": {
"uid": "2fdcccce-1948-5f5a-8938-3711b7e65e8a",
@@ -32,12 +27,7 @@
"categories": [
"university events"
],
"name": "Mathematik",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Mathematik"
},
"superCatalogs": [
{
@@ -47,12 +37,7 @@
"university events"
],
"uid": "a7404d36-282d-546e-bfa5-6c7b25ba7838",
"name": "Vorlesungsverzeichnis WS 2017",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Vorlesungsverzeichnis WS 2017"
},
{
"uid": "0718211b-d0c2-50fb-bc78-b968f20fd95b",
@@ -61,12 +46,7 @@
"categories": [
"university events"
],
"name": "Fakultät II Mathematik und Naturwissenschaften",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Fakultät II Mathematik und Naturwissenschaften"
},
{
"uid": "2fdcccce-1948-5f5a-8938-3711b7e65e8a",
@@ -75,12 +55,7 @@
"categories": [
"university events"
],
"name": "Mathematik",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"name": "Mathematik"
}
],
"origin": {

View File

@@ -1,18 +1,13 @@
{
"errorNames": [],
"instance": {
"instance": {
"academicDegree": "bachelor",
"academicDegreewithField": "Bachelor of Arts",
"academicDegreewithFieldShort": "B.A.",
"department": {
"name": "Technische Universität Berlin",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "organization",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140"
"uid": "b0f878fd-8fda-53b8-b065-a8d854c3d0d2"
},
"mainLanguage": {
"code": "de",
@@ -28,17 +23,12 @@
},
"secretary": {
"name": "Technische Universität Berlin",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "organization",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140"
"uid": "b0f878fd-8fda-53b8-b065-a8d854c3d0d2"
},
"timeMode": "parttime",
"type": "course of studies",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140"
"uid": "4c6f0a18-343d-5175-9fb1-62d28545c2aa"
},
"schema": "SCCourseOfStudies"
}

View File

@@ -1,8 +1,8 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "date series",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "1b421872-1b4c-579b-ba03-688f943d59ad",
"name": "Einführung in die Wirtschaftspolitik",
"duration": "PT2H",
"inPlace": {
@@ -10,7 +10,7 @@
"categories": [
"education"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "5a4bbced-8e1f-5f29-a1d1-336e455ce7f9",
"name": "H 0105",
"geo": {
"point": {
@@ -20,11 +20,6 @@
52.51211
]
}
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
},
"frequency": "once",
@@ -33,7 +28,7 @@
],
"event": {
"type": "academic event",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "dbb4e5e1-0789-59c1-9970-877430af56b3",
"name": "Einführung in die Wirtschaftspolitik",
"categories": [
"written exam"
@@ -41,12 +36,7 @@
"majors": [
"Economics BSc",
"Wirtschaftsingenieurwesen BSc"
],
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
]
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",

View File

@@ -1,8 +1,8 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "date series",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "4ce41895-4b54-52db-b86f-7e6920b975c8",
"name": "Distributed Algorithms",
"duration": "PT4H",
"inPlace": {
@@ -19,14 +19,9 @@
"categories": [
"education"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "b535c86a-777b-54c3-b89a-cad528d0580f",
"name": "EMH 225",
"floor": "2",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
"floorName": "2"
},
"frequency": "once",
"dates": [
@@ -34,16 +29,11 @@
],
"event": {
"type": "academic event",
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "e6fb74d4-c6d9-59bb-930f-e47eb6e39432",
"name": "Distributed Algorithms",
"categories": [
"written exam"
],
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
]
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",

View File

@@ -0,0 +1,62 @@
{
"errorNames": [],
"instance": {
"type": "date series",
"uid": "e6462830-187a-50b1-bdb4-8f39e49a88b8",
"name": "Dance course for beginners",
"duration": "PT8H",
"inPlace": {
"geo": {
"point": {
"type": "Point",
"coordinates": [
13.3266207,
52.5144409
]
}
},
"type": "room",
"categories": [
"student union"
],
"uid": "b535c86a-777b-54c3-b89a-cad528d0580f",
"name": "EMH 225",
"floorName": "2"
},
"frequency": "once",
"dates": [
"2016-04-12T11:00:00+00:00"
],
"event": {
"type": "academic event",
"uid": "4f86e8bb-ce73-520b-bfd9-e1ba9f754391",
"name": "Dance course for beginners",
"categories": [
"special"
]
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"offers": [
{
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"prices": {
"default": 6.5,
"student": 5,
"alumni": 5
},
"provider": {
"name": "Studentenwerk",
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
}
}
]
},
"schema": "SCDateSeries"
}

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"instance": {
"uid": "a5acde0d-18c4-5511-9f86-aabf2a530f91",
"dateCreated": "2017-02-07T09:26:35.957Z",
"name": "changed_testuid",
"changes": [
@@ -14,10 +14,10 @@
"action": "changed",
"type": "diff",
"object": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "072db1e5-e479-5040-88e0-4a98d731e443",
"name": "Name One",
"type": "message",
"message": "Message",
"messageBody": "Message",
"audiences": [
"students"
],

View File

@@ -1,7 +1,7 @@
{
"errorNames": [],
"instance": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"instance": {
"uid": "f71cc2c8-fef2-59ee-af0a-511cc75e7471",
"dateCreated": "2017-03-07T09:26:35.957Z",
"name": "changed_testuid",
"changes": [
@@ -14,10 +14,10 @@
"action": "changed",
"type": "diff",
"object": {
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "072db1e5-e479-5040-88e0-4a98d731e443",
"name": "Name One",
"type": "message",
"message": "Message",
"messageBody": "Message",
"audiences": [
"students"
],

View File

@@ -1,6 +1,6 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "dish",
"name": "Pizza mit Geflügelsalami und Champignons",
"categories": [
@@ -21,12 +21,18 @@
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"price": 2.85,
"prices": {
"default": 4.85,
"student": 2.85,
"employee": 2.85
"employee": 3.85,
"guest": 4.85
},
"provider": {
"name": "Studentenwerk",
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"inPlace": {
"geo": {
"point": {
"type": "Point",
@@ -45,23 +51,18 @@
"alternateNames": [
"MensaHardenberg"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "72fbc8a3-ebd1-58f9-9526-ad65cba2e402",
"address": {
"addressCountry": "Germany",
"addressLocality": "Berlin",
"addressRegion": "Berlin",
"postalCode": "10623",
"streetAddress": "Hardenbergstraße 34"
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
}
}
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "c9f32915-8ed5-5960-b850-3f7375a89922",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",

View File

@@ -1,6 +1,6 @@
{
"errorNames": [],
"instance": {
"instance": {
"type": "dish",
"name": "Sahne-Bärlauchsauce",
"description": "Nudelauswahl",
@@ -9,15 +9,20 @@
],
"offers": [
{
"price": 2.45,
"prices": {
"default": 3.45,
"student": 2.45,
"employee": 2.45
"employee": 3.45
},
"provider": {
"name": "Studentenwerk",
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"provider": {
"inPlace": {
"geo": {
"point": {
"type": "Point",
@@ -36,18 +41,13 @@
"alternateNames": [
"MensaHardenberg"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "072db1e5-e479-5040-88e0-4a98d731e443",
"address": {
"addressCountry": "Germany",
"addressLocality": "Berlin",
"addressRegion": "Berlin",
"postalCode": "10623",
"streetAddress": "Hardenbergstraße 34"
},
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
}
}
}
@@ -65,7 +65,7 @@
"Weizen",
"Milch(Laktose; Milcheiweiß)"
],
"uid": "540862f3-ea30-5b8f-8678-56b4dc217140",
"uid": "3222631f-82b3-5faf-a8e8-9c10719cc95b",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",

Some files were not shown because too many files have changed in this diff Show More