mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 22:42:54 +00:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b517837671 | ||
|
|
6f03ede8bf | ||
|
|
952207ace1 | ||
|
|
3d9d28c60c | ||
|
|
913c5691da | ||
|
|
03cdbc6f9b | ||
|
|
9f886a8968 | ||
|
|
e80afe2c93 | ||
|
|
6b10cc86d8 | ||
|
|
1aedd6332f | ||
|
|
790c8bbc3f | ||
|
|
e934017a65 | ||
|
|
88dbedd932 | ||
|
|
8b1b3444fd | ||
|
|
d5f3d71a41 | ||
|
|
cbcf9c9adb | ||
|
|
321e4f6f24 | ||
|
|
8510f11d7b | ||
|
|
68aa377fe2 | ||
|
|
29f2c77ecc | ||
|
|
29bc00616e | ||
|
|
02920af4a4 | ||
|
|
0c14b0f1a0 | ||
|
|
db0a239761 | ||
|
|
377f55bbbe | ||
|
|
8d7a0e10c6 | ||
|
|
4865f911d1 | ||
|
|
15ae5e0873 | ||
|
|
a246bdea84 | ||
|
|
8641bfc877 | ||
|
|
d34e66fbbc | ||
|
|
c6273a85d9 | ||
|
|
5558d29c2b | ||
|
|
69dfd1ae39 | ||
|
|
4638bb3684 | ||
|
|
6c687c6004 | ||
|
|
0bf1301733 | ||
|
|
827ba47892 | ||
|
|
d3b620a745 | ||
|
|
821834cfa0 | ||
|
|
c369c8520a | ||
|
|
66075ef99b | ||
|
|
7a6333aa8f | ||
|
|
e242a21e99 | ||
|
|
6fecd1e89d | ||
|
|
f6a93e668b | ||
|
|
2f96bc8569 | ||
|
|
9ce4026b1a | ||
|
|
e434b2d26e | ||
|
|
fe7f1a53ae | ||
|
|
907d61b5d2 | ||
|
|
5fb9755841 | ||
|
|
e5dd02eeca | ||
|
|
e7b4a426a9 | ||
|
|
7dd74af305 | ||
|
|
4409101647 | ||
|
|
3a141e6cf4 | ||
|
|
8a20e3e873 | ||
|
|
e196303e64 | ||
|
|
70c1a3eaa3 | ||
|
|
6060113df5 | ||
|
|
39d5becb56 | ||
|
|
f5e88569eb | ||
|
|
67041aa39d | ||
|
|
18943612a8 | ||
|
|
d167947e04 | ||
|
|
2a0dc812d8 | ||
|
|
cdb8a6507d | ||
|
|
5bedb27cad | ||
|
|
0d89b14932 | ||
|
|
5de523a4bf | ||
|
|
f97e199bb9 | ||
|
|
abda5cf0ca | ||
|
|
9658f05d31 | ||
|
|
e92bf6f7c7 |
@@ -1,16 +1,12 @@
|
|||||||
image: registry.gitlab.com/openstapps/projectmanagement/node
|
image: registry.gitlab.com/openstapps/projectmanagement/node
|
||||||
|
|
||||||
cache:
|
|
||||||
key: ${CI_COMMIT_REF_SLUG}
|
|
||||||
paths:
|
|
||||||
- node_modules
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- npm install
|
- npm install
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
- audit
|
||||||
- deploy
|
- deploy
|
||||||
- publish
|
- publish
|
||||||
|
|
||||||
@@ -26,7 +22,7 @@ build:
|
|||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
|
|
||||||
audit:
|
audit:
|
||||||
stage: test
|
stage: audit
|
||||||
script:
|
script:
|
||||||
- npm audit
|
- npm audit
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
@@ -34,9 +30,9 @@ audit:
|
|||||||
- schedules
|
- schedules
|
||||||
|
|
||||||
scheduled-audit:
|
scheduled-audit:
|
||||||
stage: test
|
stage: audit
|
||||||
script:
|
script:
|
||||||
- npm audit
|
- npm audit --audit-level=high
|
||||||
only:
|
only:
|
||||||
- schedules
|
- schedules
|
||||||
|
|
||||||
|
|||||||
5
.mailmap
Normal file
5
.mailmap
Normal 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>
|
||||||
207
CHANGELOG.md
207
CHANGELOG.md
@@ -1,9 +1,128 @@
|
|||||||
|
# [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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove keyword tag from steps ([c369c85](https://gitlab.com/openstapps/core/commit/c369c8520a2eed169555a35a50ce745c08e1f9da))
|
||||||
|
* remove redundant property declaration ([66075ef](https://gitlab.com/openstapps/core/commit/66075ef99b95198a9cd5c0a396603e089221bcd9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.36.0](https://gitlab.com/openstapps/core/compare/v0.35.0...v0.36.0) (2020-07-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add function to get translated SCThingType ([fe7f1a5](https://gitlab.com/openstapps/core/commit/fe7f1a53ae46e052e23f1b39851f1547b5a8dded))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.35.0](https://gitlab.com/openstapps/core/compare/v0.34.0...v0.35.0) (2020-05-13)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.34.0](https://gitlab.com/openstapps/core/compare/v0.33.0...v0.34.0) (2020-04-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add [@sortable](https://gitlab.com/sortable) tags to certain translatable properties ([f5e8856](https://gitlab.com/openstapps/core/commit/f5e88569eb75578febbcde67259c0c14563e53fe))
|
||||||
|
* annotate SCThing uid and url as filterable ([70c1a3e](https://gitlab.com/openstapps/core/commit/70c1a3eaa3d1c88f4b86f0df86d0d362ad1f930c))
|
||||||
|
* Update src/things/book.ts - made ISBN optional ([6060113](https://gitlab.com/openstapps/core/commit/6060113df56b871bb5014a8a961974895e52158f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.33.0](https://gitlab.com/openstapps/core/compare/v0.32.0...v0.33.0) (2020-02-11)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.32.0](https://gitlab.com/openstapps/core/compare/v0.31.0...v0.32.0) (2020-02-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* make SCContactPoint extend SCThing ([0d89b14](https://gitlab.com/openstapps/core/commit/0d89b1493293f83e9096615f653a6094519d59f2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.31.0](https://gitlab.com/openstapps/core/compare/v0.30.0...v0.31.0) (2019-11-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove categories from custom translations ([9658f05](https://gitlab.com/openstapps/core/commit/9658f05d31366b3735da3aa548ef5ed0255d8054))
|
||||||
|
* translator can now handle enum translations ([abda5cf](https://gitlab.com/openstapps/core/commit/abda5cf0caead37f085431e1e5a9771b79272ec6))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.30.0](https://gitlab.com/openstapps/core/compare/v0.29.0...v0.30.0) (2019-11-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add aggregatable tag for type field ([443cb74](https://gitlab.com/openstapps/core/commit/443cb748fba1575f5f1e16c550fd33eb7fa7901c))
|
||||||
|
* add new field sequenceIndex to message ([01f92ba](https://gitlab.com/openstapps/core/commit/01f92baa985013bfe1c79fad60351fdaf44bd676))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [0.29.0](https://gitlab.com/openstapps/core/compare/v0.28.0...v0.29.0) (2019-09-17)
|
# [0.29.0](https://gitlab.com/openstapps/core/compare/v0.28.0...v0.29.0) (2019-09-17)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add mappingIgnoredTags property to SCBackend ([149f3ff](https://gitlab.com/openstapps/core/commit/149f3ff))
|
* add mappingIgnoredTags property to SCBackend ([149f3ff](https://gitlab.com/openstapps/core/commit/149f3ffff15dce27337665abba520d11bc3014dd))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -12,7 +131,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add onlyOnType field for SCFacet ([fba63db](https://gitlab.com/openstapps/core/commit/fba63db))
|
* add onlyOnType field for SCFacet ([fba63db](https://gitlab.com/openstapps/core/commit/fba63db137c52212113545be1062d760f0c4213f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +140,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add [@filterable](https://gitlab.com/filterable) tags ([fec3371](https://gitlab.com/openstapps/core/commit/fec3371))
|
* add [@filterable](https://gitlab.com/filterable) tags ([fec3371](https://gitlab.com/openstapps/core/commit/fec33715add996ae0a7125ad00ee043d288c6671))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,12 +149,12 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* complete german translations ([bad15dc](https://gitlab.com/openstapps/core/commit/bad15dc))
|
* complete german translations ([bad15dc](https://gitlab.com/openstapps/core/commit/bad15dc8728954ee6ee23fa68c471647328830b9))
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add pluginRequestTimeout field to backend config ([88f579e](https://gitlab.com/openstapps/core/commit/88f579e))
|
* add pluginRequestTimeout field to backend config ([88f579e](https://gitlab.com/openstapps/core/commit/88f579e09bc5e7726dbc4fc788737ba49a0801cd))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +163,7 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* correct package job ([d4a8ef6](https://gitlab.com/openstapps/core/commit/d4a8ef6))
|
* correct package job ([d4a8ef6](https://gitlab.com/openstapps/core/commit/d4a8ef6a9ca69849f8b981804da45e4ba907f37b))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +172,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add new field receivingOrganisations to message ([d781dd6](https://gitlab.com/openstapps/core/commit/d781dd6))
|
* add new field receivingOrganisations to message ([d781dd6](https://gitlab.com/openstapps/core/commit/d781dd6de5cc7572b9218df959247b93cb2db305))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -62,12 +181,12 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* use correct generic for the distance filter ([f262a6b](https://gitlab.com/openstapps/core/commit/f262a6b))
|
* use correct generic for the distance filter ([f262a6b](https://gitlab.com/openstapps/core/commit/f262a6b8fa7a9d40234569ec490d5ef8e9437a75))
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add type maps from routes to requests and responses ([e1d4b2b](https://gitlab.com/openstapps/core/commit/e1d4b2b)), closes [#80](https://gitlab.com/openstapps/core/issues/80)
|
* add type maps from routes to requests and responses ([e1d4b2b](https://gitlab.com/openstapps/core/commit/e1d4b2bc9de60a2332788c9a2264760d151c8813)), closes [#80](https://gitlab.com/openstapps/core/issues/80)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -76,8 +195,8 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add mapping type from response to request and vice versa ([c18e3c1](https://gitlab.com/openstapps/core/commit/c18e3c1)), closes [#80](https://gitlab.com/openstapps/core/issues/80)
|
* add mapping type from response to request and vice versa ([c18e3c1](https://gitlab.com/openstapps/core/commit/c18e3c15f1940338b6872343f6b20dba6346f84b)), closes [#80](https://gitlab.com/openstapps/core/issues/80)
|
||||||
* support 404 (resource not found) error on plugin register route ([43851d2](https://gitlab.com/openstapps/core/commit/43851d2))
|
* support 404 (resource not found) error on plugin register route ([43851d2](https://gitlab.com/openstapps/core/commit/43851d2d358c4c342a80a863b059a6447c819c04))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -90,8 +209,8 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add ES annotations ([9c424b0](https://gitlab.com/openstapps/core/commit/9c424b0))
|
* add ES annotations ([9c424b0](https://gitlab.com/openstapps/core/commit/9c424b0f96da26d3aae9ffaadb2c640e7369ca7e))
|
||||||
* add static typed test for consistency ([ff1f554](https://gitlab.com/openstapps/core/commit/ff1f554)), closes [#71](https://gitlab.com/openstapps/core/issues/71)
|
* add static typed test for consistency ([ff1f554](https://gitlab.com/openstapps/core/commit/ff1f554e0beacb5ce2f3308c8212e2b8e4d8cbb0)), closes [#71](https://gitlab.com/openstapps/core/issues/71)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -100,8 +219,8 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* add translations for every SCThing ([f847a2a](https://gitlab.com/openstapps/core/commit/f847a2a))
|
* add translations for every SCThing ([f847a2a](https://gitlab.com/openstapps/core/commit/f847a2aa0cf576e2fd79197cdc7795638d929136))
|
||||||
* rename properties floor and message so that they are not identical to SCThingTypes ([78b64ba](https://gitlab.com/openstapps/core/commit/78b64ba))
|
* rename properties floor and message so that they are not identical to SCThingTypes ([78b64ba](https://gitlab.com/openstapps/core/commit/78b64bae08d9ca12badaedf921a24fa5ffe90552))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -110,9 +229,9 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* add thing without references, split thing ([da0507e](https://gitlab.com/openstapps/core/commit/da0507e)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
* add thing without references, split thing ([da0507e](https://gitlab.com/openstapps/core/commit/da0507ee341af75cd15dddeeb3f4cbe08899434c)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
||||||
* adjust model to remove references from things without references ([ca72c20](https://gitlab.com/openstapps/core/commit/ca72c20)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
* adjust model to remove references from things without references ([ca72c20](https://gitlab.com/openstapps/core/commit/ca72c20bd098032745ed0eb6978902b6ff6feac5)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
||||||
* remove references from origins ([1d6a2b7](https://gitlab.com/openstapps/core/commit/1d6a2b7)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
* remove references from origins ([1d6a2b7](https://gitlab.com/openstapps/core/commit/1d6a2b7841e9c38e68c9e5c718377a9c04fe50d6)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +240,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add study module interface ([d3790ad](https://gitlab.com/openstapps/core/commit/d3790ad))
|
* add study module interface ([d3790ad](https://gitlab.com/openstapps/core/commit/d3790adbd82417923d79b4a5a35c74fcaab3e050))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -138,13 +257,13 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* change SCThingMeta getInstance() return value ([4986042](https://gitlab.com/openstapps/core/commit/4986042))
|
* change SCThingMeta getInstance() return value ([4986042](https://gitlab.com/openstapps/core/commit/4986042428e24a04b73fb03d71c01353588419a7))
|
||||||
* resolve issues with things that can be offered ([623ed61](https://gitlab.com/openstapps/core/commit/623ed61)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
|
* resolve issues with things that can be offered ([623ed61](https://gitlab.com/openstapps/core/commit/623ed613a9405b53a86a33c13d48bc49d48de1ce)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* provide context based search ([3242411](https://gitlab.com/openstapps/core/commit/3242411))
|
* provide context based search ([3242411](https://gitlab.com/openstapps/core/commit/324241176849b338bee9f5d1dcaf1109f47a8bb9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -153,7 +272,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add model for plugin register route ([8188731](https://gitlab.com/openstapps/core/commit/8188731))
|
* add model for plugin register route ([8188731](https://gitlab.com/openstapps/core/commit/81887315f8c3038ec37c2197db8e193da835f6fc))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -162,14 +281,14 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9))
|
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9eb810de94ca0bb6e1298799ee3f550145))
|
||||||
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fca))
|
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fcac42c21c68b5c6aa6bcf9bbdecfdf84de7))
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add conditional "maps" for associated types ([c8bda2e](https://gitlab.com/openstapps/core/commit/c8bda2e)), closes [#50](https://gitlab.com/openstapps/core/issues/50)
|
* add conditional "maps" for associated types ([c8bda2e](https://gitlab.com/openstapps/core/commit/c8bda2eae7f44ec4a284cc26fc85051a9a45e192)), closes [#50](https://gitlab.com/openstapps/core/issues/50)
|
||||||
* provide sample JSON files with the package ([5d1e79d](https://gitlab.com/openstapps/core/commit/5d1e79d)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
|
* provide sample JSON files with the package ([5d1e79d](https://gitlab.com/openstapps/core/commit/5d1e79d4879e6ce8f43d4cebb9d8c8500d5d16b7)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -178,12 +297,12 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* add todo to SCThingsWithoutDiff and SCClasses ([9a49442](https://gitlab.com/openstapps/core/commit/9a49442)), closes [#39](https://gitlab.com/openstapps/core/issues/39)
|
* add todo to SCThingsWithoutDiff and SCClasses ([9a49442](https://gitlab.com/openstapps/core/commit/9a49442902a9f49439083a9197bd9f0a231d007d)), closes [#39](https://gitlab.com/openstapps/core/issues/39)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add SCThingTranslator class. move functionality accordingly ([90e3d22](https://gitlab.com/openstapps/core/commit/90e3d22))
|
* add SCThingTranslator class. move functionality accordingly ([90e3d22](https://gitlab.com/openstapps/core/commit/90e3d2239921bbfcea27b64aef9344ffee270b6d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -192,8 +311,8 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add laboratory and computer as room categories ([a0ab72e](https://gitlab.com/openstapps/core/commit/a0ab72e)), closes [#33](https://gitlab.com/openstapps/core/issues/33)
|
* add laboratory and computer as room categories ([a0ab72e](https://gitlab.com/openstapps/core/commit/a0ab72e597f6a14cfc0bd8935e1ef765b86b90f7)), closes [#33](https://gitlab.com/openstapps/core/issues/33)
|
||||||
* add maxRequestBodySize in backend configuration ([b5bd09e](https://gitlab.com/openstapps/core/commit/b5bd09e))
|
* add maxRequestBodySize in backend configuration ([b5bd09e](https://gitlab.com/openstapps/core/commit/b5bd09e40bfb49463815538ebaa44ff53b5d7b92))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -202,7 +321,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add model for requestBodyTooLargeError ([bc3a0f6](https://gitlab.com/openstapps/core/commit/bc3a0f6))
|
* add model for requestBodyTooLargeError ([bc3a0f6](https://gitlab.com/openstapps/core/commit/bc3a0f6d11cba836a55cbd5787d68cfe655b68a6))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -215,7 +334,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add config for maximum queries ([c7ab473](https://gitlab.com/openstapps/core/commit/c7ab473))
|
* add config for maximum queries ([c7ab473](https://gitlab.com/openstapps/core/commit/c7ab47397e2a33b1c460b9038cbf53fec148316d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -232,7 +351,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add model for syntax error ([a3f9fcb](https://gitlab.com/openstapps/core/commit/a3f9fcb))
|
* add model for syntax error ([a3f9fcb](https://gitlab.com/openstapps/core/commit/a3f9fcbfb0c35206adabc95792de076518f604f7))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +360,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add draft of todo ([2860a11](https://gitlab.com/openstapps/core/commit/2860a11))
|
* add draft of todo ([2860a11](https://gitlab.com/openstapps/core/commit/2860a11b618081ab88ecb1780a280cab37217a0e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -250,13 +369,13 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* set larger v8 stack size ([d3d08e7](https://gitlab.com/openstapps/core/commit/d3d08e7))
|
* set larger v8 stack size ([d3d08e7](https://gitlab.com/openstapps/core/commit/d3d08e7735808d4eae5aab4b263e36047c608679))
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add different origin types: remote and user ([13a4965](https://gitlab.com/openstapps/core/commit/13a4965)), closes [#12](https://gitlab.com/openstapps/core/issues/12)
|
* add different origin types: remote and user ([13a4965](https://gitlab.com/openstapps/core/commit/13a49650c4498f6edbe17c9de3598e0180b866da)), closes [#12](https://gitlab.com/openstapps/core/issues/12)
|
||||||
* add saveable thing for saving user/client data ([a4f3fab](https://gitlab.com/openstapps/core/commit/a4f3fab)), closes [#12](https://gitlab.com/openstapps/core/issues/12)
|
* add saveable thing for saving user/client data ([a4f3fab](https://gitlab.com/openstapps/core/commit/a4f3fab033ca18352c0119061f2d0e64252d4bbb)), closes [#12](https://gitlab.com/openstapps/core/issues/12)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -265,7 +384,7 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* use tag [@validatable](https://gitlab.com/validatable) to mark schema types ([7f248ee](https://gitlab.com/openstapps/core/commit/7f248ee))
|
* use tag [@validatable](https://gitlab.com/validatable) to mark schema types ([7f248ee](https://gitlab.com/openstapps/core/commit/7f248eea13c732a95c4ee8e1bc91afeee52e8c2d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -274,9 +393,9 @@
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add base scheme for academic degrees ([85c8fc4](https://gitlab.com/openstapps/core/commit/85c8fc4))
|
* add base scheme for academic degrees ([85c8fc4](https://gitlab.com/openstapps/core/commit/85c8fc49c14b0ce45cf0cfdaf46c1ebe43b23ec7))
|
||||||
* add schema for course of studies ([2d4a76a](https://gitlab.com/openstapps/core/commit/2d4a76a))
|
* add schema for course of studies ([2d4a76a](https://gitlab.com/openstapps/core/commit/2d4a76a555603a395c81a7a92ce5d95ed04de9de))
|
||||||
* add tool to generate documentation for routes ([1a07df2](https://gitlab.com/openstapps/core/commit/1a07df2))
|
* add tool to generate documentation for routes ([1a07df2](https://gitlab.com/openstapps/core/commit/1a07df2d676895264f43b0138645d7c13f60c9db))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -284,12 +403,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0.0.1](https://gitlab.com/openstapps/core/compare/2d770dd...v0.0.1) (2018-11-29)
|
## [0.0.1](https://gitlab.com/openstapps/core/compare/2d770dde4464dc4cf4cdc29927aa4e4382914148...v0.0.1) (2018-11-29)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add core ([2d770dd](https://gitlab.com/openstapps/core/commit/2d770dd))
|
* add core ([2d770dd](https://gitlab.com/openstapps/core/commit/2d770dde4464dc4cf4cdc29927aa4e4382914148))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -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.
|
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/)
|
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` |
|
| `@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 | |
|
| `@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| |
|
| `@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 | |
|
| `@integer` | number field is interpreted as integer | |
|
||||||
| `@keyword` | string field is interpreted as keyword | |
|
| `@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` |
|
| `@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 | |
|
| `@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 | |
|
| `@date` | string field is interpreted as a date field | |
|
||||||
| `@filterable` | non-object/nested field is filterable if the core schema is used to put data into a database/key-value store | |
|
| `@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 | |
|
||||||
|
| `@inheritTags` | inherit all tags from another field | `[SCThingType]::[field]` |
|
||||||
|
|
||||||
|
*Note: tags ignore casing, but for consistency they should use the variants proposed here.*
|
||||||
|
|||||||
4949
package-lock.json
generated
4949
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
63
package.json
63
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/core",
|
"name": "@openstapps/core",
|
||||||
"version": "0.30.0",
|
"version": "0.45.0",
|
||||||
"description": "StAppsCore - Generalized model of data",
|
"description": "StAppsCore - Generalized model of data",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Model",
|
"Model",
|
||||||
@@ -25,56 +25,57 @@
|
|||||||
"preversion": "npm run prepublishOnly",
|
"preversion": "npm run prepublishOnly",
|
||||||
"push": "git push && git push origin \"v$npm_package_version\"",
|
"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",
|
"schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src lib/schema",
|
||||||
"test": "nyc mocha --require ts-node/register --require source-map-support/register --ui mocha-typescript test/*.spec.ts",
|
"test": "nyc mocha --require ts-node/register --recursive 'test/*.spec.ts'",
|
||||||
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
|
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
|
||||||
},
|
},
|
||||||
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Andreas Lehmann",
|
"Andreas Lehmann",
|
||||||
"Anselm Stordeur <anselmstordeur@gmail.com>",
|
"Anselm Stordeur <anselmstordeur@gmail.com>",
|
||||||
|
"Axel Nieder-Vahrenholz",
|
||||||
"Benjamin Jöckel",
|
"Benjamin Jöckel",
|
||||||
"Imran Hossain",
|
"Frank Nagel",
|
||||||
"Jovan Krunić <jovan.krunic@gmail.com>",
|
"Jovan Krunić <jovan.krunic@gmail.com>",
|
||||||
"Michel Jonathan Schmitz",
|
"Michel Jonathan Schmitz",
|
||||||
"Rainer Killinger",
|
"Rainer Killinger <mail-openstapps@killinger.co>",
|
||||||
|
"Roman Klopsch",
|
||||||
"Sebastian Lange",
|
"Sebastian Lange",
|
||||||
"Wieland Schöbl",
|
"Wieland Schöbl"
|
||||||
"Roman Klopsch"
|
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@openstapps/core-tools": "0.19.0",
|
||||||
"@types/geojson": "1.0.6",
|
"@types/geojson": "1.0.6",
|
||||||
"@types/json-patch": "0.0.30",
|
"@types/json-patch": "0.0.30",
|
||||||
"@types/node": "10.14.14",
|
"@types/json-schema": "7.0.7",
|
||||||
|
"@types/node": "14.14.37",
|
||||||
"fast-clone": "1.5.13",
|
"fast-clone": "1.5.13",
|
||||||
"http-status-codes": "1.3.2",
|
"fast-deep-equal": "3.1.3",
|
||||||
|
"http-status-codes": "2.1.4",
|
||||||
"json-patch": "0.7.0",
|
"json-patch": "0.7.0",
|
||||||
"jsonschema": "1.2.4",
|
"json-schema": "0.3.0",
|
||||||
"ts-optchain": "0.1.3"
|
"ts-optchain": "0.1.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@krlwlfrt/async-pool": "0.1.0",
|
"@openstapps/configuration": "0.27.0",
|
||||||
"@openstapps/configuration": "0.21.1",
|
"@openstapps/logger": "0.6.0",
|
||||||
"@openstapps/core-tools": "0.8.0",
|
"@testdeck/mocha": "0.1.2",
|
||||||
"@openstapps/logger": "0.4.0",
|
"@types/chai": "4.2.16",
|
||||||
"@types/chai": "4.1.7",
|
"@types/rimraf": "3.0.0",
|
||||||
"@types/rimraf": "2.0.2",
|
"chai": "4.3.4",
|
||||||
"chai": "4.2.0",
|
"conditional-type-checks": "1.0.5",
|
||||||
"commander": "2.20.0",
|
"conventional-changelog-cli": "2.1.1",
|
||||||
"conditional-type-checks": "1.0.1",
|
"mocha": "8.3.2",
|
||||||
"conventional-changelog-cli": "2.0.23",
|
"nyc": "15.1.0",
|
||||||
"mocha": "6.2.0",
|
"rimraf": "3.0.2",
|
||||||
"mocha-typescript": "1.1.17",
|
"source-map-support": "0.5.19",
|
||||||
"nyc": "14.1.1",
|
"ts-node": "9.1.1",
|
||||||
"rimraf": "2.6.3",
|
"tslint": "6.1.3",
|
||||||
"source-map-support": "0.5.13",
|
"typedoc": "0.18.0",
|
||||||
"ts-node": "8.3.0",
|
"typescript": "3.8.3"
|
||||||
"tslint": "5.18.0",
|
|
||||||
"typedoc": "0.14.2",
|
|
||||||
"typescript": "3.5.3"
|
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
"all": true,
|
"all": true,
|
||||||
"branches": 85,
|
"branches": 90,
|
||||||
"check-coverage": true,
|
"check-coverage": true,
|
||||||
"exclude": [],
|
"exclude": [],
|
||||||
"extension": [
|
"extension": [
|
||||||
@@ -84,6 +85,8 @@
|
|||||||
"include": [
|
"include": [
|
||||||
"src/protocol/route.ts",
|
"src/protocol/route.ts",
|
||||||
"src/things/abstract/thing.ts",
|
"src/things/abstract/thing.ts",
|
||||||
|
"src/things/abstract/thing-that-can-be-offered.ts",
|
||||||
|
"src/things/abstract/thing-with-categories.ts",
|
||||||
"src/translator.ts",
|
"src/translator.ts",
|
||||||
"src/guards.ts"
|
"src/guards.ts"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*
|
*
|
||||||
* @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 ^([\+-]?\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)?)?)?)?$
|
||||||
* @see https://gist.github.com/philipashlock/8830168
|
* @see https://gist.github.com/philipashlock/8830168
|
||||||
|
*
|
||||||
|
* @date
|
||||||
*/
|
*/
|
||||||
export type SCISO8601Date = string;
|
export type SCISO8601Date = string;
|
||||||
/* tslint:enable */
|
/* tslint:enable */
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
/**
|
/**
|
||||||
* Universally unique identifier of the thing
|
* Universally unique identifier of the thing
|
||||||
*
|
*
|
||||||
|
* @filterable
|
||||||
* @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
|
* @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
|
||||||
* @see http://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
|
* @see http://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function isThing(something: unknown): something is SCThing {
|
|||||||
|
|
||||||
return Object
|
return Object
|
||||||
.values(SCThingType)
|
.values(SCThingType)
|
||||||
.indexOf(type) >= 0;
|
.indexOf(type as SCThingType) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
85
src/meta.ts
85
src/meta.ts
@@ -18,6 +18,7 @@ import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/art
|
|||||||
import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book';
|
import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book';
|
||||||
import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building';
|
import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building';
|
||||||
import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog';
|
import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog';
|
||||||
|
import {SCContactPoint, SCContactPointMeta, SCContactPointWithoutReferences} from './things/contact-point';
|
||||||
import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/course-of-studies';
|
import {SCCourseOfStudies, SCCourseOfStudiesMeta, SCCourseOfStudiesWithoutReferences} from './things/course-of-studies';
|
||||||
import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series';
|
import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series';
|
||||||
import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff';
|
import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff';
|
||||||
@@ -49,6 +50,7 @@ export const SCClasses: { [K in SCThingType]: object } = {
|
|||||||
'book': SCBookMeta,
|
'book': SCBookMeta,
|
||||||
'building': SCBuildingMeta,
|
'building': SCBuildingMeta,
|
||||||
'catalog': SCCatalogMeta,
|
'catalog': SCCatalogMeta,
|
||||||
|
'contact point': SCContactPointMeta,
|
||||||
'course of studies': SCCourseOfStudiesMeta,
|
'course of studies': SCCourseOfStudiesMeta,
|
||||||
'date series': SCDateSeriesMeta,
|
'date series': SCDateSeriesMeta,
|
||||||
'diff': SCDiffMeta,
|
'diff': SCDiffMeta,
|
||||||
@@ -76,6 +78,7 @@ export type SCThingsWithoutDiff =
|
|||||||
| SCBook
|
| SCBook
|
||||||
| SCBuilding
|
| SCBuilding
|
||||||
| SCCatalog
|
| SCCatalog
|
||||||
|
| SCContactPoint
|
||||||
| SCCourseOfStudies
|
| SCCourseOfStudies
|
||||||
| SCDateSeries
|
| SCDateSeries
|
||||||
| SCDish
|
| SCDish
|
||||||
@@ -116,26 +119,27 @@ export type SCAssociatedThingWithoutReferences<THING extends SCThings> =
|
|||||||
THING extends SCBook ? SCBookWithoutReferences :
|
THING extends SCBook ? SCBookWithoutReferences :
|
||||||
THING extends SCBuilding ? SCBuildingWithoutReferences :
|
THING extends SCBuilding ? SCBuildingWithoutReferences :
|
||||||
THING extends SCCatalog ? SCCatalogWithoutReferences :
|
THING extends SCCatalog ? SCCatalogWithoutReferences :
|
||||||
THING extends SCCourseOfStudies ? SCCourseOfStudiesWithoutReferences :
|
THING extends SCContactPoint ? SCContactPointWithoutReferences :
|
||||||
THING extends SCDateSeries ? SCDateSeriesWithoutReferences :
|
THING extends SCCourseOfStudies ? SCCourseOfStudiesWithoutReferences :
|
||||||
THING extends SCDiff ? SCDiffWithoutReferences :
|
THING extends SCDateSeries ? SCDateSeriesWithoutReferences :
|
||||||
THING extends SCDish ? SCDishWithoutReferences :
|
THING extends SCDiff ? SCDiffWithoutReferences :
|
||||||
THING extends SCFavorite ? SCFavoriteWithoutReferences :
|
THING extends SCDish ? SCDishWithoutReferences :
|
||||||
THING extends SCFloor ? SCFloorWithoutReferences :
|
THING extends SCFavorite ? SCFavoriteWithoutReferences :
|
||||||
THING extends SCMessage ? SCMessageWithoutReferences :
|
THING extends SCFloor ? SCFloorWithoutReferences :
|
||||||
THING extends SCOrganization ? SCOrganizationWithoutReferences :
|
THING extends SCMessage ? SCMessageWithoutReferences :
|
||||||
THING extends SCPerson ? SCPersonWithoutReferences :
|
THING extends SCOrganization ? SCOrganizationWithoutReferences :
|
||||||
THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences :
|
THING extends SCPerson ? SCPersonWithoutReferences :
|
||||||
THING extends SCRoom ? SCRoomWithoutReferences :
|
THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences :
|
||||||
THING extends SCSemester ? SCSemesterWithoutReferences :
|
THING extends SCRoom ? SCRoomWithoutReferences :
|
||||||
THING extends SCSetting ? SCSettingWithoutReferences :
|
THING extends SCSemester ? SCSemesterWithoutReferences :
|
||||||
THING extends SCSportCourse ? SCSportCourseWithoutReferences :
|
THING extends SCSetting ? SCSettingWithoutReferences :
|
||||||
THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
|
THING extends SCSportCourse ? SCSportCourseWithoutReferences :
|
||||||
THING extends SCTicket ? SCTicketWithoutReferences :
|
THING extends SCStudyModule ? SCStudyModuleWithoutReferences :
|
||||||
THING extends SCToDo ? SCToDoWithoutReferences :
|
THING extends SCTicket ? SCTicketWithoutReferences :
|
||||||
THING extends SCTour ? SCTourWithoutReferences :
|
THING extends SCToDo ? SCToDoWithoutReferences :
|
||||||
THING extends SCVideo ? SCVideoWithoutReferences :
|
THING extends SCTour ? SCTourWithoutReferences :
|
||||||
never;
|
THING extends SCVideo ? SCVideoWithoutReferences :
|
||||||
|
never;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thing for a thing without references
|
* Thing for a thing without references
|
||||||
@@ -146,23 +150,24 @@ export type SCAssociatedThing<THING extends SCThings> =
|
|||||||
THING extends SCBookWithoutReferences ? SCBook :
|
THING extends SCBookWithoutReferences ? SCBook :
|
||||||
THING extends SCBuildingWithoutReferences ? SCBuilding :
|
THING extends SCBuildingWithoutReferences ? SCBuilding :
|
||||||
THING extends SCCatalogWithoutReferences ? SCCatalog :
|
THING extends SCCatalogWithoutReferences ? SCCatalog :
|
||||||
THING extends SCCourseOfStudiesWithoutReferences ? SCCourseOfStudies :
|
THING extends SCContactPointWithoutReferences ? SCContactPoint :
|
||||||
THING extends SCDateSeriesWithoutReferences ? SCDateSeries :
|
THING extends SCCourseOfStudiesWithoutReferences ? SCCourseOfStudies :
|
||||||
THING extends SCDiffWithoutReferences ? SCDiff :
|
THING extends SCDateSeriesWithoutReferences ? SCDateSeries :
|
||||||
THING extends SCDishWithoutReferences ? SCDish :
|
THING extends SCDiffWithoutReferences ? SCDiff :
|
||||||
THING extends SCFavoriteWithoutReferences ? SCFavorite :
|
THING extends SCDishWithoutReferences ? SCDish :
|
||||||
THING extends SCFloorWithoutReferences ? SCFloor :
|
THING extends SCFavoriteWithoutReferences ? SCFavorite :
|
||||||
THING extends SCMessageWithoutReferences ? SCMessage :
|
THING extends SCFloorWithoutReferences ? SCFloor :
|
||||||
THING extends SCOrganizationWithoutReferences ? SCOrganization :
|
THING extends SCMessageWithoutReferences ? SCMessage :
|
||||||
THING extends SCPersonWithoutReferences ? SCPerson :
|
THING extends SCOrganizationWithoutReferences ? SCOrganization :
|
||||||
THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest :
|
THING extends SCPersonWithoutReferences ? SCPerson :
|
||||||
THING extends SCRoomWithoutReferences ? SCRoom :
|
THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest :
|
||||||
THING extends SCSemesterWithoutReferences ? SCSemester :
|
THING extends SCRoomWithoutReferences ? SCRoom :
|
||||||
THING extends SCSettingWithoutReferences ? SCSetting :
|
THING extends SCSemesterWithoutReferences ? SCSemester :
|
||||||
THING extends SCSportCourseWithoutReferences ? SCSportCourse :
|
THING extends SCSettingWithoutReferences ? SCSetting :
|
||||||
THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
|
THING extends SCSportCourseWithoutReferences ? SCSportCourse :
|
||||||
THING extends SCTicketWithoutReferences ? SCTicket :
|
THING extends SCStudyModuleWithoutReferences ? SCStudyModule :
|
||||||
THING extends SCToDoWithoutReferences ? SCToDo :
|
THING extends SCTicketWithoutReferences ? SCTicket :
|
||||||
THING extends SCTourWithoutReferences ? SCTour :
|
THING extends SCToDoWithoutReferences ? SCToDo :
|
||||||
THING extends SCVideoWithoutReferences ? SCVideo :
|
THING extends SCTourWithoutReferences ? SCTour :
|
||||||
never;
|
THING extends SCVideoWithoutReferences ? SCVideo :
|
||||||
|
never;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {ValidationError} from '@openstapps/core-tools/lib/common';
|
||||||
import {BAD_REQUEST} from 'http-status-codes';
|
import {BAD_REQUEST} from 'http-status-codes';
|
||||||
import {ValidationError} from 'jsonschema';
|
|
||||||
import {SCError} from '../error';
|
import {SCError} from '../error';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {OK} from 'http-status-codes';
|
import {OK} from 'http-status-codes';
|
||||||
import {Schema} from 'jsonschema';
|
import {JSONSchema7} from 'json-schema';
|
||||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||||
@@ -78,12 +78,12 @@ export interface SCPluginMetaData {
|
|||||||
/**
|
/**
|
||||||
* How the requests of the plugin looks like, a JSON schema for validation
|
* How the requests of the plugin looks like, a JSON schema for validation
|
||||||
*/
|
*/
|
||||||
requestSchema: Schema;
|
requestSchema: JSONSchema7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How the responses of the plugin looks like, a JSON schema for validation
|
* How the responses of the plugin looks like, a JSON schema for validation
|
||||||
*/
|
*/
|
||||||
responseSchema: Schema;
|
responseSchema: JSONSchema7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The desired route, for example /feedback.
|
* The desired route, for example /feedback.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {SCMap} from '../../general/map';
|
|||||||
import {SCSearchAvailabilityFilter} from './filters/availability';
|
import {SCSearchAvailabilityFilter} from './filters/availability';
|
||||||
import {SCSearchBooleanFilter} from './filters/boolean';
|
import {SCSearchBooleanFilter} from './filters/boolean';
|
||||||
import {SCSearchDistanceFilter} from './filters/distance';
|
import {SCSearchDistanceFilter} from './filters/distance';
|
||||||
|
import {SCSearchDateRangeFilter, SCSearchNumericRangeFilter} from './filters/range';
|
||||||
import {SCSearchValueFilter} from './filters/value';
|
import {SCSearchValueFilter} from './filters/value';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,9 @@ export type SCSearchFilterType =
|
|||||||
'availability'
|
'availability'
|
||||||
| 'boolean'
|
| 'boolean'
|
||||||
| 'distance'
|
| 'distance'
|
||||||
| 'value';
|
| 'value'
|
||||||
|
| 'date range'
|
||||||
|
| 'numeric range';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure of a filter instruction
|
* Structure of a filter instruction
|
||||||
@@ -57,4 +60,6 @@ export type SCSearchFilter =
|
|||||||
SCSearchAvailabilityFilter
|
SCSearchAvailabilityFilter
|
||||||
| SCSearchBooleanFilter
|
| SCSearchBooleanFilter
|
||||||
| SCSearchDistanceFilter
|
| SCSearchDistanceFilter
|
||||||
| SCSearchValueFilter;
|
| SCSearchValueFilter
|
||||||
|
| SCSearchNumericRangeFilter
|
||||||
|
| SCSearchDateRangeFilter;
|
||||||
|
|||||||
112
src/protocol/search/filters/range.ts
Normal file
112
src/protocol/search/filters/range.ts
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* 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 {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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ export interface SCValueFilterArguments extends SCSearchAbstractFilterArguments
|
|||||||
field: SCThingsField;
|
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[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
* Software Foundation, version 3.
|
* Software Foundation, version 3.
|
||||||
@@ -16,6 +16,7 @@ import {SCMap} from '../../general/map';
|
|||||||
import {SCThingsField} from '../../meta';
|
import {SCThingsField} from '../../meta';
|
||||||
import {SCDistanceSort} from './sorts/distance';
|
import {SCDistanceSort} from './sorts/distance';
|
||||||
import {SCDucetSort} from './sorts/ducet';
|
import {SCDucetSort} from './sorts/ducet';
|
||||||
|
import {SCGenericSort} from './sorts/generic';
|
||||||
import {SCPriceSort} from './sorts/price';
|
import {SCPriceSort} from './sorts/price';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,9 +52,9 @@ export interface SCSearchAbstractSortArguments extends SCMap<unknown> {
|
|||||||
/**
|
/**
|
||||||
* Type of a sort instruction
|
* Type of a sort instruction
|
||||||
*/
|
*/
|
||||||
export type SCSearchSortType = 'distance' | 'price' | 'ducet';
|
export type SCSearchSortType = 'distance' | 'price' | 'ducet' | 'generic';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sort instruction
|
* A sort instruction
|
||||||
*/
|
*/
|
||||||
export type SCSearchSort = SCDistanceSort | SCPriceSort | SCDucetSort;
|
export type SCSearchSort = SCDistanceSort | SCPriceSort | SCDucetSort | SCGenericSort;
|
||||||
|
|||||||
25
src/protocol/search/sorts/generic.ts
Normal file
25
src/protocol/search/sorts/generic.ts
Normal 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';
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
import {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||||
import {SCISO8601Date} from '../../general/time';
|
import {SCISO8601Date} from '../../general/time';
|
||||||
import {SCOrganizationWithoutReferences} from '../organization';
|
import {SCOrganizationWithoutReferences} from '../organization';
|
||||||
import {SCPersonWithoutReferences} from '../person';
|
import {SCPersonWithoutReferences} from '../person';
|
||||||
@@ -30,6 +30,12 @@ import {
|
|||||||
*/
|
*/
|
||||||
export interface SCCreativeWorkWithoutReferences
|
export interface SCCreativeWorkWithoutReferences
|
||||||
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
|
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Languages this creative work is available in
|
||||||
|
*/
|
||||||
|
availableLanguages?: SCLanguageCode[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date the creative work was published
|
* Date the creative work was published
|
||||||
*
|
*
|
||||||
@@ -38,9 +44,11 @@ export interface SCCreativeWorkWithoutReferences
|
|||||||
datePublished?: SCISO8601Date;
|
datePublished?: SCISO8601Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of languages this creative work is written/recorded/... in
|
* Languages this creative work is written/recorded/... in
|
||||||
|
*
|
||||||
|
* @filterable
|
||||||
*/
|
*/
|
||||||
inLanguages?: SCLanguage[];
|
inLanguage?: SCLanguageCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keywords of the creative work
|
* Keywords of the creative work
|
||||||
@@ -103,9 +111,10 @@ export class SCCreativeWorkMeta
|
|||||||
de: {
|
de: {
|
||||||
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
|
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
|
||||||
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
|
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
|
||||||
authors: 'Authoren',
|
authors: 'Autoren',
|
||||||
|
availableLanguages: 'verfügbare Übersetzungen',
|
||||||
datePublished: 'Veröffentlichungsdatum',
|
datePublished: 'Veröffentlichungsdatum',
|
||||||
inLanguages: 'verfügbare Übersetzungen',
|
inLanguage: 'Inhaltssprache',
|
||||||
keywords: 'Schlagwörter',
|
keywords: 'Schlagwörter',
|
||||||
publishers: 'Verleger',
|
publishers: 'Verleger',
|
||||||
},
|
},
|
||||||
@@ -113,8 +122,9 @@ export class SCCreativeWorkMeta
|
|||||||
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
|
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
|
||||||
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
|
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
|
||||||
authors: 'authors',
|
authors: 'authors',
|
||||||
|
availableLanguages: 'available languages',
|
||||||
datePublished: 'release date',
|
datePublished: 'release date',
|
||||||
inLanguages: 'available Languages',
|
inLanguage: 'content language',
|
||||||
keywords: 'keywords',
|
keywords: 'keywords',
|
||||||
publishers: 'publishers',
|
publishers: 'publishers',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ export interface SCThingWithCategoriesTranslatableProperties
|
|||||||
extends SCThingTranslatableProperties {
|
extends SCThingTranslatableProperties {
|
||||||
/**
|
/**
|
||||||
* translations of the categories of a thing with categories
|
* translations of the categories of a thing with categories
|
||||||
|
*
|
||||||
|
* @sortable ducet
|
||||||
*/
|
*/
|
||||||
categories?: string[];
|
categories?: string[];
|
||||||
}
|
}
|
||||||
@@ -98,6 +100,7 @@ export interface SCThingWithCategoriesSpecificValues {
|
|||||||
/**
|
/**
|
||||||
* Category specific name of a thing
|
* Category specific name of a thing
|
||||||
*
|
*
|
||||||
|
* @sortable ducet
|
||||||
* @text
|
* @text
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export enum SCThingType {
|
|||||||
Book = 'book',
|
Book = 'book',
|
||||||
Building = 'building',
|
Building = 'building',
|
||||||
Catalog = 'catalog',
|
Catalog = 'catalog',
|
||||||
|
ContactPoint = 'contact point',
|
||||||
CourseOfStudies = 'course of studies',
|
CourseOfStudies = 'course of studies',
|
||||||
DateSeries = 'date series',
|
DateSeries = 'date series',
|
||||||
Diff = 'diff',
|
Diff = 'diff',
|
||||||
@@ -101,6 +102,8 @@ export interface SCThingWithoutReferences {
|
|||||||
uid: SCUuid;
|
uid: SCUuid;
|
||||||
/**
|
/**
|
||||||
* URL of the thing
|
* URL of the thing
|
||||||
|
*
|
||||||
|
* @filterable
|
||||||
*/
|
*/
|
||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
@@ -222,6 +225,7 @@ export interface SCThingTranslatableProperties {
|
|||||||
/**
|
/**
|
||||||
* Translation of the name of the thing
|
* Translation of the name of the thing
|
||||||
*
|
*
|
||||||
|
* @sortable ducet
|
||||||
* @text
|
* @text
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export interface SCBookWithoutReferences
|
|||||||
* @filterable
|
* @filterable
|
||||||
* @keyword
|
* @keyword
|
||||||
*/
|
*/
|
||||||
isbn: string;
|
isbn?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of pages of a book
|
* Number of pages of a book
|
||||||
|
|||||||
@@ -41,15 +41,6 @@ export type SCBuildingCategories =
|
|||||||
export interface SCBuildingWithoutReferences
|
export interface SCBuildingWithoutReferences
|
||||||
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
|
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
|
||||||
SCPlaceWithoutReferences {
|
SCPlaceWithoutReferences {
|
||||||
/**
|
|
||||||
* Categories of a building
|
|
||||||
*
|
|
||||||
* @sortable ducet
|
|
||||||
* @aggregatable
|
|
||||||
* @filterable
|
|
||||||
*/
|
|
||||||
categories: SCBuildingCategories[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of floor names of the place
|
* List of floor names of the place
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export interface SCCatalogWithoutReferences
|
|||||||
*
|
*
|
||||||
* Needed for keeping order in catalog inheritance array.
|
* Needed for keeping order in catalog inheritance array.
|
||||||
*
|
*
|
||||||
|
* @filterable
|
||||||
* @integer
|
* @integer
|
||||||
*/
|
*/
|
||||||
level: number;
|
level: number;
|
||||||
|
|||||||
136
src/things/contact-point.ts
Normal file
136
src/things/contact-point.ts
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 StApps
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {SCMetaTranslations} from '../general/i18n';
|
||||||
|
import {
|
||||||
|
SCThing,
|
||||||
|
SCThingMeta,
|
||||||
|
SCThingType,
|
||||||
|
SCThingWithoutReferences,
|
||||||
|
} from './abstract/thing';
|
||||||
|
import {SCRoomWithoutReferences} from './room';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A contact point without references
|
||||||
|
*/
|
||||||
|
export interface SCContactPointWithoutReferences
|
||||||
|
extends SCThingWithoutReferences {
|
||||||
|
/**
|
||||||
|
* E-mail at the work location
|
||||||
|
*
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
email?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fax number at the work location
|
||||||
|
*
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
faxNumber?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Office hours for contacting someone at the work location
|
||||||
|
*
|
||||||
|
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
officeHours?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contact number at the work location
|
||||||
|
*
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
telephone?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of a contact point
|
||||||
|
*/
|
||||||
|
type: SCThingType.ContactPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL at the work location
|
||||||
|
*
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A contact point
|
||||||
|
*
|
||||||
|
* @see http://schema.org/ContactPoint
|
||||||
|
*
|
||||||
|
* @validatable
|
||||||
|
* @indexable
|
||||||
|
*/
|
||||||
|
export interface SCContactPoint
|
||||||
|
extends SCContactPointWithoutReferences, SCThing {
|
||||||
|
/**
|
||||||
|
* Exact place where work is performed
|
||||||
|
*/
|
||||||
|
areaServed?: SCRoomWithoutReferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of a contact point
|
||||||
|
*/
|
||||||
|
type: SCThingType.ContactPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta information about a contact point
|
||||||
|
*/
|
||||||
|
export class SCContactPointMeta
|
||||||
|
extends SCThingMeta
|
||||||
|
implements SCMetaTranslations<SCContactPoint> {
|
||||||
|
/**
|
||||||
|
* Translations of fields
|
||||||
|
*/
|
||||||
|
fieldTranslations = {
|
||||||
|
de: {
|
||||||
|
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
|
||||||
|
areaServed: 'Arbeitsraum',
|
||||||
|
email: 'E-Mail-Addresse',
|
||||||
|
faxNumber: 'Faxnummer',
|
||||||
|
officeHours: 'Sprechzeiten',
|
||||||
|
telephone: 'Telefonnummer',
|
||||||
|
url: 'Link',
|
||||||
|
},
|
||||||
|
en: {
|
||||||
|
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
|
||||||
|
areaServed: 'location',
|
||||||
|
email: 'email address',
|
||||||
|
faxNumber: 'fax number',
|
||||||
|
officeHours: 'office hours',
|
||||||
|
telephone: 'telephone number',
|
||||||
|
url: 'link',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translations of values of fields
|
||||||
|
*/
|
||||||
|
fieldValueTranslations = {
|
||||||
|
de: {
|
||||||
|
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
|
||||||
|
type: 'Kontaktinformation',
|
||||||
|
},
|
||||||
|
en: {
|
||||||
|
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
|
||||||
|
type: SCThingType.ContactPoint,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -43,15 +43,6 @@ export interface SCDishWithoutReferences
|
|||||||
*/
|
*/
|
||||||
additives?: string[];
|
additives?: string[];
|
||||||
|
|
||||||
/**
|
|
||||||
* Category of the dish
|
|
||||||
*
|
|
||||||
* @sortable ducet
|
|
||||||
* @aggregatable
|
|
||||||
* @filterable
|
|
||||||
*/
|
|
||||||
categories: SCDishCategories[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Characteristics of the dish
|
* Characteristics of the dish
|
||||||
*/
|
*/
|
||||||
@@ -100,6 +91,13 @@ export interface SCDish
|
|||||||
|
|
||||||
export interface SCDishTranslatableProperties
|
export interface SCDishTranslatableProperties
|
||||||
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
|
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
|
||||||
|
/**
|
||||||
|
* Additives of the dish
|
||||||
|
*
|
||||||
|
* @filterable
|
||||||
|
* @keyword
|
||||||
|
*/
|
||||||
|
additives?: string[];
|
||||||
/**
|
/**
|
||||||
* Characteristics of the dish
|
* Characteristics of the dish
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
import {SCMetaTranslations} from '../general/i18n';
|
import {SCMetaTranslations} from '../general/i18n';
|
||||||
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||||
|
import {SCContactPointWithoutReferences} from './contact-point';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An organization without references
|
* An organization without references
|
||||||
@@ -35,6 +36,11 @@ export interface SCOrganizationWithoutReferences
|
|||||||
*/
|
*/
|
||||||
export interface SCOrganization
|
export interface SCOrganization
|
||||||
extends SCOrganizationWithoutReferences, SCThingInPlace {
|
extends SCOrganizationWithoutReferences, SCThingInPlace {
|
||||||
|
/**
|
||||||
|
* A list of contact points concerning the organization
|
||||||
|
*/
|
||||||
|
contactPoints?: SCContactPointWithoutReferences[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of an organization
|
* Type of an organization
|
||||||
*/
|
*/
|
||||||
@@ -52,9 +58,11 @@ export class SCOrganizationMeta
|
|||||||
fieldTranslations = {
|
fieldTranslations = {
|
||||||
de: {
|
de: {
|
||||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.de,
|
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.de,
|
||||||
|
contactPoints: 'Kontaktinformationen',
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.en,
|
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations.en,
|
||||||
|
contactPoints: 'contact details',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {SCMetaTranslations, SCNationality} from '../general/i18n';
|
|||||||
import {SCISO8601Date} from '../general/time';
|
import {SCISO8601Date} from '../general/time';
|
||||||
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||||
import {SCBuildingWithoutReferences} from './building';
|
import {SCBuildingWithoutReferences} from './building';
|
||||||
|
import {SCContactPointWithoutReferences} from './contact-point';
|
||||||
import {SCOrganizationWithoutReferences} from './organization';
|
import {SCOrganizationWithoutReferences} from './organization';
|
||||||
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
|
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
|
||||||
import {SCRoomWithoutReferences} from './room';
|
import {SCRoomWithoutReferences} from './room';
|
||||||
@@ -159,7 +160,7 @@ export interface SCPerson
|
|||||||
/**
|
/**
|
||||||
* Locations where the person performs her/his work
|
* Locations where the person performs her/his work
|
||||||
*/
|
*/
|
||||||
workLocations?: SCContactPoint[];
|
workLocations?: SCContactPointWithoutReferences[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,13 +189,14 @@ export class SCPersonMeta
|
|||||||
jobTitles: 'Berufsbezeichnungen',
|
jobTitles: 'Berufsbezeichnungen',
|
||||||
nationality: 'Staatsangehörigkeit',
|
nationality: 'Staatsangehörigkeit',
|
||||||
telephone: 'Telefonnummer',
|
telephone: 'Telefonnummer',
|
||||||
workLocations: 'Arbeitsorte',
|
workLocations: 'Arbeitsstandorte',
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
|
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
|
||||||
additionalName: 'additional name',
|
additionalName: 'additional name',
|
||||||
affiliations: 'affiliations',
|
affiliations: 'affiliations',
|
||||||
birthDate: 'birth date',
|
birthDate: 'birth date',
|
||||||
|
contactDetails: 'contact details',
|
||||||
email: 'email',
|
email: 'email',
|
||||||
familyName: 'family name',
|
familyName: 'family name',
|
||||||
faxNumber: 'fax',
|
faxNumber: 'fax',
|
||||||
@@ -231,53 +233,6 @@ export class SCPersonMeta
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A contact point
|
|
||||||
*
|
|
||||||
* @see http://schema.org/ContactPoint
|
|
||||||
*/
|
|
||||||
export interface SCContactPoint {
|
|
||||||
/**
|
|
||||||
* Exact place where work is performed
|
|
||||||
*/
|
|
||||||
areaServed?: SCRoomWithoutReferences;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* E-mail at the work location
|
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
|
||||||
email?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fax number at the work location
|
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
|
||||||
faxNumber?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Times available for contacting at the work location
|
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
|
||||||
hoursAvailable?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contact number at the work location
|
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
|
||||||
telephone?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL at the work location
|
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
|
||||||
url?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gender of a person
|
* Gender of a person
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export interface SCSemesterWithoutReferences
|
|||||||
* The short name of the semester, using the given pattern.
|
* The short name of the semester, using the given pattern.
|
||||||
*
|
*
|
||||||
* @filterable
|
* @filterable
|
||||||
* @pattern ^(WS|SS) [0-9]{4}(/[0-9]{2})?$
|
* @pattern ^(WS|SS|WiSe|SoSe) [0-9]{4}(/[0-9]{2})?$
|
||||||
* @keyword
|
* @keyword
|
||||||
*/
|
*/
|
||||||
acronym: string;
|
acronym: string;
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ import {
|
|||||||
*/
|
*/
|
||||||
export interface SCSettingWithoutReferences
|
export interface SCSettingWithoutReferences
|
||||||
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
||||||
/**
|
|
||||||
* Categories of a setting
|
|
||||||
*/
|
|
||||||
categories: SCSettingCategories[];
|
|
||||||
/**
|
/**
|
||||||
* The default value of a setting
|
* The default value of a setting
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export interface SCTourWithoutReferences
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Steps of a tour
|
* Steps of a tour
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
*/
|
||||||
steps: SCTourStep[];
|
steps: SCTourStep[];
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import clone = require('fast-clone');
|
import clone = require('fast-clone');
|
||||||
import {Defined, OCType} from 'ts-optchain';
|
import equal = require('fast-deep-equal/es6');
|
||||||
import {SCTranslations} from './general/i18n';
|
import {Defined, TSOCType} from 'ts-optchain';
|
||||||
|
import {SCLanguageCode} from './general/i18n';
|
||||||
import {isThing} from './guards';
|
import {isThing} from './guards';
|
||||||
import {SCClasses} from './meta';
|
import {SCClasses} from './meta';
|
||||||
import {SCThing, SCThingType} from './things/abstract/thing';
|
import {SCThing, SCThingType} from './things/abstract/thing';
|
||||||
@@ -27,13 +28,32 @@ const standardCacheSize = 200;
|
|||||||
*/
|
*/
|
||||||
export class SCThingTranslator {
|
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
|
* Property representing the translators target language
|
||||||
*/
|
*/
|
||||||
private _language: keyof SCTranslations<SCThing>;
|
private _language: SCLanguageCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property representing the translators base language
|
* LRU cache containing already translated SCThings
|
||||||
* This means every translation is given for this language
|
|
||||||
*/
|
*/
|
||||||
private readonly cache: LRUCache<SCThing>;
|
private readonly cache: LRUCache<SCThing>;
|
||||||
|
|
||||||
@@ -42,46 +62,33 @@ export class SCThingTranslator {
|
|||||||
*/
|
*/
|
||||||
private readonly metaClasses: typeof SCClasses;
|
private readonly metaClasses: typeof SCClasses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LRU cache containing SCThings translations have been provided for
|
||||||
|
*/
|
||||||
|
private readonly sourceCache: LRUCache<SCThing>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @example
|
* @example
|
||||||
* // returns translator instance for german
|
* // returns translator instance for german
|
||||||
* new SCThingTranslator('de');
|
* new SCThingTranslator('de');
|
||||||
*/
|
*/
|
||||||
constructor(language: keyof SCTranslations<SCThing>, cacheCapacity: number = standardCacheSize) {
|
constructor(language: SCLanguageCode, cacheCapacity: number = standardCacheSize) {
|
||||||
this.cache = new LRUCache(cacheCapacity);
|
this.cache = new LRUCache(cacheCapacity);
|
||||||
|
this.sourceCache = new LRUCache(cacheCapacity);
|
||||||
this._language = language;
|
this._language = language;
|
||||||
this.metaClasses = SCClasses;
|
this.metaClasses = SCClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for language property
|
|
||||||
*/
|
|
||||||
get language(): keyof SCTranslations<SCThing> {
|
|
||||||
return this._language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for language property. Also flushes translation cache
|
|
||||||
*
|
|
||||||
* @param language The language the translator instance will use from now on
|
|
||||||
*/
|
|
||||||
set language(language: keyof SCTranslations<SCThing>) {
|
|
||||||
if (language !== this._language) {
|
|
||||||
this.cache.flush();
|
|
||||||
}
|
|
||||||
this._language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get field value translation recursively
|
* Get field value translation recursively
|
||||||
*
|
*
|
||||||
* @param data The intermediate object / primitive returned by the Proxys get() method
|
* @param data The intermediate object / primitive returned by the Proxys get() method
|
||||||
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
|
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||||
*/
|
*/
|
||||||
// tslint:disable-next-line:prefer-function-over-method
|
// tslint:disable-next-line:prefer-function-over-method
|
||||||
private deeptranslate<T>(data?: T): OCType<T> {
|
private deeptranslate<T>(data?: T): TSOCType<T> {
|
||||||
const proxy = new Proxy(
|
const proxy = new Proxy(
|
||||||
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
|
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as TSOCType<T>,
|
||||||
{
|
{
|
||||||
get: (target, key) => {
|
get: (target, key) => {
|
||||||
const obj: any = target();
|
const obj: any = target();
|
||||||
@@ -101,8 +108,8 @@ export class SCThingTranslator {
|
|||||||
* @param language The language the thing property values are translated to
|
* @param language The language the thing property values are translated to
|
||||||
* @returns The thing with all known meta values translated
|
* @returns The thing with all known meta values translated
|
||||||
*/
|
*/
|
||||||
private getAllMetaFieldTranslations<T extends SCThing>(thingType: SCThingType,
|
private getAllMetaFieldTranslations(thingType: SCThingType,
|
||||||
language: keyof SCTranslations<T>): object | undefined {
|
language: SCLanguageCode): object | undefined {
|
||||||
const fieldTranslations = {};
|
const fieldTranslations = {};
|
||||||
const metaClass = this.getMetaClassInstance(thingType);
|
const metaClass = this.getMetaClassInstance(thingType);
|
||||||
if (typeof metaClass === 'undefined') {
|
if (typeof metaClass === 'undefined') {
|
||||||
@@ -146,12 +153,12 @@ export class SCThingTranslator {
|
|||||||
* Applies known field value translations of the given SCThings meta class to an instance
|
* Applies known field value translations of the given SCThings meta class to an instance
|
||||||
* Translated values overwrite current values inplace (destructive)
|
* Translated values overwrite current values inplace (destructive)
|
||||||
*
|
*
|
||||||
* @param language The language the thing is translated to
|
* @param instance The thing / object that will be translated
|
||||||
* @param thing The thing that will be translated
|
* @param language The language the thing / object is translated to
|
||||||
* @returns The thing with translated meta field values
|
* @returns The thing with translated meta field values
|
||||||
*/
|
*/
|
||||||
private replaceAvailableMetaFieldValueTranslations(instance: any,
|
private replaceAvailableMetaFieldValueTranslations(instance: any,
|
||||||
language: keyof SCTranslations<any>): any {
|
language: SCLanguageCode): any {
|
||||||
const metaClass = this.getMetaClassInstance(instance.type);
|
const metaClass = this.getMetaClassInstance(instance.type);
|
||||||
if (typeof metaClass === 'undefined') {
|
if (typeof metaClass === 'undefined') {
|
||||||
return instance;
|
return instance;
|
||||||
@@ -159,13 +166,18 @@ export class SCThingTranslator {
|
|||||||
if (typeof metaClass.fieldValueTranslations[language] !== 'undefined') {
|
if (typeof metaClass.fieldValueTranslations[language] !== 'undefined') {
|
||||||
Object.keys(metaClass.fieldValueTranslations[language])
|
Object.keys(metaClass.fieldValueTranslations[language])
|
||||||
.forEach((key) => {
|
.forEach((key) => {
|
||||||
if (metaClass.fieldValueTranslations[language][key] instanceof Object) {
|
if (metaClass.fieldValueTranslations[language][key] instanceof Object
|
||||||
|
&& (instance as any)[key] instanceof Object) {
|
||||||
// Assigns known translations of subproperties to property in given language (e.g. categories)
|
// Assigns known translations of subproperties to property in given language (e.g. categories)
|
||||||
Object.keys((instance as any)[key])
|
Object.keys((instance as any)[key])
|
||||||
.forEach((subKey) => {
|
.forEach((subKey) => {
|
||||||
(instance as any)[key][subKey] =
|
(instance as any)[key][subKey] =
|
||||||
metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]];
|
metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]];
|
||||||
});
|
});
|
||||||
|
} else if (metaClass.fieldValueTranslations[language][key] instanceof Object
|
||||||
|
&& typeof (instance as any)[key] === 'string') {
|
||||||
|
// Assigns known translations of enum to property in given language (e.g. SCSettingInputType)
|
||||||
|
(instance as any)[key] = metaClass.fieldValueTranslations[language][key][(instance as any)[key]];
|
||||||
} else {
|
} else {
|
||||||
// Assigns property to known translation of fieldValueTranslations in given language
|
// Assigns property to known translation of fieldValueTranslations in given language
|
||||||
(instance as any)[key] = metaClass.fieldValueTranslations[language][key];
|
(instance as any)[key] = metaClass.fieldValueTranslations[language][key];
|
||||||
@@ -176,6 +188,60 @@ export class SCThingTranslator {
|
|||||||
return instance;
|
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
|
* Get field value translation recursively
|
||||||
* @example
|
* @example
|
||||||
@@ -184,23 +250,26 @@ export class SCThingTranslator {
|
|||||||
* // or
|
* // or
|
||||||
* const dishTranslatedAccess = translator.translate(dish);
|
* const dishTranslatedAccess = translator.translate(dish);
|
||||||
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
|
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
|
||||||
* // undoing the OCType<T>
|
* // undoing the TSOCType<T>
|
||||||
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
|
* 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 OCType<T> object allowing for access to translations or a translated value(s)
|
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||||
*/
|
*/
|
||||||
public translate<T extends SCThing>(data: T): OCType<T> {
|
public translatedAccess<T extends SCThing>(thing: T): TSOCType<T> {
|
||||||
return new Proxy(
|
return new Proxy(
|
||||||
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
|
((defaultValue?: Defined<T>) => (thing == null ? defaultValue : thing)) as TSOCType<T>,
|
||||||
{
|
{
|
||||||
get: (target, key) => {
|
get: (target, key) => {
|
||||||
const obj: any = target();
|
const obj: any = target();
|
||||||
const objTranslatedFromCache = this.cache.get(data);
|
if (equal(this.sourceCache.get(thing), thing)) {
|
||||||
if (typeof objTranslatedFromCache !== 'undefined') {
|
const objTranslatedFromCache = this.cache.get(thing);
|
||||||
return this.deeptranslate((objTranslatedFromCache as any)[key]);
|
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.cache.putObject(objTranslated);
|
||||||
|
this.sourceCache.putObject(thing);
|
||||||
|
|
||||||
return this.deeptranslate(objTranslated[key]);
|
return this.deeptranslate(objTranslated[key]);
|
||||||
},
|
},
|
||||||
@@ -213,52 +282,32 @@ export class SCThingTranslator {
|
|||||||
* All the values will be set to the known translations of the property/key name
|
* All the values will be set to the known translations of the property/key name
|
||||||
* @example
|
* @example
|
||||||
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
||||||
* @param language The language the object is translated to
|
* @param type The type whose property names will be translated
|
||||||
* @param thingType Type of the thing
|
|
||||||
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
||||||
*/
|
*/
|
||||||
public translatedPropertyNames<T extends SCThing>(thing: T,
|
public translatedPropertyNames<T extends SCThing>(type: SCThingType): T | undefined {
|
||||||
language?: keyof SCTranslations<T>): T | undefined {
|
return this.getAllMetaFieldTranslations(type, this.language) as T;
|
||||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
|
||||||
|
|
||||||
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively translates the given object in-place
|
* Given a SCThingType and a corresponding property name it returns the known property value translation
|
||||||
* Translated values overwrite current values (destructive)
|
* Access pattern to the meta object containing the translation can be thought of as type.field[key] with key being optional
|
||||||
*
|
* @example
|
||||||
* @param language The language the thing is translated to
|
* const singleValueTranslation = translator.translatedPropertyValue(SCThingType.Dish, 'categories', 'main dish');
|
||||||
* @param thing The thing that will be translated
|
* @param type The type for whose property values a translation is required
|
||||||
* @returns The thing translated
|
* @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 translateWholeThingDestructively(instance: any,
|
public translatedPropertyValue(type: SCThingType,
|
||||||
language?: keyof SCTranslations<any>): any {
|
field: string,
|
||||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
key?: string): string | undefined {
|
||||||
let nextInstance = instance;
|
const fieldValueTranslations = this.getMetaClassInstance(type).fieldValueTranslations[this.language] ??
|
||||||
// Recursively call this function on all nested SCThings, arrays and objects
|
this.getMetaClassInstance(type).fieldValueTranslations.en;
|
||||||
Object.keys(nextInstance)
|
const fieldTranslation = fieldValueTranslations?.[field];
|
||||||
.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
|
return fieldTranslation?.[key ?? ''] ?? key ?? fieldTranslation;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||||
import {SCBulkResponse} from '../src/protocol/routes/bulk-request';
|
import {SCBulkResponse} from '../src/protocol/routes/bulk-request';
|
||||||
import {SCMultiSearchResponse} from '../src/protocol/routes/search-multi';
|
import {SCMultiSearchResponse} from '../src/protocol/routes/search-multi';
|
||||||
import {SCSearchResponse} from '../src/protocol/routes/search';
|
import {SCSearchResponse} from '../src/protocol/routes/search';
|
||||||
|
|||||||
@@ -21,12 +21,7 @@
|
|||||||
"name": "Symposion Publishing"
|
"name": "Symposion Publishing"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inLanguages": [
|
"inLanguage": "de",
|
||||||
{
|
|
||||||
"name": "german",
|
|
||||||
"code": "de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"bookEdition": "2., überarb. u. erw. Aufl.",
|
"bookEdition": "2., überarb. u. erw. Aufl.",
|
||||||
"isbn": "3936608776",
|
"isbn": "3936608776",
|
||||||
"numberOfPages": 537,
|
"numberOfPages": 537,
|
||||||
|
|||||||
39
test/resources/ContactPoint.1.json
Normal file
39
test/resources/ContactPoint.1.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"errorNames": [],
|
||||||
|
"instance": {
|
||||||
|
"type": "contact point",
|
||||||
|
"name": "Dienstadresse",
|
||||||
|
"areaServed": {
|
||||||
|
"type": "room",
|
||||||
|
"categories": [
|
||||||
|
"education"
|
||||||
|
],
|
||||||
|
"uid": "39c1a574-04ef-5157-9c6f-e271d93eb273",
|
||||||
|
"name": "3.G 121",
|
||||||
|
"alternateNames": [
|
||||||
|
"Dienstzimmer"
|
||||||
|
],
|
||||||
|
"geo": {
|
||||||
|
"point": {
|
||||||
|
"coordinates": [
|
||||||
|
8.66919,
|
||||||
|
50.12834
|
||||||
|
],
|
||||||
|
"type": "Point"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"email": "info@example.com",
|
||||||
|
"faxNumber": "069 / 123450",
|
||||||
|
"officeHours": "Mo, Mi 8:00-13:00",
|
||||||
|
"telephone": "069 / 12345",
|
||||||
|
"url": "https://example.com",
|
||||||
|
"uid": "be34a419-e9e8-5de0-b998-dd1b19e7beef",
|
||||||
|
"origin": {
|
||||||
|
"indexed": "2018-09-11T12:30:00Z",
|
||||||
|
"name": "Dummy",
|
||||||
|
"type": "remote"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schema": "SCContactPoint"
|
||||||
|
}
|
||||||
26
test/resources/Organization.2.json
Normal file
26
test/resources/Organization.2.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"errorNames": [],
|
||||||
|
"instance": {
|
||||||
|
"type": "organization",
|
||||||
|
"uid": "20e48393-0d2b-5bdc-9d92-5e0dc1e2860f",
|
||||||
|
"contactPoints": [
|
||||||
|
{
|
||||||
|
"type": "contact point",
|
||||||
|
"name": "Dienstadresse",
|
||||||
|
"email": "info@example.com",
|
||||||
|
"faxNumber": "069 / 123450",
|
||||||
|
"officeHours": "Mo, Mi 8:00-13:00",
|
||||||
|
"telephone": "069 / 12345",
|
||||||
|
"url": "https://example.com",
|
||||||
|
"uid": "be34a419-e9e8-5de0-b998-dd1b19e7beef"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Technische Universität Berlin",
|
||||||
|
"origin": {
|
||||||
|
"indexed": "2018-09-11T12:30:00Z",
|
||||||
|
"name": "Dummy",
|
||||||
|
"type": "remote"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schema": "SCOrganization"
|
||||||
|
}
|
||||||
@@ -17,58 +17,14 @@
|
|||||||
"uid": "be34a419-e9e8-5de0-b998-dd1b19e7f451",
|
"uid": "be34a419-e9e8-5de0-b998-dd1b19e7f451",
|
||||||
"workLocations": [
|
"workLocations": [
|
||||||
{
|
{
|
||||||
"url": "http://www.fb03.uni-frankfurt.de/1234567",
|
"type": "contact point",
|
||||||
"email": "mustermann@soz.uni-frankfurt.de",
|
"name": "Dienstadresse",
|
||||||
"faxNumber": "",
|
"email": "info@example.com",
|
||||||
"telephone": "069/123-36232; -1324325",
|
"faxNumber": "069 / 123450",
|
||||||
"hoursAvailable": "siehe Homepage",
|
"officeHours": "Mo, Mi 8:00-13:00",
|
||||||
"areaServed": {
|
"telephone": "069 / 12345",
|
||||||
"type": "room",
|
"url": "https://example.com",
|
||||||
"categories": [
|
"uid": "be34a419-e9e8-5de0-b998-dd1b19e7beef"
|
||||||
"education"
|
|
||||||
],
|
|
||||||
"uid": "39c1a574-04ef-5157-9c6f-e271d93eb273",
|
|
||||||
"name": "3.G 121",
|
|
||||||
"alternateNames": [
|
|
||||||
"Dienstzimmer"
|
|
||||||
],
|
|
||||||
"geo": {
|
|
||||||
"point": {
|
|
||||||
"coordinates": [
|
|
||||||
8.66919,
|
|
||||||
50.12834
|
|
||||||
],
|
|
||||||
"type": "Point"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "http://www2.uni-frankfurt.de/12345/vizepraesidenten",
|
|
||||||
"email": "",
|
|
||||||
"faxNumber": "",
|
|
||||||
"telephone": "069/123-1235",
|
|
||||||
"hoursAvailable": "siehe Homepage",
|
|
||||||
"areaServed": {
|
|
||||||
"type": "room",
|
|
||||||
"categories": [
|
|
||||||
"education"
|
|
||||||
],
|
|
||||||
"uid": "5e54aefd-078b-5007-bca1-53dc60f79d37",
|
|
||||||
"name": "4.P 22",
|
|
||||||
"alternateNames": [
|
|
||||||
"Dienstzimmer"
|
|
||||||
],
|
|
||||||
"geo": {
|
|
||||||
"point": {
|
|
||||||
"coordinates": [
|
|
||||||
8.66898,
|
|
||||||
50.12772
|
|
||||||
],
|
|
||||||
"type": "Point"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"origin": {
|
"origin": {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"address": "http://foo.com:1234",
|
"address": "http://foo.com:1234",
|
||||||
"name": "Foo Plugin",
|
"name": "Foo Plugin",
|
||||||
"requestSchema": {
|
"requestSchema": {
|
||||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"SCFooPluginRequest": {
|
"SCFooPluginRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -33,10 +33,10 @@
|
|||||||
],
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "User query",
|
"description": "User query",
|
||||||
"id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginRequest.json"
|
"$id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginRequest.json"
|
||||||
},
|
},
|
||||||
"responseSchema": {
|
"responseSchema": {
|
||||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"SCFooPluginResponse": {
|
"SCFooPluginResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
],
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "A response to a query",
|
"description": "A response to a query",
|
||||||
"id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginResponse.json"
|
"$id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginResponse.json"
|
||||||
},
|
},
|
||||||
"route": "/foo"
|
"route": "/foo"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
"uid": "7cebbc3e-0a21-5371-ab0d-f7ba12f53dbd",
|
"uid": "7cebbc3e-0a21-5371-ab0d-f7ba12f53dbd",
|
||||||
"type": "semester",
|
"type": "semester",
|
||||||
"name": "Sommersemester 2018",
|
"name": "Sommersemester 2018",
|
||||||
"acronym": "SS 2018",
|
"acronym": "SoSe 2018",
|
||||||
"alternateNames": [
|
"alternateNames": [
|
||||||
"SoSe 2018"
|
"Sommer 2018"
|
||||||
],
|
],
|
||||||
"startDate": "2018-04-01",
|
"startDate": "2018-04-01",
|
||||||
"endDate": "2018-09-30",
|
"endDate": "2018-09-30",
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
},
|
},
|
||||||
"translations": {
|
"translations": {
|
||||||
"de": {
|
"de": {
|
||||||
"categories": ["Benutzer"],
|
|
||||||
"description": "Die Sprache in der die App angezeigt wird.",
|
"description": "Die Sprache in der die App angezeigt wird.",
|
||||||
"name": "Sprache",
|
"name": "Sprache",
|
||||||
"values": [
|
"values": [
|
||||||
@@ -25,9 +24,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"en": {
|
"en": {
|
||||||
"categories": [
|
|
||||||
"User"
|
|
||||||
],
|
|
||||||
"description": "The language this app is going to use.",
|
"description": "The language this app is going to use.",
|
||||||
"name": "Language",
|
"name": "Language",
|
||||||
"values": [
|
"values": [
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||||
import {SCBulkRoute} from '../src/protocol/routes/bulk-request';
|
import {SCBulkRoute} from '../src/protocol/routes/bulk-request';
|
||||||
import {SCBulkAddRoute} from '../src/protocol/routes/bulk-add';
|
import {SCBulkAddRoute} from '../src/protocol/routes/bulk-add';
|
||||||
import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update';
|
import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update';
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ import {Logger} from '@openstapps/logger';
|
|||||||
import {fail} from 'assert';
|
import {fail} from 'assert';
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {mkdirSync} from 'fs';
|
import {mkdirSync} from 'fs';
|
||||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||||
import {join, resolve} from 'path';
|
import {join, resolve} from 'path';
|
||||||
import {DeclarationReflection, ProjectReflection} from 'typedoc';
|
import {DeclarationReflection, ProjectReflection} from 'typedoc';
|
||||||
import {ArrayType, IntrinsicType, ReferenceType, StringLiteralType, Type, UnionType} from 'typedoc/dist/lib/models';
|
import {ArrayType, IntrinsicType, ReferenceType, StringLiteralType, Type, UnionType} from 'typedoc/dist/lib/models';
|
||||||
|
|
||||||
process.on('unhandledRejection', (err) => {
|
process.on('unhandledRejection', (err) => {
|
||||||
Logger.error('UNHANDLED REJECTION', err.stack);
|
throw err;
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,10 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import clone = require('fast-clone');
|
import clone = require('fast-clone');
|
||||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||||
import {SCThingOriginType, SCThingType} from '../src/things/abstract/thing';
|
import {SCThingOriginType, SCThingType, SCThingRemoteOrigin} from '../src/things/abstract/thing';
|
||||||
import {SCBuildingWithoutReferences} from '../src/things/building';
|
import {SCBuildingWithoutReferences} from '../src/things/building';
|
||||||
import {SCDish, SCDishMeta} from '../src/things/dish';
|
import {SCDish, SCDishMeta} from '../src/things/dish';
|
||||||
|
import {SCSetting, SCSettingInputType} from '../src/things/setting';
|
||||||
import {SCThingTranslator} from '../src/translator';
|
import {SCThingTranslator} from '../src/translator';
|
||||||
|
|
||||||
const building: SCBuildingWithoutReferences = {
|
const building: SCBuildingWithoutReferences = {
|
||||||
@@ -86,134 +87,200 @@ const dish: SCDish = {
|
|||||||
uid: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
uid: '540862f3-ea30-5b8f-8678-56b4dc217140',
|
||||||
};
|
};
|
||||||
|
|
||||||
const translator = new SCThingTranslator('de');
|
const setting: SCSetting = {
|
||||||
// tslint:disable-next-line:no-eval
|
categories: ['profile'],
|
||||||
const languageNonExistant = eval("'jp'");
|
defaultValue: 'student',
|
||||||
// this will simulate a translator always utilizing the base language translations
|
description: 'base-description',
|
||||||
const translatorWithFallback = new SCThingTranslator(languageNonExistant);
|
inputType: SCSettingInputType.SingleChoice,
|
||||||
|
name: 'group',
|
||||||
|
order: 1,
|
||||||
|
origin: {
|
||||||
|
indexed: '2018-11-11T14:30:00Z',
|
||||||
|
name: 'Dummy',
|
||||||
|
type: SCThingOriginType.Remote,
|
||||||
|
},
|
||||||
|
type: SCThingType.Setting,
|
||||||
|
uid: '2c97aa36-4aa2-43de-bc5d-a2b2cb3a530e',
|
||||||
|
values: ['student', 'employee', true, 42],
|
||||||
|
};
|
||||||
|
|
||||||
// tslint:disable:member-ordering TranslationSpecInplace
|
const translator = new SCThingTranslator('de');
|
||||||
|
const translatorEN = new SCThingTranslator('en');
|
||||||
|
// this will simulate a translator always utilizing the base language translations
|
||||||
|
const translatorWithFallback = new SCThingTranslator('tt');
|
||||||
|
|
||||||
|
const translatedThingDE = translator.translate(dish);
|
||||||
|
const translatedThingFallback = translatorWithFallback.translate(dish);
|
||||||
|
|
||||||
|
// tslint:disable:max-line-length member-ordering newline-per-chained-call prefer-function-over-method completed-docs TranslationSpecInplace
|
||||||
@suite(timeout(10000), slow(5000))
|
@suite(timeout(10000), slow(5000))
|
||||||
export class TranslationSpecInplace {
|
export class TranslationSpecInplace {
|
||||||
|
@test
|
||||||
|
public directEnumSingleValue() {
|
||||||
|
expect(translator.translatedAccess(setting).inputType()).to.equal('einfache Auswahl');
|
||||||
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directStringLiteralType() {
|
public directStringLiteralType() {
|
||||||
expect(translator.translate(dish).type()).to.equal('Essen');
|
expect(translator.translatedAccess(dish).type()).to.equal('Essen');
|
||||||
|
expect(translatedThingDE.type).to.equal('Essen');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directStringProperty() {
|
public directStringProperty() {
|
||||||
expect(translator.translate(dish).name()).to.equal('de-dish-name');
|
expect(translator.translatedAccess(dish).name()).to.equal('de-dish-name');
|
||||||
|
expect(translatedThingDE.name).to.equal('de-dish-name');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directArrayOfString() {
|
public directArrayOfString() {
|
||||||
expect(translator.translate(dish).characteristics()).to.deep
|
expect(translator.translatedAccess(dish).characteristics()).to.deep
|
||||||
.equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]);
|
.equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]);
|
||||||
|
expect(translatedThingDE.characteristics).to.deep
|
||||||
|
.equal([{name: 'de-characteristic0'}, {name: 'de-characteristic1'}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directArrayOfStringSubscript() {
|
public directArrayOfStringSubscript() {
|
||||||
expect(translator.translate(dish).characteristics[1]()).to.deep.equal({name: 'de-characteristic1'});
|
expect(translator.translatedAccess(dish).characteristics[1]()).to.deep.equal({name: 'de-characteristic1'});
|
||||||
|
expect(translatedThingDE.characteristics![1]).to.deep.equal({name: 'de-characteristic1'});
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directMetaArrayOfString() {
|
public directMetaArrayOfString() {
|
||||||
expect(translator.translate(dish).categories()).to.deep.equal(['Hauptgericht', 'Nachtisch']);
|
expect(translator.translatedAccess(dish).categories()).to.deep.equal(['Hauptgericht', 'Nachtisch']);
|
||||||
|
expect(translatedThingDE.categories).to.deep.equal(['Hauptgericht', 'Nachtisch']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directMetaArrayOfStringSubscript() {
|
public directMetaArrayOfStringSubscript() {
|
||||||
expect(translator.translate(dish).categories[1]()).to.equal('Nachtisch');
|
expect(translator.translatedAccess(dish).categories[1]()).to.equal('Nachtisch');
|
||||||
|
expect(translatedThingDE.categories[1]).to.equal('Nachtisch');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedStringLiteralType() {
|
public nestedStringLiteralType() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.type()).to.equal('Gebäude');
|
expect(translator.translatedAccess(dish).offers[0].inPlace.type()).to.equal('Gebäude');
|
||||||
|
expect(translatedThingDE.offers![0].inPlace!.type).to.equal('Gebäude');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedStringProperty() {
|
public nestedStringProperty() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.name()).to.equal('de-space-name');
|
expect(translator.translatedAccess(dish).offers[0].inPlace.name()).to.equal('de-space-name');
|
||||||
|
expect(translatedThingDE.offers![0].inPlace!.name).to.equal('de-space-name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfString() {
|
public nestedMetaArrayOfString() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories()).to.deep.equal(['Büro', 'Bildung']);
|
expect(translator.translatedAccess(dish).offers[0].inPlace.categories()).to.deep.equal(['Büro', 'Bildung']);
|
||||||
|
expect(translatedThingDE.offers![0].inPlace!.categories).to.deep.equal(['Büro', 'Bildung']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfStringSubscript() {
|
public nestedMetaArrayOfStringSubscript() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories[1]()).to.equal('Bildung');
|
expect(translator.translatedAccess(dish).offers[0].inPlace.categories[1]()).to.equal('Bildung');
|
||||||
|
expect(translatedThingDE.offers![0].inPlace!.categories[1]).to.equal('Bildung');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directStringLiteralTypeFallback() {
|
public directStringLiteralTypeFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).type()).to.equal('dish');
|
expect(translatorWithFallback.translatedAccess(dish).type()).to.equal('dish');
|
||||||
|
expect(translatedThingFallback.type).to.equal('dish');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directStringPropertyFallback() {
|
public directStringPropertyFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).name()).to.equal('base-dish-name');
|
expect(translatorWithFallback.translatedAccess(dish).name()).to.equal('base-dish-name');
|
||||||
|
expect(translatedThingFallback.name).to.equal('base-dish-name');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directArrayOfStringSubscriptFallback() {
|
public directArrayOfStringSubscriptFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).characteristics[1]())
|
expect(translatorWithFallback.translatedAccess(dish).characteristics[1]())
|
||||||
|
.to.deep.equal({name: 'base-characteristic1'});
|
||||||
|
expect(translatedThingFallback.characteristics![1])
|
||||||
.to.deep.equal({name: 'base-characteristic1'});
|
.to.deep.equal({name: 'base-characteristic1'});
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directMetaArrayOfStringFallback() {
|
public directMetaArrayOfStringFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).categories()).to.deep.equal(['main dish', 'dessert']);
|
expect(translatorWithFallback.translatedAccess(dish).categories()).to.deep.equal(['main dish', 'dessert']);
|
||||||
|
expect(translatedThingFallback.categories).to.deep.equal(['main dish', 'dessert']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directMetaArrayOfStringSubscriptFallback() {
|
public directMetaArrayOfStringSubscriptFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).categories[1]()).to.equal('dessert');
|
expect(translatorWithFallback.translatedAccess(dish).categories[1]()).to.equal('dessert');
|
||||||
|
expect(translatedThingFallback.categories[1]).to.equal('dessert');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedStringLiteralTypeFallback() {
|
public nestedStringLiteralTypeFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).offers[0].inPlace.type()).to.equal('building');
|
expect(translatorWithFallback.translatedAccess(dish).offers[0].inPlace.type()).to.equal('building');
|
||||||
|
expect(translatedThingFallback.offers![0].inPlace!.type).to.equal('building');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedStringPropertyFallback() {
|
public nestedStringPropertyFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).offers[0].inPlace.name()).to.equal('base-space-name');
|
expect(translatorWithFallback.translatedAccess(dish).offers[0].inPlace.name()).to.equal('base-space-name');
|
||||||
|
expect(translatedThingFallback.offers![0].inPlace!.name).to.equal('base-space-name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfStringFallback() {
|
public nestedMetaArrayOfStringFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).offers[0].inPlace.categories())
|
expect(translatorWithFallback.translatedAccess(dish).offers[0].inPlace.categories())
|
||||||
|
.to.deep.equal(['office', 'education']);
|
||||||
|
expect(translatedThingFallback.offers![0].inPlace!.categories)
|
||||||
.to.deep.equal(['office', 'education']);
|
.to.deep.equal(['office', 'education']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfStringSubscriptFallback() {
|
public nestedMetaArrayOfStringSubscriptFallback() {
|
||||||
expect(translatorWithFallback.translate(dish).offers[0].inPlace.categories[1]()).to.equal('education');
|
expect(translatorWithFallback.translatedAccess(dish).offers[0].inPlace.categories[1]()).to.equal('education');
|
||||||
|
expect(translatedThingFallback.offers![0].inPlace!.categories[1]).to.equal('education');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public directStringLiteralTypeUndefined() {
|
public directStringLiteralTypeUndefined() {
|
||||||
// tslint:disable-next-line:no-eval
|
// tslint:disable-next-line:no-eval
|
||||||
const undefinedThing = eval('(x) => undefined;');
|
const undefinedThing = eval('(x) => undefined;');
|
||||||
expect(translator.translate(undefinedThing())('defaultValue')).to.equal('defaultValue');
|
expect(translator.translatedAccess(undefinedThing())('defaultValue')).to.equal('defaultValue');
|
||||||
expect(translator.translate(dish).name('defaultValue')).to.not.equal('defaultValue');
|
expect(translator.translatedAccess(dish).name('defaultValue')).to.not.equal('defaultValue');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfStringSubscriptUndefined() {
|
public nestedMetaArrayOfStringSubscriptUndefined() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories[1234]('printer')).to.equal('printer');
|
// tslint:disable-next-line: no-eval
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories[1]('printer')).to.not.equal('printer');
|
const workingTranslation = eval('translator.translatedAccess(dish).offers[0].inPlace.categories[1](\'printer\');');
|
||||||
|
// tslint:disable-next-line: no-eval
|
||||||
|
const defaultValueTranslation = eval('translator.translatedAccess(dish).offers[0].inPlace.categories[1234](\'printer\');');
|
||||||
|
|
||||||
|
expect(defaultValueTranslation).to.equal('printer');
|
||||||
|
expect(workingTranslation).to.not.equal('printer');
|
||||||
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
public reaccessWithChangedSourceOmitsLRUCache() {
|
||||||
|
const translatorDE = new SCThingTranslator('de');
|
||||||
|
const dishCopy = clone(dish);
|
||||||
|
const translatedDish = translatorDE.translatedAccess(dish);
|
||||||
|
const distructivelyTranslatedDish = translatorDE.translate(dish);
|
||||||
|
|
||||||
|
(dishCopy.origin as SCThingRemoteOrigin).name = 'tranlator.spec';
|
||||||
|
expect(translatorDE.translatedAccess(dishCopy)).not.to.deep.equal(translatedDish);
|
||||||
|
expect(translatorDE.translate(dishCopy)).not.to.equal(distructivelyTranslatedDish);
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public changingTranslatorLanguageFlushesItsLRUCache() {
|
public changingTranslatorLanguageFlushesItsLRUCache() {
|
||||||
const translatorDE = new SCThingTranslator('de');
|
const translatorDE = new SCThingTranslator('de');
|
||||||
expect(translatorDE.translate(dish).name()).to.equal('de-dish-name');
|
expect(translatorDE.translatedAccess(dish).name()).to.equal('de-dish-name');
|
||||||
|
expect(translatorDE.translate(dish).name).to.equal('de-dish-name');
|
||||||
translatorDE.language = 'en';
|
translatorDE.language = 'en';
|
||||||
expect(translatorDE.translate(dish).name()).to.equal('base-dish-name');
|
expect(translatorDE.translatedAccess(dish).name()).to.equal('base-dish-name');
|
||||||
|
expect(translatorDE.translate(dish).name).to.equal('base-dish-name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
@@ -223,7 +290,7 @@ export class TranslationSpecInplace {
|
|||||||
for (let i = 0; i < 201; i++) {
|
for (let i = 0; i < 201; i++) {
|
||||||
const anotherDish = Object.assign({}, dish);
|
const anotherDish = Object.assign({}, dish);
|
||||||
anotherDish.uid = String(i);
|
anotherDish.uid = String(i);
|
||||||
expect(translatorDE.translate(anotherDish).name()).to.equal('de-dish-name');
|
expect(translatorDE.translatedAccess(anotherDish).name()).to.equal('de-dish-name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,20 +301,40 @@ export class MetaTranslationSpec {
|
|||||||
|
|
||||||
@test
|
@test
|
||||||
public consistencyWithMetaClass() {
|
public consistencyWithMetaClass() {
|
||||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
|
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish.type);
|
||||||
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, 'en');
|
const dishMetaTranslationsEN = translatorEN.translatedPropertyNames(dish.type);
|
||||||
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
|
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
|
||||||
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
|
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
|
||||||
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
public retrieveTranslatedPropertyValueType() {
|
||||||
|
const dishTypeDE = translator.translatedPropertyValue(dish.type, 'type');
|
||||||
|
const dishTypeEN = translatorEN.translatedPropertyValue(dish.type, 'type', undefined);
|
||||||
|
const dishTypeBASE = translatorWithFallback.translatedPropertyValue(dish.type, 'type');
|
||||||
|
expect(dishTypeDE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.de.type);
|
||||||
|
expect(dishTypeEN).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||||
|
expect(dishTypeBASE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
public retrieveTranslatedPropertyValueNested() {
|
||||||
|
const dishTypeDE = translator.translatedPropertyValue(dish.type, 'categories', 'main dish');
|
||||||
|
const dishTypeEN = translatorEN.translatedPropertyValue(dish.type, 'categories', 'main dish');
|
||||||
|
const dishTypeBASE = translatorWithFallback.translatedPropertyValue(dish.type, 'categories', 'main dish');
|
||||||
|
expect(dishTypeDE).to.deep.equal(SCDishMeta.getInstance<SCDishMeta>().fieldValueTranslations.de.categories['main dish']);
|
||||||
|
expect(dishTypeEN).to.deep.equal(dish.categories[0]);
|
||||||
|
expect(dishTypeBASE).to.deep.equal(dish.categories[0]);
|
||||||
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public thingWithoutMetaClass() {
|
public thingWithoutMetaClass() {
|
||||||
const dishCopy = clone(dish);
|
const dishCopy = clone(dish);
|
||||||
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
|
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
|
||||||
// this will assign a non existant SCThingType to dishCopy
|
// this will assign a non existant SCThingType to dishCopy
|
||||||
dishCopy.type = typeNonExistant();
|
dishCopy.type = typeNonExistant();
|
||||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy);
|
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy.type);
|
||||||
expect(dishMetaTranslationsDE).to.be.undefined;
|
expect(dishMetaTranslationsDE).to.be.undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {SCArticle, SCArticleWithoutReferences} from '../src/things/article';
|
|||||||
import {SCBook, SCBookWithoutReferences} from '../src/things/book';
|
import {SCBook, SCBookWithoutReferences} from '../src/things/book';
|
||||||
import {SCBuilding, SCBuildingWithoutReferences} from '../src/things/building';
|
import {SCBuilding, SCBuildingWithoutReferences} from '../src/things/building';
|
||||||
import {SCCatalog, SCCatalogWithoutReferences} from '../src/things/catalog';
|
import {SCCatalog, SCCatalogWithoutReferences} from '../src/things/catalog';
|
||||||
|
import {SCContactPoint, SCContactPointWithoutReferences} from '../src/things/contact-point';
|
||||||
import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/things/course-of-studies';
|
import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/things/course-of-studies';
|
||||||
import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/things/date-series';
|
import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/things/date-series';
|
||||||
import {SCDiff, SCDiffWithoutReferences} from '../src/things/diff';
|
import {SCDiff, SCDiffWithoutReferences} from '../src/things/diff';
|
||||||
@@ -126,6 +127,17 @@ assert<Has<SCBuildingPropertyTypes, SCThing>>(false);
|
|||||||
assert<Extends<SCBuildingWithoutReferences, SCThing>>(false);
|
assert<Extends<SCBuildingWithoutReferences, SCThing>>(false);
|
||||||
assert<Extends<SCBuilding, SCThing>>(true);
|
assert<Extends<SCBuilding, SCThing>>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types of properties of SCContactPoint
|
||||||
|
*/
|
||||||
|
type SCContactPointPropertyTypes = PropertyTypesNested<SCContactPoint>;
|
||||||
|
assert<NotHas<SCContactPointPropertyTypes, SCThingWithoutReferences>>(false);
|
||||||
|
assert<Has<SCContactPointPropertyTypes, SCThingWithoutReferences>>(true);
|
||||||
|
assert<NotHas<SCContactPointPropertyTypes, SCThing>>(true);
|
||||||
|
assert<Has<SCContactPointPropertyTypes, SCThing>>(false);
|
||||||
|
assert<Extends<SCContactPointWithoutReferences, SCThing>>(false);
|
||||||
|
assert<Extends<SCContactPoint, SCThing>>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of properties of SCCatalog
|
* Types of properties of SCCatalog
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user