Compare commits

...

143 Commits

Author SHA1 Message Date
Rainer Killinger
618a9046bc 0.67.0 2022-05-31 16:13:51 +02:00
Rainer Killinger
c43e2b38e6 refactor: remove SCMetaTranslations singletons 2022-05-31 16:10:41 +02:00
Rainer Killinger
9d0ff36af5 refactor: untangle SCCreativeWork inheritance 2022-05-30 17:00:14 +02:00
Rainer Killinger
31bb7e89ea docs: update changelog 2022-05-27 16:54:09 +02:00
Rainer Killinger
942f04e250 0.66.1 2022-05-27 16:54:06 +02:00
Rainer Killinger
930b574618 refactor: update dependencies 2022-05-27 16:51:08 +02:00
Rainer Killinger
7b88be3a75 refactor: initalize meta classes in translator 2022-05-27 15:21:59 +02:00
Jovan Krunić
5277f7601c docs: update changelog 2022-05-11 13:54:54 +02:00
Jovan Krunić
5241a01b55 0.66.0 2022-05-11 13:54:52 +02:00
484be6a890 feat: add geo filter envelope support 2022-04-28 09:50:44 +02:00
Rainer Killinger
45e0f26391 docs: update changelog 2022-04-04 20:56:06 +02:00
Rainer Killinger
ead47aca19 0.65.1 2022-04-04 20:56:04 +02:00
Rainer Killinger
f9c2414000 docs: adjust typedoc option 'entryPointStrategy' 2022-04-04 20:55:16 +02:00
Rainer Killinger
523de51160 docs: update changelog 2022-04-04 20:47:21 +02:00
Rainer Killinger
d912c03eb0 0.65.0 2022-04-04 20:47:19 +02:00
Rainer Killinger
a638f5447b refactor: update dependencies 2022-04-04 20:42:01 +02:00
Rainer Killinger
cecf95aa46 docs: update changelog 2022-03-21 11:05:27 +01:00
Rainer Killinger
6fd8c5adf3 0.64.0 2022-03-21 11:05:25 +01:00
Rainer Killinger
db24b41d99 test: adjust HDS samples to production version 2022-03-21 11:00:11 +01:00
Rainer Killinger
b1fcd22ab2 refactor: update dependencies 2022-03-17 12:44:59 +01:00
Rainer Killinger
268588fb6f docs: update changelog 2022-01-24 14:47:04 +01:00
Rainer Killinger
d3048a12d8 0.63.0 2022-01-24 14:47:02 +01:00
Rainer Killinger
e14993114f fix: add auth object to index route 2022-01-24 14:45:17 +01:00
Rainer Killinger
4237f6ad60 docs: update changelog 2022-01-21 17:15:16 +01:00
Rainer Killinger
e7c1000bc4 0.62.0 2022-01-21 17:15:14 +01:00
Rainer Killinger
e0adb2332e fix: add missing lastPublished to SCCreativeWork 2022-01-21 17:14:16 +01:00
Rainer Killinger
e5696b23e7 docs: update changelog 2022-01-21 15:07:16 +01:00
Rainer Killinger
659d0974f7 0.61.0 2022-01-21 15:07:14 +01:00
Rainer Killinger
e8304eeeb4 refactor: remove unused auth provider properties 2022-01-21 15:06:11 +01:00
Rainer Killinger
dca9d26c66 docs: update changelog 2022-01-21 12:29:55 +01:00
Rainer Killinger
852e0f5373 0.60.0 2022-01-21 12:29:52 +01:00
Rainer Killinger
26dd531d24 refactor: split up SCUserConfiguration type 2022-01-21 12:22:13 +01:00
Rainer Killinger
52bdf93356 docs: update changelog 2022-01-20 14:20:17 +01:00
Rainer Killinger
7509610145 0.59.0 2022-01-20 14:20:15 +01:00
Rainer Killinger
972cdf392d refactor: make config auth provides be optional 2022-01-20 14:18:50 +01:00
Rainer Killinger
4f758f7d0c docs: update changelog 2022-01-18 15:13:06 +01:00
Rainer Killinger
980e899807 0.58.0 2022-01-18 15:13:04 +01:00
Rainer Killinger
d1c5bb9595 refactor: use SCMap for feature configurations 2022-01-18 15:12:05 +01:00
Rainer Killinger
dc9c0f528f docs: update changelog 2022-01-18 11:06:18 +01:00
Rainer Killinger
66d64e0858 0.57.0 2022-01-18 11:06:16 +01:00
Rainer Killinger
06339786c2 refactor: update dependencies 2022-01-18 11:01:01 +01:00
Rainer Killinger
8ed68481fa refactor: rename urlFragment in routes 2022-01-18 09:50:46 +01:00
Rainer Killinger
e26042957c refactor: remodel features in app config 2022-01-18 09:50:44 +01:00
Rainer Killinger
7553620a5d feat: extend config to describe auth providers 2022-01-18 09:50:00 +01:00
Rainer Killinger
322c001e70 docs: update changelog 2021-12-17 10:35:53 +01:00
Rainer Killinger
830e249ac4 0.56.0 2021-12-17 10:35:50 +01:00
Rainer Killinger
8c9df3ea9a test: adjust testing resources 2021-12-17 10:34:03 +01:00
Rainer Killinger
f85768d32e refactor: update dependencies 2021-12-17 10:33:20 +01:00
Rainer Killinger
580ace368f docs: update changelog 2021-12-15 13:15:12 +01:00
Rainer Killinger
522be6643a 0.55.0 2021-12-15 13:15:10 +01:00
Rainer Killinger
8784309ddb refactor: update dependencies 2021-12-15 13:03:57 +01:00
Rainer Killinger
3d8f996690 refactor: make offer price property optional 2021-11-30 12:27:40 +01:00
Rainer Killinger
36a4bfcbbc docs: update changelog 2021-11-17 11:38:00 +01:00
Rainer Killinger
db347bf324 0.54.0 2021-11-17 11:37:56 +01:00
Rainer Killinger
7a2e0f20d1 feat: add SCAssessment 2021-11-16 10:56:28 +01:00
Jovan Krunić
b2d18da82a docs: update changelog 2021-10-19 16:09:46 +02:00
Jovan Krunić
fae7395cf0 0.53.0 2021-10-19 16:09:45 +02:00
Jovan Krunić
0745b1af72 refactor: adjust http status of feedback route 2021-10-12 16:50:19 +02:00
Jovan Krunić
a2b2cefe8e refactor: adjust depricated use of http-status-codes 2021-10-12 16:48:42 +02:00
wulkanat@gmail.com
04b21a7c5d docs: update changelog 2021-09-28 16:02:23 +02:00
wulkanat@gmail.com
ca7626db17 0.52.0 2021-09-28 16:02:14 +02:00
Wieland Schöbl
e8d492a18a test: add test to make sure there are no duplicate names 2021-09-27 09:06:40 +00:00
Wieland Schöbl
aa294c4e29 feat: add about config 2021-09-23 12:40:50 +00:00
Jovan Krunić
369bb906c1 docs: update changelog 2021-09-10 14:15:06 +02:00
Jovan Krunić
aa38fef293 0.51.0 2021-09-10 14:15:05 +02:00
Jovan Krunić
ded8e7dfd5 fix: add physicalobject to book categories 2021-09-10 14:13:28 +02:00
Jovan Krunić
d47897c7e8 docs: update changelog 2021-09-01 13:56:46 +02:00
Jovan Krunić
9ab5280b2e 0.50.0 2021-09-01 13:56:44 +02:00
Wieland Schöbl
596788f3a1 test: migrate schema.spec.ts from TypeDoc to Easy AST 2021-09-01 11:40:32 +00:00
Rainer Killinger
70271a4849 docs: update changelog 2021-08-27 17:27:23 +02:00
Rainer Killinger
98ab64403f 0.49.5 2021-08-27 17:27:21 +02:00
Rainer Killinger
3d1bb6ef13 docs: update changelog 2021-08-27 17:25:06 +02:00
Rainer Killinger
d5f39517e8 0.49.4 2021-08-27 17:20:40 +02:00
Rainer Killinger
dfe35d71a3 fix: test resources from hds2 2021-08-27 17:19:25 +02:00
wulkanat@gmail.com
cdaa83122f docs: update changelog 2021-08-18 09:57:29 +02:00
wulkanat@gmail.com
937919f1a7 0.49.3 2021-08-18 09:57:22 +02:00
Wieland Schöbl
3249300dac refactor: move indexable test files to separate folder 2021-08-17 18:55:27 +02:00
wulkanat@gmail.com
5acf49fd52 docs: update changelog 2021-08-17 18:15:19 +02:00
wulkanat@gmail.com
07b5ad1618 0.49.2 2021-08-17 18:15:11 +02:00
Wieland Schöbl
d56c3d11a8 refactor: move indexable test files to separate folder 2021-08-17 17:51:53 +02:00
wulkanat@gmail.com
83f00f40bf docs: update changelog 2021-08-13 11:04:27 +02:00
wulkanat@gmail.com
782ee3758a 0.49.1 2021-08-13 11:04:20 +02:00
Wieland Schöbl
8a28d6fa86 fix: documentation generation 2021-08-13 08:41:54 +00:00
wulkanat@gmail.com
ed53c6595e docs: update changelog 2021-08-12 15:45:19 +02:00
wulkanat@gmail.com
49ea2c59ab 0.49.0 2021-08-12 15:45:12 +02:00
openstappsbot
869fa831ea refactor: update all 2021-08-12 13:10:08 +00:00
Wieland Schöbl
21eeecd5ee feat: add elasticsearch mappings to build
Add backwards compatibility check with typescript v3.8.3
2021-08-12 13:09:45 +00:00
Rainer Killinger
2dfb64bafd refactor: remodel entities for library search and results 2021-08-12 12:41:03 +00:00
Jovan Krunić
4ab8770fbc refactor: every indexable thing can be a favorite 2021-08-04 13:57:06 +00:00
Jovan Krunić
2cf1027796 ci: manual web docs for feature branches 2021-08-04 11:43:22 +02:00
openstappsbot
3aed37ecb4 refactor: update all 2021-08-02 13:06:03 +00:00
Jovan Krunić
ddb26b8207 ci: fix elasticsearch service (change runner)
Closes #135
2021-07-29 17:28:44 +02:00
Jovan Krunić
805c1f0937 refactor: specific settings for user group and language 2021-07-27 14:02:56 +02:00
Jovan Krunić
5377d026f3 refactor: define user groups in an extra file 2021-07-21 14:53:08 +02:00
Rainer Killinger
148fd77f4d docs: update changelog 2021-07-14 12:41:31 +02:00
Rainer Killinger
4036bfd193 0.48.0 2021-07-14 12:41:26 +02:00
Rainer Killinger
f4f372b9ad docs: adjust @validatable documentation 2021-07-14 11:16:56 +02:00
Rainer Killinger
872c1f5fc3 fix: correct parameter name of thing update route 2021-07-14 11:16:55 +02:00
Rainer Killinger
4f2ca30dab refactor: make resonse error types validatable 2021-07-14 11:16:55 +02:00
Wieland Schöbl
882483ee24 feat: support geo shape queries 2021-07-09 13:32:28 +00:00
openstappsbot
c998166938 refactor: update all 2021-06-23 13:11:10 +00:00
Rainer Killinger
d61e33de39 docs: update changelog 2021-06-15 10:48:03 +02:00
Rainer Killinger
07d6c4770a 0.47.0 2021-06-15 10:48:01 +02:00
openstappsbot
aab3e9fa6c refactor: update all 2021-06-15 10:46:58 +02:00
Rainer Killinger
4a4cd4e6d4 fix: set date-series frequency non translatable 2021-06-15 09:41:27 +02:00
Wieland Schöbl
942cd11469 feat: make SCDateSeries.frequency compliant with schema.org 2021-06-07 12:23:48 +02:00
Wieland Schöbl
fe090c7387 test: increase schema timeout 2021-05-12 18:03:09 +02:00
Wieland Schöbl
f0782d8820 test: add mapping test 2021-05-12 17:52:22 +02:00
Jovan Krunić
a2461d5904 docs: update changelog 2021-05-04 16:51:52 +02:00
Jovan Krunić
d2e0069dc2 0.46.0 2021-05-04 16:51:50 +02:00
Wieland Schöbl
9c6972af78 feat: change range offer to use date range
add date range type
change availability filter
2021-05-04 16:48:10 +02:00
Rainer Killinger
56b03aa0b9 docs: update changelog 2021-04-26 10:29:36 +02:00
Rainer Killinger
b517837671 0.45.0 2021-04-26 10:29:34 +02:00
Rainer Killinger
6f03ede8bf refactor: make SCCatalog level filterable 2021-04-13 16:11:44 +02:00
wulkanat@gmail.com
952207ace1 docs: update changelog 2021-04-12 15:06:12 +02:00
wulkanat@gmail.com
3d9d28c60c 0.44.0 2021-04-12 15:06:04 +02:00
Wieland Schöbl
913c5691da feat: add support for multiple values in the value filter 2021-04-08 08:06:38 +00:00
Rainer Killinger
03cdbc6f9b docs: update changelog 2021-04-07 13:34:33 +02:00
Rainer Killinger
9f886a8968 0.43.0 2021-04-07 13:34:29 +02:00
openstappsbot
e80afe2c93 refactor: update all 2021-04-06 16:12:49 +00:00
Rainer Killinger
6b10cc86d8 refactor: update @types/node for node version 14 2021-04-06 14:08:42 +02:00
openstappsbot
1aedd6332f refactor: update all 2021-03-29 04:15:38 +00:00
Rainer Killinger
790c8bbc3f docs: update changelog 2021-02-16 14:04:46 +01:00
Rainer Killinger
e934017a65 0.42.0 2021-02-16 14:04:40 +01:00
Rainer Killinger
88dbedd932 refactor: update dependenices 2021-02-15 10:57:25 +01:00
Rainer Killinger
8b1b3444fd refactor: align SCCreativeWork to schema.org spec 2021-02-15 10:37:43 +01:00
Rainer Killinger
d5f3d71a41 refactor: overhaul translator as mentioned in #118 2021-02-15 10:37:38 +01:00
wulkanat@gmail.com
cbcf9c9adb docs: update changelog 2021-02-08 14:59:21 +01:00
wulkanat@gmail.com
321e4f6f24 0.41.0 2021-02-08 14:59:14 +01:00
Wieland Schöbl
8510f11d7b fix: add date, numeric range filter to SCSearchFilter 2021-02-05 13:50:18 +01:00
wulkanat@gmail.com
68aa377fe2 docs: update changelog 2021-02-05 12:59:54 +01:00
wulkanat@gmail.com
29f2c77ecc 0.40.0 2021-02-05 12:59:47 +01:00
Wieland Schöbl
29bc00616e feat: add range filter, date sorting support 2021-02-02 15:07:49 +01:00
Rainer Killinger
02920af4a4 refactor: make SCDish additives translatable 2021-02-01 13:24:12 +00:00
Rainer Killinger
0c14b0f1a0 test: change SCSemester sample data acronym 2020-12-02 17:22:17 +01:00
Rainer Killinger
db0a239761 refactor: change SCSemester acronym pattern 2020-12-02 17:19:46 +01:00
Jovan Krunić
377f55bbbe docs: update changelog 2020-12-01 17:16:02 +01:00
Jovan Krunić
8d7a0e10c6 0.39.0 2020-12-01 17:16:01 +01:00
Rainer Killinger
4865f911d1 refactor: utilize null coalescing 2020-11-23 10:06:14 +01:00
Rainer Killinger
15ae5e0873 refactor: remove narrow property value translation 2020-11-23 10:06:14 +01:00
Rainer Killinger
a246bdea84 feat: extend property value translation retrival 2020-11-23 10:06:13 +01:00
Wieland Schöbl
8641bfc877 docs: add @inheritTags documentation 2020-11-11 11:40:36 +01:00
Michel Jonathan Schmitz
d34e66fbbc docs: update changelog 2020-11-02 09:06:11 +01:00
147 changed files with 6363 additions and 3050 deletions

View File

@@ -5,6 +5,7 @@ before_script:
stages:
- build
- review
- test
- audit
- deploy
@@ -21,6 +22,46 @@ build:
- lib
expire_in: 1 week
build-ts-3.8.3:
tags:
- performance
stage: build
script:
- npm uninstall typescript
- npm install typescript@3.8.3
- npm run build
docs_review:
dependencies:
- build
stage: review
script:
- npm run documentation
- ./node_modules/.bin/surge -p ./docs -d https://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh/
when: manual
environment:
name: review/$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_NAME
url: https://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh/
on_stop: stop_review
except:
- master
- develop
tags:
- secrecy
stop_review:
stage: review
variables:
GIT_STRATEGY: none
script:
- ./node_modules/.bin/surge teardown $CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh
when: manual
environment:
name: review/$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_NAME
action: stop
tags:
- secrecy
audit:
stage: audit
script:
@@ -47,6 +88,21 @@ test:
- report
- coverage
mapping:
tags:
- performance
dependencies:
- build
stage: test
services:
- name: registry.gitlab.com/openstapps/database:master
alias: elasticsearch
script:
- npm run mappings-integration
artifacts:
paths:
- lib
package:
dependencies:
- build

5
.mailmap Normal file
View File

@@ -0,0 +1,5 @@
Rainer Killinger <mail-openstapps@killinger.co> Rainer Killinger <git@killinger.co>
Rainer Killinger <mail-openstapps@killinger.co> Rainer Killinger <killinge@hrz.uni-frankfurt.de>
Rainer Killinger <mail-openstapps@killinger.co> Rainer Killinger <killinger@hrz.uni-frankfurt.de>
Wieland Schöbl <wulkanat@gmail.com> wulkanat@gmail.com <wulkanat@gmail.com>
Wieland Schöbl <wulkanat@gmail.com> Wieland Schöbl <wieland.schoebl@campus.tu-berlin.de>

View File

@@ -1,8 +1,241 @@
# [0.38.0](https://gitlab.com/openstapps/core/compare/v0.37.0...v0.38.0) (2020-10-30)
## [0.66.1](https://gitlab.com/openstapps/core/compare/v0.66.0...v0.66.1) (2022-05-27)
# [0.66.0](https://gitlab.com/openstapps/core/compare/v0.65.1...v0.66.0) (2022-05-11)
### Features
* Replaced `jsonschema` package for `json-schema`
* add geo filter envelope support ([484be6a](https://gitlab.com/openstapps/core/commit/484be6a890d743601efa5d40d33ea2c619f3126d))
## [0.65.1](https://gitlab.com/openstapps/core/compare/v0.65.0...v0.65.1) (2022-04-04)
# [0.65.0](https://gitlab.com/openstapps/core/compare/v0.64.0...v0.65.0) (2022-04-04)
# [0.64.0](https://gitlab.com/openstapps/core/compare/v0.63.0...v0.64.0) (2022-03-21)
# [0.63.0](https://gitlab.com/openstapps/core/compare/v0.62.0...v0.63.0) (2022-01-24)
### Bug Fixes
* add auth object to index route ([e149931](https://gitlab.com/openstapps/core/commit/e14993114f0ec370775010eee4ad0d302a0beebb))
# [0.62.0](https://gitlab.com/openstapps/core/compare/v0.61.0...v0.62.0) (2022-01-21)
### Bug Fixes
* add missing lastPublished to SCCreativeWork ([e0adb23](https://gitlab.com/openstapps/core/commit/e0adb2332ec24ce388c4c008b51b7aa941948532))
# [0.61.0](https://gitlab.com/openstapps/core/compare/v0.60.0...v0.61.0) (2022-01-21)
# [0.60.0](https://gitlab.com/openstapps/core/compare/v0.59.0...v0.60.0) (2022-01-21)
# [0.59.0](https://gitlab.com/openstapps/core/compare/v0.58.0...v0.59.0) (2022-01-20)
# [0.58.0](https://gitlab.com/openstapps/core/compare/v0.57.0...v0.58.0) (2022-01-18)
# [0.57.0](https://gitlab.com/openstapps/core/compare/v0.56.0...v0.57.0) (2022-01-18)
### Features
* extend config to describe auth providers ([7553620](https://gitlab.com/openstapps/core/commit/7553620a5d330ebfb66461afeab700e36bd37165))
# [0.56.0](https://gitlab.com/openstapps/core/compare/v0.55.0...v0.56.0) (2021-12-17)
# [0.55.0](https://gitlab.com/openstapps/core/compare/v0.54.0...v0.55.0) (2021-12-15)
# [0.54.0](https://gitlab.com/openstapps/core/compare/v0.53.0...v0.54.0) (2021-11-17)
### Features
* add SCAssessment ([7a2e0f2](https://gitlab.com/openstapps/core/commit/7a2e0f20d1c64ab1deb7ab30bfb4bab4daaabd6d))
# [0.53.0](https://gitlab.com/openstapps/core/compare/v0.52.0...v0.53.0) (2021-10-19)
# [0.52.0](https://gitlab.com/openstapps/core/compare/v0.51.0...v0.52.0) (2021-09-28)
### Features
* add about config ([aa294c4](https://gitlab.com/openstapps/core/commit/aa294c4e29e9191bef6d79487b0b321fbc34f6fb))
# [0.51.0](https://gitlab.com/openstapps/core/compare/v0.50.0...v0.51.0) (2021-09-10)
### Bug Fixes
* add physicalobject to book categories ([ded8e7d](https://gitlab.com/openstapps/core/commit/ded8e7dfd51094c02a86e1383a4e94c069c10e64))
# [0.50.0](https://gitlab.com/openstapps/core/compare/v0.49.5...v0.50.0) (2021-09-01)
## [0.49.5](https://gitlab.com/openstapps/core/compare/v0.49.3...v0.49.5) (2021-08-27)
### Bug Fixes
* test resources from hds2 ([dfe35d7](https://gitlab.com/openstapps/core/commit/dfe35d71a38c35064726365f99714abff3b30ba6))
## [0.49.3](https://gitlab.com/openstapps/core/compare/v0.49.2...v0.49.3) (2021-08-18)
## [0.49.2](https://gitlab.com/openstapps/core/compare/v0.49.1...v0.49.2) (2021-08-17)
## [0.49.1](https://gitlab.com/openstapps/core/compare/v0.49.0...v0.49.1) (2021-08-13)
### Bug Fixes
* documentation generation ([8a28d6f](https://gitlab.com/openstapps/core/commit/8a28d6fa8657d778d6ae0d38cda7da3531d6478c))
# [0.49.0](https://gitlab.com/openstapps/core/compare/v0.48.0...v0.49.0) (2021-08-12)
### Features
* add elasticsearch mappings to build ([21eeecd](https://gitlab.com/openstapps/core/commit/21eeecd5ee0d68a4faa93bb70d2187ce35807b01))
# [0.48.0](https://gitlab.com/openstapps/core/compare/v0.47.0...v0.48.0) (2021-07-14)
### Bug Fixes
* correct parameter name of thing update route ([872c1f5](https://gitlab.com/openstapps/core/commit/872c1f5fc3884b6df6f5025287873d98b27dd6b1))
### Features
* support geo shape queries ([882483e](https://gitlab.com/openstapps/core/commit/882483ee2490938014904bc26687bd1648992ae6))
# [0.47.0](https://gitlab.com/openstapps/core/compare/v0.46.0...v0.47.0) (2021-06-15)
### Bug Fixes
* set date-series frequency non translatable ([4a4cd4e](https://gitlab.com/openstapps/core/commit/4a4cd4e6d4b01ac34b5338dfcf4aeb959f54461d))
### Features
* make SCDateSeries.frequency compliant with schema.org ([942cd11](https://gitlab.com/openstapps/core/commit/942cd1146966aa9e60321160489a6605877925e9))
# [0.46.0](https://gitlab.com/openstapps/core/compare/v0.45.0...v0.46.0) (2021-05-04)
### Features
* change range offer to use date range ([9c6972a](https://gitlab.com/openstapps/core/commit/9c6972af787678567409877b6bc9f9417e1374e2))
# [0.45.0](https://gitlab.com/openstapps/core/compare/v0.44.0...v0.45.0) (2021-04-26)
# [0.44.0](https://gitlab.com/openstapps/core/compare/v0.43.0...v0.44.0) (2021-04-12)
### Features
* add support for multiple values in the value filter ([913c569](https://gitlab.com/openstapps/core/commit/913c5691da46ad2591fe14bcf7286f12b29ab5ee))
# [0.43.0](https://gitlab.com/openstapps/core/compare/v0.42.0...v0.43.0) (2021-04-07)
# [0.42.0](https://gitlab.com/openstapps/core/compare/v0.41.0...v0.42.0) (2021-02-16)
# [0.41.0](https://gitlab.com/openstapps/core/compare/v0.40.0...v0.41.0) (2021-02-08)
### Bug Fixes
* add date, numeric range filter to SCSearchFilter ([8510f11](https://gitlab.com/openstapps/core/commit/8510f11d7b4c62a6b239a70f47fe07e8cc86ab63))
# [0.40.0](https://gitlab.com/openstapps/core/compare/v0.39.0...v0.40.0) (2021-02-05)
### Features
* add range filter, date sorting support ([29bc006](https://gitlab.com/openstapps/core/commit/29bc00616e87a8d346d8c304fab2e3818921c75e))
# [0.39.0](https://gitlab.com/openstapps/core/compare/v0.38.1...v0.39.0) (2020-12-01)
### Features
* extend property value translation retrival ([a246bde](https://gitlab.com/openstapps/core/commit/a246bdea84e0ca390be6ab38723d637626db87d2))
## [0.38.1](https://gitlab.com/openstapps/core/compare/v0.38.0...v0.38.1) (2020-11-02)
# [0.38.0](https://gitlab.com/openstapps/core/compare/v0.37.0...v0.38.0) (2020-10-30)
# [0.37.0](https://gitlab.com/openstapps/core/compare/v0.36.0...v0.37.0) (2020-09-23)

View File

@@ -35,16 +35,18 @@ node --require ts-node/register src/cli.ts routes PATH/TO/ROUTES.md
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 |
|-------------------|-------------------------------------------|---------------|
| 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 | whether the property is being used on the top type or across all types: `global` |
| `@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 | |
| `@filterable` | non-object/nested field is filterable 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. Fields are always sortable through generic sort, even without annotation. | sort method to be used: `ducet`, `price`, `distance` |
| `@text` | string field is interpreted as text | |
| `@date` | string field is interpreted as a date field | |
| `@validatable` | Marks the type for json schema generation, which can be checked at runtime. Any top-level type that is put into a database should always be marked as validatable. | |
| `@filterable` | non-object/nested field is filterable if the core schema is used to put data into a database/key-value store | |
| `@inheritTags` | inherit all tags from another field | `[SCThingType]::[field]` |
*Note: tags ignore casing, but for consistency they should use the variants proposed here.*

5092
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.38.1",
"version": "0.67.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -14,17 +14,19 @@
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"build": "npm run tslint && npm run compile && npm run pack && npm run schema",
"build": "npm run tslint && npm run compile && npm run pack && npm run schema && npm run mappings",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
"check-configuration": "openstapps-configuration",
"compile": "rimraf lib && tsc",
"documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib",
"documentation": "typedoc --name \"@openstapps/core\" --includeVersion --out docs --readme README.md --listInvalidSymbolLinks --entryPointStrategy expand src",
"pack": "openstapps-core-tools pack",
"postversion": "npm run changelog",
"prepublishOnly": "npm ci && npm run build",
"preversion": "npm run prepublishOnly",
"push": "git push && git push origin \"v$npm_package_version\"",
"schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src lib/schema",
"mappings": "mkdir lib/mappings && openstapps-es-mapping-generator mapping ../core/src -i minlength,pattern,see,tjs-format -m lib/mappings/mappings.json -a lib/mappings/aggregations.json",
"mappings-integration": "openstapps-es-mapping-generator put-es-templates lib/mappings/mappings.json http://elasticsearch:9200/",
"test": "nyc mocha --require ts-node/register --recursive 'test/*.spec.ts'",
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
},
@@ -32,44 +34,51 @@
"contributors": [
"Andreas Lehmann",
"Anselm Stordeur <anselmstordeur@gmail.com>",
"Axel Nieder-Vahrenholz",
"Benjamin Jöckel",
"Imran Hossain",
"Frank Nagel",
"Jovan Krunić <jovan.krunic@gmail.com>",
"Michel Jonathan Schmitz",
"Rainer Killinger <mail-openstapps@killinger.co>",
"Roman Klopsch",
"Sebastian Lange",
"Wieland Schöbl",
"Roman Klopsch"
"Wieland Schöbl"
],
"dependencies": {
"@openstapps/core-tools": "0.16.0",
"@openstapps/core-tools": "0.30.1",
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/json-schema": "7.0.6",
"@types/node": "10.17.44",
"fast-clone": "1.5.13",
"http-status-codes": "2.1.4",
"@types/json-schema": "7.0.11",
"@types/node": "14.18.18",
"fast-deep-equal": "3.1.3",
"http-status-codes": "2.2.0",
"json-patch": "0.7.0",
"json-schema": "0.2.5",
"json-schema": "0.4.0",
"rfdc": "1.3.0",
"ts-optchain": "0.1.8"
},
"devDependencies": {
"@openstapps/configuration": "0.25.0",
"@openstapps/logger": "0.5.0",
"@testdeck/mocha": "0.1.2",
"@types/chai": "4.2.14",
"@types/rimraf": "3.0.0",
"chai": "4.2.0",
"@openstapps/configuration": "0.29.1",
"@openstapps/es-mapping-generator": "0.1.0",
"@openstapps/logger": "0.8.1",
"@testdeck/mocha": "0.2.0",
"@types/chai": "4.3.1",
"@types/lodash": "4.14.182",
"@types/mocha": "9.1.1",
"@types/rimraf": "3.0.2",
"chai": "4.3.6",
"conditional-type-checks": "1.0.5",
"conventional-changelog-cli": "2.1.0",
"mocha": "8.2.0",
"conventional-changelog-cli": "2.2.2",
"lodash": "4.17.21",
"mocha": "10.0.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"source-map-support": "0.5.19",
"ts-node": "9.0.0",
"source-map-support": "0.5.21",
"surge": "0.23.1",
"ts-node": "10.8.0",
"tslint": "6.1.3",
"typedoc": "0.18.0",
"typescript": "3.8.3"
"typedoc": "0.22.15",
"typescript": "4.3.5"
},
"nyc": {
"all": true,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -15,7 +15,9 @@
// tslint:disable-next-line:no-implicit-dependencies
import {Polygon} from 'geojson';
import {SCTranslations} from '../general/i18n';
import {SCSetting} from '../things/setting';
import {SCMap} from '../general/map';
import {SCLanguageSetting, SCSetting, SCUserGroupSetting} from '../things/setting';
import {SCFeatureConfiguration} from './feature';
/**
* An app configuration menu item
@@ -80,15 +82,22 @@ export interface SCAppConfigurationMenuCategory {
* An app configuration
*/
export interface SCAppConfiguration {
/**
* The about page
*
* Mapping route -> page config
*/
aboutPages: SCMap<SCAboutPage>;
/**
* Polygon that encapsulates the main campus
*/
campusPolygon: Polygon;
/**
* A list of features to en- or disable
* Maps of enabled features (plugins and external services)
*/
features: SCAppConfigurationFeature;
features: SCFeatureConfiguration;
/**
* A URL where images are available
@@ -112,8 +121,9 @@ export interface SCAppConfiguration {
/**
* A list of available settings in the app
* !Important! Use provided specific settings, for other settings use general SCSetting
*/
settings: SCSetting[];
settings: Array<SCUserGroupSetting | SCLanguageSetting | SCSetting>;
/**
* Map of store URLs
@@ -126,16 +136,6 @@ export interface SCAppConfiguration {
url?: string;
}
/**
* Map of features
*/
export interface SCAppConfigurationFeature {
/**
* Whether or not widgets are enabled
*/
widgets: boolean;
}
/**
* URLs of published apps
*/
@@ -173,3 +173,147 @@ export interface SCAppConfigurationMenuCategoryTranslationName {
*/
name: string;
}
export enum SCAboutPageContentType {
SECTION = 'section',
ROUTER_LINK = 'router link',
TABLE = 'table',
MARKDOWN = 'markdown',
}
export interface SCAboutPageTranslationTitle {
/**
* Translation of the title
*/
title: string;
}
export interface SCAboutPageTranslationValue {
/**
* Translation of the value
*/
value: string;
}
/**
* A (mostly) self-contained section, akin to markdown `# Title`
*/
export interface SCAboutPageSection {
/**
* If the section should be contained in a card
*/
card?: true;
/**
* The content of the section
*/
content: SCAboutPageContent;
/**
* The title of the section
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
/**
* Type
*/
type: SCAboutPageContentType.SECTION;
}
/**
* A router link that can lead to a new page
*
* For external links, prefer markdown `[destination](link)`
*/
export interface SCAboutPageRouterLink {
/**
* Icon of the destination
*/
icon?: string;
/**
* Router link
*/
link: string;
/**
* Title of the destination
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
/**
* Type
*/
type: SCAboutPageContentType.ROUTER_LINK;
}
/**
* A simple table element
*/
export interface SCAboutPageTable {
/**
* Rows of the table
*/
rows: SCAboutPageContent[][];
/**
* Type
*/
type: SCAboutPageContentType.TABLE;
}
/**
* A markdown element
*/
export interface SCAboutPageMarkdown {
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationValue>;
/**
* Type
*/
type: SCAboutPageContentType.MARKDOWN;
/**
* Value (Markdown)
*/
value: string;
}
export type SCAboutPageContent =
| SCAboutPageMarkdown
| SCAboutPageTable
| SCAboutPageSection
| SCAboutPageRouterLink;
/**
* Root of the about page
*/
export interface SCAboutPage {
/**
* Content of the page
*/
content: SCAboutPageContent[];
/**
* Header (title) of the page
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2021 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 {SCUserConfigurationMap} from './user';
/**
* Supported authorization provider types
*
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-1.3.1
* @see https://github.com/gbv/paia
*/
export type SCAuthorizationProviderType = 'default' | 'paia' ;
/**
* An authorization provider complete configuration
*/
export interface SCAuthorizationProvider {
/**
* An authorization provider client configuration
*/
client: SCAuthorizationProviderClient;
/**
* An authorization provider endpoints configuration
*/
endpoints: SCAuthorizationProviderEndpoints;
}
/**
* An authorization provider client configuration
*/
export interface SCAuthorizationProviderClient {
/**
* Client ID
*/
clientId: string;
/**
* Scopes to request
*/
scopes: string;
/**
* Main url to reach authorization provider
*/
url: string;
}
/**
* An authorization provider endpoints configuration
*/
export interface SCAuthorizationProviderEndpoints {
/**
* URL to start authentication flow
*/
authorization: string;
/**
* URL to end current session
*/
endSession?: string;
/**
* Mapping of how to create SCUser from userinfo endpoint response (using JSONPath syntax)
*
* @see https://www.npmjs.com/package/jsonpath
*/
mapping: SCUserConfigurationMap;
/**
* URL to revoke a token
*/
revoke?: string;
/**
* URL to get access Token
*/
token: string;
/**
* URL to general user info endpoint
*/
userinfo: string;
}

49
src/config/feature.ts Normal file
View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2021 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 '../general/map';
import {SCAuthorizationProviderType} from './authorization';
export interface SCFeatureConfiguration {
/**
* Map of extern services mapped by their name (statically)
*/
extern?: SCMap<SCFeatureConfigurationExtern>;
/**
* Map of plugins registered with the backend mapped by their name.
*/
plugins?: SCMap<SCFeatureConfigurationPlugin>;
}
export interface SCFeatureConfigurationPlugin {
/**
* URL path registered with the backend
*/
urlPath: string;
}
export interface SCFeatureConfigurationExtern {
/**
* Key of authorization provider available in SCConfigFile
*/
authProvider?: SCAuthorizationProviderType;
/**
* URL of extern service
*/
url: string;
}

View File

@@ -14,6 +14,7 @@
*/
import {SCLicensePlate} from '../general/namespaces';
import {SCAppConfiguration} from './app';
import {SCAuthorizationProvider, SCAuthorizationProviderType} from './authorization';
import {SCBackendConfiguration, SCBackendInternalConfiguration} from './backend';
/**
@@ -27,6 +28,11 @@ export interface SCConfigFile {
*/
app: SCAppConfiguration;
/**
* Configuration for the supported authorization providers
*/
auth: { [key in SCAuthorizationProviderType]?: SCAuthorizationProvider; };
/**
* Configuration for the backend that is visible to clients
*/

64
src/config/user.ts Normal file
View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2021 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/>.
*/
/**
* User configuration keys mapped to string type while including their requiredness
*/
export type SCUserConfigurationMap = { [K in keyof SCUserConfigurationOptional]?: string } & { [K in keyof SCUserConfigurationRequired]: string };
/**
* A user configuration
*/
export type SCUserConfiguration = SCUserConfigurationRequired & SCUserConfigurationOptional;
/**
* A user configurations required properties
*/
interface SCUserConfigurationRequired {
/**
* ID given to the user
*/
id: string;
/**
* The complete name of the user combining all the parts of the name into one
*/
name: string;
}
/**
* A user configurations optional properties
*/
interface SCUserConfigurationOptional {
/**
* User's e-mail
*/
email?: string;
/**
* User's family name
*/
familyName?: string;
/**
* User's given name
*/
givenName?: string;
/**
* Role assigned to the user
*/
role?: string;
/**
* Student ID given to the user
*/
studentId?: string;
}

View File

@@ -16,8 +16,10 @@
/**
* An ISO8601 date
*
* @pattern ^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$
* @pattern ^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])(T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])([\.,][0-9]{0,7})?(Z|[+-](?:2[0-3]|[01][0-9])(:?[0-5][0-9])?)?)?$
* @see https://gist.github.com/philipashlock/8830168
*
* @date
*/
export type SCISO8601Date = string;
/* tslint:enable */
@@ -35,6 +37,6 @@ export type SCISO8601Duration = string;
/**
* An ISO8601 time
*
* @pattern \d{2}:\d{2}(:\d{2})?
* @pattern ^(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])$
*/
export type SCISO8601Time = string;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -15,11 +15,12 @@
import {SCThingType} from './things/abstract/thing';
import {SCAcademicEvent, SCAcademicEventMeta, SCAcademicEventWithoutReferences} from './things/academic-event';
import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/article';
import {SCAssessment, SCAssessmentMeta, SCAssessmentWithoutReferences} from './things/assessment';
import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book';
import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building';
import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog';
import {SCContactPoint, SCContactPointMeta, SCContactPointWithoutReferences} from './things/contact-point';
import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/course-of-studies';
import {SCCourseOfStudy, SCCourseOfStudyMeta, SCCourseOfStudyWithoutReferences} from './things/course-of-study';
import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series';
import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff';
import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/dish';
@@ -27,8 +28,14 @@ import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/
import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/floor';
import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/message';
import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/organization';
import {SCPeriodical, SCPeriodicalMeta, SCPeriodicalWithoutReferences} from './things/periodical';
import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/person';
import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/point-of-interest';
import {
SCPublicationEvent,
SCPublicationEventMeta,
SCPublicationEventWithoutReferences,
} from './things/publication-event';
import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/room';
import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/semester';
import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/setting';
@@ -45,13 +52,14 @@ import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/video';
*/
export const SCClasses: { [K in SCThingType]: object } = {
/* tslint:enable */
'assessment': SCAssessmentMeta,
'academic event': SCAcademicEventMeta,
'article': SCArticleMeta,
'book': SCBookMeta,
'building': SCBuildingMeta,
'catalog': SCCatalogMeta,
'contact point': SCContactPointMeta,
'course of studies': SCCourseOfStudiesMeta,
'course of study': SCCourseOfStudyMeta,
'date series': SCDateSeriesMeta,
'diff': SCDiffMeta,
'dish': SCDishMeta,
@@ -59,8 +67,10 @@ export const SCClasses: { [K in SCThingType]: object } = {
'floor': SCFloorMeta,
'message': SCMessageMeta,
'organization': SCOrganizationMeta,
'periodical': SCPeriodicalMeta,
'person': SCPersonMeta,
'point of interest': SCPointOfInterestMeta,
'publication event': SCPublicationEventMeta,
'room': SCRoomMeta,
'semester': SCSemesterMeta,
'setting': SCSettingMeta,
@@ -72,25 +82,26 @@ export const SCClasses: { [K in SCThingType]: object } = {
'video': SCVideoMeta,
};
export type SCThingsWithoutDiff =
SCAcademicEvent
export type SCIndexableThings =
SCAssessment
| SCAcademicEvent
| SCArticle
| SCBook
| SCBuilding
| SCCatalog
| SCContactPoint
| SCCourseOfStudies
| SCCourseOfStudy
| SCDateSeries
| SCDish
| SCFavorite
| SCFloor
| SCMessage
| SCOrganization
| SCPeriodical
| SCPerson
| SCPointOfInterest
| SCPublicationEvent
| SCRoom
| SCSemester
| SCSetting
| SCSportCourse
| SCStudyModule
| SCTicket
@@ -102,8 +113,8 @@ export type SCThingsWithoutDiff =
* An object that exists in the StAppsCore
*/
export type SCThings =
SCThingsWithoutDiff
| SCDiff;
SCIndexableThings
| SCDiff | SCFavorite | SCSetting;
/**
* A field of a thing
@@ -114,60 +125,66 @@ export type SCThingsField = keyof SCThings | string;
* Thing without references for a thing
*/
export type SCAssociatedThingWithoutReferences<THING extends SCThings> =
THING extends SCAcademicEvent ? SCAcademicEventWithoutReferences :
THING extends SCArticle ? SCArticleWithoutReferences :
THING extends SCBook ? SCBookWithoutReferences :
THING extends SCBuilding ? SCBuildingWithoutReferences :
THING extends SCCatalog ? SCCatalogWithoutReferences :
THING extends SCContactPoint ? SCContactPointWithoutReferences :
THING extends SCCourseOfStudies ? SCCourseOfStudiesWithoutReferences :
THING extends SCDateSeries ? SCDateSeriesWithoutReferences :
THING extends SCDiff ? SCDiffWithoutReferences :
THING extends SCDish ? SCDishWithoutReferences :
THING extends SCFavorite ? SCFavoriteWithoutReferences :
THING extends SCFloor ? SCFloorWithoutReferences :
THING extends SCMessage ? SCMessageWithoutReferences :
THING extends SCOrganization ? SCOrganizationWithoutReferences :
THING extends SCPerson ? SCPersonWithoutReferences :
THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences :
THING extends SCRoom ? SCRoomWithoutReferences :
THING extends SCSemester ? SCSemesterWithoutReferences :
THING extends SCSetting ? SCSettingWithoutReferences :
THING extends SCSportCourse ? SCSportCourseWithoutReferences :
THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
THING extends SCTicket ? SCTicketWithoutReferences :
THING extends SCToDo ? SCToDoWithoutReferences :
THING extends SCTour ? SCTourWithoutReferences :
THING extends SCVideo ? SCVideoWithoutReferences :
never;
THING extends SCAssessment ? SCAssessmentWithoutReferences :
THING extends SCAcademicEvent ? SCAcademicEventWithoutReferences :
THING extends SCArticle ? SCArticleWithoutReferences :
THING extends SCBook ? SCBookWithoutReferences :
THING extends SCBuilding ? SCBuildingWithoutReferences :
THING extends SCCatalog ? SCCatalogWithoutReferences :
THING extends SCContactPoint ? SCContactPointWithoutReferences :
THING extends SCCourseOfStudy ? SCCourseOfStudyWithoutReferences :
THING extends SCDateSeries ? SCDateSeriesWithoutReferences :
THING extends SCDiff ? SCDiffWithoutReferences :
THING extends SCDish ? SCDishWithoutReferences :
THING extends SCFavorite ? SCFavoriteWithoutReferences :
THING extends SCFloor ? SCFloorWithoutReferences :
THING extends SCMessage ? SCMessageWithoutReferences :
THING extends SCOrganization ? SCOrganizationWithoutReferences :
THING extends SCPeriodical ? SCPeriodicalWithoutReferences :
THING extends SCPerson ? SCPersonWithoutReferences :
THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences :
THING extends SCPublicationEvent ? SCPublicationEventWithoutReferences :
THING extends SCRoom ? SCRoomWithoutReferences :
THING extends SCSemester ? SCSemesterWithoutReferences :
THING extends SCSetting ? SCSettingWithoutReferences :
THING extends SCSportCourse ? SCSportCourseWithoutReferences :
THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
THING extends SCTicket ? SCTicketWithoutReferences :
THING extends SCToDo ? SCToDoWithoutReferences :
THING extends SCTour ? SCTourWithoutReferences :
THING extends SCVideo ? SCVideoWithoutReferences :
never;
/**
* Thing for a thing without references
*/
export type SCAssociatedThing<THING extends SCThings> =
THING extends SCAcademicEventWithoutReferences ? SCAcademicEvent :
THING extends SCArticleWithoutReferences ? SCArticle :
THING extends SCBookWithoutReferences ? SCBook :
THING extends SCBuildingWithoutReferences ? SCBuilding :
THING extends SCCatalogWithoutReferences ? SCCatalog :
THING extends SCContactPointWithoutReferences ? SCContactPoint :
THING extends SCCourseOfStudiesWithoutReferences ? SCCourseOfStudies :
THING extends SCDateSeriesWithoutReferences ? SCDateSeries :
THING extends SCDiffWithoutReferences ? SCDiff :
THING extends SCDishWithoutReferences ? SCDish :
THING extends SCFavoriteWithoutReferences ? SCFavorite :
THING extends SCFloorWithoutReferences ? SCFloor :
THING extends SCMessageWithoutReferences ? SCMessage :
THING extends SCOrganizationWithoutReferences ? SCOrganization :
THING extends SCPersonWithoutReferences ? SCPerson :
THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest :
THING extends SCRoomWithoutReferences ? SCRoom :
THING extends SCSemesterWithoutReferences ? SCSemester :
THING extends SCSettingWithoutReferences ? SCSetting :
THING extends SCSportCourseWithoutReferences ? SCSportCourse :
THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
THING extends SCTicketWithoutReferences ? SCTicket :
THING extends SCToDoWithoutReferences ? SCToDo :
THING extends SCTourWithoutReferences ? SCTour :
THING extends SCVideoWithoutReferences ? SCVideo :
never;
THING extends SCAssessmentWithoutReferences ? SCAssessment :
THING extends SCAcademicEventWithoutReferences ? SCAcademicEvent :
THING extends SCArticleWithoutReferences ? SCArticle :
THING extends SCBookWithoutReferences ? SCBook :
THING extends SCBuildingWithoutReferences ? SCBuilding :
THING extends SCCatalogWithoutReferences ? SCCatalog :
THING extends SCContactPointWithoutReferences ? SCContactPoint :
THING extends SCCourseOfStudyWithoutReferences ? SCCourseOfStudy :
THING extends SCDateSeriesWithoutReferences ? SCDateSeries :
THING extends SCDiffWithoutReferences ? SCDiff :
THING extends SCDishWithoutReferences ? SCDish :
THING extends SCFavoriteWithoutReferences ? SCFavorite :
THING extends SCFloorWithoutReferences ? SCFloor :
THING extends SCMessageWithoutReferences ? SCMessage :
THING extends SCOrganizationWithoutReferences ? SCOrganization :
THING extends SCPeriodicalWithoutReferences ? SCPeriodical :
THING extends SCPersonWithoutReferences ? SCPerson :
THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest :
THING extends SCPublicationEventWithoutReferences ? SCPublicationEvent :
THING extends SCRoomWithoutReferences ? SCRoom :
THING extends SCSemesterWithoutReferences ? SCSemester :
THING extends SCSettingWithoutReferences ? SCSetting :
THING extends SCSportCourseWithoutReferences ? SCSportCourse :
THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
THING extends SCTicketWithoutReferences ? SCTicket :
THING extends SCToDoWithoutReferences ? SCToDo :
THING extends SCTourWithoutReferences ? SCTour :
THING extends SCVideoWithoutReferences ? SCVideo :
never;

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when an internal server error occurred
*
* @validatable
*/
export class SCInternalServerErrorResponse extends SCError {
/**
@@ -32,7 +34,7 @@ export class SCInternalServerErrorResponse extends SCError {
* and the internal server error should be displayed to the client
*/
constructor(err?: Error, stack = false) {
super('InternalServerError', 'Internal server error', BAD_GATEWAY, stack);
super('InternalServerError', 'Internal server error', StatusCodes.BAD_GATEWAY, stack);
if (stack) {
this.additionalData = err;

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} 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
*
* @validatable
*/
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
@@ -25,6 +27,6 @@ export class SCMethodNotAllowedErrorResponse extends SCError {
* @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);
super('MethodNotAllowedError', 'HTTP method is not allowed on this route', StatusCodes.METHOD_NOT_ALLOWED, stack);
}
}

View File

@@ -12,11 +12,13 @@
* 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_FOUND} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned when the requested route or resource was not found
*
* @validatable
*/
export class SCNotFoundErrorResponse extends SCError {
/**
@@ -25,6 +27,6 @@ export class SCNotFoundErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('NotFoundError', 'Resource not found', NOT_FOUND, stack);
super('NotFoundError', 'Resource not found', StatusCodes.NOT_FOUND, stack);
}
}

View File

@@ -12,12 +12,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {NOT_ACCEPTABLE} from 'http-status-codes';
import {StatusCodes} 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.
*
* @validatable
*/
export class SCParametersNotAcceptable extends SCError {
/**
@@ -27,6 +29,6 @@ export class SCParametersNotAcceptable extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('ParametersNotAcceptable', message, NOT_ACCEPTABLE, stack);
super('ParametersNotAcceptable', message, StatusCodes.NOT_ACCEPTABLE, stack);
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {CONFLICT} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
import {SCPluginMetaData} from '../routes/plugin-register';
@@ -20,6 +20,8 @@ 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.
*
* @validatable
*/
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
/**
@@ -36,7 +38,7 @@ export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, plugin: SCPluginMetaData, stack = false) {
super('SCPluginAlreadyRegisteredError', message, CONFLICT, stack);
super('SCPluginAlreadyRegisteredError', message, StatusCodes.CONFLICT, stack);
if (stack) {
this.additionalData = plugin;
}

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned whenever there is an unexpected error while creating a plugin
*
* @validatable
*/
export class SCPluginRegisteringFailedErrorResponse extends SCError {
/**
@@ -26,6 +28,6 @@ export class SCPluginRegisteringFailedErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('PluginRegisteringFailedError', message, INTERNAL_SERVER_ERROR, stack);
super('PluginRegisteringFailedError', message, StatusCodes.INTERNAL_SERVER_ERROR, stack);
}
}

View File

@@ -12,11 +12,13 @@
* 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 {REQUEST_TOO_LONG} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when the request body is too large.
*
* @validatable
*/
export class SCRequestBodyTooLargeErrorResponse extends SCError {
/**
@@ -25,6 +27,6 @@ export class SCRequestBodyTooLargeErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('RequestBodyTooLargeError', 'The request body is too large.', REQUEST_TOO_LONG, stack);
super('RequestBodyTooLargeError', 'The request body is too large.', StatusCodes.REQUEST_TOO_LONG, stack);
}
}

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned whenever there is a syntax error
*
* @validatable
*/
export class SCSyntaxErrorResponse extends SCError {
/**
@@ -26,6 +28,6 @@ export class SCSyntaxErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('SyntaxError', message, BAD_REQUEST, stack);
super('SyntaxError', message, StatusCodes.BAD_REQUEST, stack);
}
}

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned, when to many request are submitted at once
*
* @validatable
*/
export class SCTooManyRequestsErrorResponse extends SCError {
/**
@@ -28,7 +30,7 @@ export class SCTooManyRequestsErrorResponse extends SCError {
super(
'TooManyRequestsError',
'Too many requests. You can not submit more than 5 queries an once',
TOO_MANY_REQUESTS,
StatusCodes.TOO_MANY_REQUESTS,
stack,
);
}

View File

@@ -12,11 +12,13 @@
* 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 {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned when the content type of the request is not supported
*
* @validatable
*/
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
@@ -25,6 +27,6 @@ export class SCUnsupportedMediaTypeErrorResponse extends SCError {
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
super('UnsupportedMediaTypeError', 'Unsupported media type', UNSUPPORTED_MEDIA_TYPE, stack);
super('UnsupportedMediaTypeError', 'Unsupported media type', StatusCodes.UNSUPPORTED_MEDIA_TYPE, stack);
}
}

View File

@@ -12,12 +12,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {ValidationError} from '@openstapps/core-tools/lib/common';
import {BAD_REQUEST} from 'http-status-codes';
import {ValidationError} from '@openstapps/core-tools/lib/types/validator';
import {StatusCodes} from 'http-status-codes';
import {SCError} from '../error';
/**
* An error that is returned when the validation of a request fails
*
* @validatable
*/
export class SCValidationErrorResponse extends SCError {
/**
@@ -32,7 +34,7 @@ export class SCValidationErrorResponse extends SCError {
* @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);
super('ValidationError', 'Validation of request failed', StatusCodes.BAD_REQUEST, stack);
this.additionalData = errors;
}
}

View File

@@ -78,9 +78,9 @@ export interface SCRoute {
statusCodeSuccess: number;
/**
* URL fragment of the route
* URL path of the route
*/
urlFragment: string;
urlPath: string;
}
/**
@@ -112,16 +112,16 @@ export abstract class SCAbstractRoute implements SCRoute {
*/
statusCodeSuccess = 200;
/**
* @see SCRoute.urlFragment
* @see SCRoute.urlPath
*/
urlFragment = '/';
urlPath = '/';
/**
* Get "compiled" URL fragment
* Get "compiled" URL path
*
* @param parameters Parameters to compile URL fragment with
* @param parameters Parameters to compile URL path with
*/
public getUrlFragment(parameters: SCMap<string> = {}): string {
public getUrlPath(parameters: SCMap<string> = {}): string {
let obligatoryParameters: string[] = [];
if (typeof this.obligatoryParameters === 'object') {
@@ -132,7 +132,7 @@ export abstract class SCAbstractRoute implements SCRoute {
throw new Error('Extraneous parameters provided.');
}
return this.urlFragment
return this.urlPath
.split('/')
.map((part) => {
if (part.indexOf(':') !== 0) {

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCUuid} from '../../general/uuid';
import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../things/abstract/thing-that-can-be-offered';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
@@ -88,7 +88,7 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBookAvailabilityRequest';
this.responseBodyName = 'SCBookAvailabilityResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/bookAvailability';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/bookAvailability';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {CREATED} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCThings} from '../../meta';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -59,7 +59,7 @@ export class SCBulkAddRoute extends SCAbstractRoute {
};
this.requestBodyName = 'SCBulkAddRequest';
this.responseBodyName = 'SCBulkAddResponse';
this.statusCodeSuccess = CREATED;
this.urlFragment = '/bulk/:UID';
this.statusCodeSuccess = StatusCodes.CREATED;
this.urlPath = '/bulk/:UID';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {NO_CONTENT} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
import {SCNotFoundErrorResponse} from '../errors/not-found';
@@ -59,7 +59,7 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
};
this.requestBodyName = 'SCBulkDoneRequest';
this.responseBodyName = 'SCBulkDoneResponse';
this.statusCodeSuccess = NO_CONTENT;
this.urlFragment = '/bulk/:UID/done';
this.statusCodeSuccess = StatusCodes.NO_CONTENT;
this.urlPath = '/bulk/:UID/done';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCISO8601Date} from '../../general/time';
import {SCUuid} from '../../general/uuid';
import {SCThingType} from '../../things/abstract/thing';
@@ -98,7 +98,7 @@ export class SCBulkRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCBulkRequest';
this.responseBodyName = 'SCBulkResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/bulk';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/bulk';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {NO_CONTENT} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCMessage} from '../../things/message';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -59,8 +59,8 @@ export class SCFeedbackRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCFeedbackRequest';
this.responseBodyName = 'SCFeedbackResponse';
this.statusCodeSuccess = NO_CONTENT;
this.urlFragment = '/feedback';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/feedback';
}
}

View File

@@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCAppConfiguration} from '../../config/app';
import {SCAuthorizationProvider, SCAuthorizationProviderType} from '../../config/authorization';
import {SCBackendConfiguration} from '../../config/backend';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -42,6 +43,11 @@ export interface SCIndexResponse {
*/
app: SCAppConfiguration;
/**
* @see SCAuthorizationProvider
*/
auth: { [key in SCAuthorizationProviderType]?: SCAuthorizationProvider; };
/**
* @see SCBackendConfiguration
*/
@@ -65,7 +71,7 @@ export class SCIndexRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCIndexRequest';
this.responseBodyName = 'SCIndexResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {JSONSchema7} from 'json-schema';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -122,7 +122,7 @@ export class SCPluginRegisterRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCPluginRegisterRequest';
this.responseBodyName = 'SCPluginRegisterResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/plugin/register';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/plugin/register';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCMap} from '../../general/map';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -63,7 +63,7 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCMultiSearchRequest';
this.responseBodyName = 'SCMultiSearchResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/search/multi';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/search/multi';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
@@ -56,7 +56,7 @@ export class SCSearchRoute extends SCAbstractRoute {
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCSearchRequest';
this.responseBodyName = 'SCSearchResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/search';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/search';
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {OK} from 'http-status-codes';
import {StatusCodes} from 'http-status-codes';
import {SCThings} from '../../meta';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -55,12 +55,12 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
];
this.method = SCRouteHttpVerbs.PUT;
this.obligatoryParameters = {
TYPE: 'SCThingTypes',
TYPE: 'SCThingType',
UID: 'SCUuid',
};
this.requestBodyName = 'SCThingUpdateRequest';
this.responseBodyName = 'SCThingUpdateResponse';
this.statusCodeSuccess = OK;
this.urlFragment = '/:TYPE/:UID';
this.statusCodeSuccess = StatusCodes.OK;
this.urlPath = '/:TYPE/:UID';
}
}

View File

@@ -19,6 +19,8 @@ import {SCMap} from '../../general/map';
import {SCSearchAvailabilityFilter} from './filters/availability';
import {SCSearchBooleanFilter} from './filters/boolean';
import {SCSearchDistanceFilter} from './filters/distance';
import {SCGeoFilter} from './filters/geo';
import {SCSearchDateRangeFilter, SCSearchNumericRangeFilter} from './filters/range';
import {SCSearchValueFilter} from './filters/value';
/**
@@ -28,7 +30,10 @@ export type SCSearchFilterType =
'availability'
| 'boolean'
| 'distance'
| 'value';
| 'value'
| 'date range'
| 'numeric range'
| 'geo';
/**
* Structure of a filter instruction
@@ -57,4 +62,7 @@ export type SCSearchFilter =
SCSearchAvailabilityFilter
| SCSearchBooleanFilter
| SCSearchDistanceFilter
| SCSearchValueFilter;
| SCSearchValueFilter
| SCSearchNumericRangeFilter
| SCSearchDateRangeFilter
| SCGeoFilter;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -33,17 +33,17 @@ export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAva
*/
export interface SCAvailabilityFilterArguments extends SCSearchAbstractFilterArguments {
/**
* Field which marks the start of the availability
* Field which marks availability range
*/
fromField: SCThingsField;
field: SCThingsField;
/**
* Time to check. Defaults to 'now'
* If set, the provided time will apply to the full hour, day, week, etc.
*/
time?: SCISO8601Date | 'now';
scope?: 's' | 'm' | 'H' | 'd' | 'w' | 'M' | 'y';
/**
* Field which marks the end of the availability
* Time to check. Defaults current time if not set
*/
toField: SCThingsField;
time?: SCISO8601Date;
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2021 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 {Polygon, Position} from 'geojson';
import {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/**
* A geo filter
*
* Filter for documents that are in relation to some geo data
*/
export interface SCGeoFilter extends SCSearchAbstractFilter<SCGeoFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'geo';
}
/**
* A rectangular geo shape, representing the top-left and bottom-right corners
*
* This is an extension of the Geojson type
* http://geojson.org/geojson-spec.html
*/
export interface Envelope {
/**
* The top-left and bottom-right corners of the bounding box
*/
coordinates: [Position, Position];
/**
* The type of the geometry
*/
type: 'envelope';
}
/**
* Arguments for filter instruction by geo data
*/
export interface SCGeoFilterArguments extends SCSearchAbstractFilterArguments {
/**
* Field on which to filter
*/
field: SCThingsField;
/**
* Geo data to check up on
*/
shape: Polygon | Envelope;
/**
* Spatial relation between the provided shape and the shape of the field.
*
* intersects - both shapes intersect (default)
* disjoint - both shapes don't intersect
* within - the search shape contains the field shape
* contains - the search shape is contained in the field shape
*/
spatialRelation?: 'intersects' | 'disjoint' | 'within' | 'contains';
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (C) 2020-2021 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 {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/**
* A date range filter
*
* Filter for documents with a date field that satisfies the given constraints
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
*/
export interface SCSearchDateRangeFilter extends SCSearchAbstractFilter<SCDateRangeFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'date range';
}
/**
* A distance filter
*
* Filter for documents with a numeric field that satisfies the given constraints
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
*/
export interface SCSearchNumericRangeFilter extends SCSearchAbstractFilter<SCNumericRangeFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'numeric range';
}
/**
* Additional arguments for date range filters
*
* Filter uses a plain string to allow for date math expressions
* @see https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/date-math-expressions.html
*/
export interface SCDateRangeFilterArguments extends SCRangeFilterArguments<string> {
/**
* Optional date format specifier
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
*/
format?: string;
/**
* Optional timezone specifier
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_time_zone_in_range_queries
*/
timeZone?: string;
}
/**
* Additional arguments for numeric range filters
*/
export type SCNumericRangeFilterArguments = SCRangeFilterArguments<number>;
/**
* Additional arguments for range filters
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
*/
export interface SCRangeFilterArguments<T> extends SCSearchAbstractFilterArguments {
/**
* Bounds of the range
*/
bounds: Bounds<T>;
/**
* Field where the filter will be applied
*/
field: SCThingsField;
/**
* Relation when searching on other range fields
*
* Intersects (Default): Both search and field range intersect
* Within: Search range is within the field range
* Contains: Search range contains the field range
*/
relation?: 'intersects' | 'within' | 'contains';
}
export interface Bounds<T> {
/**
* The lower bound
*/
lowerBound?: Bound<T>;
/**
* The upper bound
*/
upperBound?: Bound<T>;
}
export interface Bound<T> {
/**
* Limit of the bound
*/
limit: T;
/**
* Bound mode
*/
mode: 'inclusive' | 'exclusive';
}

View File

@@ -32,7 +32,7 @@ export interface SCValueFilterArguments extends SCSearchAbstractFilterArguments
field: SCThingsField;
/**
* Value to filter. Value has to match the field exactly.
* Value to filter. One or more values has to match the field exactly.
*/
value: string;
value: string | string[];
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019, 2020 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.
@@ -16,6 +16,7 @@ import {SCMap} from '../../general/map';
import {SCThingsField} from '../../meta';
import {SCDistanceSort} from './sorts/distance';
import {SCDucetSort} from './sorts/ducet';
import {SCGenericSort} from './sorts/generic';
import {SCPriceSort} from './sorts/price';
/**
@@ -51,9 +52,9 @@ export interface SCSearchAbstractSortArguments extends SCMap<unknown> {
/**
* Type of a sort instruction
*/
export type SCSearchSortType = 'distance' | 'price' | 'ducet';
export type SCSearchSortType = 'distance' | 'price' | 'ducet' | 'generic';
/**
* A sort instruction
*/
export type SCSearchSort = SCDistanceSort | SCPriceSort | SCDucetSort;
export type SCSearchSort = SCDistanceSort | SCPriceSort | SCDucetSort | SCGenericSort;

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2020 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 {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
/**
* Sort instruction for generic sort such as date
*/
export interface SCGenericSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> {
/**
* @see SCSearchAbstractSort.type
*/
type: 'generic';
}

View File

@@ -22,26 +22,25 @@ export interface SCAcademicDegreeWithoutReferences
extends SCThingWithoutReferences {
/**
* The achievable academic degree
*
* @filterable
* @sortable ducet
*/
academicDegree: SCGermanAcademicDegree;
academicDegree: string;
/**
* The achievable academic degree with academic field specification
* (eg. Master of Science)
*
* @filterable
* @keyword
*/
academicDegreewithField: string;
academicDegreewithField?: string;
/**
* The achievable academic degree with academic field specification
* shorted (eg. M.Sc.).
*
* @filterable
* @keyword
*/
academicDegreewithFieldShort: string;
academicDegreewithFieldShort?: string;
}
/**
@@ -62,13 +61,13 @@ export class SCAcademicDegreeMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
academicDegree: 'Hochschulgrad',
academicDegreewithField: 'Abschlussbezeichnungen',
academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)',
...new SCThingMeta().fieldTranslations.de,
academicDegree: 'Abschlussgrad',
academicDegreewithField: 'Abschlussbezeichnung',
academicDegreewithFieldShort: 'Abschlussbezeichnung (kurz)',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
academicDegree: 'academic degree',
academicDegreewithField: 'acedemic degree and discipline',
academicDegreewithFieldShort: 'acedemic degree and discipline (short)',
@@ -80,33 +79,10 @@ export class SCAcademicDegreeMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
academicDegree: {
'bachelor': 'Bachelor',
'diploma': 'Diplom',
'doctor': 'Doktor',
'licentiate': 'Lizenziat',
'magister': 'Magister',
'master': 'Master',
'masterstudent': 'Meisterschüler',
'state examination': 'Staatsexamen',
},
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}
/**
* Types of (german) academic degrees
*/
export type SCGermanAcademicDegree =
'bachelor'
| 'diploma'
| 'doctor'
| 'licentiate'
| 'magister'
| 'master'
| 'master pupil'
| 'state examination' ;

View File

@@ -77,7 +77,7 @@ export class SCAcademicTermWithoutReferencesMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
acronym: 'Akronym',
endDate: 'Enddatum',
eventsEndDate: 'Enddatum der Veranstaltungen',
@@ -85,7 +85,7 @@ export class SCAcademicTermWithoutReferencesMeta
startDate: 'Startdatum',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
acronym: 'acronym',
endDate: 'end date',
eventsEndDate: 'end date of events',
@@ -99,10 +99,10 @@ export class SCAcademicTermWithoutReferencesMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -12,35 +12,49 @@
* 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 {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from './thing-that-can-be-offered';
import {SCPublicationEventWithoutReferences} from '../publication-event';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/**
* A creative work without references
*/
export interface SCCreativeWorkWithoutReferences
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
extends SCThingWithoutReferences {
/**
* Languages this creative work is available in
*/
availableLanguages?: SCLanguageCode[];
/**
* Date the creative work was published
*
* @filterable
*/
datePublished?: SCISO8601Date;
/**
* List of languages this creative work is written/recorded/... in
* Edition of a creative work (e.g. the book edition or edition of an article)
*
* @keyword
*/
inLanguages?: SCLanguage[];
edition?: string;
/**
* Date (in text form) the creative work was published for the first time
*
* @keyword
*/
firstPublished?: string;
/**
* Languages this creative work is written/recorded/... in
*
* @filterable
*/
inLanguage?: SCLanguageCode;
/**
* Keywords of the creative work
@@ -51,6 +65,13 @@ export interface SCCreativeWorkWithoutReferences
*/
keywords?: string[];
/**
* Date (in text form) the creative work was most recently
*
* @keyword
*/
lastPublished?: string;
/**
* Translated fields of the creative work
*/
@@ -61,17 +82,32 @@ export interface SCCreativeWorkWithoutReferences
* A creative work
*/
export interface SCCreativeWork
extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
extends SCCreativeWorkWithoutReferences, SCThing {
/**
* Authors of the creative work
*/
authors?: SCPersonWithoutReferences[];
/**
* A creative work to which the creative work belongs
*/
isPartOf?: SCCreativeWorkWithoutReferences;
/**
* List of events at which the creative work was published
*/
publications?: SCPublicationEventWithoutReferences[];
/**
* List of publishers of the creative work
*/
publishers?: Array<SCPersonWithoutReferences | SCOrganizationWithoutReferences>;
/**
* A text representing on organization on whose behalf the creator was working
*/
sourceOrganization?: string;
/**
* Translated fields of the creative work
*/
@@ -82,7 +118,7 @@ export interface SCCreativeWork
* Translatable properties of creative works
*/
export interface SCCreativeWorkTranslatableProperties
extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
extends SCThingTranslatableProperties {
/**
* Translation of the keywords of the creative work
*
@@ -101,22 +137,36 @@ export class SCCreativeWorkMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
authors: 'Authoren',
...new SCThingMeta().fieldTranslations.de,
name: 'Titel',
authors: 'beteiligte Personen',
availableLanguages: 'verfügbare Übersetzungen',
datePublished: 'Veröffentlichungsdatum',
inLanguages: 'verfügbare Übersetzungen',
edition: 'Ausgabe',
firstPublished: 'erste Veröffentlichung',
inLanguage: 'Inhaltssprache',
isPartOf: 'erschienen in',
keywords: 'Schlagwörter',
lastPublished: 'aktuellste Veröffentlichung',
publishers: 'Verleger',
publications: 'Veröffentlichungen',
sourceOrganization: 'Körperschaft',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
authors: 'authors',
...new SCThingMeta().fieldTranslations.en,
name: 'title',
authors: 'involved persons',
availableLanguages: 'available languages',
datePublished: 'release date',
inLanguages: 'available Languages',
edition: 'edition',
firstPublished: 'first published',
inLanguage: 'content language',
isPartOf: 'published in',
keywords: 'keywords',
lastPublished: 'last published',
publishers: 'publishers',
publications: 'publications',
sourceOrganization: 'corporation',
},
};
@@ -125,12 +175,10 @@ export class SCCreativeWorkMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -86,7 +86,7 @@ export class SCEventMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
academicTerms: 'Semester',
catalogs: 'Verzeichnis',
creativeWorks: 'begleitende Werke',
@@ -96,7 +96,7 @@ export class SCEventMeta
remainingAttendeeCapacity: 'verfügbare Anzahl an Teilnehmern',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
academicTerms: 'academic terms',
catalogs: 'catalogs',
creativeWorks: 'related material',
@@ -112,10 +112,10 @@ export class SCEventMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -145,13 +145,13 @@ export class SCPlaceWithoutReferencesMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
address: 'Adresse',
geo: 'Geoinformation',
openingHours: 'Öffnungszeiten',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
address: 'address',
geo: 'geographic information',
openingHours: 'opening hours',
@@ -163,10 +163,10 @@ export class SCPlaceWithoutReferencesMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2021 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 {SCISO8601Date} from '../../general/time';
/**
* Date Range
*
* CAUTION: Changing the name requires changes in the core-tools premaps
*/
export type SCISO8601DateRange = SCRange<SCISO8601Date>;
/**
* Generic range type
*/
export type SCRange<T> = {
/**
* Greater than value
*/
gt?: never;
/**
* Greater or equal to value
*/
gte?: T;
/**
* Greater than value
*/
lt?: never;
/**
* Greater or equal to value
*/
lte?: T;
} | {
// tslint:disable:completed-docs
gt?: T;
gte?: never;
lt?: T;
lte?: never;
} | {
gt?: T;
gte?: never;
lt?: never;
lte?: T;
} | {
gt?: never;
gte?: T;
lt?: T;
lte?: never;
// tslint:enable:completed-docs
};

View File

@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCIndexableThings} from '../../meta';
import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
/**
@@ -19,18 +20,17 @@ import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
*/
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>
export interface SCSaveableThing
extends SCSaveableThingWithoutReferences, SCThing {
/**
* The contained data
*/
data: T;
data: SCIndexableThings;
/**
* Type of the origin
*/

View File

@@ -34,11 +34,11 @@ export class SCThingInPlaceMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
inPlace: 'Ort',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
inPlace: 'location',
},
};
@@ -48,10 +48,10 @@ export class SCThingInPlaceMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -54,11 +54,11 @@ export class SCThingThatAcceptsPaymentsWithoutReferencesMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
paymentsAccepted: 'Bezahlmethoden',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
paymentsAccepted: 'accepted payment methods',
},
};
@@ -68,7 +68,7 @@ export class SCThingThatAcceptsPaymentsWithoutReferencesMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
paymentsAccepted: {
'cafeteria card': 'Mensakarte',
'cash': 'Bar',
@@ -76,7 +76,7 @@ export class SCThingThatAcceptsPaymentsWithoutReferencesMeta
},
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -13,10 +13,10 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCInPlace} from './place';
import {SCISO8601DateRange} from './range';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/**
@@ -100,19 +100,14 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup>
availability: SCThingThatCanBeOfferedAvailability;
/**
* The time when the thing becomes unavailable as an SCISO8601Date formatted string.
* The time when the thing is available.
*/
availabilityEnds?: SCISO8601Date;
/**
* The time when the thing becomes available as an SCISO8601Date formatted string.
*/
availabilityStarts?: SCISO8601Date;
availabilityRange?: SCISO8601DateRange;
/**
* List of prices that are distinct for specific groups
*/
prices: T;
prices?: T;
/**
* Provider of an offer
@@ -155,21 +150,16 @@ export type SCThingThatCanBeOfferedAvailability =
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,
...new SCThingMeta().fieldTranslations.de,
offers: 'Angebote',
},
en: {
...SCThingMeta.getInstance().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
offers: 'offers',
},
};
@@ -179,26 +169,10 @@ export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup>
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new 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

@@ -120,22 +120,17 @@ export interface SCThingWithCategoriesSpecificValues {
export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
/**
* Instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
categories: 'Kategorien',
categorySpecificValues: 'besondere Kategorien',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
categories: 'categories',
categorySpecificValues: 'category with specific values',
},
@@ -146,27 +141,10 @@ export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<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() {
}
}

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCMap} from '../../general/map';
import {SCISO8601Date} from '../../general/time';
import {SCUuid} from '../../general/uuid';
import {SCOrganizationWithoutReferences} from '../organization';
@@ -22,13 +23,15 @@ import {SCPersonWithoutReferences} from '../person';
* Types a thing can be
*/
export enum SCThingType {
Assessment = 'assessment',
AcademicEvent = 'academic event',
Article = 'article',
Book = 'book',
Periodical = 'periodical',
Building = 'building',
Catalog = 'catalog',
ContactPoint = 'contact point',
CourseOfStudies = 'course of studies',
CourseOfStudy = 'course of study',
DateSeries = 'date series',
Diff = 'diff',
Dish = 'dish',
@@ -38,6 +41,7 @@ export enum SCThingType {
Organization = 'organization',
Person = 'person',
PointOfInterest = 'point of interest',
PublicationEvent = 'publication event',
Room = 'room',
Semester = 'semester',
Setting = 'setting',
@@ -60,6 +64,7 @@ export interface SCThingWithoutReferences {
* @keyword
*/
alternateNames?: string[];
/**
* Description of the thing
*
@@ -67,12 +72,21 @@ export interface SCThingWithoutReferences {
* @text
*/
description?: string;
/**
* The identifier property represents any kind of additional identifier for any kind of SCThing
*
* E.g. GTIN codes, UUIDs, Database IDs etc.
*/
identifiers?: SCMap<string>;
/**
* URL of an image of the thing
*
* @keyword
*/
image?: string;
/**
* Name of the thing
*
@@ -82,12 +96,21 @@ export interface SCThingWithoutReferences {
* @text
*/
name: string;
/**
* URL of a reference Web page that unambiguously indicates the item's identity
*
* E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website.
*/
sameAs?: string;
/**
* Translations of specific values of the object
*
* Take precedence over "main" value for selected languages.
*/
translations?: SCTranslations<SCThingTranslatableProperties>;
/**
* Type of the thing
*
@@ -96,16 +119,11 @@ export interface SCThingWithoutReferences {
* @aggregatable global
*/
type: SCThingType;
/**
* Universally unique identifier of the thing
*/
uid: SCUuid;
/**
* URL of the thing
*
* @filterable
*/
url?: string;
}
/**
@@ -251,11 +269,6 @@ export interface SCThingTranslatablePropertyOrigin {
* Meta information about things
*/
export class SCThingMeta implements SCMetaTranslations<SCThing> {
/**
* Set type definiton for singleton instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
@@ -263,24 +276,26 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
de: {
alternateNames: 'alternative Namen',
description: 'Beschreibung',
identifiers: 'Alternative Identifikation',
image: 'Bild',
name: 'Name',
origin: 'Ursprung',
sameAs: 'ursprünglicher Link',
translations: 'Übersetzungen',
type: 'Typ',
uid: 'Identifikation',
url: 'URL',
},
en: {
alternateNames: 'alternate names',
description: 'description',
identifiers: 'alternative identification',
image: 'image',
name: 'name',
origin: 'origin',
sameAs: 'original link',
translations: 'translations',
type: 'type',
uid: 'identification',
url: 'URL',
},
};
@@ -295,19 +310,4 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
type: 'Thing',
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance
*/
public static getInstance<T extends SCThingMeta>(): T {
if (!SCThingMeta._instance.has(this.name)) {
SCThingMeta._instance.set(this.name, new this());
}
return SCThingMeta._instance.get(this.name) as T;
}
protected constructor() {
}
}

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) 2021 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/>.
*/
/**
* Types of data consumers
*/
export type SCUserGroup =
'students'
| 'employees'
| 'guests';

View File

@@ -128,15 +128,15 @@ export class SCAcademicEventMeta
*/
fieldTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
...new SCEventMeta().fieldTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
majors: 'Hauptfächer',
originalCategory: 'ursprüngliche Kategorie',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
...new SCEventMeta().fieldTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
majors: 'majors',
originalCategory: 'original category',
@@ -148,8 +148,8 @@ export class SCAcademicEventMeta
*/
fieldValueTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
...new SCEventMeta().fieldValueTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
'colloquium': 'Kolloquium',
@@ -171,8 +171,8 @@ export class SCAcademicEventMeta
type: 'akademische Veranstaltung',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
...new SCEventMeta().fieldValueTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.AcademicEvent,
},

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -20,26 +20,40 @@ import {
SCCreativeWorkWithoutReferences,
} from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences} from './abstract/thing-that-can-be-offered';
import {
SCThingWithCategories,
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
import {SCPeriodicalWithoutReferences} from './periodical';
/**
* Categories of an article
*/
export type SCArticleCategories = 'unipedia'
| 'article'
| 'eArticle';
/**
* An article without references
*/
export interface SCArticleWithoutReferences
extends SCCreativeWorkWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
SCThingThatCanBeOfferedWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
/**
* Article itself as markdown
*
* @text
*/
articleBody: string;
articleBody?: string;
/**
* Categories of an article
*/
categories: SCArticleCategories[];
/**
* Translated fields of an article
@@ -59,8 +73,18 @@ export interface SCArticleWithoutReferences
* @indexable
*/
export interface SCArticle
extends SCCreativeWork, SCArticleWithoutReferences,
SCThingWithCategories<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
extends SCCreativeWork,
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
SCArticleWithoutReferences {
/**
* A periodical to which this article belongs
*/
isPartOf?: SCPeriodicalWithoutReferences;
/**
* Additional information about how to find the article inside of its "parent" (which is provided in 'isPartOf')
* e.g. "40, 2011, S. 2-3"
*/
reference?: string;
/**
* Translated fields of an article
*/
@@ -73,15 +97,12 @@ export interface SCArticle
}
/**
* Categories of articles
*/
export type SCArticleCategories = 'unipedia';
/**
* Translatable properties of creative works
* Translatable properties of an article
*/
export interface SCArticleTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
extends SCThingWithCategoriesTranslatableProperties,
SCThingThatCanBeOfferedTranslatableProperties,
SCCreativeWorkTranslatableProperties {
/**
* Translation of the article itself as markdown
*
@@ -100,17 +121,23 @@ export class SCArticleMeta
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
...new SCCreativeWorkMeta().fieldTranslations
.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
categories: 'Format',
reference: 'Referenz',
articleBody: 'Artikelinhalt',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
...new SCCreativeWorkMeta().fieldTranslations
.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
categories: 'format',
reference: 'reference',
articleBody: 'article body',
},
};
@@ -120,21 +147,30 @@ export class SCArticleMeta
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta().fieldValueTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
'unipedia': 'Unipedia',
article: 'Artikel',
eArticle: 'E-Aufsatz',
unipedia: 'Unipedia',
},
type: 'Artikel',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta().fieldValueTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Article,
categories: {
article: 'article',
eArticle: 'E-Article',
unipedia: 'unipedia',
},
},
};
}

162
src/things/assessment.ts Normal file
View File

@@ -0,0 +1,162 @@
/*
* Copyright (C) 2019-2021 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 {SCISO8601Date} from '../general/time';
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta} from './abstract/thing-with-categories';
import {SCCourseOfStudyWithoutReferences} from './course-of-study';
/**
* Categories of assessments
*/
export type SCAssessmentCategories = 'university assessment';
/**
* An assessment without references
*
*/
export interface SCAssessmentWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCAssessmentCategories, SCThingWithCategoriesSpecificValues> {
/**
* Number of attempts
*
* @integer
*/
attempt?: number;
/**
* Date assessment was taken or graded
*/
date?: SCISO8601Date;
/**
* ECTS (credit-points)
*
* @float
*/
ects?: number;
/**
* Grade
*/
grade: string;
/**
* Current status
*/
status?: string;
/**
* Translated fields of an assessment
*/
translations?: SCTranslations<SCAssessmentTranslatableProperties>;
/**
* Type of an assessment
*/
type: SCThingType.Assessment;
}
/**
* An assessment
*
* @validatable
*/
export interface SCAssessment
extends SCAssessmentWithoutReferences, SCThing,
SCThingWithCategories<SCAssessmentCategories, SCThingWithCategoriesSpecificValues> {
/**
* Course of study the assessment was taken for
*/
courseOfStudy?: SCCourseOfStudyWithoutReferences;
/**
* An array of assessments from the 'level 0' (root) assessment to the direct parent
*/
superAssessments?: SCAssessmentWithoutReferences[];
/**
* Translated fields of an assessment
*/
translations?: SCTranslations<SCAssessmentTranslatableProperties>;
/**
* Type of an assessment
*/
type: SCThingType.Assessment;
}
export interface SCAssessmentTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties {
/**
* @see SCAssessmentWithoutReferences.status
*/
status?: string;
}
/**
* Study module meta data
*/
export class SCAssessmentMeta
extends SCThingMeta
implements SCMetaTranslations<SCAssessment> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...new SCThingWithCategoriesWithoutReferencesMeta<SCAssessmentCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
attempt: 'Versuch',
courseOfStudy: 'Studiengang',
date: 'Datum',
ects: 'ECTS-Punkte',
grade: 'Note',
status: 'Status',
superAssessments: 'übergeordnete Prüfungen',
},
en: {
...new SCThingWithCategoriesWithoutReferencesMeta<SCAssessmentCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
attempt: 'attempt',
courseOfStudy: 'course of study',
date: 'date',
ects: 'ECTS points',
grade: 'grade',
status: 'status',
superAssessments: 'parent assessments',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...new SCThingWithCategoriesWithoutReferencesMeta<SCAssessmentCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'Prüfung',
},
en: {
...new SCThingWithCategoriesWithoutReferencesMeta<SCAssessmentCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Assessment,
},
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -20,29 +20,55 @@ import {
SCCreativeWorkWithoutReferences,
} from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingWithCategoriesTranslatableProperties} from './abstract/thing-with-categories';
import {SCPersonWithoutReferences} from './person';
import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences} from './abstract/thing-that-can-be-offered';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
/**
* Categories of a book
*/
export type SCBookCategories = 'audio'
| 'book'
| 'cd'
| 'dvd'
| 'ePhoto'
| 'ebook'
| 'hierarchy'
| 'kit'
| 'manuscript'
| 'map'
| 'microfilm'
| 'musicalscore'
| 'photo'
| 'physicalobject'
| 'retro'
| 'sensorimage'
| 'unknown'
| 'video';
/**
* A book without references
*/
export interface SCBookWithoutReferences
extends SCCreativeWorkWithoutReferences {
extends SCCreativeWorkWithoutReferences,
SCThingThatCanBeOfferedWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCBookCategories, SCThingWithCategoriesSpecificValues> {
/**
* Edition of a book
*
* @filterable
* @keyword
* Categories of a book
*/
bookEdition?: string;
categories: SCBookCategories[];
/**
* ISBN of a book
* ISBNs of a book
*
* @filterable
* @keyword
*/
isbn?: string;
ISBNs?: string[];
/**
* Number of pages of a book
@@ -69,12 +95,9 @@ export interface SCBookWithoutReferences
* @indexable
*/
export interface SCBook
extends SCCreativeWork, SCBookWithoutReferences {
/**
* Authors of the creative work
*/
authors: SCPersonWithoutReferences[];
extends SCCreativeWork,
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
SCBookWithoutReferences {
/**
* Translated properties of a book
*/
@@ -90,13 +113,9 @@ export interface SCBook
* Translatable properties of a book
*/
export interface SCBookTranslatableFields
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
/**
* Translation of an edition of a book
*
* @keyword
*/
bookEdition?: string;
extends SCThingWithCategoriesTranslatableProperties,
SCThingThatCanBeOfferedTranslatableProperties,
SCCreativeWorkTranslatableProperties {
}
/**
@@ -108,17 +127,21 @@ export class SCBookMeta extends SCThingMeta implements SCMetaTranslations<SCBook
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
bookEdition: 'Buchausgabe',
isbn: 'ISBN',
numberOfPages: 'Seitenzahl',
...new SCCreativeWorkMeta().fieldTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBookCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
categories: 'Format',
ISBNs: 'ISBN',
numberOfPages: 'Seitenanzahl',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
bookEdition: 'book edition',
isbn: 'ISBN',
...new SCCreativeWorkMeta().fieldTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBookCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
categories: 'format',
ISBNs: 'ISBN',
numberOfPages: 'number of pages',
},
};
@@ -128,14 +151,62 @@ export class SCBookMeta extends SCThingMeta implements SCMetaTranslations<SCBook
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta()
.fieldValueTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBookCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
categories: {
audio: 'Tonträger',
book: 'Buch',
cd: 'CD',
dvd: 'DVD',
ePhoto: 'E-Photo',
ebook: 'E-Book',
hierarchy: 'mehrteiliges Werk',
kit: 'Medienkombination',
manuscript: 'Handschrift',
map: 'Karte',
microfilm: 'Mikrofilm, Mikrofiche',
musicalscore: 'Noten',
photo: 'Abbildung',
physicalobject: 'Objekt',
retro: 'Retro (Buch)',
sensorimage: 'Blindenschrift',
unknown: 'Unbekannt',
video: 'Film',
},
type: 'Buch',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta()
.fieldValueTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBookCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.Book,
categories: {
audio: 'audio material',
book: 'book',
cd: 'CD',
dvd: 'DVD',
ePhoto: 'E-Photo',
ebook: 'E-Book',
hierarchy: 'multipart item',
kit: 'media combination',
manuscript: 'manuscript',
map: 'map',
microfilm: 'microfilm, microfiche',
musicalscore: 'sheet music',
photo: 'illustration',
physicalobject: 'object',
retro: 'retro (book)',
sensorimage: 'braille',
unknown: 'unknown',
video: 'film',
},
},
};
}

View File

@@ -99,15 +99,15 @@ export class SCBuildingMeta
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.de,
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
floors: 'Etagen',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.en,
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
floors: 'floors',
},
};
@@ -117,9 +117,9 @@ export class SCBuildingMeta
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.de,
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
categories: {
'cafe': 'Café',
'canteen': 'Kantine',
@@ -133,9 +133,9 @@ export class SCBuildingMeta
type: 'Gebäude',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.en,
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
type: SCThingType.Building,
},
};

View File

@@ -33,6 +33,7 @@ export interface SCCatalogWithoutReferences
*
* Needed for keeping order in catalog inheritance array.
*
* @filterable
* @integer
*/
level: number;
@@ -88,7 +89,7 @@ export class SCCatalogMeta
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
academicTerm: 'Semester',
level: 'Ebene',
@@ -96,7 +97,7 @@ export class SCCatalogMeta
superCatalogs: 'übergeordnete Verzeichnisse',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
academicTerm: 'academic term',
level: 'level',
@@ -110,7 +111,7 @@ export class SCCatalogMeta
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
'university events': 'Universitätsveranstaltung',
@@ -118,7 +119,7 @@ export class SCCatalogMeta
type: 'Verzeichnis',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Catalog,
},

View File

@@ -73,7 +73,7 @@ export interface SCContactPointWithoutReferences
* A contact point
*
* @see http://schema.org/ContactPoint
*
*
* @validatable
* @indexable
*/
@@ -101,7 +101,7 @@ export class SCContactPointMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
areaServed: 'Arbeitsraum',
email: 'E-Mail-Addresse',
faxNumber: 'Faxnummer',
@@ -110,7 +110,7 @@ export class SCContactPointMeta
url: 'Link',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
areaServed: 'location',
email: 'email address',
faxNumber: 'fax number',
@@ -125,11 +125,11 @@ export class SCContactPointMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
type: 'Kontaktinformation',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
type: SCThingType.ContactPoint,
},
};

View File

@@ -26,119 +26,113 @@ import {SCDateSeriesWithoutReferences} from './date-series';
import {SCOrganizationWithoutReferences} from './organization';
/**
* A course of studies without references
* A course of study without references
*/
export interface SCCourseOfStudiesWithoutReferences
export interface SCCourseOfStudyWithoutReferences
extends SCAcademicDegreeWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* The main language in which the course of studies
* The main language in which the course of study
* is beeing offered
*/
mainLanguage: SCLanguage;
mainLanguage?: SCLanguage;
/**
* Actual major of the course of studies (eg. physics)
* The modes the course of study is offered in
*
* @filterable
* @keyword
*/
major: string;
mode?: SCCourseOfStudyMode;
/**
* The modes the course of studies is offered in
* The time modes the course of study is offered in
*
* @filterable
*/
mode: SCCourseOfStudiesMode;
/**
* The time modes the course of studies is offered in
*/
timeMode: SCCourseOfStudiesTimeMode;
timeMode?: SCCourseOfStudyTimeMode;
/**
* Translated fields of a dish
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
translations?: SCTranslations<SCCourseOfStudyTranslatableProperties>;
/**
* Type of the course of studies
* Type of the course of study
*/
type: SCThingType.CourseOfStudies;
type: SCThingType.CourseOfStudy;
}
/**
* A course of studies
* A course of study
*
* @validatable
* @indexable
*/
export interface SCCourseOfStudies
extends SCCourseOfStudiesWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>, SCAcademicDegree {
export interface SCCourseOfStudy
extends SCCourseOfStudyWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>, SCAcademicDegree {
/**
* The department that manages the course of studies
* The department that manages the course of study
*/
department: SCOrganizationWithoutReferences;
department?: SCOrganizationWithoutReferences;
/**
* The secretary that administers requests and
* questions concerning the course of studies
* questions concerning the course of study
*/
secretary: SCOrganizationWithoutReferences;
secretary?: SCOrganizationWithoutReferences;
/**
* Dates at which the course of studies is planned to start
* Dates at which the course of study is planned to start
*/
startDates?: SCDateSeriesWithoutReferences[];
/**
* Translated fields of a course of studies
* Translated fields of a course of study
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
translations?: SCTranslations<SCCourseOfStudyTranslatableProperties>;
/**
* Type of the course of studies
* Type of the course of study
*/
type: SCThingType.CourseOfStudies;
type: SCThingType.CourseOfStudy;
}
/**
* Translatable properties of a course of studies
* Translatable properties of a course of study
*/
export interface SCCourseOfStudiesTranslatableProperties
export interface SCCourseOfStudyTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
// noop
// noop
}
/**
* Meta information about a course of studies
* Meta information about a course of study
*/
export class SCCourseOfStudiesMeta
export class SCCourseOfStudyMeta
extends SCThingMeta
implements SCMetaTranslations<SCCourseOfStudies> {
implements SCMetaTranslations<SCCourseOfStudy> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCAcademicDegreeMeta.getInstance<SCAcademicDegreeMeta>()
...new SCAcademicDegreeMeta()
.fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.de,
department: 'Fachbereich',
mainLanguage: 'Unterrichtssprache',
major: 'Studienfach',
mode: 'Studiengangsart',
secretary: 'Sekretariat',
startDates: 'Startdatum',
timeMode: 'Zeitmodell',
},
en: {
...SCAcademicDegreeMeta.getInstance<SCAcademicDegreeMeta>()
...new SCAcademicDegreeMeta()
.fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.de,
department: 'department',
mainLanguage: 'main language',
major: 'major',
mode: 'mode',
secretary: 'secretary',
startDates: 'start dates',
@@ -151,7 +145,7 @@ export class SCCourseOfStudiesMeta
*/
fieldValueTranslations = {
de: {
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
...new SCAcademicDegreeMeta().fieldValueTranslations.de,
modes: {
combination: 'Kombinationsstudiengang',
'double-degree': 'Doppelstudium',
@@ -165,32 +159,32 @@ export class SCCourseOfStudiesMeta
type: 'Studiengang',
},
en: {
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en,
...new SCAcademicDegreeMeta().fieldValueTranslations.en,
modes: {
combination: 'combination course of studies',
'double-degree': 'double degree course of studies',
dual: 'dual course of studies',
standard: 'course of studies',
combination: 'combination course of study',
'double-degree': 'double degree course of study',
dual: 'dual course of study',
standard: 'course of study',
},
timeMode: {
fulltime: 'full-time',
parttime: 'part-time',
},
type: SCThingType.CourseOfStudies,
type: SCThingType.CourseOfStudy,
},
};
}
/**
* Types of (german) course of studies modes
* Types of (german) course of study modes
*/
export type SCCourseOfStudiesMode = 'combination'
export type SCCourseOfStudyMode = 'combination'
| 'dual'
| 'double-degree'
| 'standard' ;
/**
* Types of (german) course of studies time modes
* Types of (german) course of study time modes
*/
export type SCCourseOfStudiesTimeMode = 'fulltime'
export type SCCourseOfStudyTimeMode = 'fulltime'
| 'parttime' ;

View File

@@ -65,9 +65,9 @@ export interface SCDateSeriesWithoutReferences
/**
* Frequency of the date series
*
* @keyword
* @filterable
*/
frequency: string;
repeatFrequency?: SCISO8601Duration;
/**
* Translated properties
@@ -123,27 +123,27 @@ export class SCDateSeriesMeta
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>()
.fieldTranslations.de,
dates: 'Einzeltermine',
duration: 'Dauer',
event: 'Event',
exceptions: 'Ausnahmen',
frequency: 'Frequenz',
repeatFrequency: 'Frequenz',
performers: 'Vortragende',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>()
.fieldTranslations.en,
dates: 'dates',
duration: 'duration',
event: 'event',
exceptions: 'exceptions',
frequency: 'frequency',
repeatFrequency: 'frequency',
performers: 'performers',
},
};
@@ -153,16 +153,16 @@ export class SCDateSeriesMeta
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>()
.fieldValueTranslations.de,
type: 'Terminserie',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCSportCoursePriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.DateSeries,
},
@@ -174,8 +174,4 @@ export class SCDateSeriesMeta
*/
export interface SCDateSeriesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
/**
* @see SCDateSeriesWithoutReferences.frequency
*/
frequency?: string;
}

View File

@@ -15,7 +15,7 @@
import * as jsonpatch from 'json-patch';
import {SCMetaTranslations} from '../general/i18n';
import {SCISO8601Date} from '../general/time';
import {SCThingsWithoutDiff} from '../meta';
import {SCIndexableThings} from '../meta';
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
/**
@@ -48,14 +48,13 @@ export interface SCDiffWithoutReferences
* A diff
*
* @validatable
* @indexable
*/
export interface SCDiff
extends SCDiffWithoutReferences, SCThing {
/**
* Original object the diff was generated on
*/
object: SCThingsWithoutDiff;
object: SCIndexableThings;
/**
* Type of a diff
@@ -74,14 +73,14 @@ export class SCDiffMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
action: 'Aktion',
changes: 'Änderungen',
dateCreated: 'Erstellungsdatum',
object: 'Objekt',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
action: 'action',
changes: 'changes',
dateCreated: 'date created',
@@ -94,7 +93,7 @@ export class SCDiffMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
action: {
'changed': 'geändert',
'removed': 'gelöscht',
@@ -102,7 +101,7 @@ export class SCDiffMeta
type: 'Unterschied',
},
en: {
...SCThingMeta.getInstance().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
type: SCThingType.Diff,
},
};

View File

@@ -91,6 +91,13 @@ export interface SCDish
export interface SCDishTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/**
* Additives of the dish
*
* @filterable
* @keyword
*/
additives?: string[];
/**
* Characteristics of the dish
*/
@@ -195,9 +202,9 @@ export class SCDishMeta
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.de,
additives: 'Zusatzstoffe',
characteristics: 'Merkmale',
@@ -205,9 +212,9 @@ export class SCDishMeta
nutrition: 'Nährwertangaben',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.en,
additives: 'additives',
characteristics: 'characteristics',
@@ -221,9 +228,9 @@ export class SCDishMeta
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
categories: {
appetizer: 'Vorspeise',
@@ -236,9 +243,9 @@ export class SCDishMeta
type: 'Essen',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.Dish,
},

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -14,45 +14,24 @@
*/
import {SCSaveableThing, SCSaveableThingWithoutReferences} from './abstract/saveable-thing';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicEventWithoutReferences} from './academic-event';
import {SCArticleWithoutReferences} from './article';
import {SCBookWithoutReferences} from './book';
import {SCBuildingWithoutReferences} from './building';
import {SCPersonWithoutReferences} from './person';
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
import {SCRoomWithoutReferences} from './room';
import {SCSportCourseWithoutReferences} from './sport-course';
import {SCToDoWithoutReferences} from './todo';
/**
* Types that can be made a favorite (added as a favorite)
*/
export type SCFavoriteDataTypes = SCAcademicEventWithoutReferences
| SCArticleWithoutReferences
| SCBookWithoutReferences
| SCBuildingWithoutReferences
| SCPersonWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences
| SCSportCourseWithoutReferences
| SCToDoWithoutReferences;
/**
* A favorite without references
*/
export interface SCFavoriteWithoutReferences
extends SCSaveableThingWithoutReferences {
// noop
/**
* Type of a favorite
*/
type: SCThingType.Favorite;
}
/**
* A favorite
*
* @validatable
* @indexable
*/
export interface SCFavorite
extends SCSaveableThing<SCFavoriteDataTypes>, SCFavoriteWithoutReferences {
export interface SCFavorite extends SCSaveableThing {
/**
* Type of a favorite
*/

View File

@@ -114,13 +114,13 @@ export class SCFloorMeta
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.de,
floorName: 'Etagenbezeichnung',
plan: 'Grundriss',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.en,
floorName: 'floor name',
plan: 'plan',
@@ -132,12 +132,12 @@ export class SCFloorMeta
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.de,
type: 'Etage',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.en,
type: SCThingType.Floor,
},

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -22,13 +22,24 @@ import {
} from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
import {SCUserGroup} from './abstract/user-groups';
import {SCOrganizationWithoutReferences} from './organization';
/**
* Categories of a message
*/
export type SCMessageCategories = 'news';
/**
* A message without references
*/
export interface SCMessageWithoutReferences
extends SCCreativeWorkWithoutReferences {
extends SCCreativeWorkWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCMessageCategories, SCThingWithCategoriesSpecificValues> {
/**
* Organizational unit for which the message is intended
*/
@@ -39,7 +50,12 @@ export interface SCMessageWithoutReferences
*
* @filterable
*/
audiences: SCMessageAudience[];
audiences: SCUserGroup[];
/**
* Categories of a message
*/
categories: SCMessageCategories[];
/**
* When the message was created
@@ -90,14 +106,6 @@ export interface SCMessage
type: SCThingType.Message;
}
/**
* Audiences for messages
*/
export type SCMessageAudience =
'students'
| 'employees'
| 'guests';
/**
* Translatable properties of a message
*/
@@ -122,8 +130,9 @@ export class SCMessageMeta
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.de,
...new SCCreativeWorkMeta().fieldTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCMessageCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
audienceOrganizations: 'Zielgruppenorganisationen',
audiences: 'Zielgruppen',
dateCreated: 'Erstellungsdatum',
@@ -131,8 +140,9 @@ export class SCMessageMeta
sequenceIndex: 'Sequenzindex',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
.en,
...new SCCreativeWorkMeta().fieldTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCMessageCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
audienceOrganizations: 'audience organizations',
audiences: 'audiences',
dateCreated: 'date created',
@@ -146,18 +156,23 @@ export class SCMessageMeta
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.de,
...new SCCreativeWorkMeta().fieldValueTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCMessageCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
audiences: {
'employees': 'Angestellte',
'guests': 'Gäste',
'students': 'Studenten',
employees: 'Angestellte',
guests: 'Gäste',
students: 'Studenten',
},
categories: {
news: 'Neuigkeiten',
},
type: 'Nachricht',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
.fieldValueTranslations.en,
...new SCCreativeWorkMeta().fieldValueTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCMessageCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Message,
},
};

View File

@@ -57,11 +57,11 @@ export class SCOrganizationMeta
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.de,
...new SCThingInPlaceMeta().fieldTranslations.de,
contactPoints: 'Kontaktinformationen',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.en,
...new SCThingInPlaceMeta().fieldTranslations.en,
contactPoints: 'contact details',
},
};
@@ -71,11 +71,11 @@ export class SCOrganizationMeta
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldValueTranslations.de,
...new SCThingInPlaceMeta().fieldValueTranslations.de,
type: 'Einrichtung',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldValueTranslations.en,
...new SCThingInPlaceMeta().fieldValueTranslations.en,
type: SCThingType.Organization,
},
};

149
src/things/periodical.ts Normal file
View File

@@ -0,0 +1,149 @@
/*
* Copyright (C) 2021 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 {
SCCreativeWork,
SCCreativeWorkMeta,
SCCreativeWorkTranslatableProperties,
SCCreativeWorkWithoutReferences,
} from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences} from './abstract/thing-that-can-be-offered';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
/**
* Categories of a periodical
*/
export type SCPeriodicalCategories = 'journal' | 'electronic';
/**
* A periodical without references
*/
export interface SCPeriodicalWithoutReferences
extends SCCreativeWorkWithoutReferences,
SCThingThatCanBeOfferedWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCPeriodicalCategories, SCThingWithCategoriesSpecificValues> {
/**
* Categories of a periodical
*/
categories: SCPeriodicalCategories[];
/**
* A list of ISSNs of a periodical
*
* @filterable
* @keyword
*/
ISSNs?: string[];
/**
* Translated properties of a periodical
*/
translations?: SCTranslations<SCPeriodicalTranslatableFields>;
/**
* Type of a periodical
*/
type: SCThingType.Periodical;
}
/**
* A publication published at regular intervals (e.g. a magazine or newspaper)
*
* @validatable
* @indexable
*/
export interface SCPeriodical
extends SCCreativeWork,
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
SCPeriodicalWithoutReferences {
/**
* Translated properties of a periodical
*/
translations?: SCTranslations<SCPeriodicalTranslatableFields>;
/**
* Type of a periodical
*/
type: SCThingType.Periodical;
}
/**
* Translatable properties of a periodical
*/
export interface SCPeriodicalTranslatableFields
extends SCThingWithCategoriesTranslatableProperties,
SCThingThatCanBeOfferedTranslatableProperties,
SCCreativeWorkTranslatableProperties {
}
/**
* Meta information about a periodical
*/
export class SCPeriodicalMeta extends SCThingMeta implements SCMetaTranslations<SCPeriodical> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...new SCCreativeWorkMeta().fieldTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPeriodicalCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
categories: 'Format',
ISSNs: 'ISSN',
},
en: {
...new SCCreativeWorkMeta().fieldTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPeriodicalCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
categories: 'format',
ISSNs: 'ISSN',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...new SCCreativeWorkMeta().fieldValueTranslations.de,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPeriodicalCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
type: 'Periodikum',
categories: {
electronic: 'E-Journal',
journal: 'Zeitschrift',
},
},
en: {
...new SCCreativeWorkMeta().fieldValueTranslations.en,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPeriodicalCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
type: 'periodical',
categories: {
electronic: 'E-Journal',
journal: 'journal',
},
},
};
}

View File

@@ -57,7 +57,7 @@ export interface SCPersonWithoutReferences
* @filterable
* @keyword
*/
familyName: string;
familyName?: string;
/**
* The private fax number of the person.
@@ -80,7 +80,7 @@ export interface SCPersonWithoutReferences
* @filterable
* @keyword
*/
givenName: string;
givenName?: string;
/**
* Honorific prefix of the person.
@@ -174,7 +174,7 @@ export class SCPersonMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
additionalName: 'Zusatzname',
affiliations: 'Zugehörigkeiten',
birthDate: 'Geburtsdatum',
@@ -192,7 +192,7 @@ export class SCPersonMeta
workLocations: 'Arbeitsstandorte',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
additionalName: 'additional name',
affiliations: 'affiliations',
birthDate: 'birth date',
@@ -217,7 +217,7 @@ export class SCPersonMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
gender: {
'female': 'weiblich',
'inter': 'divers',
@@ -227,7 +227,7 @@ export class SCPersonMeta
type: 'Person',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
type: SCThingType.Person,
},
};

View File

@@ -82,17 +82,17 @@ export class SCPointOfInterestMeta
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
...new SCThingInPlaceMeta().fieldTranslations
.de,
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
...new SCThingInPlaceMeta().fieldTranslations
.en,
},
};
@@ -102,9 +102,9 @@ export class SCPointOfInterestMeta
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.de,
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
categories: {
'card charger': 'Kartenaufwerter',
'computer': 'Computer',
@@ -115,9 +115,9 @@ export class SCPointOfInterestMeta
type: 'Sonderziel',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.en,
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
type: SCThingType.PointOfInterest,
},
};

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2021 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 {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event';
import {SCThingMeta, SCThingTranslatableProperties, SCThingType} from './abstract/thing';
/**
* An publication event without references
*/
export interface SCPublicationEventWithoutReferences
extends SCEventWithoutReferences {
/**
* All the locations related to the event (e.g. where a creative work was published)
*/
locations?: string[];
/**
* An organization (or a person) that is publishing at the event
*/
publisher?: string;
/**
* Translated fields of an publication event
*/
translations?: SCTranslations<SCPublicationEventTranslatableProperties>;
/**
* Type of an publication event
*/
type: SCThingType.PublicationEvent;
}
/**
* An publication event
*
* @validatable
* @indexable
*/
export interface SCPublicationEvent
extends SCEvent, SCPublicationEventWithoutReferences {
/**
* Translated fields of an publication event
*/
translations?: SCTranslations<SCPublicationEventTranslatableProperties>;
/**
* Type of an publication event
*/
type: SCThingType.PublicationEvent;
}
/**
* Translatable properties of an publication event
*/
export interface SCPublicationEventTranslatableProperties extends SCThingTranslatableProperties {
}
/**
* Meta information about publication events
*/
export class SCPublicationEventMeta
extends SCThingMeta
implements SCMetaTranslations<SCPublicationEvent> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...new SCEventMeta().fieldTranslations.de,
locations: 'Erscheinungsorte',
publisher: 'Verlag',
},
en: {
...new SCEventMeta().fieldTranslations.en,
locations: 'places of publication',
publisher: 'publisher',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...new SCEventMeta().fieldValueTranslations.de,
type: 'Veröffentlichung',
},
en: {
...new SCEventMeta().fieldValueTranslations.en,
type: 'publication event',
},
};
}

View File

@@ -127,23 +127,23 @@ export class SCRoomMeta
*/
fieldTranslations = {
de: {
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.de,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta()
.fieldTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.de,
floorName: 'Etagenbezeichnung',
inventory: 'Bestand',
},
en: {
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.en,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta()
.fieldTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.en,
floorName: 'floor name',
inventory: 'inventory',
@@ -155,12 +155,12 @@ export class SCRoomMeta
*/
fieldValueTranslations = {
de: {
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.de,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta()
.fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories,
SCRoomSpecificValues>().fieldValueTranslations.de,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.de,
categories: {
'cafe': 'Café',
@@ -180,12 +180,12 @@ export class SCRoomMeta
type: 'Raum',
},
en: {
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.en,
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta()
.fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories,
SCRoomSpecificValues>().fieldValueTranslations.en,
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.en,
type: SCThingType.Room,
},

View File

@@ -29,7 +29,7 @@ export interface SCSemesterWithoutReferences
* The short name of the semester, using the given pattern.
*
* @filterable
* @pattern ^(WS|SS) [0-9]{4}(/[0-9]{2})?$
* @pattern ^(WS|SS|WiSe|SoSe) [0-9]{4}(/[0-9]{2})?$
* @keyword
*/
acronym: string;
@@ -65,7 +65,7 @@ export class SCSemesterMeta
*/
fieldTranslations = {
de: {
...SCAcademicTermWithoutReferencesMeta.getInstance<SCAcademicTermWithoutReferencesMeta>().fieldTranslations.de,
...new SCAcademicTermWithoutReferencesMeta().fieldTranslations.de,
acronym: 'Abkürzung',
endDate: 'Ende',
eventsEndDate: 'Vorlesungsschluss',
@@ -73,7 +73,7 @@ export class SCSemesterMeta
startDate: 'Beginn',
},
en: {
...SCAcademicTermWithoutReferencesMeta.getInstance<SCAcademicTermWithoutReferencesMeta>().fieldTranslations.en,
...new SCAcademicTermWithoutReferencesMeta().fieldTranslations.en,
acronym: 'acronym',
endDate: 'end date',
eventsEndDate: 'semester ending',
@@ -87,12 +87,12 @@ export class SCSemesterMeta
*/
fieldValueTranslations = {
de: {
...SCAcademicTermWithoutReferencesMeta.getInstance<SCAcademicTermWithoutReferencesMeta>()
...new SCAcademicTermWithoutReferencesMeta()
.fieldValueTranslations.de,
type: 'Semester',
},
en: {
...SCAcademicTermWithoutReferencesMeta.getInstance<SCAcademicTermWithoutReferencesMeta>()
...new SCAcademicTermWithoutReferencesMeta()
.fieldValueTranslations.en,
type: SCThingType.Semester,
},

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
import {
SCThingWithCategories,
@@ -21,6 +21,7 @@ import {
SCThingWithCategoriesWithoutReferences,
SCThingWithCategoriesWithoutReferencesMeta,
} from './abstract/thing-with-categories';
import {SCUserGroup} from './abstract/user-groups';
/**
* A setting without references
@@ -83,7 +84,6 @@ export enum SCSettingInputType {
* A setting with references
*
* @validatable
* @indexable
*/
export interface SCSetting
extends SCSettingWithoutReferences, SCThing,
@@ -129,7 +129,7 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
defaultValue: 'Standard Wert',
inputType: 'Eingabetyp',
@@ -138,7 +138,7 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
values: 'Werte',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
defaultValue: 'default value',
inputType: 'input type',
@@ -153,7 +153,7 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
credentials: 'Anmeldedaten',
@@ -171,9 +171,61 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
type: 'Einstellung',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
...new SCThingWithCategoriesWithoutReferencesMeta<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Setting,
},
};
}
/**
* A user group setting
*/
export interface SCUserGroupSetting extends SCSetting {
/**
* Exact categories of the setting
*/
categories: ['profile'];
/**
* The default value of the setting
*/
defaultValue: SCUserGroup;
/**
* Specific name of the setting
*/
name: 'group';
/**
* Chosen value of the setting
*/
value?: SCUserGroup;
/**
* The possible values of the setting
*/
values: SCUserGroup[];
}
/**
* A language setting
*/
export interface SCLanguageSetting extends SCSetting {
/**
* Exact categories of the setting
*/
categories: ['profile'];
/**
* The default value of the setting
*/
defaultValue: SCLanguageCode;
/**
* Specific name of the setting
*/
name: 'language';
/**
* Chosen value of the setting
*/
value?: SCLanguageCode;
/**
* The possible values of the setting
*/
values: SCLanguageCode[];
}

View File

@@ -52,10 +52,10 @@ export class SCSportCourseMeta
*/
fieldTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.de,
...new SCEventMeta().fieldTranslations.de,
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldTranslations.en,
...new SCEventMeta().fieldTranslations.en,
},
};
@@ -64,11 +64,11 @@ export class SCSportCourseMeta
*/
fieldValueTranslations = {
de: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.de,
...new SCEventMeta().fieldValueTranslations.de,
type: 'Sportkurs',
},
en: {
...SCEventMeta.getInstance<SCEventMeta>().fieldValueTranslations.en,
...new SCEventMeta().fieldValueTranslations.en,
type: SCThingType.SportCourse,
},
};

View File

@@ -150,8 +150,8 @@ export class SCStudyModuleMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingMeta().fieldTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.de,
academicEvents: 'Veranstaltungen',
ects: 'ECTS-Punkte',
@@ -164,8 +164,8 @@ export class SCStudyModuleMeta
secretary: 'Sekretariat',
},
en: {
...SCThingMeta.getInstance().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingMeta().fieldTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldTranslations.en,
academicEvents: 'academic events',
ects: 'ECTS points',
@@ -184,8 +184,8 @@ export class SCStudyModuleMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingMeta().fieldValueTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
necessity: {
'elective': 'Wahlfach',
@@ -195,8 +195,8 @@ export class SCStudyModuleMeta
type: 'Studiengangmodul',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance<SCAcademicPriceGroup>()
...new SCThingMeta().fieldValueTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.StudyModule,
},

View File

@@ -70,14 +70,14 @@ export class SCTicketMeta
*/
fieldTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.de,
approxWaitingTime: 'ungefähre Wartezeit',
currentTicketNumber: 'aktuelle Ticketnummer',
serviceType: 'Service Kategorie',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
...new SCThingInPlaceMeta().fieldTranslations
.en,
approxWaitingTime: 'approximate waiting time',
currentTicketNumber: 'current ticket number',
@@ -90,12 +90,12 @@ export class SCTicketMeta
*/
fieldValueTranslations = {
de: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.de,
type: 'Ticket',
},
en: {
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
...new SCThingInPlaceMeta()
.fieldValueTranslations.en,
type: SCThingType.Ticket,
},

View File

@@ -88,14 +88,14 @@ export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations<SCToDo
*/
fieldTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
...new SCThingWithCategoriesWithoutReferencesMeta<string,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
done: 'Erledigt',
dueDate: 'Fälligkeitsdatum',
priority: 'Priorität',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
...new SCThingWithCategoriesWithoutReferencesMeta<string,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
done: 'done',
dueDate: 'due date',
@@ -108,12 +108,12 @@ export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations<SCToDo
*/
fieldValueTranslations = {
de: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
...new SCThingWithCategoriesWithoutReferencesMeta<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'ToDo',
},
en: {
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
...new SCThingWithCategoriesWithoutReferencesMeta<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.ToDo,
},

View File

@@ -65,12 +65,12 @@ export class SCTourMeta
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...new SCThingMeta().fieldTranslations.de,
init: 'Initiales Skript',
steps: 'Schritte',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...new SCThingMeta().fieldTranslations.en,
init: 'initial script',
steps: 'steps',
},
@@ -81,11 +81,11 @@ export class SCTourMeta
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...new SCThingMeta().fieldValueTranslations.de,
type: 'Tour',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...new SCThingMeta().fieldValueTranslations.en,
type: SCThingType.Tour,
},
};

View File

@@ -12,17 +12,19 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCLanguage, SCMetaTranslations} from '../general/i18n';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n';
import {SCISO8601Duration} from '../general/time';
import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkWithoutReferences} from './abstract/creative-work';
import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences} from './abstract/creative-work';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences} from './abstract/thing-that-can-be-offered';
import {SCPersonWithoutReferences} from './person';
/**
* A video without references
*/
export interface SCVideoWithoutReferences
extends SCCreativeWorkWithoutReferences {
extends SCCreativeWorkWithoutReferences,
SCThingThatCanBeOfferedWithoutReferences {
/**
* The Duration of the Video
*/
@@ -52,6 +54,11 @@ export interface SCVideoWithoutReferences
*/
transcript?: string;
/**
* Translated fields of a video
*/
translations?: SCTranslations<SCVideoTranslatableFields>;
/**
* Type of an Video
*/
@@ -123,18 +130,34 @@ export interface SCVideoTrack {
* @indexable
*/
export interface SCVideo
extends SCCreativeWork, SCVideoWithoutReferences {
extends SCCreativeWork,
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
SCVideoWithoutReferences {
/**
* Persons acting in the Video
*/
actors?: SCPersonWithoutReferences[];
/**
* Translated fields of a video
*/
translations?: SCTranslations<SCVideoTranslatableFields>;
/**
* Type of a video
*/
type: SCThingType.Video;
}
/**
* Translatable properties of a video
*/
export interface SCVideoTranslatableFields
extends SCCreativeWorkTranslatableProperties,
SCThingThatCanBeOfferedTranslatableProperties {
}
/**
* Meta information about a video
*/
@@ -146,8 +169,9 @@ export class SCVideoMeta
*/
fieldTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
...new SCCreativeWorkMeta().fieldTranslations
.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
actors: 'Darsteller',
duration: 'Dauer',
sources: 'Quellen',
@@ -156,8 +180,9 @@ export class SCVideoMeta
transcript: 'Transkript',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
...new SCCreativeWorkMeta().fieldTranslations
.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
actors: 'actors',
duration: 'duration',
sources: 'sources',
@@ -172,12 +197,16 @@ export class SCVideoMeta
*/
fieldValueTranslations = {
de: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta()
.fieldValueTranslations.de,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.de,
type: 'Video',
},
en: {
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
...new SCCreativeWorkMeta()
.fieldValueTranslations.en,
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>()
.fieldValueTranslations.en,
type: SCThingType.Video,
},

View File

@@ -12,9 +12,10 @@
* 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 clone = require('fast-clone');
import equal = require('fast-deep-equal/es6');
import clone = require('rfdc');
import {Defined, TSOCType} from 'ts-optchain';
import {SCTranslations} from './general/i18n';
import {SCLanguageCode} from './general/i18n';
import {isThing} from './guards';
import {SCClasses} from './meta';
import {SCThing, SCThingType} from './things/abstract/thing';
@@ -27,13 +28,32 @@ const standardCacheSize = 200;
*/
export class SCThingTranslator {
/**
* Getter for language property
*/
get language(): SCLanguageCode {
return this._language;
}
/**
* Setter for language property. Also flushes translation cache
*
* @param language The language the translator instance will use from now on
*/
set language(language: SCLanguageCode) {
if (language !== this._language) {
this.cache.flush();
}
this._language = language;
}
/**
* Property representing the translators target language
*/
private _language: keyof SCTranslations<SCThing>;
private _language: SCLanguageCode;
/**
* Property representing the translators base language
* This means every translation is given for this language
* LRU cache containing already translated SCThings
*/
private readonly cache: LRUCache<SCThing>;
@@ -42,34 +62,28 @@ export class SCThingTranslator {
*/
private readonly metaClasses: typeof SCClasses;
/**
* LRU cache containing SCThings translations have been provided for
*/
private readonly sourceCache: LRUCache<SCThing>;
/**
* @example
* // returns translator instance for german
* new SCThingTranslator('de');
*/
constructor(language: keyof SCTranslations<SCThing>, cacheCapacity: number = standardCacheSize) {
constructor(language: SCLanguageCode, cacheCapacity: number = standardCacheSize) {
this.cache = new LRUCache(cacheCapacity);
this.sourceCache = new LRUCache(cacheCapacity);
this._language = language;
this.metaClasses = SCClasses;
}
/**
* Getter for language property
*/
get language(): keyof SCTranslations<SCThing> {
return this._language;
}
/**
* Setter for language property. Also flushes translation cache
*
* @param language The language the translator instance will use from now on
*/
set language(language: keyof SCTranslations<SCThing>) {
if (language !== this._language) {
this.cache.flush();
// Initalize all meta classes once
if (typeof (this.metaClasses as any)[Object.keys(this.metaClasses)[0]] === 'function') {
for (const metaClass of Object.keys(this.metaClasses)) {
(this.metaClasses as any)[metaClass] = new (SCClasses as any)[metaClass]();
}
}
this._language = language;
}
/**
@@ -101,8 +115,8 @@ export class SCThingTranslator {
* @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 {
private getAllMetaFieldTranslations(thingType: SCThingType,
language: SCLanguageCode): object | undefined {
const fieldTranslations = {};
const metaClass = this.getMetaClassInstance(thingType);
if (typeof metaClass === 'undefined') {
@@ -136,7 +150,7 @@ export class SCThingTranslator {
*/
private getMetaClassInstance(thingType: SCThingType): any {
if (thingType in this.metaClasses) {
return new (this.metaClasses as any)[thingType]();
return this.metaClasses[thingType];
}
return undefined;
@@ -151,7 +165,7 @@ export class SCThingTranslator {
* @returns The thing with translated meta field values
*/
private replaceAvailableMetaFieldValueTranslations(instance: any,
language: keyof SCTranslations<any>): any {
language: SCLanguageCode): any {
const metaClass = this.getMetaClassInstance(instance.type);
if (typeof metaClass === 'undefined') {
return instance;
@@ -181,6 +195,60 @@ export class SCThingTranslator {
return instance;
}
/**
* Recursively translates the given object in-place
* Translated values overwrite current values (destructive)
*
* @param instance The thing / object that will be translated
* @returns The thing translated
*/
private translateThingInPlaceDestructively<T>(instance: T): T {
const targetLanguage = this.language;
let nextInstance = instance as any;
// Recursively call this function on all nested SCThings, arrays and objects
Object.keys(nextInstance)
.forEach((key) => {
if (
isThing(nextInstance[key]) ||
nextInstance[key] instanceof Array ||
nextInstance[key] instanceof Object) {
nextInstance[key] = this.translateThingInPlaceDestructively(nextInstance[key]);
}
});
// Spread variable translations given by the connector into thing
if (typeof nextInstance.translations?.[targetLanguage] !== 'undefined') {
nextInstance = {...nextInstance, ...nextInstance.translations![targetLanguage]} as T;
}
// Spread known translations from meta classes into (partly) translated thing
this.replaceAvailableMetaFieldValueTranslations(nextInstance, targetLanguage);
return nextInstance;
}
/**
* Recursively translates the given object in-place
* Translated values overwrite current values (destructive)
*
* @param instance The thing / object that will be translated
* @returns The thing translated
*/
public translate<T extends SCThing>(thing: T): T {
if (equal(this.sourceCache.get(thing), thing)) {
const cachedInstance = this.cache.get(thing);
if (typeof cachedInstance !== 'undefined') {
return cachedInstance as T;
}
}
const translatedInstance = this.translateThingInPlaceDestructively(clone()(thing));
delete translatedInstance.translations;
this.cache.putObject(translatedInstance);
this.sourceCache.putObject(thing);
return translatedInstance as T;
}
/**
* Get field value translation recursively
* @example
@@ -191,21 +259,24 @@ export class SCThingTranslator {
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
* // undoing the TSOCType<T>
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
* @param data Top level object that gets passed through the recursion
* @param thing Top level object that gets passed through the recursion
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
*/
public translate<T extends SCThing>(data: T): TSOCType<T> {
public translatedAccess<T extends SCThing>(thing: T): TSOCType<T> {
return new Proxy(
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as TSOCType<T>,
((defaultValue?: Defined<T>) => (thing == null ? defaultValue : thing)) as TSOCType<T>,
{
get: (target, key) => {
const obj: any = target();
const objTranslatedFromCache = this.cache.get(data);
if (typeof objTranslatedFromCache !== 'undefined') {
return this.deeptranslate((objTranslatedFromCache as any)[key]);
if (equal(this.sourceCache.get(thing), thing)) {
const objTranslatedFromCache = this.cache.get(thing);
if (typeof objTranslatedFromCache !== 'undefined') {
return this.deeptranslate((objTranslatedFromCache as any)[key]);
}
}
const objTranslated = this.translateWholeThingDestructively(clone(obj));
const objTranslated = this.translateThingInPlaceDestructively(clone()(obj));
this.cache.putObject(objTranslated);
this.sourceCache.putObject(thing);
return this.deeptranslate(objTranslated[key]);
},
@@ -217,73 +288,33 @@ export class SCThingTranslator {
* 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);
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudy>(SCThingType.CourseOfStudy);
* @param type The type whose property names will be translated
* @param language The language all property names will be translated to
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
*/
public translatedPropertyNames<T extends SCThing>(type: SCThingType,
language?: keyof SCTranslations<T>): T | undefined {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
public translatedPropertyNames<T extends SCThing>(type: SCThingType): T | undefined {
return this.getAllMetaFieldTranslations(type, this.language) as T;
}
/**
* Given a SCThingType this function will translate it
*
* @param type The type that will be translated
* @param language The language the type will be translated to
* @returns Known translation of type parameter
* Given a SCThingType and a corresponding property name it returns the known property value translation
* Access pattern to the meta object containing the translation can be thought of as type.field[key] with key being optional
* @example
* const singleValueTranslation = translator.translatedPropertyValue(SCThingType.Dish, 'categories', 'main dish');
* @param type The type for whose property values a translation is required
* @param field The property for which a translation is required
* @param key If specified tries to access the field with this key
* @returns Known translation for the property
*/
public translatedThingType<T extends unknown>(type: SCThingType,
language?: keyof SCTranslations<T>): string {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
const metaClass = this.getMetaClassInstance(type);
public translatedPropertyValue(type: SCThingType,
field: string,
key?: string): string | undefined {
const fieldValueTranslations = this.getMetaClassInstance(type).fieldValueTranslations[this.language] ??
this.getMetaClassInstance(type).fieldValueTranslations.en;
const fieldTranslation = fieldValueTranslations?.[field];
if (typeof metaClass.fieldValueTranslations[targetLanguage] !== 'undefined' &&
typeof metaClass.fieldValueTranslations[targetLanguage].type !== 'undefined') {
return metaClass.fieldValueTranslations[targetLanguage].type as string ;
}
return type;
return fieldTranslation?.[key ?? ''] ?? key ?? fieldTranslation;
}
/**
* Recursively translates the given object in-place
* Translated values overwrite current values (destructive)
*
* @param instance The thing / object that will be translated
* @param language The language the thing / object is translated to
* @returns The thing translated
*/
public translateWholeThingDestructively(instance: any,
language?: keyof SCTranslations<any>): any {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
let nextInstance = instance;
// Recursively call this function on all nested SCThings, arrays and objects
Object.keys(nextInstance)
.forEach((key) => {
if (
isThing((nextInstance as any)[key]) ||
nextInstance[key] instanceof Array ||
nextInstance[key] instanceof Object) {
nextInstance[key] = this.translateWholeThingDestructively(nextInstance[key], targetLanguage);
}
});
// Spread variable translations given by the connector into thing
if (typeof nextInstance.translations !== 'undefined') {
if (typeof nextInstance.translations![targetLanguage] !== 'undefined') {
nextInstance = {...nextInstance, ...nextInstance.translations![targetLanguage]} as typeof instance;
}
}
// Spread known translations from meta classes into (partly) translated thing
this.replaceAvailableMetaFieldValueTranslations(nextInstance, targetLanguage);
return nextInstance;
}
}
/**

44
test/compat.spec.ts Normal file
View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2021 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 {lightweightProjectFromPath} from '@openstapps/core-tools/lib/easy-ast/easy-ast';
import {LightweightProject} from '@openstapps/core-tools/lib/easy-ast/types/lightweight-project';
import {expect} from 'chai';
import {reduce} from 'lodash';
process.on('unhandledRejection', (err) => {
throw err;
});
describe('Mapping Compatibility', () => {
let project: LightweightProject;
before(function () {
this.timeout(15000);
this.slow(10000);
project = lightweightProjectFromPath('src');
});
it('non-exported definitions should not have duplicate names across files', () => {
reduce(project, (result, file) => reduce(file, (result2, _, key) => {
expect(result2[key]).to.be.undefined;
return {
[key]: true,
...result2,
};
}, result), {} as Record<string, boolean>);
});
});

140
test/features.spec.ts Normal file
View File

@@ -0,0 +1,140 @@
/*
* 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 {isLightweightClass, isLightweightEnum, isUnionType} from '@openstapps/core-tools/lib/easy-ast/ast-util';
import {LightweightAliasDefinition} from '@openstapps/core-tools/lib/easy-ast/types/lightweight-alias-definition';
import {LightweightProjectWithIndex} from '@openstapps/core-tools/lib/easy-ast/types/lightweight-project';
import {LightweightType} from '@openstapps/core-tools/lib/easy-ast/types/lightweight-type';
import {LightweightClassDefinition} from '@openstapps/core-tools/src/easy-ast/types/lightweight-class-definition';
import {LightweightDefinition} from '@openstapps/core-tools/src/easy-ast/types/lightweight-definition';
import {LightweightProperty} from '@openstapps/core-tools/src/easy-ast/types/lightweight-property';
import {expect} from 'chai';
import {assign, chain, clone, flatMap, isNil, reduce, reject, some} from 'lodash';
process.on('unhandledRejection', (err) => {
throw err;
});
describe('Features', () => {
let project: LightweightProjectWithIndex;
let thingNames: string[];
let things: LightweightClassDefinition[];
let thingsWithoutReferences: LightweightClassDefinition[];
before(function () {
this.timeout(15000);
this.slow(10000);
project = new LightweightProjectWithIndex('src');
const thingsReflection = project.definitions['SCIndexableThings'] as LightweightAliasDefinition;
expect(isLightweightEnum(thingsReflection)).to.be.true;
expect(isUnionType(thingsReflection.type!)).to.be.true;
thingsReflection.type!.specificationTypes!.push({
flags: 524_288,
referenceName: 'SCDiff',
});
// tslint:disable-next-line:no-unused-expression
expect(thingsReflection.type?.specificationTypes?.every(it => typeof it.referenceName !== 'undefined')).to.be.true;
thingNames = thingsReflection.type?.specificationTypes?.map(type => type.referenceName!) ?? [];
things = thingNames
.map(it => project.definitions[it])
.filter(isLightweightClass);
thingsWithoutReferences = thingNames
.map(it => project.definitions[`${it}WithoutReferences`])
.filter(isLightweightClass);
});
const inheritedProperties = function (classLike: LightweightClassDefinition):
Record<string, LightweightProperty> | undefined {
return reduce(
[...(classLike.implementedDefinitions ?? []), ...(classLike.extendedDefinitions ?? [])],
(obj, extension) => {
const object = project.definitions[extension.referenceName ?? ''];
return assign(obj, isLightweightClass(object)
? inheritedProperties(object)
: obj);
},
clone(classLike.properties)
);
};
it('should have an origin', () => {
for (const thing of things) {
expect(inheritedProperties(thing)?.['origin']).not.to.be.undefined;
}
});
it('should not have duplicate names', () => {
reduce(project.files, (fileResult, file) =>
reduce(file, (definitionResult, definition: LightweightDefinition) => {
expect(definitionResult[definition.name]).to.be.undefined;
definitionResult[definition.name] = true; // something that's not undefined
return definitionResult;
}, fileResult), {} as Record<string, true>);
});
it('should not have properties referencing SCThing', () => {
const allPropertyReferenceNames: (property: LightweightProperty) => string[] = property => reject([
property.type.referenceName!,
...flatMap(property.properties, allPropertyReferenceNames),
], isNil);
const typeHasSCThingReferences: (type?: LightweightType) => boolean = type => type?.referenceName
? hasSCThingReferences(project.definitions[type.referenceName])
: some(type?.specificationTypes, typeHasSCThingReferences);
const hasSCThingReferences: (definition?: LightweightDefinition) => boolean = definition =>
isLightweightClass(definition)
? chain(inheritedProperties(definition))
.flatMap(it => flatMap(it.properties, allPropertyReferenceNames))
.map(it => project.definitions[it] as LightweightDefinition)
.some(it => it.name === 'SCThing' || hasSCThingReferences(it))
.value()
: definition ? typeHasSCThingReferences(definition.type) : false;
for (const thing of things) {
expect(hasSCThingReferences(thing)).to.be.false;
}
});
function extendsSCThing(definition?: LightweightDefinition): boolean {
return isLightweightClass(definition)
? chain([
...(definition as LightweightClassDefinition).extendedDefinitions ?? [],
...(definition as LightweightClassDefinition).implementedDefinitions ?? [],
])
.map(it => it.referenceName)
.reject(isNil)
.some(it => it === 'SCThing' || extendsSCThing(project.definitions[it!]))
.value()
: false;
}
it('should extend SCThing if it is an SCThing', () => {
for (const thing of things) {
expect(extendsSCThing(thing)).to.be.true;
}
});
it('should not extend SCThing if it is an SCThingWithoutReferences', () => {
for (const thingWithoutReferences of thingsWithoutReferences) {
expect(extendsSCThing(thingWithoutReferences)).to.be.false;
}
});
});

View File

@@ -116,8 +116,10 @@ export class GuardsSpec {
@test
public isSearchResponse() {
const notASearchResponse = {...GuardsSpec.searchResponse};
// @ts-ignore
delete notASearchResponse.pagination;
expect(isSearchResponse(notASearchResponse)).to.be.equal(false);
// @ts-ignore
delete notASearchResponse.data;
expect(isSearchResponse(notASearchResponse)).to.be.equal(false);
expect(isSearchResponse(null)).to.be.equal(false);

View File

@@ -0,0 +1,36 @@
{
"errorNames": [],
"instance": {
"attempt": 1,
"date": "2020-04-01",
"ects": 20,
"grade": "N/A",
"status": "ongoing",
"uid": "681a59a1-23c2-5d78-861a-8c86a3abf404",
"name": "Introductory courses extreme math",
"categories": [
"university assessment"
],
"courseOfStudy": {
"academicDegree": "bachelor",
"academicDegreewithField": "Bachelor of Arts",
"academicDegreewithFieldShort": "B.A.",
"mainLanguage": {
"code": "de",
"name": "german"
},
"mode": "dual",
"name": "Astroturfing",
"timeMode": "parttime",
"type": "course of study",
"uid": "4c6f0a18-343d-5175-9fb1-62d28545c2aa"
},
"origin": {
"indexed": "2020-04-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "assessment"
},
"schema": "SCAssessment"
}

View File

@@ -0,0 +1,51 @@
{
"errorNames": [],
"instance": {
"attempt": 1,
"date": "2020-04-01",
"ects": 6,
"grade": "very much 1.0",
"status": "passed",
"uid": "681a59a1-23c2-5d78-861a-8c86a3abf303",
"name": "Mathe 9001",
"categories": [
"university assessment"
],
"superAssessments": [
{
"attempt": 1,
"date": "2020-04-01",
"ects": 20,
"grade": "N/A",
"status": "ongoing",
"uid": "681a59a1-23c2-5d78-861a-8c86a3abf404",
"name": "Introductory courses extreme math",
"categories": [
"university assessment"
],
"type": "assessment"
}
],
"courseOfStudy": {
"academicDegree": "bachelor",
"academicDegreewithField": "Bachelor of Arts",
"academicDegreewithFieldShort": "B.A.",
"mainLanguage": {
"code": "de",
"name": "german"
},
"mode": "dual",
"name": "Astroturfing",
"timeMode": "parttime",
"type": "course of study",
"uid": "4c6f0a18-343d-5175-9fb1-62d28545c2aa"
},
"origin": {
"indexed": "2020-04-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "assessment"
},
"schema": "SCAssessment"
}

View File

@@ -21,6 +21,9 @@
"audiences": [
"students"
],
"categories": [
"news"
],
"sequenceIndex": 1010,
"origin": {
"indexed": "2018-09-11T12:30:00Z",

View File

@@ -21,6 +21,9 @@
"audiences": [
"students"
],
"categories": [
"news"
],
"sequenceIndex": 1020,
"origin": {
"indexed": "2018-09-11T12:30:00Z",

View File

@@ -6,17 +6,67 @@
"uid": "3af3ccaa-f066-5eff-9a3d-a70567f3d70d",
"data": {
"type": "academic event",
"description": "Grundlagen, algebraische Grundbegriffe, Vektorräume, lineare Abbildungen und Gleichungen, Determinanten",
"uid": "b17eb963-42b5-5861-adce-2b7b2607ef0a",
"name": "Lineare Algebra I für Mathematiker",
"description": "Fortsetzung der Algebra I: Galoistheorie mit Anwendungen, ausgewählte Spezialthemen.",
"uid": "681a59a1-23c2-5d78-861a-8c86a3abf2b9",
"name": "Algebra II",
"categories": [
"lecture"
],
"academicTerms": [
{
"uid": "aacd5611-b5be-54ce-b39f-c52f7e9a631d",
"type": "semester",
"name": "Sommersemester 2018",
"acronym": "SS 2018",
"alternateNames": [
"SoSe 2018"
],
"startDate": "2018-04-01",
"endDate": "2018-09-30",
"eventsStartDate": "2018-04-09",
"eventsEndDate": "2018-07-13"
}
],
"performers": [
{
"type": "person",
"uid": "7f8ce700-2679-51a5-86b5-3dfba85a33ff",
"givenName": "Peter",
"familyName": "Bürgisser",
"gender": "male",
"honorificPrefix": "Prof. Dr.",
"name": "Peter Bürgisser"
}
],
"majors": [
"Wirtschaftsmathematik BSc",
"Technomathematik BSc",
"Mathematik BSc"
]
"Mathematik D",
"Mathematik L2",
"Mathematik StRGym",
"Mathematik StRBeruf",
"Mathematik BSc",
"Mathematik MSc"
],
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote",
"maintainer": {
"type": "organization",
"name": "tubIT",
"uid": "25f76840-db89-5da2-a8a2-75992f637613"
},
"modified": "2018-09-01T10:00:00Z",
"originalId": "foo bar",
"responsibleEntity": {
"type": "person",
"uid": "7f8ce700-2679-51a5-86b5-3dfba85a33ff",
"givenName": "Peter",
"familyName": "Bürgisser",
"gender": "male",
"honorificPrefix": "Prof. Dr.",
"name": "Peter Bürgisser"
}
}
},
"origin": {
"created": "2018-09-11T12:30:00Z",

View File

@@ -22,8 +22,8 @@
},
{
"arguments": {
"fromField": "availabilityStarts",
"toField": "availabilityEnds",
"scope": "d",
"field": "availabilityRange",
"time": "2018-01-15T04:13:00+00:00"
},
"type": "availability"

View File

@@ -6,7 +6,7 @@
"categories": [
"unipedia"
],
"url": "https://www.mydesk.tu-berlin.de/wiki/abk%C3%BCrzungen",
"sameAs": "https://www.mydesk.tu-berlin.de/wiki/abk%C3%BCrzungen",
"name": "Abkürzungen",
"keywords": [
"Abkürzungen",

View File

@@ -6,7 +6,7 @@
"categories": [
"unipedia"
],
"url": "https://www.mydesk.tu-berlin.de/wiki/ag_ziethen",
"sameAs": "https://www.mydesk.tu-berlin.de/wiki/ag_ziethen",
"name": "AG Ziethen",
"keywords": [
"Bologna",

View File

@@ -0,0 +1,36 @@
{
"errorNames": [],
"instance": {
"type": "article",
"uid": "d541eda5-1542-59b2-969e-7dbbee0bd2a8",
"name": "Mozart und Frankfurt am Main : drei Generationen Mozart in Frankfurt am Main",
"description": "Ill.",
"categories": [
"article"
],
"authors": [
{
"type": "person",
"uid": "56d46c9b-8ede-52ae-a40f-6800cff577e5",
"name": "Greve, Clemens"
}
],
"firstPublished": "2008",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB198305427",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB198305427",
"type": "remote",
"url": "https://ubffm.hds.hebis.de"
},
"isPartOf": {
"uid": "bc5e5399-a24c-5c01-9c1b-0c8b83272087",
"name": "Archiv für Frankfurts Geschichte und Kunst",
"type": "periodical",
"categories": []
},
"reference": "Band 71 (2008), Seite 27-40"
},
"schema": "SCArticle"
}

View File

@@ -0,0 +1,36 @@
{
"errorNames": [],
"instance": {
"type": "article",
"uid": "554a4a89-df73-5197-ac85-c8a5a3a9c5b0",
"name": "Ursula Janik : [Markthändlerin]",
"description": "Ill.",
"categories": [
"article"
],
"authors": [
{
"type": "person",
"uid": "c6e44e1f-f76c-53f8-a18f-47fa54ae0e90",
"name": "Fröhlich, Ute B."
}
],
"firstPublished": "2002",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB107025590",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB107025590",
"type": "remote",
"url": "https://ubffm.hds.hebis.de"
},
"isPartOf": {
"uid": "f84c1851-042e-542f-ba7a-158b32dfb82f",
"name": "Frankfurter Allgemeine. R, Rhein-Main-Zeitung",
"type": "periodical",
"categories": []
},
"reference": "Heft 190 (17. 8 2002), Seite 62"
},
"schema": "SCArticle"
}

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