Compare commits

...

64 Commits

Author SHA1 Message Date
Jovan Krunić
dd56d97945 0.23.0 2019-07-03 15:30:33 +02:00
Jovan Krunić
43851d2d35 feat: support 404 (resource not found) error on plugin register route 2019-07-03 15:13:38 +02:00
Karl-Philipp Wulfert
b6272e9229 test: update NYC configuration 2019-06-28 12:42:45 +02:00
Karl-Philipp Wulfert
13dae1fb06 build: update dependencies 2019-06-28 12:38:28 +02:00
Karl-Philipp Wulfert
c18e3c15f1 feat: add mapping type from response to request and vice versa
Fixes #80
2019-06-28 12:36:52 +02:00
Karl-Philipp Wulfert
54d44f1acb docs: update changelog 2019-06-28 11:32:37 +02:00
Karl-Philipp Wulfert
47b686dfd0 0.22.0 2019-06-28 11:32:36 +02:00
Wieland Schöbl
89eb10451c refactor: state types of generics explicitly 2019-06-27 12:16:29 +02:00
Karl-Philipp Wulfert
ceab7cc7ef refactor: tidy structure of source files
Fixes #79
2019-06-19 16:18:03 +02:00
Karl-Philipp Wulfert
5de9bf3794 docs: add missing copyright years 2019-06-19 14:24:06 +02:00
Karl-Philipp Wulfert
02593a013c docs: add missing contributor 2019-06-19 14:23:57 +02:00
Karl-Philipp Wulfert
472038ec62 docs: update changelog 2019-06-19 14:21:49 +02:00
Karl-Philipp Wulfert
3a84d12f26 0.21.0 2019-06-19 14:21:48 +02:00
Karl-Philipp Wulfert
b621a12689 refactor: adjust to new tslint settings 2019-06-18 17:26:54 +02:00
Karl-Philipp Wulfert
6ffa4efbaf build: add automatic publishing
Fixes #72
2019-06-17 15:40:40 +02:00
Karl-Philipp Wulfert
e41169a9c7 refactor: adjust model to not contain any 2019-06-17 10:06:38 +00:00
Karl-Philipp Wulfert
46194b177b test: walk along dependency chains 2019-06-17 10:06:38 +00:00
Karl-Philipp Wulfert
ff1f554e0b feat: add static typed test for consistency
Fixes #71
2019-06-17 10:06:38 +00:00
Benjamin Jöckel
9c424b0f96 feat: add ES annotations 2019-06-11 16:42:52 +02:00
Jovan Krunić
55b5248660 docs: update changelog 2019-06-11 16:21:56 +02:00
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
154 changed files with 6625 additions and 6198 deletions

View File

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

29
.gitignore vendored
View File

@@ -20,7 +20,7 @@ coverage
# nyc test coverage # nyc test coverage
.nyc_output .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 .grunt
# Bower dependency directory (https://bower.io/) # Bower dependency directory (https://bower.io/)
@@ -29,14 +29,14 @@ bower_components
# node-waf configuration # node-waf configuration
.lock-wscript .lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html) # Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release build/Release
# Dependency directories # Dependency directories
node_modules/ node_modules/
jspm_packages/ jspm_packages/
# Typescript v1 declaration files # TypeScript v1 declaration files
typings/ typings/
# Optional npm cache directory # Optional npm cache directory
@@ -57,6 +57,29 @@ typings/
# dotenv environment variables file # dotenv environment variables file
.env .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 # ignore ide files
.idea .idea
.vscode .vscode

View File

@@ -50,6 +50,21 @@ test:
- report - report
- coverage - coverage
package:
dependencies:
- build
tags:
- secrecy
stage: deploy
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc
- npm publish
only:
- /^v[0-9]+.[0-9]+.[0-9]+$/
artifacts:
paths:
- lib
pages: pages:
stage: deploy stage: deploy
script: script:

View File

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

View File

@@ -1,3 +1,95 @@
# [0.22.0](https://gitlab.com/openstapps/core/compare/v0.21.0...v0.22.0) (2019-06-28)
# [0.21.0](https://gitlab.com/openstapps/core/compare/v0.20.0...v0.21.0) (2019-06-19)
### Features
* add ES annotations ([9c424b0](https://gitlab.com/openstapps/core/commit/9c424b0))
* add static typed test for consistency ([ff1f554](https://gitlab.com/openstapps/core/commit/ff1f554)), closes [#71](https://gitlab.com/openstapps/core/issues/71)
# [0.20.0](https://gitlab.com/openstapps/core/compare/v0.19.0...v0.20.0) (2019-06-11)
### Bug Fixes
* add translations for every SCThing ([f847a2a](https://gitlab.com/openstapps/core/commit/f847a2a))
* rename properties floor and message so that they are not identical to SCThingTypes ([78b64ba](https://gitlab.com/openstapps/core/commit/78b64ba))
# [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) # [0.12.0](https://gitlab.com/openstapps/core/compare/v0.11.0...v0.12.0) (2019-03-14)

View File

@@ -29,3 +29,21 @@ To generate a documentation for the routes use the following command.
```shell ```shell
node --require ts-node/register src/cli.ts routes PATH/TO/ROUTES.md node --require ts-node/register src/cli.ts routes PATH/TO/ROUTES.md
``` ```
### Annotations
Annotations are used to add additional informations to fields, which are used to autogenerate mappings from the core objects.
External dependencies can not be covered by the annotations. Documentation about some of the annotations can be found in: [typedoc](https://typedoc.org/guides/doccomments/)
| annotation | description | parameters |
|-------------------|-------------------------------------------|---------------|
| `@aggregatable` | used for generating of aggregations of the field if the core schema is used to put data into a database/key-value store | |
| `@float` | number field is interpreted as float | |
| `@indexable` | marks the type as indexable if the core schema is used to put data into a database/key-value store| |
| `@integer` | number field is interpreted as integer | |
| `@keyword` | string field is interpreted as keyword | |
| `@sortable` | field is sortable if the core schema is used to put data into a database/key-value store | sort method to be used: ducet, price, distance |
| `@text` | string field is interpreted as text | |
| `@validatable` | marks the type as validatable if the core schema is used to put data into a database/key-value store | |

4474
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@openstapps/core", "name": "@openstapps/core",
"version": "0.13.0", "version": "0.23.0",
"description": "StAppsCore - Generalized model of data", "description": "StAppsCore - Generalized model of data",
"keywords": [ "keywords": [
"Model", "Model",
@@ -14,73 +14,95 @@
"main": "./lib/index.js", "main": "./lib/index.js",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"scripts": { "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'", "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", "check-configuration": "openstapps-configuration",
"compile": "tsc", "compile": "rimraf lib && tsc",
"documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib", "documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib",
"pack": "openstapps-core-tools pack", "pack": "openstapps-core-tools pack",
"postversion": "npm run changelog",
"prepublishOnly": "npm ci && 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", "preversion": "npm run prepublishOnly",
"test": "nyc mocha --require ts-node/register --ui mocha-typescript test/*.spec.ts", "push": "git push && git push origin \"v$npm_package_version\"",
"tslint": "tslint 'src/**/*.ts'" "schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src lib/schema",
"test": "nyc mocha --require ts-node/register --require source-map-support/register --ui mocha-typescript test/*.spec.ts",
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
}, },
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>", "author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
"contributors": [ "contributors": [
"Anselm Stordeur <anselmstordeur@gmail.com>",
"Jovan Krunic <jovan.krunic@gmail.com>",
"Andreas Lehmann", "Andreas Lehmann",
"Sebastian Lange", "Anselm Stordeur <anselmstordeur@gmail.com>",
"Benjamin Jöckel",
"Imran Hossain",
"Jovan Krunić <jovan.krunic@gmail.com>",
"Michel Jonathan Schmitz",
"Rainer Killinger", "Rainer Killinger",
"Imran Hossain" "Sebastian Lange",
"Wieland Schöbl"
], ],
"dependencies": { "dependencies": {
"@types/geojson": "1.0.6", "@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30", "@types/json-patch": "0.0.30",
"@types/node": "10.14.10",
"fast-clone": "1.5.13",
"http-status-codes": "1.3.2",
"json-patch": "0.7.0", "json-patch": "0.7.0",
"jsonschema": "1.2.4", "jsonschema": "1.2.4",
"ts-optchain": "0.1.3" "ts-optchain": "0.1.3"
}, },
"devDependencies": { "devDependencies": {
"@openstapps/configuration": "0.8.0", "@krlwlfrt/async-pool": "0.1.0",
"@openstapps/core-tools": "0.3.0", "@openstapps/configuration": "0.21.0",
"@openstapps/logger": "0.0.5", "@openstapps/core-tools": "0.7.0",
"@openstapps/logger": "0.3.1",
"@types/chai": "4.1.7", "@types/chai": "4.1.7",
"@types/node": "10.14.4",
"@types/rimraf": "2.0.2", "@types/rimraf": "2.0.2",
"async-pool-native": "0.1.0",
"chai": "4.2.0", "chai": "4.2.0",
"commander": "2.19.0", "commander": "2.20.0",
"conventional-changelog-cli": "2.0.12", "conditional-type-checks": "1.0.1",
"mocha": "6.0.2", "conventional-changelog-cli": "2.0.21",
"mocha": "6.1.4",
"mocha-typescript": "1.1.17", "mocha-typescript": "1.1.17",
"nyc": "13.3.0", "nyc": "14.1.1",
"rimraf": "2.6.3", "rimraf": "2.6.3",
"ts-node": "8.0.3", "source-map-support": "0.5.12",
"tslint": "5.15.0", "ts-node": "8.3.0",
"tslint": "5.18.0",
"typedoc": "0.14.2", "typedoc": "0.14.2",
"typescript": "3.4.1" "typescript": "3.5.2"
}, },
"nyc": { "nyc": {
"all": true,
"branches": 85,
"check-coverage": true, "check-coverage": true,
"per-file": true,
"lines": 95,
"statements": 95,
"functions": 95,
"branches": 95,
"include": [
"src/core/Route.ts",
"src/core/Thing.ts",
"src/core/Translator.ts"
],
"exclude": [], "exclude": [],
"extension": [ "extension": [
".ts" ".ts"
], ],
"functions": 95,
"include": [
"src/protocol/route.ts",
"src/things/abstract/thing.ts",
"src/translator.ts",
"src/guards.ts"
],
"lines": 95,
"per-file": true,
"reporter": [ "reporter": [
"html", "html",
"text-summary" "text-summary"
], ],
"all": true "require": [
"ts-node/register"
],
"statements": 95
},
"openstappsConfiguration": {
"hasCli": false,
"ignoreCiEntries": [
"build"
],
"standardBuild": false,
"standardDocumentation": false
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,9 +12,10 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// tslint:disable-next-line:no-implicit-dependencies
import {Polygon} from 'geojson'; import {Polygon} from 'geojson';
import {SCSetting} from '../../things/Setting'; import {SCTranslations} from '../general/i18n';
import {SCTranslations} from '../i18n'; import {SCSetting} from '../things/setting';
/** /**
* An app configuration menu item * An app configuration menu item
@@ -126,11 +127,11 @@ export interface SCAppConfiguration {
} }
/** /**
* * Map of features
*/ */
export interface SCAppConfigurationFeature { export interface SCAppConfigurationFeature {
/** /**
* * Whether or not widgets are enabled
*/ */
widgets: boolean; widgets: boolean;
} }
@@ -148,7 +149,7 @@ export interface SCAppConfigurationStoreUrl {
*/ */
ios?: string; ios?: string;
/** /**
* Microsoft Store URL * Microsoft Store URL
*/ */
uwp?: string; uwp?: string;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,11 +12,11 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingType} from '../../Thing'; import {SCMap, SCRestrictedMap} from '../general/map';
import {SCSearchSortType} from '../sorts/Abstract'; import {SCUuid} from '../general/uuid';
import {SCUuid} from '../UUID'; import {SCSearchSortType} from '../protocol/search/sort';
import {SCMap} from './../Map'; import {SCThingType} from '../things/abstract/thing';
import {SCMonitoringConfiguration} from './Monitoring'; import {SCMonitoringConfiguration} from './monitoring';
/** /**
* A backend configuration * A backend configuration
@@ -72,7 +72,7 @@ export interface SCBackendConfigurationSortableField {
/** /**
* A list of SC types on which this field exists * A list of SC types on which this field exists
* *
* If no type is given it is assumed it exists on every type * If no type is given it is assumed it exists on every type
*/ */
onlyOnTypes?: SCThingType[]; onlyOnTypes?: SCThingType[];
@@ -84,10 +84,25 @@ export interface SCBackendConfigurationSortableField {
} }
/**
* Possible context names to be used by the search request
*/
export type SCSearchContext =
| 'default'
| 'dining'
| 'place';
/**
* A boosting configuration for one context
*/
export type SCBackendConfigurationSearchBoostingContext =
SCRestrictedMap<SCSearchContext,
SCBackendConfigurationSearchBoostingType[]>;
/** /**
* A boosting configuration for one SCType * 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 * The factor of which the scores matching this type should be multiplied by
@@ -98,7 +113,7 @@ export interface SCBackendConfigurationSearchBoosting {
* Outer-Map: * Outer-Map:
* Fields of this type that should be boosted if they match a given value * 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` * For nest fields you can use the `.` as a separator. For example `academicTerms.acronym`
* *
* Inner-map: * Inner-map:
* Value of the field that should be boosted by the given number * Value of the field that should be boosted by the given number
* For example `"SS 2019": 2` * For example `"SS 2019": 2`
@@ -143,7 +158,7 @@ export interface SCBackendInternalConfiguration {
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the * The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
* set of results * set of results
*/ */
boostings: SCBackendConfigurationSearchBoosting[]; boostings: SCBackendConfigurationSearchBoostingContext;
/** /**
* Configuration of the database * Configuration of the database
@@ -159,10 +174,9 @@ export interface SCBackendInternalConfiguration {
/** /**
* Configuration of the database * Configuration of the database
*/ */
export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<any> { export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<unknown> {
/** /**
* Name of the database used by the backend * Name of the database used by the backend
*/ */
name: string; name: string;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,9 +12,9 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAppConfiguration} from '../types/config/App'; import {SCLicensePlate} from '../general/namespaces';
import {SCBackendConfiguration, SCBackendInternalConfiguration} from '../types/config/Backend'; import {SCAppConfiguration} from './app';
import {SCLicensePlate} from '../types/namespaces'; import {SCBackendConfiguration, SCBackendInternalConfiguration} from './backend';
/** /**
* A configuration file that configures app and backend * A configuration file that configures app and backend

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -140,7 +140,7 @@ export interface SCMonitoringWatcher {
/** /**
* Query to execute against the database * Query to execute against the database
*/ */
query: any; query: unknown;
/** /**
* A list of triggers * A list of triggers

View File

@@ -1,303 +0,0 @@
/*
* 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, SCThingsField} from './Classes';
import {SCThing, SCThingType} from './Thing';
import {SCTranslations} from './types/i18n';
import {Defined, OCType} from 'ts-optchain';
/**
* SCThingTranslator class
*/
export class SCThingTranslator {
/**
* Property representing the translators base language.
* This means every translation is given for this language.
*/
private baseLanguage: keyof SCTranslations<SCThing>;
/**
* Property representing the translators target language
*/
private language: keyof SCTranslations<SCThing>;
/**
* Property provinding 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>, baseLanguage?: keyof SCTranslations<SCThing>) {
this.baseLanguage = baseLanguage ? baseLanguage : 'en';
this.language = language;
this.metaClasses = SCClasses;
}
/**
* Get field value translation recursively
*
* @param firstObject Top level object that gets passed through the recursion
* @param data The intermediate object / primitive returned by the Proxys get() method
* @param keyPath The keypath that (in the end) leads to the translatable property (when added to firstObject)
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
*/
private deeptranslate<T, K extends SCThing>(firstObject: K, data?: T, keyPath?: string): OCType<T> {
const proxy = new Proxy(
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
{
get: (target, key) => {
const obj: any = target();
const extendedKeyPath = [keyPath, key.toString()].filter((e) => e != null).join('.');
let possiblePrimitive = obj[key];
// check if obj[key] is an array that contains primitive type (arrays in SCThings are not mixing types)
if (obj[key] instanceof Array && obj[key].length) {
possiblePrimitive = obj[key][0];
}
if (typeof possiblePrimitive === 'string' ||
typeof possiblePrimitive === 'number' ||
typeof possiblePrimitive === 'boolean') {
// returns final translation for primitive data types
return this.deeptranslate(firstObject,
this.getFieldValueTranslation(firstObject, extendedKeyPath),
extendedKeyPath);
}
// recursion to get more calls to the Proxy handler 'get()' (key path not complete)
return this.deeptranslate(firstObject, obj[key], extendedKeyPath);
},
},
);
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 (metaClass === undefined) {
return undefined;
}
// Assigns every property in fieldTranslations to the known base language translation
if (metaClass.fieldTranslations[this.baseLanguage] !== undefined) {
Object.keys(metaClass.fieldTranslations[this.baseLanguage]).forEach((key) => {
(fieldTranslations as any)[key] = metaClass.fieldTranslations[this.baseLanguage][key];
});
}
// Assigns every property in fieldTranslations to the known translation in given language
if (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;
}
/**
* Returns property value at a certain (key) path of an object.
* @example
* // returns value of dish.offers[0].inPlace.categories[1]
* const dish: SCDish = {...};
* this.valueFromPath(dish, 'offers[0].inPlace.categories[1]');
* @param path Key path to evaluate
* @param obj Object to evaluate the key path upon
* @param separator Key path seperation element. Defaults to '.'
* @returns Property value at at key path
*/
private valueFromPath<T extends SCThing>(path: string, obj: T, separator = '.') {
path = path.replace(/\[/g, '.');
path = path.replace(/\]/g, '.');
path = path.replace(/\.\./g, '.');
path = path.replace(/\.$/, '');
const properties = path.split(separator);
return properties.reduce((prev: any, curr: any) => prev && prev[curr], obj);
}
/**
* Get field value translation
* @example
* // returns translation of the property (if available) in the language defined when creating the translator object
* const dish: SCDish = {...};
* translator.translate(dish, 'offers[0].inPlace.categories[1]');
* @param thing SCThing to get value translation for
* @param field Field to get value translation for (keypath allowed)
* @returns Translated value(s) or value(s) itself
*/
public getFieldValueTranslation<T extends SCThing>(thing: T,
field: SCThingsField): string | string[] {
let translationPath = 'translations.' + this.language + '.' + field;
const regexTrimProperties = /.*(?:(\..*)(\[\d+\])|(\.[^\d]*$)|(\..*)(\.[\d]*$))/;
const pathMatch = field.match(regexTrimProperties);
// when translation is given in thing
let translation = this.valueFromPath(translationPath, thing);
if (translation) {
return translation;
} else if (pathMatch && pathMatch[1] && pathMatch[2] || pathMatch && pathMatch[4] && pathMatch[5]) {
// accessing iteratable of nested thing
const keyPath = (pathMatch[1] ? pathMatch[1] : pathMatch[4]) + (pathMatch[2] ? pathMatch[2] : pathMatch[5]);
const redactedField = field.replace(keyPath, '');
// when translation is given in nested thing
translationPath = `${redactedField}.translations.${this.language}${keyPath}`;
translation = this.valueFromPath(translationPath, thing);
if (translation) {
return translation;
}
// when translation is given in nested meta thing via iterateable index
const nestedType = this.valueFromPath(field.replace(keyPath, '.type'), thing) as SCThingType;
translationPath = `fieldValueTranslations.${this.language}${keyPath}`;
translation = this.valueFromPath(translationPath.replace(
/\[(?=[^\[]*$).*|(?=[\d+]*$).*/, '[' + this.valueFromPath(field, thing) + ']'),
this.getMetaClassInstance(nestedType));
if (translation) {
return translation;
}
} else if (pathMatch && pathMatch[3]) {
// accessing meta or instance of nested thing primitive value depth > 0
const keyPath = pathMatch[3];
const redactedField = field.replace(pathMatch[3], '');
// when translation is given in nested thing
translationPath = `${redactedField}.translations.${this.language}${keyPath}`;
if (this.valueFromPath(translationPath, thing)) {
return this.valueFromPath(translationPath, thing);
}
// when translation is given in nested meta thing
const nestedType = this.valueFromPath(field.replace(keyPath, '.type'), thing) as SCThingType;
translationPath = `fieldValueTranslations.${this.language}${keyPath}`;
translation = this.valueFromPath(translationPath, this.getMetaClassInstance(nestedType));
if (translation instanceof Object) { // lookup translated keys in meta thing property
const translations: string[] = [];
this.valueFromPath(field, thing).forEach((key: string) => {
translationPath = `fieldValueTranslations.${this.language}${keyPath}.${key}`;
translations.push(this.valueFromPath(translationPath, this.getMetaClassInstance(nestedType)));
});
return translations;
}
if (!translation) { // translation not given, return as is
return this.valueFromPath(field, thing) as string;
}
return translation;
}
// accessing meta thing primitive value depth = 0
translationPath = `fieldValueTranslations.${this.language}.${field}`;
translation = this.valueFromPath(translationPath, this.getMetaClassInstance(thing.type));
if (translation) {
if (translation instanceof Object) { // lookup translated keys in meta thing property
const translations: string[] = [];
this.valueFromPath(field, thing).forEach((key: string) => {
translationPath = `fieldValueTranslations.${this.language}.${field}.${key}`;
translations.push(this.valueFromPath(translationPath, this.getMetaClassInstance(thing.type)));
});
return translations;
}
return translation;
}
// accessing meta thing primitive via iteratable index value depth = 0
translation = this.valueFromPath(translationPath.replace(
/\[(?=[^\[]*$).*|(?=[\d+]*$).*/, '[' + this.valueFromPath(field, thing) + ']'),
this.getMetaClassInstance(thing.type));
if (translation) {
return translation;
}
// last resort: return as is
return this.valueFromPath(field, thing) as string;
}
/**
* 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();
let translatable = obj[key];
if (obj[key] instanceof Array && obj[key].length) {
translatable = obj[key][0];
if (typeof obj[key][0] === 'object' && !obj[key][0].origin) {
translatable = obj[key][0][Object.keys(obj[key][0])[0]];
}
}
if (typeof translatable === 'string') {
// retrieve final translation
return this.deeptranslate(data!, this.getFieldValueTranslation(data!, key.toString()), key.toString());
}
// recursion to get more calls to the Proxy handler 'get()' (key path not complete)
return this.deeptranslate(data!, obj[key], key.toString());
},
},
);
}
/**
* 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;
}
}

View File

@@ -1,81 +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 {SCThing, SCThingMeta, SCThingTranslatableProperties} 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 {
/**
* Address of the place
*/
address?: SCPostalAddress;
/**
* Positional information of the place
*
* !!! BEWARE !!!
* Can not be a GeometryCollection because ElasticSearch does not allow distance filtering/sorting on other types
*/
geo: SCGeoInformation;
/**
* Opening hours of the place
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
*/
openingHours?: string;
/**
* Translated fields of a place
*/
translations?: SCTranslations<SCPlaceWithoutReferencesTranslatableProperties>;
}
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().fieldTranslations.de,
},
en: {
... SCThingMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingMeta.getInstance().fieldValueTranslations.de,
},
en: {
... SCThingMeta.getInstance().fieldValueTranslations.en,
},
};
}

View File

@@ -1,64 +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 {SCThing, SCThingMeta} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/**
* Types of payment that are accepted at a place.
*/
export type SCThingThatAcceptsPaymentsAcceptedPayments =
'Cash'
| 'Credit'
| 'Cafeteria Card';
/**
* A place without references that accepts payments
*/
export interface SCThingThatAcceptsPaymentsWithoutReferences extends SCThing {
/**
* Accepted payments of the place
*/
paymentsAccepted?: SCThingThatAcceptsPaymentsAcceptedPayments[];
}
/**
* 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().fieldTranslations.de,
},
en: {
... SCThingMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingMeta.getInstance().fieldValueTranslations.de,
},
en: {
... SCThingMeta.getInstance().fieldValueTranslations.en,
},
};
}

View File

@@ -1,23 +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 {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* A thing that has translations
*/
export interface SCThingWithTranslations extends SCThing {
translations: SCTranslations<SCThingTranslatableProperties>;
}

View File

@@ -1,179 +0,0 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {ValidationError} from 'jsonschema';
/**
* A generic error that can be returned by the backend if somethings fails during the processing of a request
*
* @validatable
*/
export interface SCErrorResponse extends Error {
/**
* Additional data that describes the error
*/
additionalData?: any;
/**
* HTTP status code to return this error with
*/
statusCode: number;
}
/**
* An error that can be created by the backend during the processing of a request
*/
export abstract class SCError implements SCErrorResponse {
/**
* Call stack of the error
*/
stack?: string;
/**
* Instatiate an SCError
* @param name Name of the error
* @param message Message of the error
* @param statusCode HTTP status code to return this error with
* @param stack Set to true if a stack trace should be created
*/
constructor(public name: string, public message: string, public statusCode: number, stack?: boolean) {
// generate stacktrace if needed
if (stack) {
this.stack = (new Error()).stack;
}
}
}
/**
* An error that is returned when the validation of a request fails
*/
export class SCValidationErrorResponse extends SCError {
/**
* List of validatation errors
*/
additionalData: ValidationError[];
/**
* Create a SCValidationErrorResponse
* @param errors List of validation errors
* @param stack Set to true if a stack trace should be created
*/
constructor(errors: ValidationError[], stack?: boolean) {
super('ValidationError', 'Validation of request failed', 400, stack);
this.additionalData = errors;
}
}
/**
* An error that is returned when the content type of the request is not supported
*/
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
* Create a SCUnsupportedMediaTypeErrorResponse
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('UnsupportedMediaTypeError', 'Unsupported media type', 415, stack);
}
}
/**
* An error that is returned, when the used HTTP method is not allowed on the requested route
*/
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
* Create a SCMethodNotAllowedErrorResponse
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('MethodNotAllowedError', 'HTTP method is not allowed on this route', 405, stack);
}
}
/**
* An error that is returned, when the request body is too large.
*/
export class SCRequestBodyTooLargeErrorResponse extends SCError {
/**
* Create a SCRequestBodyTooLargeErrorResponse
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('RequestBodyTooLargeError', 'The request body is too large.', 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) {
super('TooManyRequestsError', 'Too many requests. You can not submit more than 5 queries an once', 429, stack);
}
}
/**
* An error that is returned when the requested route or resource was not found
*/
export class SCNotFoundErrorResponse extends SCError {
/**
* Create a SCNotFoundErrorResponse
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('NotFoundError', 'Resource not found', 404, stack);
}
}
/**
* An error that is returned whenever there is a syntax error
*/
export class SCSyntaxErrorResponse extends SCError {
/**
* Create a SyntaxError
* @param message Describes the syntax error
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('SyntaxError', message, 400, stack);
}
}
/**
* An error that is returned, when an internal server error occurred
*/
export class SCInternalServerErrorResponse extends SCError {
/**
* Internal error that occurred. If the stack is disabled this error is not set for security reasons
*/
additionalData?: Error;
/**
* Create a SCInternalServerErrorResponse
* @param err Internal server error
* @param stack Set to true if a stack trace should be created
* and the internal server error should be displayed to the client
*/
constructor(err?: Error, stack?: boolean) {
super('InternalServerError', 'Internal server error', 502, stack);
if (stack) {
this.additionalData = err;
}
}
}

View File

@@ -1,27 +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 {SCAppConfiguration} from '../../../types/config/App';
import {SCBackendConfiguration} from '../../../types/config/Backend';
/**
* A response to an index request
*
* @validatable
*/
export interface SCIndexResponse {
app: SCAppConfiguration;
backend: SCBackendConfiguration;
}

View File

@@ -1,21 +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/>.
*/
/**
* Response for an entity update request
*
* @validatable
*/
export interface SCThingUpdateResponse {
}

View File

@@ -1,21 +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 {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../../base/ThingThatCanBeOffered';
/**
* List of availabilities of a book
* @validatable
*/
export type SCBookAvailabilityResponse = Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;

View File

@@ -1,20 +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/>.
*/
/**
* Response to a request to add a thing to a bulk
* @validatable
*/
export interface SCBulkAddResponse {
}

View File

@@ -1,20 +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/>.
*/
/**
* Response to a request to change the state of a bulk to done
* @validatable
*/
export interface SCBulkDoneResponse {
}

View File

@@ -1,21 +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/>.
*/
/**
* A response to a feedback request
*
* @validatable
*/
export interface SCFeedbackResponse {
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMap} from '../../../types/Map';
import {SCSearchResult} from './SearchResponse';
/**
* A multi search response
*
* This is a map of [[SCSearchResponse]]s indexed by name
*
* @validatable
*/
export type SCMultiSearchResponse = SCMap<SCSearchResult>;

View File

@@ -1,148 +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 {SCAcademicDegree, SCAcademicDegreeMeta} from '../base/AcademicDegree';
import {SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCDateSeriesWithoutReferences} from './DateSeries';
import {SCOrganization} from './Organization';
/**
* A course of studies without references
*/
export interface SCCourseOfStudiesWithoutReferences extends
SCAcademicDegree,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* The main language in which the course of studies
* is beeing offered
*/
mainLanguage: SCLanguage;
/**
* Actual major of the course of studies (eg. physics)
*/
major: string;
/**
* The modes the course of studies is offered in
*/
mode: SCCourseOfStudiesMode;
/**
* The time modes the course of studies is offered in
*/
timeMode: SCCourseOfStudiesTimeMode;
/**
* Translated fields of a dish
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
/**
* Type of the course of studies
*/
type: SCThingType.CourseOfStudies;
}
/**
* A course of studies
*
* @validatable
*/
export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
/**
* The department that manages the course of studies
*/
department: SCOrganization;
/**
* The secretary that administers requests and
* questions concerning the course of studies
*/
secretary: SCOrganization;
/**
* Dates at which the course of studies is planned to start
*/
startDates?: SCDateSeriesWithoutReferences[];
/**
* Type of the course of studies
*/
type: SCThingType.CourseOfStudies;
}
export interface SCCourseOfStudiesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
}
/**
* Meta information about a course of studies
*/
export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslations<SCCourseOfStudies> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCAcademicDegreeMeta.getInstance().fieldTranslations.de,
},
en: {
... SCAcademicDegreeMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
modes: {
combination: 'Kombinationsstudiengang',
dual: 'Dualer Studiengang',
fulltime: 'Vollzeitstudiengang',
parttime: 'Teilzeitstudiengang',
},
type: 'Studiengang',
},
en: {
... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en,
academicDegree: 'Hochschulabschluss',
department: 'Fachbereich',
major: 'Studienfach',
modes: 'Studiengangsarten',
secretary: 'Sekretariat',
type: SCThingType.CourseOfStudies,
},
};
}
/**
* Types of (german) course of studies modes
*/
export type SCCourseOfStudiesMode = 'combination' |
'dual' |
'double-degree' |
'standard' ;
/**
* Types of (german) course of studies time modes
*/
export type SCCourseOfStudiesTimeMode = 'fulltime' |
'parttime' ;

View File

@@ -1,44 +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 {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
/**
* An organization without references
*/
export interface SCOrganizationWithoutReferences extends SCThing {
/**
* Type of an organization
*/
type: SCThingType.Organization;
}
/**
* An organization
*
* @validatable
*/
export interface SCOrganization extends SCOrganizationWithoutReferences, SCThingInPlace {
/**
* Type of an organization
*/
type: SCThingType.Organization;
}
/**
* Meta information about an organization
*/
export class SCOrganizationMeta extends SCThingMeta {
}

View File

@@ -1,110 +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 {SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place';
import {SCThingInPlace} from '../base/ThingInPlace';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* A point of interest without references
*/
export interface SCPointOfInterestWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>,
SCPlaceWithoutReferences {
/**
* Translated properties of a point of interest
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of a point of interest
*/
type: SCThingType.PointOfInterest;
}
/**
* A point of interest
*
* @validatable
*/
export interface SCPointOfInterest extends SCPointOfInterestWithoutReferences, SCThingInPlace {
/**
* Translated properties of a point of interest
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of a point of interest
*/
type: SCThingType.PointOfInterest;
}
/**
* Categories of a point of interest
*/
export type SCPointOfInterestCategories =
'computer'
| 'validator'
| 'card charger'
| 'printer'
| 'disabled access';
/**
* Meta information about points of interest
*/
export class SCPointOfInterestMeta extends SCThingMeta implements SCMetaTranslations<SCPointOfInterest> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de,
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
type: 'Sonderziel',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.PointOfInterest,
},
};
}

View File

@@ -1,168 +0,0 @@
/*
* Copyright (C) 2018, 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {
SCThingThatAcceptsPaymentsWithoutReferences,
SCThingThatAcceptsPaymentsWithoutReferencesMeta,
} from '../base/ThingThatAcceptsPayments';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCMap} from '../types/Map';
/**
* Categories of a room
*/
export type SCRoomCategories =
'cafe'
| 'canteen'
| 'computer'
| 'education'
| 'laboratory'
| 'learn'
| 'library'
| 'lounge'
| 'office'
| 'restaurant'
| 'restroom'
| 'student canteen'
| 'student union';
/**
* A room without references
*/
export interface SCRoomWithoutReferences
extends SCPlaceWithoutReferences, SCThingThatAcceptsPaymentsWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCRoomCategories, SCRoomSpecificValues> {
/**
* The name of the floor in which the room is in.
*/
floor?: string;
/**
* The inventory of the place/room as a list of items and their quantity.
*/
inventory?: SCMap<number>;
/**
* Translations of specific values of the object
*
* Take precedence over "main" value for selected languages.
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of the room
*/
type: SCThingType.Room;
}
/**
* A room
*
* @validatable
*/
export interface SCRoom extends SCRoomWithoutReferences, SCThingInPlace {
/**
* Translations of specific values of the object
*
* Take precedence over "main" value for selected languages.
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of the room
*/
type: SCThingType.Room;
}
/**
* Category specific values of a room
*/
export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValues {
/**
* Category specific opening hours of the room
*/
openingHours?: string;
}
/**
* Meta information about a place
*/
export class SCRoomMeta extends SCThingMeta implements SCMetaTranslations<SCRoom> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.de,
... SCThingInPlaceMeta.getInstance().fieldTranslations.de,
},
en: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.en,
... SCThingInPlaceMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldValueTranslations.de,
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de,
categories: {
'cafe': 'Café',
'canteen': 'Kantine',
'computer': 'PC-Pool',
'education': 'Bildung',
'laboratory': 'Labor',
'learn': 'Lernen',
'library': 'Bibliothek',
'lounge': 'Lounge',
'office': 'Büro',
'restaurant': 'Restaurant',
'restroom': 'Toilette',
'student canteen': 'Mensa',
'student union': 'Studentenvereinigung',
},
type: 'Raum',
},
en: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldValueTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldValueTranslations.en,
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Room,
},
};
}

View File

@@ -1,163 +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 {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
export type SCSettingCategories = string;
/**
* A setting without references
*/
export interface SCSettingWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
/**
* The type of input/value this setting is carrying
*/
input: SCSettingInputType;
/**
* The order number this setting should show up in its category list
*/
order: number;
/**
* Translated fields of a setting
*/
translations?: SCTranslations<SCSettingValueTranslatableProperties>;
/**
* The type of this model
*/
type: SCThingType.Setting;
}
/**
* The types of input/value a setting object can carry
*/
export type SCSettingInputType = SCSettingSingleChoice
| SCSettingMultipleChoice
| SCSettingNumber
| SCSettingText
| SCSettingPassword;
/**
* A setting with references
*
* @validatable
*/
export interface SCSetting extends SCSettingWithoutReferences {
/**
* The type of this model
*/
type: SCThingType.Setting;
}
/**
* Input type with single choice as value
*/
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
*/
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;
}
/**
* Translatable properties of a setting
*/
export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
}
/**
* Meta information about settings
*/
export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCSetting> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'Einstellung',
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Setting,
},
};
}

View File

@@ -1,86 +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 {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
import {SCISO8601Duration} from '../types/Time';
/**
* A ticket without references
*/
export interface SCTicketWithoutReferences extends SCThing {
/**
* Approximate wait time
*/
approxWaitingTime: SCISO8601Duration;
/**
* Waiting number of the ticket
*/
currentTicketNumber: string;
/**
* Service type of the ticket
*/
serviceType: any;
/**
* Type of a ticket
*/
type: SCThingType.Ticket;
}
/**
* A ticket
*
* @validatable
*/
export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace {
/**
* Type of a ticket
*/
type: SCThingType.Ticket;
}
/**
* Meta information about a ticket
*/
export class SCTicketMeta extends SCThingMeta implements SCMetaTranslations<SCTicket> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.de,
},
en: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de,
type: 'Ticket',
},
en: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Ticket,
},
};
}

View File

@@ -1,81 +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 {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, SCThingType} from '../Thing';
/**
* Type guard to check if something is a SCThing
*
* @param {any} 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
*/
export function isThingWithTranslations(thing: SCThing): thing is SCThingWithTranslations {
return typeof thing.translations !== 'undefined';
}
/**
* Type guard to check if something is a bulk response
*
* @param {any} something Something to check
*/
export function isBulkResponse(something: any): something is SCBulkResponse {
return typeof something.expiration === 'string'
&& typeof something.source === 'string'
&& typeof something.state === 'string'
&& typeof something.type === 'string'
&& typeof something.uid === 'string';
}
/**
* Type guard to check if something is a search response
*
* @param {any} something Something to check
*/
export function isSearchResponse(something: any): something is SCSearchResponse {
return Array.isArray(something.data)
&& Array.isArray(something.facets)
&& typeof something.pagination !== 'undefined'
&& typeof something.pagination.count === 'number'
&& typeof something.pagination.offset === 'number'
&& typeof something.pagination.total === 'number'
&& typeof something.stats !== 'undefined'
&& typeof something.stats.time === 'number';
}
/**
* 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 as boolean);
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -29,7 +29,7 @@ export interface SCLanguage {
/** /**
* A list of possible languages in english * A list of possible languages in english
* *
* @see https://en.wikipedia.org/wiki/ISO_639-1 * @see https://en.wikipedia.org/wiki/ISO_639-1
*/ */
export type SCLanguageName = export type SCLanguageName =
@@ -221,7 +221,7 @@ export type SCLanguageName =
/** /**
* A List of all possible Languages as ISO 639-1 Codes * A List of all possible Languages as ISO 639-1 Codes
* *
* @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes * @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/ */
export type SCLanguageCode = export type SCLanguageCode =
@@ -690,10 +690,10 @@ export interface SCTranslations<T> {
* (Source: https://stackoverflow.com/a/51365037) * (Source: https://stackoverflow.com/a/51365037)
*/ */
type RecursivePartial<T> = { type RecursivePartial<T> = {
[P in keyof T]?: [P in keyof T]-?:
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
T[P] extends object ? RecursivePartial<T[P]> : T[P] extends object ? RecursivePartial<T[P]> :
T[P]; T[P];
}; };
/** /**
@@ -714,6 +714,12 @@ type SCRequiredTranslation<T> = {
* Interface to be implemented by all Meta classes * Interface to be implemented by all Meta classes
*/ */
export interface SCMetaTranslations<T> { export interface SCMetaTranslations<T> {
/**
* Field translations
*/
fieldTranslations: SCRequiredTranslation<T>; fieldTranslations: SCRequiredTranslation<T>;
fieldValueTranslations: any; /**
* Field value translations
*/
fieldValueTranslations: unknown;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -15,10 +15,10 @@
/** /**
* Capsulation for a map with a string as key with values of type `T` * Capsulation for a map with a string as key with values of type `T`
* *
* !!! BEWARE !!! * !!! BEWARE !!!
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map) * 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. * @typeparam T Can be any type.
*/ */
export interface SCMap<T> { export interface SCMap<T> {
@@ -27,3 +27,20 @@ export interface SCMap<T> {
*/ */
[key: string]: 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
};

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.

126
src/guards.ts Normal file
View File

@@ -0,0 +1,126 @@
/*
* 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
* unknown 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 {SCTranslations} from './general/i18n';
import {SCBulkResponse} from './protocol/routes/bulk-request';
import {SCSearchResponse} from './protocol/routes/search';
import {SCMultiSearchResponse} from './protocol/routes/search-multi';
import {SCThing, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from './things/abstract/thing';
/**
* Type guard to check if something is a SCThing
*
* @param something Something to check
*/
export function isThing(something: unknown): something is SCThing {
if (typeof something !== 'object' || something === null) {
return false;
}
if (!('type' in something)) {
return false;
}
// tslint:disable-next-line:completed-docs
const type = (something as { type: unknown; }).type;
if (typeof type !== 'string') {
return false;
}
return Object
.values(SCThingType)
.indexOf(type) >= 0;
}
/**
* Type guard to check if translations exist
*
* @param thing Thing to check
*/
export function isThingWithTranslations(thing: SCThingWithoutReferences)
// tslint:disable-next-line:completed-docs
: thing is SCThingWithoutReferences & { translations: SCTranslations<SCThingTranslatableProperties>; } {
return typeof thing.translations !== 'undefined';
}
/**
* Type guard to check if something is a bulk response
*
* @param something Something to check
*/
export function isBulkResponse(something: unknown): something is SCBulkResponse {
if (typeof something !== 'object' || something === null) {
return false;
}
if (!('expiration' in something)
|| !('source' in something)
|| !('state' in something)
|| !('type' in something)
|| !('uid' in something)) {
return false;
}
const {expiration, source, state, type, uid} = something as {
// tslint:disable:completed-docs
expiration: unknown;
source: unknown;
state: unknown;
type: unknown;
uid: unknown;
// tslint:enable
};
return typeof expiration === 'string'
&& typeof source === 'string'
&& typeof state === 'string'
&& typeof type === 'string'
&& typeof uid === 'string';
}
/**
* Type guard to check if something is a search response
*
* @param something Something to check
*/
export function isSearchResponse(something: unknown): something is SCSearchResponse {
if (!(typeof something === 'object') || something === null) {
return false;
}
const somethingObject = (something as { [key: string]: { [key: string]: string; }; });
return Array.isArray(somethingObject.data)
&& Array.isArray(somethingObject.facets)
&& typeof somethingObject.pagination !== 'undefined'
&& typeof somethingObject.pagination.count === 'number'
&& typeof somethingObject.pagination.offset === 'number'
&& typeof somethingObject.pagination.total === 'number'
&& typeof somethingObject.stats !== 'undefined'
&& typeof somethingObject.stats.time === 'number';
}
/**
* Type guard to check if something is a multi search response
*
* @param something Something to check
*/
export function isMultiSearchResponse(something: unknown): something is SCMultiSearchResponse {
const initialValue = Object.keys(something as { [key: string]: string; }).length > 0 ? true : false;
return Object.keys(something as { [key: string]: string; })
.reduce((previousOnesAreSearchResponses, key) => {
return previousOnesAreSearchResponses && isSearchResponse((something as { [key: string]: string; })[key]);
}, initialValue 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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,36 +12,37 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingType} from './Thing'; import {SCThingType} from './things/abstract/thing';
import {SCAcademicEvent, SCAcademicEventMeta, SCAcademicEventWithoutReferences} from './things/AcademicEvent'; import {SCAcademicEvent, SCAcademicEventMeta, SCAcademicEventWithoutReferences} from './things/academic-event';
import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/Article'; import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/article';
import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/Book'; import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book';
import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/Building'; import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building';
import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/Catalog'; import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog';
import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/CourseOfStudies'; import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/course-of-studies';
import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/DateSeries'; import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series';
import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/Diff'; import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff';
import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/Dish'; import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/dish';
import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/Favorite'; import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/favorite';
import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/Floor'; import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/floor';
import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/Message'; import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/message';
import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/Organization'; import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/organization';
import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/Person'; import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/person';
import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/PointOfInterest'; import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/point-of-interest';
import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/Room'; import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/room';
import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/Semester'; import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/semester';
import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/Setting'; import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/setting';
import {SCSportCourse, SCSportCourseMeta, SCSportCourseWithoutReferences} from './things/SportCourse'; import {SCSportCourse, SCSportCourseMeta, SCSportCourseWithoutReferences} from './things/sport-course';
import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/Ticket'; import {SCStudyModule, SCStudyModuleMeta, SCStudyModuleWithoutReferences} from './things/study-module';
import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/ToDo'; import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/ticket';
import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/Tour'; import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/todo';
import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/Video'; import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/tour';
import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/video';
/* tslint:disable:variable-name */ /* tslint:disable:variable-name */
/** /**
* A map of things, from type to meta data * A map of things, from type to meta data
*/ */
export const SCClasses: { [K in SCThingType]: any } = { export const SCClasses: { [K in SCThingType]: object } = {
/* tslint:enable */ /* tslint:enable */
'academic event': SCAcademicEventMeta, 'academic event': SCAcademicEventMeta,
'article': SCArticleMeta, 'article': SCArticleMeta,
@@ -62,6 +63,7 @@ export const SCClasses: { [K in SCThingType]: any } = {
'semester': SCSemesterMeta, 'semester': SCSemesterMeta,
'setting': SCSettingMeta, 'setting': SCSettingMeta,
'sport course': SCSportCourseMeta, 'sport course': SCSportCourseMeta,
'study module': SCStudyModuleMeta,
'ticket': SCTicketMeta, 'ticket': SCTicketMeta,
'todo': SCToDoMeta, 'todo': SCToDoMeta,
'tour': SCTourMeta, 'tour': SCTourMeta,
@@ -87,6 +89,7 @@ export type SCThingsWithoutDiff =
| SCSemester | SCSemester
| SCSetting | SCSetting
| SCSportCourse | SCSportCourse
| SCStudyModule
| SCTicket | SCTicket
| SCToDo | SCToDo
| SCTour | SCTour
@@ -127,11 +130,12 @@ export type SCAssociatedThingWithoutReferences<THING extends SCThings> =
THING extends SCSemester ? SCSemesterWithoutReferences : THING extends SCSemester ? SCSemesterWithoutReferences :
THING extends SCSetting ? SCSettingWithoutReferences : THING extends SCSetting ? SCSettingWithoutReferences :
THING extends SCSportCourse ? SCSportCourseWithoutReferences : THING extends SCSportCourse ? SCSportCourseWithoutReferences :
THING extends SCTicket ? SCTicketWithoutReferences : THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
THING extends SCToDo ? SCToDoWithoutReferences : THING extends SCTicket ? SCTicketWithoutReferences :
THING extends SCTour ? SCTourWithoutReferences : THING extends SCToDo ? SCToDoWithoutReferences :
THING extends SCVideo ? SCVideoWithoutReferences : THING extends SCTour ? SCTourWithoutReferences :
never; THING extends SCVideo ? SCVideoWithoutReferences :
never;
/** /**
* Thing for a thing without references * Thing for a thing without references
@@ -156,8 +160,9 @@ export type SCAssociatedThing<THING extends SCThings> =
THING extends SCSemesterWithoutReferences ? SCSemester : THING extends SCSemesterWithoutReferences ? SCSemester :
THING extends SCSettingWithoutReferences ? SCSetting : THING extends SCSettingWithoutReferences ? SCSetting :
THING extends SCSportCourseWithoutReferences ? SCSportCourse : THING extends SCSportCourseWithoutReferences ? SCSportCourse :
THING extends SCTicketWithoutReferences ? SCTicket : THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
THING extends SCToDoWithoutReferences ? SCToDo : THING extends SCTicketWithoutReferences ? SCTicket :
THING extends SCTourWithoutReferences ? SCTour : THING extends SCToDoWithoutReferences ? SCToDo :
THING extends SCVideoWithoutReferences ? SCVideo : THING extends SCTourWithoutReferences ? SCTour :
never; THING extends SCVideoWithoutReferences ? SCVideo :
never;

56
src/protocol/error.ts Normal file
View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* A generic error that can be returned by the backend if somethings fails during the processing of a request
*
* @validatable
*/
export interface SCErrorResponse extends Error {
/**
* Additional data that describes the error
*/
additionalData?: unknown;
/**
* HTTP status code to return this error with
*/
statusCode: number;
}
/**
* An error that can be created by the backend during the processing of a request
*/
export abstract class SCError implements SCErrorResponse {
/**
* Call stack of the error
*/
stack?: string;
/**
* Instatiate an SCError
*
* @param name Name of the error
* @param message Message of the error
* @param statusCode HTTP status code to return this error with
* @param stack Set to true if a stack trace should be created
*/
constructor(public name: string, public message: string, public statusCode: number, stack = false) {
// generate stacktrace if needed
if (stack) {
this.stack = (new Error()).stack;
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {BAD_GATEWAY} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when an internal server error occurred
*/
export class SCInternalServerErrorResponse extends SCError {
/**
* Internal error that occurred. If the stack is disabled this error is not set for security reasons
*/
additionalData?: Error;
/**
* Create a SCInternalServerErrorResponse
*
* @param err Internal server error
* @param stack Set to true if a stack trace should be created
* and the internal server error should be displayed to the client
*/
constructor(err?: Error, stack = false) {
super('InternalServerError', 'Internal server error', BAD_GATEWAY, stack);
if (stack) {
this.additionalData = err;
}
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {METHOD_NOT_ALLOWED} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when the used HTTP method is not allowed on the requested route
*/
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
* Create a SCMethodNotAllowedErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('MethodNotAllowedError', 'HTTP method is not allowed on this route', METHOD_NOT_ALLOWED, stack);
}
}

View File

@@ -12,21 +12,19 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCBuildingWithoutReferences} from '../things/Building'; import {NOT_FOUND} from 'http-status-codes';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest'; import {SCError} from '../error';
import {SCRoomWithoutReferences} from '../things/Room';
/** /**
* Something that is or happens in a place * An error that is returned when the requested route or resource was not found
*
* !Important!
* This is not a SCThing.
*/ */
export interface SCInPlace { export class SCNotFoundErrorResponse extends SCError {
/** /**
* Place the thing is or happens in * Create a SCNotFoundErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/ */
inPlace?: constructor(stack?: boolean) {
SCBuildingWithoutReferences super('NotFoundError', 'Resource not found', NOT_FOUND, stack);
| SCPointOfInterestWithoutReferences }
| SCRoomWithoutReferences;
} }

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 {NOT_ACCEPTABLE} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned when the request is in the right format, but contains parameters that are invalid or not
* acceptable.
*/
export class SCParametersNotAcceptable extends SCError {
/**
* Create a ParametersNotAcceptable
*
* @param message contains more details to what you did wrong
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('ParametersNotAcceptable', message, NOT_ACCEPTABLE, stack);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {CONFLICT} from 'http-status-codes';
import {SCError} from '../error';
import {SCPluginMetaData} from '../routes/plugin-register';
/**
* An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin
* running at the same time.
* This usually indicates that there is more than one instance a plugin running.
*/
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
/**
* Meta data of a registered plugin, which is in a conflict with the plugin we want to register.
* If the stack is disabled this is not set for security reasons
*/
additionalData?: SCPluginMetaData;
/**
* Create a SCPluginAlreadyRegisteredError
*
* @param message Provide further information why an already registered plugin matches the one we want to register
* @param plugin Provides meta data of a registered plugin, which is in a conflict with the plugin we want to register
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, plugin: SCPluginMetaData, stack = false) {
super('SCPluginAlreadyRegisteredError', message, CONFLICT, stack);
if (stack) {
this.additionalData = plugin;
}
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {INTERNAL_SERVER_ERROR} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned whenever there is an unexpected error while creating a plugin
*/
export class SCPluginRegisteringFailedErrorResponse extends SCError {
/**
* Create a PluginRegisteringFailedError
*
* @param message Describes what went wrong wile registering the plugin
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('PluginRegisteringFailedError', message, INTERNAL_SERVER_ERROR, stack);
}
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,37 +12,19 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {REQUEST_TOO_LONG} from 'http-status-codes';
import {SCError} from '../error';
/** /**
* A postal address * An error that is returned, when the request body is too large.
*/ */
export interface SCPostalAddress { export class SCRequestBodyTooLargeErrorResponse extends SCError {
/** /**
* Country of the address * Create a SCRequestBodyTooLargeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/ */
addressCountry: string; constructor(stack?: boolean) {
super('RequestBodyTooLargeError', 'The request body is too large.', REQUEST_TOO_LONG, stack);
/** }
* City of the address
*/
addressLocality: string;
/**
* State of the address
*/
addressRegion?: string;
/**
* Zip code of the address
*/
postalCode: string;
/**
* Optional post box number
*/
postOfficeBoxNumber?: string;
/**
* Street of the address - with house number!
*/
streetAddress: string;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,25 +12,20 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCUuid} from '../../../types/UUID'; import {BAD_REQUEST} from 'http-status-codes';
import {SCBulkParameters} from './BulkRequest'; import {SCError} from '../error';
/** /**
* Requested Bulk from backend * An error that is returned whenever there is a syntax error
*
* @validatable
*/ */
export interface SCBulkResponse extends SCBulkParameters { export class SCSyntaxErrorResponse extends SCError {
/** /**
* State of bulk * Create a SyntaxError
* *
* The state is `in progress` while it accepts things to be added to the bulk. * @param message Describes the syntax error
* The state is `done` once it is closed. * @param stack Set to true if a stack trace should be created
*/ */
state: 'in progress' | 'done'; constructor(message: string, stack?: boolean) {
super('SyntaxError', message, BAD_REQUEST, stack);
/** }
* Universally unique identifier of the bulk
*/
uid: SCUuid;
} }

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {TOO_MANY_REQUESTS} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when to many request are submitted at once
*/
export class SCTooManyRequestsErrorResponse extends SCError {
/**
* Create a SCTooManyRequestsErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super(
'TooManyRequestsError',
'Too many requests. You can not submit more than 5 queries an once',
TOO_MANY_REQUESTS,
stack,
);
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {UNSUPPORTED_MEDIA_TYPE} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned when the content type of the request is not supported
*/
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
* Create a SCUnsupportedMediaTypeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('UnsupportedMediaTypeError', 'Unsupported media type', UNSUPPORTED_MEDIA_TYPE, stack);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {BAD_REQUEST} from 'http-status-codes';
import {ValidationError} from 'jsonschema';
import {SCError} from '../error';
/**
* An error that is returned when the validation of a request fails
*/
export class SCValidationErrorResponse extends SCError {
/**
* List of validatation errors
*/
additionalData: ValidationError[];
/**
* Create a SCValidationErrorResponse
*
* @param errors List of validation errors
* @param stack Set to true if a stack trace should be created
*/
constructor(errors: ValidationError[], stack?: boolean) {
super('ValidationError', 'Validation of request failed', BAD_REQUEST, stack);
this.additionalData = errors;
}
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,29 +12,17 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/** import {SCMap} from '../general/map';
* Possible HTTP verbs for routes import {SCErrorResponse} from './error';
*/ import {SCIndexRequest, SCIndexResponse} from './routes';
import {SCErrorResponse} from './protocol/errors/ErrorResponse'; import {SCBookAvailabilityRequest, SCBookAvailabilityResponse} from './routes/book-availability';
import {SCBookAvailabilityRequest} from './protocol/routes/bookAvailability/BookAvailabilityRequest'; import {SCBulkAddRequest, SCBulkAddResponse} from './routes/bulk-add';
import {SCBookAvailabilityResponse} from './protocol/routes/bookAvailability/BookAvailabilityResponse'; import {SCBulkDoneRequest, SCBulkDoneResponse} from './routes/bulk-done';
import {SCBulkRequest} from './protocol/routes/bulk/BulkRequest'; import {SCBulkRequest, SCBulkResponse} from './routes/bulk-request';
import {SCBulkResponse} from './protocol/routes/bulk/BulkResponse'; import {SCFeedbackRequest, SCFeedbackResponse} from './routes/feedback';
import {SCBulkAddRequest} from './protocol/routes/bulk/UID/BulkAddRequest'; import {SCSearchRequest, SCSearchResponse} from './routes/search';
import {SCBulkAddResponse} from './protocol/routes/bulk/UID/BulkAddResponse'; import {SCMultiSearchRequest, SCMultiSearchResponse} from './routes/search-multi';
import {SCBulkDoneRequest} from './protocol/routes/bulk/UID/BulkDoneRequest'; import {SCThingUpdateRequest, SCThingUpdateResponse} from './routes/thing-update';
import {SCBulkDoneResponse} from './protocol/routes/bulk/UID/BulkDoneResponse';
import {SCFeedbackRequest} from './protocol/routes/feedback/FeedbackRequest';
import {SCFeedbackResponse} from './protocol/routes/feedback/FeedbackResponse';
import {SCIndexRequest} from './protocol/routes/INDEX/IndexRequest';
import {SCIndexResponse} from './protocol/routes/INDEX/IndexResponse';
import {SCMultiSearchRequest} from './protocol/routes/search/MultiSearchRequest';
import {SCMultiSearchResponse} from './protocol/routes/search/MultiSearchResponse';
import {SCSearchRequest} from './protocol/routes/search/SearchRequest';
import {SCSearchResponse} from './protocol/routes/search/SearchResponse';
import {SCThingUpdateRequest} from './protocol/routes/TYPE/UID/ThingUpdateRequest';
import {SCThingUpdateResponse} from './protocol/routes/TYPE/UID/ThingUpdateResponse';
import {SCMap} from './types/Map';
/** /**
* Possible Verbs for HTTP requests * Possible Verbs for HTTP requests
@@ -48,7 +36,8 @@ export enum SCRouteHttpVerbs {
/** /**
* The constructor of an error response * The constructor of an error response
*/ */
export type SCErrorResponseConstructor = new (...args: any) => SCErrorResponse; // tslint:disable-next-line:no-any
export type SCErrorResponseConstructor = new (...args: any[]) => SCErrorResponse;
/** /**
* A description of a route * A description of a route
@@ -94,19 +83,41 @@ export interface SCRoute {
* An abstract route * An abstract route
*/ */
export abstract class SCAbstractRoute implements SCRoute { export abstract class SCAbstractRoute implements SCRoute {
/**
* @see SCRoute.errorNames
*/
errorNames: SCErrorResponseConstructor[] = []; errorNames: SCErrorResponseConstructor[] = [];
/**
* @see SCRoute.method
*/
method: SCRouteHttpVerbs = SCRouteHttpVerbs.GET; method: SCRouteHttpVerbs = SCRouteHttpVerbs.GET;
/**
* @see SCRoute.obligatoryParameters
*/
obligatoryParameters?: SCMap<string>; obligatoryParameters?: SCMap<string>;
/**
* @see SCRoute.requestBodyName
*/
requestBodyName = 'any'; requestBodyName = 'any';
/**
* @see SCRoute.responseBodyName
*/
responseBodyName = 'any'; responseBodyName = 'any';
/**
* @see SCRoute.statusCodeSuccess
*/
statusCodeSuccess = 200; statusCodeSuccess = 200;
/**
* @see SCRoute.urlFragment
*/
urlFragment = '/'; urlFragment = '/';
public getUrlFragment(parameters?: SCMap<string>): string { /**
if (typeof parameters === 'undefined') { * Get "compiled" URL fragment
parameters = {}; *
} * @param parameters Parameters to compile URL fragment with
*/
public getUrlFragment(parameters: SCMap<string> = {}): string {
let obligatoryParameters: string[] = []; let obligatoryParameters: string[] = [];
if (typeof this.obligatoryParameters === 'object') { if (typeof this.obligatoryParameters === 'object') {
@@ -126,14 +137,13 @@ export abstract class SCAbstractRoute implements SCRoute {
const parameter = part.substr(1); const parameter = part.substr(1);
// @ts-ignore
if (typeof parameters[parameter] === 'undefined') { if (typeof parameters[parameter] === 'undefined') {
throw new Error(`Parameter '${parameter}' not provided.`); throw new Error(`Parameter '${parameter}' not provided.`);
} }
// @ts-ignore
return parameters[parameter]; return parameters[parameter];
}).join('/'); })
.join('/');
} }
} }
@@ -164,3 +174,33 @@ export type SCResponses =
| SCMultiSearchResponse | SCMultiSearchResponse
| SCSearchResponse | SCSearchResponse
| SCThingUpdateResponse; | SCThingUpdateResponse;
/**
* Associated response for a request
*/
export type SCAssociatedResponse<REQUEST> =
REQUEST extends SCBookAvailabilityRequest ? SCBookAvailabilityResponse :
REQUEST extends SCBulkRequest ? SCBulkResponse :
REQUEST extends SCBulkAddRequest ? SCBulkAddResponse :
REQUEST extends SCBulkDoneRequest ? SCBulkDoneResponse :
REQUEST extends SCFeedbackRequest ? SCFeedbackResponse :
REQUEST extends SCIndexRequest ? SCIndexResponse :
REQUEST extends SCMultiSearchRequest ? SCMultiSearchResponse :
REQUEST extends SCSearchRequest ? SCSearchResponse :
REQUEST extends SCThingUpdateRequest ? SCThingUpdateResponse :
never;
/**
* Associated request for a response
*/
export type SCAssociatedRequest<RESPONSE> =
RESPONSE extends SCBookAvailabilityResponse ? SCBookAvailabilityRequest :
RESPONSE extends SCBulkResponse ? SCBulkRequest :
RESPONSE extends SCBulkAddResponse ? SCBulkAddRequest :
RESPONSE extends SCBulkDoneResponse ? SCBulkDoneRequest :
RESPONSE extends SCFeedbackResponse ? SCFeedbackRequest :
RESPONSE extends SCIndexResponse ? SCIndexRequest :
RESPONSE extends SCMultiSearchResponse ? SCMultiSearchRequest :
RESPONSE extends SCSearchResponse ? SCSearchRequest :
RESPONSE extends SCThingUpdateResponse ? SCThingUpdateRequest :
never;

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,20 +12,21 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {OK} from 'http-status-codes';
import {SCUuid} from '../../../types/UUID'; import {SCUuid} from '../../general/uuid';
import { import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../things/abstract/thing-that-can-be-offered';
SCInternalServerErrorResponse, import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCMethodNotAllowedErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCNotFoundErrorResponse, import {SCNotFoundErrorResponse} from '../errors/not-found';
SCRequestBodyTooLargeErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCSyntaxErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCUnsupportedMediaTypeErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCValidationErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
} from '../../errors/ErrorResponse'; import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
/** /**
* Request to check the availability of books * Request to check the availability of books
*
* @validatable * @validatable
*/ */
export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid; export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid;
@@ -50,6 +51,13 @@ export interface SCBookAvailabilityRequestByUuid {
uid: SCUuid; uid: SCUuid;
} }
/**
* List of availabilities of a book
*
* @validatable
*/
export type SCBookAvailabilityResponse = Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
/** /**
* Route for book availability * Route for book availability
* *
@@ -80,7 +88,7 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBookAvailabilityRequest'; this.requestBodyName = 'SCBookAvailabilityRequest';
this.responseBodyName = 'SCBookAvailabilityResponse'; this.responseBodyName = 'SCBookAvailabilityResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/bookAvailability'; this.urlFragment = '/bookAvailability';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,24 +12,32 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThings} from '../../../../Classes'; import {CREATED} from 'http-status-codes';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; import {SCThings} from '../../meta';
import { import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCInternalServerErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCMethodNotAllowedErrorResponse, import {SCNotFoundErrorResponse} from '../errors/not-found';
SCNotFoundErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCRequestBodyTooLargeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCSyntaxErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCUnsupportedMediaTypeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCValidationErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
} from '../../../errors/ErrorResponse';
/** /**
* Request to add a thing to a bulk * Request to add a thing to a bulk
*
* @validatable * @validatable
*/ */
export type SCBulkAddRequest = SCThings; export type SCBulkAddRequest = SCThings;
/**
* Response to a request to add a thing to a bulk
*
* @validatable
*/
export interface SCBulkAddResponse {
}
/** /**
* Route for indexing SC things in a bulk * Route for indexing SC things in a bulk
*/ */
@@ -51,7 +59,7 @@ export class SCBulkAddRoute extends SCAbstractRoute {
}; };
this.requestBodyName = 'SCBulkAddRequest'; this.requestBodyName = 'SCBulkAddRequest';
this.responseBodyName = 'SCBulkAddResponse'; this.responseBodyName = 'SCBulkAddResponse';
this.statusCodeSuccess = 201; this.statusCodeSuccess = CREATED;
this.urlFragment = '/bulk/:UID'; this.urlFragment = '/bulk/:UID';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,24 +12,32 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; import {NO_CONTENT} from 'http-status-codes';
import { import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCInternalServerErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCMethodNotAllowedErrorResponse, import {SCNotFoundErrorResponse} from '../errors/not-found';
SCNotFoundErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCRequestBodyTooLargeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCSyntaxErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCUnsupportedMediaTypeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCValidationErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
} from '../../../errors/ErrorResponse';
/** /**
* Request to change the bulk state to done (close the bulk process) * Request to change the bulk state to done (close the bulk process)
*
* @validatable * @validatable
*/ */
export interface SCBulkDoneRequest { export interface SCBulkDoneRequest {
} }
/**
* Response to a request to change the state of a bulk to done
*
* @validatable
*/
export interface SCBulkDoneResponse {
}
/** /**
* Route for closing bulks * Route for closing bulks
*/ */
@@ -51,7 +59,7 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
}; };
this.requestBodyName = 'SCBulkDoneRequest'; this.requestBodyName = 'SCBulkDoneRequest';
this.responseBodyName = 'SCBulkDoneResponse'; this.responseBodyName = 'SCBulkDoneResponse';
this.statusCodeSuccess = 204; this.statusCodeSuccess = NO_CONTENT;
this.urlFragment = '/bulk/:UID/done'; this.urlFragment = '/bulk/:UID/done';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,17 +12,17 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {OK} from 'http-status-codes';
import {SCThingType} from '../../../Thing'; import {SCISO8601Date} from '../../general/time';
import {SCISO8601Date} from '../../../types/Time'; import {SCUuid} from '../../general/uuid';
import { import {SCThingType} from '../../things/abstract/thing';
SCInternalServerErrorResponse, import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCMethodNotAllowedErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCRequestBodyTooLargeErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCSyntaxErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCUnsupportedMediaTypeErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCValidationErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
} from '../../errors/ErrorResponse'; import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
/** /**
* A bulk request * A bulk request
@@ -56,11 +56,31 @@ export interface SCBulkParameters {
/** /**
* Type of things that are indexed in this bulk. * Type of things that are indexed in this bulk.
* *
*/ */
type: SCThingType; type: SCThingType;
} }
/**
* Requested Bulk from backend
*
* @validatable
*/
export interface SCBulkResponse extends SCBulkParameters {
/**
* State of bulk
*
* The state is `in progress` while it accepts things to be added to the bulk.
* The state is `done` once it is closed.
*/
state: 'in progress' | 'done';
/**
* Universally unique identifier of the bulk
*/
uid: SCUuid;
}
/** /**
* Route for bulk creation * Route for bulk creation
*/ */
@@ -78,7 +98,7 @@ export class SCBulkRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBulkRequest'; this.requestBodyName = 'SCBulkRequest';
this.responseBodyName = 'SCBulkResponse'; this.responseBodyName = 'SCBulkResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/bulk'; this.urlFragment = '/bulk';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,16 +12,15 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {NO_CONTENT} from 'http-status-codes';
import {SCMessage} from '../../../things/Message'; import {SCMessage} from '../../things/message';
import { import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCInternalServerErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCMethodNotAllowedErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCRequestBodyTooLargeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCSyntaxErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCUnsupportedMediaTypeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCValidationErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
} from '../../errors/ErrorResponse';
/** /**
* User feedback * User feedback
@@ -35,6 +34,14 @@ export interface SCFeedbackRequest extends SCMessage {
metaData: SCFeedbackRequestMetaData; metaData: SCFeedbackRequestMetaData;
} }
/**
* A response to a feedback request
*
* @validatable
*/
export interface SCFeedbackResponse {
}
/** /**
* Route for feedback submission * Route for feedback submission
*/ */
@@ -52,7 +59,7 @@ export class SCFeedbackRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCFeedbackRequest'; this.requestBodyName = 'SCFeedbackRequest';
this.responseBodyName = 'SCFeedbackResponse'; this.responseBodyName = 'SCFeedbackResponse';
this.statusCodeSuccess = 204; this.statusCodeSuccess = NO_CONTENT;
this.urlFragment = '/feedback'; this.urlFragment = '/feedback';
} }
} }
@@ -74,7 +81,7 @@ export interface SCFeedbackRequestMetaData {
/** /**
* Scope/app state at feedback invocation * Scope/app state at feedback invocation
*/ */
scope: any; scope: unknown;
/** /**
* Whether or not the feedback is sendable * Whether or not the feedback is sendable
@@ -84,7 +91,7 @@ export interface SCFeedbackRequestMetaData {
/** /**
* App state that feedback was invoked from * App state that feedback was invoked from
*/ */
state: any; state: unknown;
/** /**
* User agent * User agent

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,15 +12,16 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {OK} from 'http-status-codes';
import { import {SCAppConfiguration} from '../../config/app';
SCInternalServerErrorResponse, import {SCBackendConfiguration} from '../../config/backend';
SCMethodNotAllowedErrorResponse, import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCRequestBodyTooLargeErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCSyntaxErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCUnsupportedMediaTypeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCValidationErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
} from '../../errors/ErrorResponse'; import {SCValidationErrorResponse} from '../errors/validation';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
/** /**
* Index request * Index request
@@ -30,6 +31,23 @@ import {
export interface SCIndexRequest { export interface SCIndexRequest {
} }
/**
* A response to an index request
*
* @validatable
*/
export interface SCIndexResponse {
/**
* @see SCAppConfiguration
*/
app: SCAppConfiguration;
/**
* @see SCBackendConfiguration
*/
backend: SCBackendConfiguration;
}
/** /**
* Route to request meta information about the deployment * Route to request meta information about the deployment
*/ */
@@ -47,7 +65,7 @@ export class SCIndexRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCIndexRequest'; this.requestBodyName = 'SCIndexRequest';
this.responseBodyName = 'SCIndexResponse'; this.responseBodyName = 'SCIndexResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/'; this.urlFragment = '/';
} }
} }

View File

@@ -0,0 +1,128 @@
/*
* 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 {OK} from 'http-status-codes';
import {Schema} from 'jsonschema';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
import {SCNotFoundErrorResponse} from '../errors/not-found';
import {SCParametersNotAcceptable} from '../errors/parameters-not-acceptable';
import {SCPluginAlreadyRegisteredErrorResponse} from '../errors/plugin-already-registered';
import {SCPluginRegisteringFailedErrorResponse} from '../errors/plugin-registering-failed';
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
/**
* Plugin register request
*
* @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;
}
/**
* Plugin register response
*
* @validatable
*/
export interface SCPluginRegisterResponse {
/**
* Whether the desired action succeeded or failed (true for success, false if an error occurred)
*/
success: boolean;
}
/**
* Route to register plugins
*/
export class SCPluginRegisterRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCNotFoundErrorResponse,
SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
];
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCPluginRegisterRequest';
this.responseBodyName = 'SCPluginRegisterResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/plugin/register';
}
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,18 +12,18 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {OK} from 'http-status-codes';
import {SCMap} from '../../../types/Map'; import {SCMap} from '../../general/map';
import { import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCInternalServerErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCMethodNotAllowedErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCRequestBodyTooLargeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCSyntaxErrorResponse, import {SCTooManyRequestsErrorResponse} from '../errors/too-many-requests';
SCTooManyRequestsErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCUnsupportedMediaTypeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCValidationErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
} from '../../errors/ErrorResponse'; import {SCSearchQuery} from '../search/query';
import {SCSearchQuery} from './SearchRequest'; import {SCSearchResult} from '../search/result';
/** /**
* A multi search request * A multi search request
@@ -36,6 +36,15 @@ import {SCSearchQuery} from './SearchRequest';
*/ */
export type SCMultiSearchRequest = SCMap<SCSearchQuery>; export type SCMultiSearchRequest = SCMap<SCSearchQuery>;
/**
* A multi search response
*
* This is a map of [[SCSearchResponse]]s indexed by name
*
* @validatable
*/
export type SCMultiSearchResponse = SCMap<SCSearchResult>;
/** /**
* Route for submission of multiple search requests at once * Route for submission of multiple search requests at once
*/ */
@@ -54,7 +63,7 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCMultiSearchRequest'; this.requestBodyName = 'SCMultiSearchRequest';
this.responseBodyName = 'SCMultiSearchResponse'; this.responseBodyName = 'SCMultiSearchResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/search/multi'; this.urlFragment = '/search/multi';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,17 +12,16 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import {OK} from 'http-status-codes';
import {SCSearchFilter} from '../../../types/filters/Abstract'; import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCSearchSort} from '../../../types/sorts/Abstract'; import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
import { import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCInternalServerErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCMethodNotAllowedErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCRequestBodyTooLargeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCSyntaxErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
SCUnsupportedMediaTypeErrorResponse, import {SCSearchQuery} from '../search/query';
SCValidationErrorResponse, import {SCSearchResult} from '../search/result';
} from '../../errors/ErrorResponse';
/** /**
* A search request * A search request
@@ -33,33 +32,11 @@ export interface SCSearchRequest extends SCSearchQuery {
} }
/** /**
* A search query * A search response
*
* @validatable
*/ */
export interface SCSearchQuery { export interface SCSearchResponse extends SCSearchResult {
/**
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
*/
filter?: SCSearchFilter;
/**
* Number of things to skip in result set (paging)
*/
from?: number;
/**
* A term to search for
*/
query?: string;
/**
* Number of things to have in the result set (paging)
*/
size?: number;
/**
* A list of sorting parameters to order the result set by
*/
sort?: SCSearchSort[];
} }
/** /**
@@ -79,7 +56,7 @@ export class SCSearchRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST; this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCSearchRequest'; this.requestBodyName = 'SCSearchRequest';
this.responseBodyName = 'SCSearchResponse'; this.responseBodyName = 'SCSearchResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/search'; this.urlFragment = '/search';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,17 +12,16 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThings} from '../../../../Classes'; import {OK} from 'http-status-codes';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route'; import {SCThings} from '../../meta';
import { import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
SCInternalServerErrorResponse, import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
SCMethodNotAllowedErrorResponse, import {SCNotFoundErrorResponse} from '../errors/not-found';
SCNotFoundErrorResponse, import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
SCRequestBodyTooLargeErrorResponse, import {SCSyntaxErrorResponse} from '../errors/syntax-error';
SCSyntaxErrorResponse, import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
SCUnsupportedMediaTypeErrorResponse, import {SCValidationErrorResponse} from '../errors/validation';
SCValidationErrorResponse, import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
} from '../../../errors/ErrorResponse';
/** /**
* Request to update an existing thing * Request to update an existing thing
@@ -31,6 +30,14 @@ import {
*/ */
export type SCThingUpdateRequest = SCThings; export type SCThingUpdateRequest = SCThings;
/**
* Response for an entity update request
*
* @validatable
*/
export interface SCThingUpdateResponse {
}
/** /**
* Route for updating existing things * Route for updating existing things
*/ */
@@ -53,7 +60,7 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
}; };
this.requestBodyName = 'SCThingUpdateRequest'; this.requestBodyName = 'SCThingUpdateRequest';
this.responseBodyName = 'SCThingUpdateResponse'; this.responseBodyName = 'SCThingUpdateResponse';
this.statusCodeSuccess = 200; this.statusCodeSuccess = OK;
this.urlFragment = '/:TYPE/:UID'; this.urlFragment = '/:TYPE/:UID';
} }
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,18 +12,34 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {Point, Polygon} from 'geojson'; import {SCThingsField} from '../../meta';
/** /**
* Positional information * A search facet
*/ */
export interface SCGeoInformation { export interface SCFacet {
/** /**
* Center point of a place * Buckets for the aggregation
*/ */
point: Point; buckets: SCFacetBucket[];
/** /**
* Shape of a place * Field of the aggregation
*/ */
polygon?: Polygon; field: SCThingsField;
}
/**
* A bucket of a facet
*/
export interface SCFacetBucket {
/**
* Count of matching search results
*/
count: number;
/**
* Key of a bucket
*/
key: string;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,14 +12,14 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMap} from '../Map'; import {SCMap} from '../../general/map';
/** /**
* All available filter types * All available filter types
*/ */
import {SCSearchAvailabilityFilter} from './Availability'; import {SCSearchAvailabilityFilter} from './filters/availability';
import {SCSearchBooleanFilter} from './Boolean'; import {SCSearchBooleanFilter} from './filters/boolean';
import {SCSearchDistanceFilter} from './Distance'; import {SCSearchDistanceFilter} from './filters/distance';
import {SCSearchValueFilter} from './Value'; import {SCSearchValueFilter} from './filters/value';
/** /**
* Filter instruction types * Filter instruction types
@@ -48,7 +48,7 @@ export interface SCSearchAbstractFilter<T extends SCSearchAbstractFilterArgument
/** /**
* Arguments for the filter instruction * Arguments for the filter instruction
*/ */
export type SCSearchAbstractFilterArguments = SCMap<any>; export type SCSearchAbstractFilterArguments = SCMap<unknown>;
/** /**
* Available filter instructions * Available filter instructions

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,9 +12,9 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingsField} from '../../Classes'; import {SCISO8601Date} from '../../../general/time';
import {SCISO8601Date} from '../Time'; import {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/** /**
* An availability filter * An availability filter
@@ -22,6 +22,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstrac
* Filter for documents where it cannot be safely determined that they are not available * Filter for documents where it cannot be safely determined that they are not available
*/ */
export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAvailabilityFilterArguments> { export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAvailabilityFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'availability'; type: 'availability';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter} from './Abstract'; import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter} from '../filter';
/** /**
* A boolean filter * A boolean filter
@@ -20,6 +20,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter}
* This filter can be used to combine multiple filters with boolean operations. * This filter can be used to combine multiple filters with boolean operations.
*/ */
export interface SCSearchBooleanFilter extends SCSearchAbstractFilter<SCBooleanFilterArguments> { export interface SCSearchBooleanFilter extends SCSearchAbstractFilter<SCBooleanFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'boolean'; type: 'boolean';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,9 +12,10 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// tslint:disable-next-line:no-implicit-dependencies
import {Position} from 'geojson'; import {Position} from 'geojson';
import {SCThingsField} from '../../Classes'; import {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/** /**
* A distance filter * A distance filter
@@ -22,6 +23,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstrac
* Filter for documents that are in the given distance of the given location * Filter for documents that are in the given distance of the given location
*/ */
export interface SCSearchDistanceFilter extends SCSearchAbstractFilter<SCSearchAbstractFilterArguments> { export interface SCSearchDistanceFilter extends SCSearchAbstractFilter<SCSearchAbstractFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'distance'; type: 'distance';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,13 +12,16 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingsField} from '../../Classes'; import {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract'; import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/** /**
* Filters for documents that match the value on the given field * Filters for documents that match the value on the given field
*/ */
export interface SCSearchValueFilter extends SCSearchAbstractFilter<SCValueFilterArguments> { export interface SCSearchValueFilter extends SCSearchAbstractFilter<SCValueFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'value'; type: 'value';
} }

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCSearchContext} from '../../config/backend';
import {SCSearchFilter} from './filter';
import {SCSearchSort} from './sort';
/**
* A search query
*/
export interface SCSearchQuery {
/**
* The context name from where the search query was initiated
*/
context?: SCSearchContext;
/**
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
*/
filter?: SCSearchFilter;
/**
* Number of things to skip in result set (paging)
*/
from?: number;
/**
* A term to search for
*/
query?: string;
/**
* Number of things to have in the result set (paging)
*/
size?: number;
/**
* A list of sorting parameters to order the result set by
*/
sort?: SCSearchSort[];
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,15 +12,8 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThings, SCThingsField} from '../../../Classes'; import {SCThings} from '../../meta';
import {SCFacet} from './facet';
/**
* A search response
*
* @validatable
*/
export interface SCSearchResponse extends SCSearchResult {
}
/** /**
* A search response * A search response
@@ -39,48 +32,18 @@ export interface SCSearchResult {
/** /**
* Pagination information * Pagination information
*/ */
pagination: SCSearchResponsePagination; pagination: SCSearchResultPagination;
/** /**
* Stats of the search engine * Stats of the search engine
*/ */
stats: SCSearchResponseSearchEngineStats; stats: SCSearchResultSearchEngineStats;
}
/**
* A search facet
*/
export interface SCFacet {
/**
* Buckets for the aggregation
*/
buckets: SCFacetBucket[];
/**
* Field of the aggregation
*/
field: SCThingsField;
}
/**
* A bucket of a facet
*/
export interface SCFacetBucket {
/**
* Count of matching search results
*/
count: number;
/**
* Key of a bucket
*/
key: string;
} }
/** /**
* Stores information about Pagination * Stores information about Pagination
*/ */
export interface SCSearchResponsePagination { export interface SCSearchResultPagination {
/** /**
* Count of given data. Same as data.length * Count of given data. Same as data.length
*/ */
@@ -100,7 +63,7 @@ export interface SCSearchResponsePagination {
/** /**
* Statistics of search engine * Statistics of search engine
*/ */
export interface SCSearchResponseSearchEngineStats { export interface SCSearchResultSearchEngineStats {
/** /**
* Response time of the search engine in ms * Response time of the search engine in ms
*/ */

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,11 +12,11 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingsField} from '../../Classes'; import {SCMap} from '../../general/map';
import {SCMap} from '../Map'; import {SCThingsField} from '../../meta';
import {SCDistanceSort} from './Distance'; import {SCDistanceSort} from './sorts/distance';
import {SCDucetSort} from './Ducet'; import {SCDucetSort} from './sorts/ducet';
import {SCPriceSort} from './Price'; import {SCPriceSort} from './sorts/price';
/** /**
* Abstract sort instruction * Abstract sort instruction
@@ -41,7 +41,7 @@ export interface SCSearchAbstractSort<T extends SCSearchAbstractSortArguments> {
/** /**
* Map of arguments for the sort instruction * Map of arguments for the sort instruction
*/ */
export interface SCSearchAbstractSortArguments extends SCMap<any> { export interface SCSearchAbstractSortArguments extends SCMap<unknown> {
/** /**
* Field to sort by * Field to sort by
*/ */

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,13 +12,17 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// tslint:disable-next-line:no-implicit-dependencies
import {Position} from 'geojson'; import {Position} from 'geojson';
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
/** /**
* Sort instruction to sort by distance * Sort instruction to sort by distance
*/ */
export interface SCDistanceSort extends SCSearchAbstractSort<SCDistanceSortArguments> { export interface SCDistanceSort extends SCSearchAbstractSort<SCDistanceSortArguments> {
/**
* @see SCSearchAbstractSort.type
*/
type: 'distance'; type: 'distance';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,11 +12,14 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
/** /**
* Sort instruction for ducet sort * Sort instruction for ducet sort
*/ */
export interface SCDucetSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> { export interface SCDucetSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> {
/**
* @see SCSearchAbstractSort.type
*/
type: 'ducet'; type: 'ducet';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,13 +12,16 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCSportCoursePriceGroup} from '../../things/DateSeries'; import {SCSportCoursePriceGroup} from '../../../things/date-series';
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract'; import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
/** /**
* Sort instruction to sort by price * Sort instruction to sort by price
*/ */
export interface SCPriceSort extends SCSearchAbstractSort<SCPriceSortArguments> { export interface SCPriceSort extends SCSearchAbstractSort<SCPriceSortArguments> {
/**
* @see SCSearchAbstractSort.type
*/
type: 'price'; type: 'price';
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,51 +12,64 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing} from '../Thing'; import {SCMetaTranslations} from '../../general/i18n';
import {SCThingMeta} from '../Thing'; import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
import {SCMetaTranslations} from '../types/i18n';
/** /**
* An academic degree without references * An academic degree without references
*/ */
export interface SCAcademicDegreeWithoutReferences extends SCThing { export interface SCAcademicDegreeWithoutReferences
extends SCThingWithoutReferences {
/** /**
* The achievable academic degree * The achievable academic degree
*/ */
academicDegree: SCGermanAcademicDegree; academicDegree: SCGermanAcademicDegree;
/** /**
* The achievable academic degree with academic field specification * The achievable academic degree with academic field specification
* (eg. Master of Science) * (eg. Master of Science)
*
* @keyword
*/ */
academicDegreewithField: string; academicDegreewithField: string;
/** /**
* The achievable academic degree with academic field specification * The achievable academic degree with academic field specification
* shorted (eg. M.Sc.). * shorted (eg. M.Sc.).
*
* @keyword
*/ */
academicDegreewithFieldShort: string; academicDegreewithFieldShort: string;
} }
export interface SCAcademicDegree extends SCAcademicDegreeWithoutReferences { /**
* An academic degree
*/
export interface SCAcademicDegree
extends SCAcademicDegreeWithoutReferences, SCThing {
// noop
} }
/** /**
* Meta information about academic degrees * Meta information about academic degrees
*/ */
export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslations<SCAcademicDegree> { export class SCAcademicDegreeMeta
extends SCThingMeta implements SCMetaTranslations<SCAcademicDegree> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
...SCThingMeta.getInstance().fieldTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
academicDegree: 'Hochschulgrad', academicDegree: 'Hochschulgrad',
academicDegreewithField: 'Abschlussbezeichnungen', academicDegreewithField: 'Abschlussbezeichnungen',
academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)', academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)',
}, },
en: { en: {
...SCThingMeta.getInstance().fieldTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
academicDegree: 'academic degree',
academicDegreewithField: 'acedemic degree and discipline',
academicDegreewithFieldShort: 'acedemic degree and discipline (short)',
}, },
}; };
@@ -65,7 +78,7 @@ export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslati
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
...SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
academicDegree: { academicDegree: {
'bachelor': 'Bachelor', 'bachelor': 'Bachelor',
'diploma': 'Diplom', 'diploma': 'Diplom',
@@ -78,7 +91,7 @@ export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslati
}, },
}, },
en: { en: {
...SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
}, },
}; };
} }
@@ -86,11 +99,12 @@ export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslati
/** /**
* Types of (german) academic degrees * Types of (german) academic degrees
*/ */
export type SCGermanAcademicDegree = 'bachelor' | export type SCGermanAcademicDegree =
'diploma' | 'bachelor'
'doctor' | | 'diploma'
'licentiate' | | 'doctor'
'magister' | | 'licentiate'
'master' | | 'magister'
'master pupil' | | 'master'
'state examination' ; | 'master pupil'
| 'state examination' ;

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,16 +12,20 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta} from '../Thing'; import {SCMetaTranslations} from '../../general/i18n';
import {SCMetaTranslations} from '../types/i18n'; import {SCISO8601Date} from '../../general/time';
import {SCISO8601Date} from '../types/Time'; import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
/** /**
* An academic term without references * 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 * Short name of the academic term, using the given pattern
*
* @aggregatable
* @keyword
*/ */
acronym: string; acronym: string;
@@ -46,31 +50,50 @@ export interface SCAcademicTermWithoutReferences extends SCThing {
startDate: SCISO8601Date; startDate: SCISO8601Date;
} }
/**
* An academic term
*/
export interface SCAcademicTerm
extends SCAcademicTermWithoutReferences, SCThing {
// noop
}
/** /**
* Meta information about academic terms * Meta information about academic terms
*/ */
export class SCAcademicTermWithoutReferencesMeta extends SCThingMeta implements SCMetaTranslations<SCThing> { export class SCAcademicTermWithoutReferencesMeta
extends SCThingMeta implements SCMetaTranslations<SCThing> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
acronym: 'Akronym',
endDate: 'Enddatum',
eventsEndDate: 'Enddatum der Veranstaltungen',
eventsStartDate: 'Startdatum der Veranstaltungen',
startDate: 'Startdatum',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldTranslations.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 * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
}, },
}; };
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,21 +12,24 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing'; import {SCLanguage, SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCOrganizationWithoutReferences} from '../things/Organization'; import {SCISO8601Date} from '../../general/time';
import {SCPersonWithoutReferences} from '../things/Person'; import {SCOrganizationWithoutReferences} from '../organization';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCPersonWithoutReferences} from '../person';
import {SCISO8601Date} from '../types/Time'; import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
import { import {
SCAcademicPriceGroup, SCAcademicPriceGroup,
SCThingThatCanBeOffered, SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties,
} from './ThingThatCanBeOffered'; SCThingThatCanBeOfferedWithoutReferences,
} from './thing-that-can-be-offered';
/** /**
* A creative work without references * A creative work without references
*/ */
export interface SCCreativeWorkWithoutReferences extends SCThing { export interface SCCreativeWorkWithoutReferences
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/** /**
* Date the creative work was published * Date the creative work was published
*/ */
@@ -39,6 +42,9 @@ export interface SCCreativeWorkWithoutReferences extends SCThing {
/** /**
* Keywords of the creative work * Keywords of the creative work
*
* @aggregatable
* @keyword
*/ */
keywords?: string[]; keywords?: string[];
@@ -51,7 +57,8 @@ export interface SCCreativeWorkWithoutReferences extends SCThing {
/** /**
* A creative work * A creative work
*/ */
export interface SCCreativeWork extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> { export interface SCCreativeWork
extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/** /**
* Authors of the creative work * Authors of the creative work
*/ */
@@ -75,6 +82,8 @@ export interface SCCreativeWorkTranslatableProperties
extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties { extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/** /**
* Translation of the keywords of the creative work * Translation of the keywords of the creative work
*
* @keyword
*/ */
keywords?: string[]; keywords?: string[];
} }
@@ -82,28 +91,43 @@ export interface SCCreativeWorkTranslatableProperties
/** /**
* Meta information about creative works * Meta information about creative works
*/ */
export class SCCreativeWorkMeta extends SCThingMeta implements SCMetaTranslations<SCCreativeWork> { export class SCCreativeWorkMeta
extends SCThingMeta implements SCMetaTranslations<SCCreativeWork> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().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: { en: {
... SCThingMeta.getInstance().fieldTranslations.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 * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
}, },
}; };
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,21 +12,24 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta} from '../Thing'; import {SCMetaTranslations} from '../../general/i18n';
import {SCCatalogWithoutReferences} from '../things/Catalog'; import {SCCatalogWithoutReferences} from '../catalog';
import {SCPersonWithoutReferences} from '../things/Person'; import {SCPersonWithoutReferences} from '../person';
import {SCSemesterWithoutReferences} from '../things/Semester'; import {SCSemesterWithoutReferences} from '../semester';
import {SCMetaTranslations} from '../types/i18n'; import {SCCreativeWorkWithoutReferences} from './creative-work';
import {SCCreativeWorkWithoutReferences} from './CreativeWork'; import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
/** /**
* An event without references * An event without references
*/ */
export interface SCEventWithoutReferences extends SCThing { export interface SCEventWithoutReferences
extends SCThingWithoutReferences {
/** /**
* Maximum number of participants of the event * Maximum number of participants of the event
* *
* A maximum number of people that can participate in the event. * A maximum number of people that can participate in the event.
*
* @integer
*/ */
maximumParticipants?: number; maximumParticipants?: number;
@@ -34,6 +37,8 @@ export interface SCEventWithoutReferences extends SCThing {
* Remaining attendee capacity of the event * Remaining attendee capacity of the event
* *
* This number represents the remaining open spots. * This number represents the remaining open spots.
*
* @integer
*/ */
remainingAttendeeCapacity?: number; remainingAttendeeCapacity?: number;
} }
@@ -41,7 +46,8 @@ export interface SCEventWithoutReferences extends SCThing {
/** /**
* An event * An event
*/ */
export interface SCEvent extends SCEventWithoutReferences { export interface SCEvent
extends SCEventWithoutReferences, SCThing {
/** /**
* Academic terms that an event belongs to, e.g. semester(s). * Academic terms that an event belongs to, e.g. semester(s).
*/ */
@@ -73,28 +79,43 @@ export interface SCEvent extends SCEventWithoutReferences {
/** /**
* Meta information about events * Meta information about events
*/ */
export class SCEventMeta extends SCThingMeta implements SCMetaTranslations<SCEvent> { export class SCEventMeta
extends SCThingMeta implements SCMetaTranslations<SCEvent> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().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: { en: {
... SCThingMeta.getInstance().fieldTranslations.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 * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
}, },
}; };
} }

View File

@@ -0,0 +1,176 @@
/*
* 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/>.
*/
// tslint:disable-next-line:no-implicit-dependencies
import {Point, Polygon} from 'geojson';
import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCBuildingWithoutReferences} from '../building';
import {SCPointOfInterestWithoutReferences} from '../point-of-interest';
import {SCRoomWithoutReferences} from '../room';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/**
* Positional information
*/
export interface SCGeoInformation {
/**
* Center point of a place
*/
point: Point;
/**
* Shape of a place
*/
polygon?: Polygon;
}
/**
* A postal address
*/
export interface SCPostalAddress {
/**
* Country of the address
*/
addressCountry: string;
/**
* City of the address
*/
addressLocality: string;
/**
* State of the address
*/
addressRegion?: string;
/**
* Zip code of the address
*/
postalCode: string;
/**
* Optional post box number
*/
postOfficeBoxNumber?: string;
/**
* Street of the address - with house number!
*/
streetAddress: string;
}
/**
* A place without references
*/
export interface SCPlaceWithoutReferences
extends SCThingWithoutReferences {
/**
* Address of the place
*/
address?: SCPostalAddress;
/**
* Positional information of the place
*
* !!! BEWARE !!!
* Can not be a GeometryCollection because ElasticSearch does not allow distance filtering/sorting on other types
*/
geo: SCGeoInformation;
/**
* Opening hours of the place
*
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
* @keyword
*/
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 of a place
*/
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,
},
};
}
/**
* 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, 2019 StApps * Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,24 +12,27 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * 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. * An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/ */
export interface SCSaveableThingWithoutReferences 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 * Type of the origin
*/ */
origin: SCThingUserOrigin; origin: SCThingUserOrigin;
} }
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThing<T extends SCThing> extends SCSaveableThingWithoutReferences {
/**
* The contained data
*/
data: T;
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,29 +12,33 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta} from '../Thing'; import {SCMetaTranslations} from '../../general/i18n';
import {SCMetaTranslations} from '../types/i18n'; import {SCInPlace} from './place';
import {SCInPlace} from '../types/Places'; import {SCThing, SCThingMeta} from './thing';
/** /**
* A thing that is or happens in a place * A thing that is or happens in a place
*/ */
export interface SCThingInPlace extends SCThing, SCInPlace {} export interface SCThingInPlace
extends SCThing, SCInPlace {
// noop
}
/** /**
* Meta information about thing in a place * Meta information about thing in a place
*/ */
export class SCThingInPlaceMeta extends SCThingMeta implements SCMetaTranslations<SCThingInPlace> { export class SCThingInPlaceMeta
extends SCThingMeta implements SCMetaTranslations<SCThingInPlace> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
inPlace: 'Ort', inPlace: 'Ort',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
inPlace: 'location', inPlace: 'location',
}, },
}; };
@@ -42,12 +46,12 @@ export class SCThingInPlaceMeta extends SCThingMeta implements SCMetaTranslation
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
}, },
}; };
} }

View File

@@ -0,0 +1,80 @@
/*
* 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 {SCMetaTranslations} from '../../general/i18n';
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
/**
* Types of payment that are accepted at a place.
*/
export type SCThingThatAcceptsPaymentsAcceptedPayments =
'cash'
| 'credit'
| 'cafeteria card';
/**
* A thing without references that accepts payments
*/
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-2019 StApps * Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,12 +12,12 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingTranslatableProperties} from '../Thing'; import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCOrganizationWithoutReferences} from '../things/Organization'; import {SCISO8601Date} from '../../general/time';
import {SCPersonWithoutReferences} from '../things/Person'; import {SCOrganizationWithoutReferences} from '../organization';
import {SCTranslations} from '../types/i18n'; import {SCPersonWithoutReferences} from '../person';
import {SCISO8601Date} from '../types/Time'; import {SCInPlace} from './place';
import {SCInPlace} from './../types/Places'; import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/** /**
* Default price without distinction * Default price without distinction
@@ -25,6 +25,9 @@ import {SCInPlace} from './../types/Places';
export interface SCPriceGroup { export interface SCPriceGroup {
/** /**
* Default price of the thing * Default price of the thing
*
* @sortable price
* @float
*/ */
default: number; default: number;
} }
@@ -32,28 +35,49 @@ export interface SCPriceGroup {
/** /**
* Price distinctions for academic context * Price distinctions for academic context
*/ */
export interface SCAcademicPriceGroup extends SCPriceGroup { export interface SCAcademicPriceGroup
extends SCPriceGroup {
/** /**
* Price for employees * Price for employees
*
* @sortable price
* @float
*/ */
employee?: number; employee?: number;
/** /**
* Price for guests * Price for guests
*
* @sortable price
* @float
*/ */
guest?: number; guest?: number;
/** /**
* Price for students * Price for students
*
* @sortable price
* @float
*/ */
student?: number; student?: number;
} }
/** /**
* A thing without references that has a price tag * A thing without references that can be offered
*/
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> export interface SCThingThatCanBeOffered<T extends SCPriceGroup>
extends SCThing { extends SCThing, SCThingThatCanBeOfferedWithoutReferences {
/** /**
* List of offers for that thing * List of offers for that thing
*/ */
@@ -103,6 +127,8 @@ export interface SCThingThatCanBeOfferedTranslatableProperties
extends SCThingTranslatableProperties { extends SCThingTranslatableProperties {
/** /**
* Availability of an offer * Availability of an offer
*
* @keyword
*/ */
'offers[].availability'?: string; 'offers[].availability'?: string;
} }
@@ -122,3 +148,57 @@ export type SCThingThatCanBeOfferedAvailability =
| 'out of stock' | 'out of stock'
| 'online only' | 'online only'
| 'limited availability'; | 'limited availability';
/**
* Meta information about a thing without references that accepts payments
*/
export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup>
implements SCMetaTranslations<SCThingThatCanBeOffered<T>> {
/**
* Instance
*/
protected static _instance = new Map<string, unknown>();
/**
* 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,
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T extends SCPriceGroup>(): SCThingThatCanBeOfferedMeta<T> {
if (!SCThingThatCanBeOfferedMeta._instance.has(this.name)) {
SCThingThatCanBeOfferedMeta._instance.set(this.name, new SCThingThatCanBeOfferedMeta<T>());
}
return SCThingThatCanBeOfferedMeta._instance
.get(this.name) as SCThingThatCanBeOfferedMeta<T>;
}
protected constructor() {
}
}

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,21 +12,23 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing'; import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCMap} from '../../general/map';
import {SCMap} from '../types/Map'; import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/** /**
* A thing without references with categories * A thing without references with categories
* *
* !!! BEWARE !!! * !!! BEWARE !!!
* `T` should be a union type - e.g. `T = 'foo' | 'bar' | 'foobar';` * `T` should be a string literal union type - e.g. `T = 'foo' | 'bar' | 'foobar';`
*/ */
export interface SCThingWithCategoriesWithoutReferences<T, export interface SCThingWithCategoriesWithoutReferences<T, U extends SCThingWithCategoriesSpecificValues>
U extends SCThingWithCategoriesSpecificValues> extends SCThingWithoutReferences {
extends SCThing {
/** /**
* Categories of a thing with categories * Categories of a thing with categories
*
* @sortable ducet
* @aggregatable
*/ */
categories: T[]; categories: T[];
@@ -43,10 +45,22 @@ export interface SCThingWithCategoriesWithoutReferences<T,
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>; 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 * 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 * translations of the categories of a thing with categories
*/ */
@@ -61,67 +75,92 @@ export interface SCThingWithCategoriesTranslatableProperties extends SCThingTran
export interface SCThingWithCategoriesSpecificValues { export interface SCThingWithCategoriesSpecificValues {
/** /**
* Category specific alternate names of a thing * Category specific alternate names of a thing
*
* @keyword
*/ */
alternateNames?: string[]; alternateNames?: string[];
/** /**
* Category specific description of a thing * Category specific description of a thing
*
* @text
*/ */
description?: string; description?: string;
/** /**
* Category specific image of a thing * URL of a category specific image of a thing
*
* @keyword
*/ */
image?: string; image?: string;
/** /**
* Category specific name of a thing * Category specific name of a thing
*
* @text
*/ */
name?: string; name?: string;
/** /**
* Category specific URL of a thing * Category specific URL of a thing
*
* @keyword
*/ */
url?: string; url?: string;
} }
/** /**
* Meta information about a thing without references that accepts payments * 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 export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> { implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
protected static _instance: SCThingMeta; /**
* Instance
*/
protected static _instance = new Map<string, unknown>();
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
categories: 'Kategorien',
categorySpecificValues: 'besondere Kategorien',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
categories: 'categories',
categorySpecificValues: 'category with specific values',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
}, },
}; };
// tslint:disable:static-this
/** /**
* Function to retrieve typed singleton instance (including generics) * Function to retrieve typed singleton instance (including generics)
*/ */
public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> { public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> {
return this._instance || (this._instance = new this<T, U>()); if (!SCThingWithCategoriesWithoutReferencesMeta._instance.has(this.name)) {
SCThingWithCategoriesWithoutReferencesMeta._instance
.set(this.name, new SCThingWithCategoriesWithoutReferencesMeta<T, U>());
}
return SCThingWithCategoriesWithoutReferencesMeta._instance
.get(this.name) as SCThingWithCategoriesWithoutReferencesMeta<T, U>;
} }
protected constructor() { protected constructor() {

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,11 +12,11 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCOrganization} from './things/Organization'; import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCPerson} from './things/Person'; import {SCISO8601Date} from '../../general/time';
import {SCMetaTranslations, SCTranslations} from './types/i18n'; import {SCUuid} from '../../general/uuid';
import {SCISO8601Date} from './types/Time'; import {SCOrganizationWithoutReferences} from '../organization';
import {SCUuid} from './types/UUID'; import {SCPersonWithoutReferences} from '../person';
/** /**
* Types a thing can be * Types a thing can be
@@ -41,6 +41,7 @@ export enum SCThingType {
Semester = 'semester', Semester = 'semester',
Setting = 'setting', Setting = 'setting',
SportCourse = 'sport course', SportCourse = 'sport course',
StudyModule = 'study module',
Ticket = 'ticket', Ticket = 'ticket',
ToDo = 'todo', ToDo = 'todo',
Tour = 'tour', Tour = 'tour',
@@ -48,33 +49,36 @@ export enum SCThingType {
} }
/** /**
* A thing * A thing without references
*/ */
export interface SCThing { export interface SCThingWithoutReferences {
/** /**
* Alternate names of the thing * Alternate names of the thing
*
* @keyword
*/ */
alternateNames?: string[]; alternateNames?: string[];
/** /**
* Description of the thing * Description of the thing
* *
* @minLength 1 * @minLength 1
* @text
*/ */
description?: string; description?: string;
/** /**
* Image of the thing * URL of an image of the thing
*
* @keyword
*/ */
image?: string; image?: string;
/** /**
* Name of the thing * Name of the thing
* *
* @minLength 1 * @minLength 1
* @sortable ducet
* @text
*/ */
name: string; name: string;
/**
* Origin of the thing
*/
origin: SCThingRemoteOrigin | SCThingUserOrigin;
/** /**
* Translations of specific values of the object * Translations of specific values of the object
* *
@@ -83,6 +87,9 @@ export interface SCThing {
translations?: SCTranslations<SCThingTranslatableProperties>; translations?: SCTranslations<SCThingTranslatableProperties>;
/** /**
* Type of the thing * Type of the thing
*
* @sortable ducet
* @aggregatable
*/ */
type: SCThingType; type: SCThingType;
/** /**
@@ -95,6 +102,16 @@ export interface SCThing {
url?: string; url?: string;
} }
/**
* A thing
*/
export interface SCThing extends SCThingWithoutReferences {
/**
* Origin of the thing
*/
origin: SCThingRemoteOrigin | SCThingUserOrigin;
}
/** /**
* Possible types of an origin * Possible types of an origin
*/ */
@@ -112,7 +129,7 @@ export interface SCThingOrigin {
* *
* e.g. restaurant of a dish * e.g. restaurant of a dish
*/ */
maintainer?: SCPerson | SCOrganization; maintainer?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
/** /**
* When the thing was modified last in the origin * When the thing was modified last in the origin
@@ -136,6 +153,8 @@ export interface SCThingRemoteOrigin extends SCThingOrigin {
/** /**
* Name of the origin * Name of the origin
*
* @text
*/ */
name: string; name: string;
@@ -149,7 +168,7 @@ export interface SCThingRemoteOrigin extends SCThingOrigin {
* *
* e.g. an organizer for an event * e.g. an organizer for an event
*/ */
responsibleEntity?: SCPerson | SCOrganization; responsibleEntity?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
/** /**
* Type of the origin * Type of the origin
@@ -193,10 +212,14 @@ export interface SCThingUserOrigin extends SCThingOrigin {
export interface SCThingTranslatableProperties { export interface SCThingTranslatableProperties {
/** /**
* Translation of the description of the thing * Translation of the description of the thing
*
* @text
*/ */
description?: string; description?: string;
/** /**
* Translation of the name of the thing * Translation of the name of the thing
*
* @text
*/ */
name?: string; name?: string;
/** /**
@@ -211,6 +234,8 @@ export interface SCThingTranslatableProperties {
export interface SCThingTranslatablePropertyOrigin { export interface SCThingTranslatablePropertyOrigin {
/** /**
* Translation of the name of the origin * Translation of the name of the origin
*
* @text
*/ */
name: string; name: string;
} }
@@ -222,7 +247,7 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
/** /**
* Set type definiton for singleton instance * Set type definiton for singleton instance
*/ */
protected static _instance: SCThingMeta; protected static _instance = new Map<string, unknown>();
/** /**
* Translations of fields * Translations of fields
@@ -255,7 +280,7 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
type: 'Ding', type: 'Ding',
}, },
@@ -264,13 +289,18 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
}, },
}; };
// tslint:disable:static-this
/** /**
* Function to retrieve typed singleton instance * Function to retrieve typed singleton instance
*/ */
public static getInstance<T extends SCThingMeta>(): T { public static getInstance<T extends SCThingMeta>(): T {
const typedThis = this as any as typeof SCThingMeta; if (!SCThingMeta._instance.has(this.name)) {
return (typedThis._instance || (typedThis._instance = new this())) as T; SCThingMeta._instance.set(this.name, new this());
}
return SCThingMeta._instance.get(this.name) as T;
} }
protected constructor() {} protected constructor() {
}
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,30 +12,35 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event'; import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event';
import {SCThingMeta, SCThingType} from './abstract/thing';
import { import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta, SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories'; } from './abstract/thing-with-categories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/** /**
* An academic event without references * An academic event without references
*/ */
export interface SCAcademicEventWithoutReferences export interface SCAcademicEventWithoutReferences
extends SCEventWithoutReferences, extends SCEventWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories, SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesSpecificValues> {
/** /**
* Majors of the academic event that this event belongs to * Majors of the academic event that this event belongs to
*
* @aggregatable
* @keyword
*/ */
majors?: string[]; majors?: string[];
/** /**
* Original unmapped category from the source of the academic event * Original unmapped category from the source of the academic event
*
* @keyword
*/ */
originalCategory?: string; originalCategory?: string;
@@ -54,8 +59,11 @@ export interface SCAcademicEventWithoutReferences
* An academic event * An academic event
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferences { export interface SCAcademicEvent
extends SCEvent, SCAcademicEventWithoutReferences,
SCThingWithCategories<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
/** /**
* Translated fields of an academic event * Translated fields of an academic event
*/ */
@@ -75,6 +83,7 @@ export type SCAcademicEventCategories =
| 'seminar' | 'seminar'
| 'integrated course' | 'integrated course'
| 'written exam' | 'written exam'
| 'oral exam'
| 'tutorial' | 'tutorial'
| 'project' | 'project'
| 'colloquium' | 'colloquium'
@@ -92,11 +101,15 @@ export interface SCAcademicEventTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties { extends SCThingWithCategoriesTranslatableProperties {
/** /**
* Translations of the majors of the academic event that this event belongs to * Translations of the majors of the academic event that this event belongs to
*
* @keyword
*/ */
majors?: string[]; majors?: string[];
/** /**
* Translation of the original unmapped category from the source of the academic event * Translation of the original unmapped category from the source of the academic event
*
* @keyword
*/ */
originalCategory?: string; originalCategory?: string;
} }
@@ -104,37 +117,59 @@ export interface SCAcademicEventTranslatableProperties
/** /**
* Meta information about academic events * Meta information about academic events
*/ */
export class SCAcademicEventMeta extends SCThingMeta implements SCMetaTranslations<SCAcademicEvent> { export class SCAcademicEventMeta
extends SCThingMeta
implements SCMetaTranslations<SCAcademicEvent> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCEventMeta.getInstance().fieldTranslations.de, ...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de, SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
majors: 'Hauptfächer',
originalCategory: 'ursprüngliche Kategorie',
}, },
en: { en: {
... SCEventMeta.getInstance().fieldTranslations.en, ...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en, SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
majors: 'majors',
originalCategory: 'original category',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCEventMeta.getInstance().fieldValueTranslations.de, ...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de, 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', type: 'akademische Veranstaltung',
}, },
en: { en: {
... SCEventMeta.getInstance().fieldValueTranslations.en, ...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.AcademicEvent, type: SCThingType.AcademicEvent,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,30 +12,32 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import { import {
SCCreativeWork, SCCreativeWork,
SCCreativeWorkMeta, SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties, SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences, SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork'; } from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import { import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta, SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories'; } from './abstract/thing-with-categories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/** /**
* An article without references * An article without references
*/ */
export interface SCArticleWithoutReferences export interface SCArticleWithoutReferences
extends SCCreativeWorkWithoutReferences, extends SCCreativeWorkWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesSpecificValues> {
/** /**
* Article itself as markdown * Article itself as markdown
*
* @text
*/ */
articleBody: string; articleBody: string;
@@ -54,8 +56,11 @@ export interface SCArticleWithoutReferences
* An article * An article
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCArticle extends SCCreativeWork, SCArticleWithoutReferences { export interface SCArticle
extends SCCreativeWork, SCArticleWithoutReferences,
SCThingWithCategories<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
/** /**
* Translated fields of an article * Translated fields of an article
*/ */
@@ -79,6 +84,8 @@ export interface SCArticleTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
/** /**
* Translation of the article itself as markdown * Translation of the article itself as markdown
*
* @text
*/ */
articleBody?: string[]; articleBody?: string[];
} }
@@ -86,37 +93,47 @@ export interface SCArticleTranslatableProperties
/** /**
* Meta information about an article * Meta information about an article
*/ */
export class SCArticleMeta extends SCThingMeta implements SCMetaTranslations<SCArticle> { export class SCArticleMeta
extends SCThingMeta implements SCMetaTranslations<SCArticle> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories, .de,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
articleBody: 'Artikelinhalt',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories, .en,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
articleBody: 'article body',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories, .fieldValueTranslations.de,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
'unipedia': 'Unipedia',
},
type: 'Artikel', type: 'Artikel',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories, .fieldValueTranslations.en,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Article, type: SCThingType.Article,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,33 +12,40 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import { import {
SCCreativeWork, SCCreativeWork,
SCCreativeWorkMeta, SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties, SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences, SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork'; } from './abstract/creative-work';
import {SCThingWithCategoriesTranslatableProperties} from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingMeta, SCThingType} from '../Thing'; import {SCThingWithCategoriesTranslatableProperties} from './abstract/thing-with-categories';
import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCPersonWithoutReferences} from './person';
import {SCPersonWithoutReferences} from './Person';
/** /**
* A book without references * A book without references
*/ */
export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences { export interface SCBookWithoutReferences
extends SCCreativeWorkWithoutReferences {
/** /**
* Edition of a book * Edition of a book
*
* @keyword
*/ */
bookEdition?: string; bookEdition?: string;
/** /**
* ISBN of a book * ISBN of a book
*
* @keyword
*/ */
isbn: string; isbn: string;
/** /**
* Number of pages of a book * Number of pages of a book
*
* @integer
*/ */
numberOfPages?: number; numberOfPages?: number;
@@ -57,8 +64,10 @@ export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences
* A book * A book
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCBook extends SCCreativeWork, SCBookWithoutReferences { export interface SCBook
extends SCCreativeWork, SCBookWithoutReferences {
/** /**
* Authors of the creative work * Authors of the creative work
*/ */
@@ -82,6 +91,8 @@ export interface SCBookTranslatableFields
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
/** /**
* Translation of an edition of a book * Translation of an edition of a book
*
* @keyword
*/ */
bookEdition?: string; bookEdition?: string;
} }
@@ -95,23 +106,33 @@ export class SCBookMeta extends SCThingMeta implements SCMetaTranslations<SCBook
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
bookEdition: 'Buchausgabe',
isbn: 'ISBN',
numberOfPages: 'Seitenzahl',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
bookEdition: 'book edition',
isbn: 'ISBN',
numberOfPages: 'number of pages',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
type: 'Buch', type: 'Buch',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
type: SCThingType.Book, type: SCThingType.Book,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,19 +12,21 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import { import {
SCPlace,
SCPlaceWithoutReferences, SCPlaceWithoutReferences,
SCPlaceWithoutReferencesMeta, SCPlaceWithoutReferencesMeta,
SCPlaceWithoutReferencesTranslatableProperties, SCPlaceWithoutReferencesTranslatableProperties,
} from '../base/Place'; } from './abstract/place';
import {SCThingMeta, SCThingType} from './abstract/thing';
import { import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta, SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories'; } from './abstract/thing-with-categories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
export type SCBuildingCategories = export type SCBuildingCategories =
'cafe' 'cafe'
@@ -37,16 +39,20 @@ export type SCBuildingCategories =
| 'restroom'; | 'restroom';
export interface SCBuildingWithoutReferences export interface SCBuildingWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
SCThingWithCategoriesSpecificValues>,
SCPlaceWithoutReferences { SCPlaceWithoutReferences {
/** /**
* Categories of a building * Categories of a building
*
* @sortable ducet
* @aggregatable
*/ */
categories: SCBuildingCategories[]; categories: SCBuildingCategories[];
/** /**
* List of floor names of the place * List of floor names of the place
*
* @keyword
*/ */
floors?: string[]; floors?: string[];
@@ -65,8 +71,11 @@ export interface SCBuildingWithoutReferences
* A building * A building
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCBuilding extends SCBuildingWithoutReferences { export interface SCBuilding
extends SCBuildingWithoutReferences, SCPlace,
SCThingWithCategories<SCBuildingCategories, SCThingWithCategoriesSpecificValues> {
/** /**
* Translated fields of a building * Translated fields of a building
*/ */
@@ -79,39 +88,45 @@ export interface SCBuilding extends SCBuildingWithoutReferences {
} }
export interface SCBuildingTranslatableProperties export interface SCBuildingTranslatableProperties
extends SCPlaceWithoutReferencesTranslatableProperties, SCThingWithCategoriesTranslatableProperties { extends SCPlaceWithoutReferencesTranslatableProperties, SCThingWithCategoriesTranslatableProperties {
/**
* @see SCBuilding.floors
*/
floors?: string[]; floors?: string[];
} }
/** /**
* Meta information about a place * Meta information about a place
*/ */
export class SCBuildingMeta extends SCThingMeta implements SCMetaTranslations<SCBuilding> { export class SCBuildingMeta
extends SCThingMeta
implements SCMetaTranslations<SCBuilding> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de, SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, ...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.de,
floors: 'Etagen', floors: 'Etagen',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en, SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, ...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.en,
floors: 'floors',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, ...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.de,
categories: { categories: {
'cafe': 'Café', 'cafe': 'Café',
'canteen': 'Kantine', 'canteen': 'Kantine',
@@ -125,9 +140,9 @@ export class SCBuildingMeta extends SCThingMeta implements SCMetaTranslations<SC
type: 'Gebäude', type: 'Gebäude',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, ...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.en,
type: SCThingType.Building, type: SCThingType.Building,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,25 +12,28 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm'; import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCAcademicTermWithoutReferences} from './abstract/academic-term';
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
import { import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta, SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories'; } from './abstract/thing-with-categories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations} from '../types/i18n';
/** /**
* A catalog without references * A catalog without references
*/ */
export interface SCCatalogWithoutReferences export interface SCCatalogWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCCatalogCategories, extends SCThingWithCategoriesWithoutReferences<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesSpecificValues> {
/** /**
* Level of the catalog (0 for 'root catalog', 1 for its subcatalog, 2 for its subcatalog etc.) * Level of the catalog (0 for 'root catalog', 1 for its subcatalog, 2 for its subcatalog etc.)
* *
* Needed for keeping order in catalog inheritance array. * Needed for keeping order in catalog inheritance array.
*
* @integer
*/ */
level: number; level: number;
@@ -44,8 +47,11 @@ export interface SCCatalogWithoutReferences
* A catalog * A catalog
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCCatalog extends SCCatalogWithoutReferences { export interface SCCatalog
extends SCCatalogWithoutReferences, SCThing,
SCThingWithCategories<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
/** /**
* Academic term that a catalog belongs to (e.g. semester) * Academic term that a catalog belongs to (e.g. semester)
*/ */
@@ -61,42 +67,59 @@ export interface SCCatalog extends SCCatalogWithoutReferences {
*/ */
superCatalogs?: SCCatalogWithoutReferences[]; superCatalogs?: SCCatalogWithoutReferences[];
/**
* Translated fields of a catalog
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/** /**
* Type of a catalog * Type of a catalog
*/ */
type: SCThingType.Catalog; type: SCThingType.Catalog;
} }
/** /**
* Catalog meta data * Catalog meta data
*/ */
export class SCCatalogMeta extends SCThingMeta implements SCMetaTranslations<SCCatalog> { export class SCCatalogMeta
extends SCThingMeta implements SCMetaTranslations<SCCatalog> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de, SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
academicTerm: 'Semester',
level: 'Ebene',
superCatalog: 'übergeordnetes Verzeichniss',
superCatalogs: 'übergeordnete Verzeichnisse',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en, SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
academicTerm: 'academic term',
level: 'level',
superCatalog: 'parent catalog',
superCatalogs: 'parent catalogs',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
'university events': 'Universitätsveranstaltung',
},
type: 'Verzeichnis', type: 'Verzeichnis',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Catalog, type: SCThingType.Catalog,
}, },
}; };

View File

@@ -0,0 +1,195 @@
/*
* 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 {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCAcademicDegree, SCAcademicDegreeMeta, SCAcademicDegreeWithoutReferences} from './abstract/academic-degree';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from './abstract/thing-that-can-be-offered';
import {SCDateSeriesWithoutReferences} from './date-series';
import {SCOrganizationWithoutReferences} from './organization';
/**
* A course of studies without references
*/
export interface SCCourseOfStudiesWithoutReferences
extends SCAcademicDegreeWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* The main language in which the course of studies
* is beeing offered
*/
mainLanguage: SCLanguage;
/**
* Actual major of the course of studies (eg. physics)
*
* @keyword
*/
major: string;
/**
* The modes the course of studies is offered in
*/
mode: SCCourseOfStudiesMode;
/**
* The time modes the course of studies is offered in
*/
timeMode: SCCourseOfStudiesTimeMode;
/**
* Translated fields of a dish
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
/**
* Type of the course of studies
*/
type: SCThingType.CourseOfStudies;
}
/**
* A course of studies
*
* @validatable
* @indexable
*/
export interface SCCourseOfStudies
extends SCCourseOfStudiesWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>, SCAcademicDegree {
/**
* The department that manages the course of studies
*/
department: SCOrganizationWithoutReferences;
/**
* The secretary that administers requests and
* questions concerning the course of studies
*/
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 {
// noop
}
/**
* Meta information about a course of studies
*/
export class SCCourseOfStudiesMeta
extends SCThingMeta
implements SCMetaTranslations<SCCourseOfStudies> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCAcademicDegreeMeta.getInstance<SCAcademicDegreeMeta>()
.fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
department: 'Fachbereich',
mainLanguage: 'Unterrichtssprache',
major: 'Studienfach',
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',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
modes: {
combination: 'Kombinationsstudiengang',
'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' ;
/**
* Types of (german) course of studies time modes
*/
export type SCCourseOfStudiesTimeMode = 'fulltime'
| 'parttime' ;

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,25 +12,30 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCISO8601Date, SCISO8601Duration} from '../general/time';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
import { import {
SCAcademicPriceGroup, SCAcademicPriceGroup,
SCThingThatCanBeOffered, SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties,
} from '../base/ThingThatCanBeOffered'; SCThingThatCanBeOfferedWithoutReferences,
import {SCThingMeta, SCThingType} from '../Thing'; } from './abstract/thing-that-can-be-offered';
import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCAcademicEventWithoutReferences} from './academic-event';
import {SCISO8601Date, SCISO8601Duration} from '../types/Time'; import {SCPersonWithoutReferences} from './person';
import {SCAcademicEventWithoutReferences} from './AcademicEvent'; import {SCSportCourseWithoutReferences} from './sport-course';
import {SCPersonWithoutReferences} from './Person';
import {SCSportCourseWithoutReferences} from './SportCourse';
/** /**
* Price groups for sport courses * Price groups for sport courses
*/ */
export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup { export interface SCSportCoursePriceGroup
extends SCAcademicPriceGroup {
/** /**
* Price for alumnis * Price for alumnis
*
* @float
*/ */
alumni?: number; alumni?: number;
} }
@@ -39,7 +44,7 @@ export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup {
* A date without references * A date without references
*/ */
export interface SCDateSeriesWithoutReferences export interface SCDateSeriesWithoutReferences
extends SCThingThatCanBeOffered<SCSportCoursePriceGroup> { extends SCThingThatCanBeOfferedWithoutReferences {
/** /**
* Dates of the date series that are initially planned to be held * Dates of the date series that are initially planned to be held
*/ */
@@ -57,6 +62,8 @@ export interface SCDateSeriesWithoutReferences
/** /**
* Frequency of the date series * Frequency of the date series
*
* @keyword
*/ */
frequency: string; frequency: string;
@@ -75,8 +82,12 @@ export interface SCDateSeriesWithoutReferences
* A date series * A date series
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPlace { export interface SCDateSeries
extends SCDateSeriesWithoutReferences,
SCThingInPlace,
SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
/** /**
* Event to which the date series belongs * Event to which the date series belongs
*/ */
@@ -102,32 +113,55 @@ export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPl
/** /**
* Meta information about a date series * Meta information about a date series
*/ */
export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations<SCDateSeries> { export class SCDateSeriesMeta
extends SCThingMeta
implements SCMetaTranslations<SCDateSeries> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.de, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldTranslations.de,
dates: 'Einzeltermine',
duration: 'Dauer',
event: 'Event',
exceptions: 'Ausnahmen',
frequency: 'Frequenz',
performers: 'Vortragende',
}, },
en: { en: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.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 * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
dates: 'Einzeltermine', .fieldValueTranslations.de,
duration: 'Dauer', ...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
frequency: 'Wiederholung', .fieldValueTranslations.de,
type: 'Wiederholungreihe', type: 'Terminserie',
}, },
en: { en: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.DateSeries, type: SCThingType.DateSeries,
}, },
}; };
@@ -138,5 +172,8 @@ export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations<
*/ */
export interface SCDateSeriesTranslatableProperties export interface SCDateSeriesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties { extends SCThingThatCanBeOfferedTranslatableProperties {
/**
* @see SCDateSeriesWithoutReferences.frequency
*/
frequency?: string; frequency?: string;
} }

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -13,15 +13,16 @@
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as jsonpatch from 'json-patch'; import * as jsonpatch from 'json-patch';
import {SCThingsWithoutDiff} from '../Classes'; import {SCMetaTranslations} from '../general/i18n';
import {SCThing, SCThingMeta, SCThingType} from '../Thing'; import {SCISO8601Date} from '../general/time';
import {SCMetaTranslations} from '../types/i18n'; import {SCThingsWithoutDiff} from '../meta';
import {SCISO8601Date} from '../types/Time'; import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
/** /**
* A diff without references * A diff without references
*/ */
export interface SCDiffWithoutReferences extends SCThing { export interface SCDiffWithoutReferences
extends SCThingWithoutReferences {
/** /**
* Action of the diff * Action of the diff
*/ */
@@ -47,8 +48,10 @@ export interface SCDiffWithoutReferences extends SCThing {
* A diff * A diff
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCDiff extends SCDiffWithoutReferences { export interface SCDiff
extends SCDiffWithoutReferences, SCThing {
/** /**
* Original object the diff was generated on * Original object the diff was generated on
*/ */
@@ -63,37 +66,43 @@ export interface SCDiff extends SCDiffWithoutReferences {
/** /**
* Meta information about a diff * Meta information about a diff
*/ */
export class SCDiffMeta extends SCThingMeta implements SCMetaTranslations<SCDiff> { export class SCDiffMeta
/** extends SCThingMeta
* Set type definiton for singleton instance implements SCMetaTranslations<SCDiff> {
*/
protected static _instance: SCThingMeta;
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
action: 'Aktion', action: 'Aktion',
changes: 'Änderungen', changes: 'Änderungen',
dateCreated: 'Erstellungsdatum', dateCreated: 'Erstellungsdatum',
object: 'Objekt',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
action: 'action',
changes: 'changes',
dateCreated: 'date created',
object: 'object',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance().fieldValueTranslations.de,
action: {
'changed': 'geändert',
'removed': 'gelöscht',
},
type: 'Unterschied', type: 'Unterschied',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Diff, type: SCThingType.Diff,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,36 +12,41 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCThingMeta, SCThingType} from './abstract/thing';
import { import {
SCAcademicPriceGroup, SCAcademicPriceGroup,
SCThingThatCanBeOffered, SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties,
} from '../base/ThingThatCanBeOffered'; SCThingThatCanBeOfferedWithoutReferences,
} from './abstract/thing-that-can-be-offered';
import { import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta, SCThingWithCategoriesWithoutReferencesMeta,
} from '../base/ThingWithCategories'; } from './abstract/thing-with-categories';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/** /**
* A dish without references * A dish without references
*/ */
export interface SCDishWithoutReferences export interface SCDishWithoutReferences
extends SCThingWithCategoriesWithoutReferences< extends SCThingThatCanBeOfferedWithoutReferences,
SCDishCategories, SCThingWithCategoriesWithoutReferences<SCDishCategories, SCThingWithCategoriesSpecificValues> {
SCThingWithCategoriesSpecificValues
>,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/** /**
* Additives of the dish * Additives of the dish
*
* @keyword
*/ */
additives?: string[]; additives?: string[];
/** /**
* Category of the dish * Category of the dish
*
* @sortable ducet
* @aggregatable
*/ */
categories: SCDishCategories[]; categories: SCDishCategories[];
@@ -70,8 +75,11 @@ export interface SCDishWithoutReferences
* A dish * A dish
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCDish extends SCDishWithoutReferences { 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) * Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish)
*/ */
@@ -101,12 +109,16 @@ export interface SCDishTranslatableProperties
*/ */
export interface SCDishCharacteristic { export interface SCDishCharacteristic {
/** /**
* URL to the image of the characteristic * URL of an image of the characteristic
*
* @keyword
*/ */
image?: string; image?: string;
/** /**
* Name of the characteristic * Name of the characteristic
*
* @text
*/ */
name: string; name: string;
} }
@@ -130,36 +142,50 @@ export type SCDishCategories =
export interface SCNutritionInformation { export interface SCNutritionInformation {
/** /**
* Number of calories contained (in kcal) * Number of calories contained (in kcal)
*
* @float
*/ */
calories?: number; calories?: number;
/** /**
* Content of carbohydrates (in grams) * Content of carbohydrates (in grams)
*
* @float
*/ */
carbohydrateContent?: number; carbohydrateContent?: number;
/** /**
* Content of fat (in grams) * Content of fat (in grams)
*
* @float
*/ */
fatContent?: number; fatContent?: number;
/** /**
* Content of proteins (in grams) * Content of proteins (in grams)
*
* @float
*/ */
proteinContent?: number; proteinContent?: number;
/** /**
* Content of salt (in grams) * Content of salt (in grams)
*
* @float
*/ */
saltContent?: number; saltContent?: number;
/** /**
* Content of saturated fat (in grams) * Content of saturated fat (in grams)
*
* @float
*/ */
saturatedFatContent?: number; saturatedFatContent?: number;
/** /**
* Content of sugar (in grams) * Content of sugar (in grams)
*
* @float
*/ */
sugarContent?: number; sugarContent?: number;
} }
@@ -167,28 +193,44 @@ export interface SCNutritionInformation {
/** /**
* Meta information about a dish * Meta information about a dish
*/ */
export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish> { export class SCDishMeta
extends SCThingMeta
implements SCMetaTranslations<SCDish> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de, SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.de,
additives: 'Zusatzstoffe',
characteristics: 'Merkmale',
dishAddOns: 'Beilagen',
nutrition: 'Nährwertangaben',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en, SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldTranslations.en,
additives: 'additives',
characteristics: 'characteristics',
dishAddOns: 'side dishes',
nutrition: 'nutrition information',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
categories: { categories: {
appetizer: 'Vorspeise', appetizer: 'Vorspeise',
dessert: 'Nachtisch', dessert: 'Nachtisch',
@@ -200,8 +242,10 @@ export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish
type: 'Essen', type: 'Essen',
}, },
en: { en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en, SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.Dish, type: SCThingType.Dish,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,17 +12,17 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCSaveableThing, SCSaveableThingWithoutReferences} from '../base/SaveableThing'; import {SCSaveableThing, SCSaveableThingWithoutReferences} from './abstract/saveable-thing';
import {SCThingMeta, SCThingType} from '../Thing'; import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicEventWithoutReferences} from './AcademicEvent'; import {SCAcademicEventWithoutReferences} from './academic-event';
import {SCArticleWithoutReferences} from './Article'; import {SCArticleWithoutReferences} from './article';
import {SCBookWithoutReferences} from './Book'; import {SCBookWithoutReferences} from './book';
import {SCBuildingWithoutReferences} from './Building'; import {SCBuildingWithoutReferences} from './building';
import {SCPersonWithoutReferences} from './Person'; import {SCPersonWithoutReferences} from './person';
import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; import {SCPointOfInterestWithoutReferences} from './point-of-interest';
import {SCRoomWithoutReferences} from './Room'; import {SCRoomWithoutReferences} from './room';
import {SCSportCourseWithoutReferences} from './SportCourse'; import {SCSportCourseWithoutReferences} from './sport-course';
import {SCToDoWithoutReferences} from './ToDo'; import {SCToDoWithoutReferences} from './todo';
/** /**
* Types that can be made a favorite (added as a favorite) * Types that can be made a favorite (added as a favorite)
@@ -40,16 +40,19 @@ export type SCFavoriteDataTypes = SCAcademicEventWithoutReferences
/** /**
* A favorite without references * A favorite without references
*/ */
export interface SCFavoriteWithoutReferences extends SCSaveableThingWithoutReferences { export interface SCFavoriteWithoutReferences
extends SCSaveableThingWithoutReferences {
// noop
} }
/** /**
* A favorite * A favorite
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCFavorite extends SCSaveableThing<SCFavoriteDataTypes> { export interface SCFavorite
extends SCSaveableThing<SCFavoriteDataTypes>, SCFavoriteWithoutReferences {
/** /**
* Type of a favorite * Type of a favorite
*/ */
@@ -59,5 +62,6 @@ export interface SCFavorite extends SCSaveableThing<SCFavoriteDataTypes> {
/** /**
* Meta information about a favorite * 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) 2019 StApps
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,26 +12,30 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// tslint:disable-next-line:no-implicit-dependencies
import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson'; import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson';
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingType} from '../Thing'; import {SCThingMeta, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from './abstract/thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; import {SCPointOfInterestWithoutReferences} from './point-of-interest';
import {SCRoomWithoutReferences} from './Room'; import {SCRoomWithoutReferences} from './room';
/** /**
* A floor without references * 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. * Floor name in the place it is in e.g. "first floor", "ground floor". This doesn't reference the building name.
*
* @text
*/ */
floorName: string; floorName: string;
/** /**
* Floor plan * Floor plan
*/ */
plan: SCFloorFeatureCollectionWithPlaces<LineString, any>; plan: SCFloorFeatureCollectionWithPlaces<LineString>;
/** /**
* Translated fields of a floor * Translated fields of a floor
@@ -48,8 +52,10 @@ export interface SCFloorWithoutReferences extends SCThing {
* A floor * A floor
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace { export interface SCFloor
extends SCFloorWithoutReferences, SCThingInPlace {
/** /**
* Translated fields of a floor * Translated fields of a floor
*/ */
@@ -64,19 +70,20 @@ export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace {
/** /**
* A feature collection * A feature collection
*/ */
export interface SCFloorFeatureCollectionWithPlaces<T extends GeometryObject, P = any> export interface SCFloorFeatureCollectionWithPlaces<T extends GeometryObject>
extends FeatureCollection<T, P> { extends FeatureCollection<T> {
/** /**
* Features of the collection * Features of the collection
*/ */
features: Array<SCFloorFeatureWithPlace<T, P>>; features: Array<SCFloorFeatureWithPlace<T>>;
} }
/*** /***
* A feature with a place * A feature with a place
*/ */
export interface SCFloorFeatureWithPlace<T extends GeometryObject, P = any> export interface SCFloorFeatureWithPlace<T extends GeometryObject>
extends Feature<T, P> { // tslint:disable-next-line:no-any TODO
extends Feature<T, any> {
/** /**
* The place of the feature * The place of the feature
*/ */
@@ -86,9 +93,12 @@ export interface SCFloorFeatureWithPlace<T extends GeometryObject, P = any>
/** /**
* Translatable properties of a floor * Translatable properties of a floor
*/ */
export interface SCFloorTranslatableProperties extends SCThingTranslatableProperties { export interface SCFloorTranslatableProperties
extends SCThingTranslatableProperties {
/** /**
* Translation of the floor name * Translation of the floor name
*
* @text
*/ */
floorName?: string; floorName?: string;
} }
@@ -96,29 +106,39 @@ export interface SCFloorTranslatableProperties extends SCThingTranslatableProper
/** /**
* Meta information about floors * Meta information about floors
*/ */
export class SCFloorMeta extends SCThingMeta implements SCMetaTranslations<SCFloor> { export class SCFloorMeta
extends SCThingMeta
implements SCMetaTranslations<SCFloor> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.de, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.de,
floorName: 'Etagenbezeichnung',
plan: 'Grundriss',
}, },
en: { en: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.en, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
.en,
floorName: 'floor name',
plan: 'plan',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.de,
type: 'Etage', type: 'Etage',
}, },
en: { en: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, ...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
.fieldValueTranslations.en,
type: SCThingType.Floor, type: SCThingType.Floor,
}, },
}; };

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 * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,21 +12,22 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCISO8601Date} from '../general/time';
import { import {
SCCreativeWork, SCCreativeWork,
SCCreativeWorkMeta, SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties, SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences, SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork'; } from './abstract/creative-work';
import {SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingMeta, SCThingType} from '../Thing'; import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/** /**
* A message without references * A message without references
*/ */
export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferences { export interface SCMessageWithoutReferences
extends SCCreativeWorkWithoutReferences {
/** /**
* Audience of the message * Audience of the message
*/ */
@@ -39,8 +40,10 @@ export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferen
/** /**
* Message itself * Message itself
*
* @text
*/ */
message: string; messageBody: string;
/** /**
* Translated fields of a message * Translated fields of a message
@@ -57,8 +60,10 @@ export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferen
* A message * A message
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences { export interface SCMessage
extends SCCreativeWork, SCMessageWithoutReferences {
/** /**
* Translated fields of a message * Translated fields of a message
*/ */
@@ -85,36 +90,55 @@ export interface SCMessageTranslatableProperties
extends SCCreativeWorkTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties { extends SCCreativeWorkTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/** /**
* Message itself * Message itself
*
* @text
*/ */
message?: string; messageBody?: string;
} }
/** /**
* Meta information about messages * Meta information about messages
*/ */
export class SCMessageMeta extends SCThingMeta implements SCMetaTranslations<SCMessage> { export class SCMessageMeta
extends SCThingMeta
implements SCMetaTranslations<SCMessage> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
audiences: 'Zielgruppen',
dateCreated: 'Erstellungsdatum',
messageBody: 'Nachrichteninhalt',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
audiences: 'audiences',
dateCreated: 'date created',
messageBody: 'message body',
}, },
}; };
/** /**
* Translations of values of fields * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
audiences: {
'employees': 'Angestellte',
'guests': 'Gäste',
'students': 'Studenten',
},
type: 'Nachricht', type: 'Nachricht',
}, },
en: { en: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, ...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
type: SCThingType.Message, type: SCThingType.Message,
}, },
}; };

View File

@@ -0,0 +1,74 @@
/*
* 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 {SCMetaTranslations} from '../general/i18n';
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
/**
* An organization without references
*/
export interface SCOrganizationWithoutReferences
extends SCThingWithoutReferences {
/**
* Type of an organization
*/
type: SCThingType.Organization;
}
/**
* An organization
*
* @validatable
* @indexable
*/
export interface SCOrganization
extends SCOrganizationWithoutReferences, SCThingInPlace {
/**
* Type of an organization
*/
type: SCThingType.Organization;
}
/**
* Meta information about an organization
*/
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) 2019 StApps
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,20 +12,23 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingMeta, SCThingType} from '../Thing'; import {SCMetaTranslations, SCNationality} from '../general/i18n';
import {SCMetaTranslations, SCNationality} from '../types/i18n'; import {SCISO8601Date} from '../general/time';
import {SCISO8601Date} from '../types/Time'; import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
import {SCBuildingWithoutReferences} from './Building'; import {SCBuildingWithoutReferences} from './building';
import {SCOrganizationWithoutReferences} from './Organization'; import {SCOrganizationWithoutReferences} from './organization';
import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; import {SCPointOfInterestWithoutReferences} from './point-of-interest';
import {SCRoomWithoutReferences} from './Room'; import {SCRoomWithoutReferences} from './room';
/** /**
* A person without references * A person without references
*/ */
export interface SCPersonWithoutReferences extends SCThing { export interface SCPersonWithoutReferences
extends SCThingWithoutReferences {
/** /**
* Additional first names of the person. * Additional first names of the person.
*
* @keyword
*/ */
additionalName?: string; additionalName?: string;
@@ -38,16 +41,22 @@ export interface SCPersonWithoutReferences extends SCThing {
* The private email address of the person. * The private email address of the person.
* *
* @TJS-format email * @TJS-format email
*
* @keyword
*/ */
email?: string; email?: string;
/** /**
* The family name of the person. * The family name of the person.
*
* @keyword
*/ */
familyName: string; familyName: string;
/** /**
* The private fax number of the person. * The private fax number of the person.
*
* @keyword
*/ */
faxNumber?: string; faxNumber?: string;
@@ -58,26 +67,36 @@ export interface SCPersonWithoutReferences extends SCThing {
/** /**
* The first name of the person. * The first name of the person.
*
* @keyword
*/ */
givenName: string; givenName: string;
/** /**
* Honorific prefix of the person. * Honorific prefix of the person.
*
* @keyword
*/ */
honorificPrefix?: string; honorificPrefix?: string;
/** /**
* Honorific suffix of the person. * Honorific suffix of the person.
*
* @keyword
*/ */
honorificSuffix?: string; honorificSuffix?: string;
/** /**
* Titles of jobs that the person has. * Titles of jobs that the person has.
*
* @keyword
*/ */
jobTitles?: string[]; jobTitles?: string[];
/** /**
* The complete name of the person combining all the parts of the name into one. * The complete name of the person combining all the parts of the name into one.
*
* @text
*/ */
name: string; name: string;
@@ -88,6 +107,8 @@ export interface SCPersonWithoutReferences extends SCThing {
/** /**
* The private telephone number of the person. * The private telephone number of the person.
*
* @keyword
*/ */
telephone?: string; telephone?: string;
@@ -101,8 +122,10 @@ export interface SCPersonWithoutReferences extends SCThing {
* A person * A person
* *
* @validatable * @validatable
* @indexable
*/ */
export interface SCPerson extends SCPersonWithoutReferences { export interface SCPerson
extends SCPersonWithoutReferences, SCThing {
/** /**
* Organization the person works for * Organization the person works for
*/ */
@@ -129,29 +152,67 @@ export interface SCPerson extends SCPersonWithoutReferences {
/** /**
* Meta information about a person * Meta information about a person
*/ */
export class SCPersonMeta extends SCThingMeta implements SCMetaTranslations<SCPerson> { export class SCPersonMeta
extends SCThingMeta
implements SCMetaTranslations<SCPerson> {
/** /**
* Translations of fields * Translations of fields
*/ */
fieldTranslations = { fieldTranslations = {
de: { de: {
... SCThingMeta.getInstance().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: { en: {
... SCThingMeta.getInstance().fieldTranslations.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 * Translations of values of fields
*/ */
fieldValueTranslations = { fieldValueTranslations = {
de: { de: {
... SCThingMeta.getInstance().fieldValueTranslations.de, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
gender: {
'female': 'weiblich',
'inter': 'divers',
'male': 'männlich',
'undefined': 'undefiniert',
},
type: 'Person', type: 'Person',
}, },
en: { en: {
... SCThingMeta.getInstance().fieldValueTranslations.en, ...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
type: SCThingType.Person, type: SCThingType.Person,
}, },
}; };
@@ -170,26 +231,36 @@ export interface SCContactPoint {
/** /**
* E-mail at the work location * E-mail at the work location
*
* @keyword
*/ */
email?: string; email?: string;
/** /**
* Fax number at the work location * Fax number at the work location
*
* @keyword
*/ */
faxNumber?: string; faxNumber?: string;
/** /**
* Times available for contacting at the work location * Times available for contacting at the work location
*
* @keyword
*/ */
hoursAvailable?: string; hoursAvailable?: string;
/** /**
* Contact number at the work location * Contact number at the work location
*
* @keyword
*/ */
telephone?: string; telephone?: string;
/** /**
* URL at the work location * URL at the work location
*
* @keyword
*/ */
url?: string; url?: string;
} }

View File

@@ -0,0 +1,124 @@
/*
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
/**
* A point of interest without references
*/
export interface SCPointOfInterestWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCPointOfInterestCategories, SCThingWithCategoriesSpecificValues>,
SCPlaceWithoutReferences {
/**
* Translated properties of a point of interest
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of a point of interest
*/
type: SCThingType.PointOfInterest;
}
/**
* A point of interest
*
* @validatable
* @indexable
*/
export interface SCPointOfInterest
extends SCPointOfInterestWithoutReferences, SCThingInPlace, SCPlace,
SCThingWithCategories<SCPointOfInterestCategories, SCThingWithCategoriesSpecificValues> {
/**
* Translated properties of a point of interest
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of a point of interest
*/
type: SCThingType.PointOfInterest;
}
/**
* Categories of a point of interest
*/
export type SCPointOfInterestCategories =
'computer'
| 'validator'
| 'card charger'
| 'printer'
| 'disabled access';
/**
* Meta information about points of interest
*/
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,
},
};
}

192
src/things/room.ts Normal file
View File

@@ -0,0 +1,192 @@
/*
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCMap} from '../general/map';
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
import {
SCThingThatAcceptsPayments,
SCThingThatAcceptsPaymentsWithoutReferences,
SCThingThatAcceptsPaymentsWithoutReferencesMeta,
} from './abstract/thing-that-accepts-payments';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
/**
* Categories of a room
*/
export type SCRoomCategories =
'cafe'
| 'canteen'
| 'computer'
| 'education'
| 'laboratory'
| 'learn'
| 'library'
| 'lounge'
| 'office'
| 'restaurant'
| 'restroom'
| 'student canteen'
| 'student union';
/**
* A room without references
*/
export interface SCRoomWithoutReferences
extends SCPlaceWithoutReferences, SCThingThatAcceptsPaymentsWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCRoomCategories, SCRoomSpecificValues> {
/**
* The name of the floor in which the room is in.
*
* @text
*/
floorName?: string;
/**
* The inventory of the place/room as a list of items and their quantity.
*/
inventory?: SCMap<number>;
/**
* Translations of specific values of the object
*
* Take precedence over "main" value for selected languages.
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of the room
*/
type: SCThingType.Room;
}
/**
* A room
*
* @validatable
* @indexable
*/
export interface SCRoom
extends SCRoomWithoutReferences, SCThingInPlace, SCThingThatAcceptsPayments, SCPlace,
SCThingWithCategories<SCRoomCategories, SCRoomSpecificValues> {
/**
* Translations of specific values of the object
*
* Take precedence over "main" value for selected languages.
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
/**
* Type of the room
*/
type: SCThingType.Room;
}
/**
* Category specific values of a room
*/
export interface SCRoomSpecificValues
extends SCThingWithCategoriesSpecificValues {
/**
* Category specific opening hours of the room
*
* @keyword
*/
openingHours?: string;
}
/**
* Meta information about a place
*/
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',
'office': 'Büro',
'restaurant': 'Restaurant',
'restroom': 'Toilette',
'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,
},
};
}

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