Compare commits

...

22 Commits

Author SHA1 Message Date
Sebastian Lange
2f96bc8569 0.36.0 2020-07-16 11:37:56 +02:00
Rainer Killinger
9ce4026b1a build: lower npm audit vulnerabilities 2020-07-01 08:00:26 +00:00
Rainer Killinger
e434b2d26e test: add tests for translatedThingType function 2020-07-01 08:00:26 +00:00
Rainer Killinger
fe7f1a53ae feat: add function to get translated SCThingType 2020-07-01 08:00:26 +00:00
Frank Nagel
907d61b5d2 ci: Change 'npm audit' failure behaviour
The audit fails only if the results include a vulnerability with a level of
at least 'high' in scheduled pipelines.
2020-06-19 13:12:14 +02:00
Rainer Killinger
5fb9755841 docs: update changelog 2020-05-13 11:59:43 +02:00
Rainer Killinger
e5dd02eeca 0.35.0 2020-05-13 11:59:33 +02:00
Rainer Killinger
e7b4a426a9 test: adapt tests for translatedPropertyNames 2020-05-04 13:09:03 +02:00
Rainer Killinger
7dd74af305 refactor: simplify use of translatedPropertyNames 2020-05-04 13:08:56 +02:00
Rainer Killinger
4409101647 docs: update changelog 2020-04-21 13:40:19 +02:00
Rainer Killinger
3a141e6cf4 0.34.0 2020-04-21 13:40:11 +02:00
Rainer Killinger
8a20e3e873 build: update indirect dependencies 2020-04-14 11:06:27 +02:00
Rainer Killinger
e196303e64 refactor: state explicit type in isThing function 2020-04-14 11:05:09 +02:00
Rainer Killinger
70c1a3eaa3 feat: annotate SCThing uid and url as filterable 2020-04-14 11:03:49 +02:00
Axel Nieder-Vahrenholz
6060113df5 feat: Update src/things/book.ts - made ISBN optional 2020-04-06 09:58:51 +00:00
Rainer Killinger
39d5becb56 test: add all files with functions in coverage 2020-03-09 09:34:34 +00:00
Wieland Schöbl
f5e88569eb feat: add @sortable tags to certain translatable properties 2020-02-21 12:55:59 +01:00
Rainer Killinger
67041aa39d docs: update changelog 2020-02-11 14:39:12 +01:00
Rainer Killinger
18943612a8 0.33.0 2020-02-11 14:39:07 +01:00
Rainer Killinger
d167947e04 refactor: update dependencies 2020-02-11 13:06:03 +01:00
Rainer Killinger
2a0dc812d8 ci: saperate aduit jobs from test stage 2020-02-06 13:23:25 +01:00
Rainer Killinger
cdb8a6507d docs: update changelog 2020-02-04 16:15:26 +01:00
12 changed files with 1923 additions and 974 deletions

View File

@@ -11,6 +11,7 @@ before_script:
stages:
- build
- test
- audit
- deploy
- publish
@@ -26,7 +27,7 @@ build:
expire_in: 1 week
audit:
stage: test
stage: audit
script:
- npm audit
allow_failure: true
@@ -34,9 +35,9 @@ audit:
- schedules
scheduled-audit:
stage: test
stage: audit
script:
- npm audit
- npm audit --audit-level=high
only:
- schedules

View File

@@ -1,10 +1,38 @@
# [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/9658f05))
* translator can now handle enum translations ([abda5cf](https://gitlab.com/openstapps/core/commit/abda5cf))
* 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))
@@ -13,8 +41,8 @@
### Features
* add aggregatable tag for type field ([443cb74](https://gitlab.com/openstapps/core/commit/443cb74))
* add new field sequenceIndex to message ([01f92ba](https://gitlab.com/openstapps/core/commit/01f92ba))
* 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))
@@ -23,7 +51,7 @@
### 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))
@@ -32,7 +60,7 @@
### 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))
@@ -41,7 +69,7 @@
### 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))
@@ -50,12 +78,12 @@
### 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
* 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))
@@ -64,7 +92,7 @@
### Bug Fixes
* correct package job ([d4a8ef6](https://gitlab.com/openstapps/core/commit/d4a8ef6))
* correct package job ([d4a8ef6](https://gitlab.com/openstapps/core/commit/d4a8ef6a9ca69849f8b981804da45e4ba907f37b))
@@ -73,7 +101,7 @@
### 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))
@@ -82,12 +110,12 @@
### 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
* 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)
@@ -96,8 +124,8 @@
### 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)
* support 404 (resource not found) error on plugin register route ([43851d2](https://gitlab.com/openstapps/core/commit/43851d2))
* 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/43851d2d358c4c342a80a863b059a6447c819c04))
@@ -110,8 +138,8 @@
### Features
* add ES annotations ([9c424b0](https://gitlab.com/openstapps/core/commit/9c424b0))
* add static typed test for consistency ([ff1f554](https://gitlab.com/openstapps/core/commit/ff1f554)), closes [#71](https://gitlab.com/openstapps/core/issues/71)
* add ES annotations ([9c424b0](https://gitlab.com/openstapps/core/commit/9c424b0f96da26d3aae9ffaadb2c640e7369ca7e))
* add static typed test for consistency ([ff1f554](https://gitlab.com/openstapps/core/commit/ff1f554e0beacb5ce2f3308c8212e2b8e4d8cbb0)), closes [#71](https://gitlab.com/openstapps/core/issues/71)
@@ -120,8 +148,8 @@
### Bug Fixes
* add translations for every SCThing ([f847a2a](https://gitlab.com/openstapps/core/commit/f847a2a))
* rename properties floor and message so that they are not identical to SCThingTypes ([78b64ba](https://gitlab.com/openstapps/core/commit/78b64ba))
* 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/78b64bae08d9ca12badaedf921a24fa5ffe90552))
@@ -130,9 +158,9 @@
### Bug Fixes
* add thing without references, split thing ([da0507e](https://gitlab.com/openstapps/core/commit/da0507e)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
* adjust model to remove references from things without references ([ca72c20](https://gitlab.com/openstapps/core/commit/ca72c20)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
* remove references from origins ([1d6a2b7](https://gitlab.com/openstapps/core/commit/1d6a2b7)), closes [#69](https://gitlab.com/openstapps/core/issues/69)
* 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/ca72c20bd098032745ed0eb6978902b6ff6feac5)), 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)
@@ -141,7 +169,7 @@
### 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))
@@ -158,13 +186,13 @@
### Bug Fixes
* change SCThingMeta getInstance() return value ([4986042](https://gitlab.com/openstapps/core/commit/4986042))
* resolve issues with things that can be offered ([623ed61](https://gitlab.com/openstapps/core/commit/623ed61)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
* 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/623ed613a9405b53a86a33c13d48bc49d48de1ce)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
### 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))
@@ -173,7 +201,7 @@
### 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))
@@ -182,14 +210,14 @@
### Bug Fixes
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9))
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fca))
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9eb810de94ca0bb6e1298799ee3f550145))
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fcac42c21c68b5c6aa6bcf9bbdecfdf84de7))
### Features
* add conditional "maps" for associated types ([c8bda2e](https://gitlab.com/openstapps/core/commit/c8bda2e)), closes [#50](https://gitlab.com/openstapps/core/issues/50)
* provide sample JSON files with the package ([5d1e79d](https://gitlab.com/openstapps/core/commit/5d1e79d)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
* 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/5d1e79d4879e6ce8f43d4cebb9d8c8500d5d16b7)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
@@ -198,12 +226,12 @@
### 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
* 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))
@@ -212,8 +240,8 @@
### Features
* add laboratory and computer as room categories ([a0ab72e](https://gitlab.com/openstapps/core/commit/a0ab72e)), closes [#33](https://gitlab.com/openstapps/core/issues/33)
* add maxRequestBodySize in backend configuration ([b5bd09e](https://gitlab.com/openstapps/core/commit/b5bd09e))
* 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/b5bd09e40bfb49463815538ebaa44ff53b5d7b92))
@@ -222,7 +250,7 @@
### 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))
@@ -235,7 +263,7 @@
### 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))
@@ -252,7 +280,7 @@
### 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))
@@ -261,7 +289,7 @@
### 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))
@@ -270,13 +298,13 @@
### 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
* 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 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 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/a4f3fab033ca18352c0119061f2d0e64252d4bbb)), closes [#12](https://gitlab.com/openstapps/core/issues/12)
@@ -285,7 +313,7 @@
### 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))
@@ -294,9 +322,9 @@
### Features
* add base scheme for academic degrees ([85c8fc4](https://gitlab.com/openstapps/core/commit/85c8fc4))
* add schema for course of studies ([2d4a76a](https://gitlab.com/openstapps/core/commit/2d4a76a))
* add tool to generate documentation for routes ([1a07df2](https://gitlab.com/openstapps/core/commit/1a07df2))
* 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/2d4a76a555603a395c81a7a92ce5d95ed04de9de))
* add tool to generate documentation for routes ([1a07df2](https://gitlab.com/openstapps/core/commit/1a07df2d676895264f43b0138645d7c13f60c9db))
@@ -304,12 +332,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
* add core ([2d770dd](https://gitlab.com/openstapps/core/commit/2d770dd))
* add core ([2d770dd](https://gitlab.com/openstapps/core/commit/2d770dde4464dc4cf4cdc29927aa4e4382914148))

2678
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.32.0",
"version": "0.36.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -36,7 +36,7 @@
"Imran Hossain",
"Jovan Krunić <jovan.krunic@gmail.com>",
"Michel Jonathan Schmitz",
"Rainer Killinger",
"Rainer Killinger <mail-openstapps@killinger.co>",
"Sebastian Lange",
"Wieland Schöbl",
"Roman Klopsch"
@@ -44,30 +44,30 @@
"dependencies": {
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/node": "10.14.14",
"@types/node": "10.17.14",
"fast-clone": "1.5.13",
"http-status-codes": "1.3.2",
"http-status-codes": "1.4.0",
"json-patch": "0.7.0",
"jsonschema": "1.2.4",
"jsonschema": "1.2.5",
"ts-optchain": "0.1.3"
},
"devDependencies": {
"@krlwlfrt/async-pool": "0.1.0",
"@openstapps/configuration": "0.21.1",
"@openstapps/core-tools": "0.8.0",
"@openstapps/configuration": "0.23.0",
"@openstapps/core-tools": "0.14.0",
"@openstapps/logger": "0.4.0",
"@types/chai": "4.1.7",
"@types/rimraf": "2.0.2",
"@types/chai": "4.2.8",
"@types/rimraf": "2.0.3",
"chai": "4.2.0",
"commander": "2.20.0",
"conditional-type-checks": "1.0.1",
"conventional-changelog-cli": "2.0.23",
"conditional-type-checks": "1.0.5",
"conventional-changelog-cli": "2.0.31",
"mocha": "6.2.0",
"mocha-typescript": "1.1.17",
"nyc": "14.1.1",
"rimraf": "2.6.3",
"rimraf": "3.0.2",
"source-map-support": "0.5.13",
"ts-node": "8.3.0",
"ts-node": "8.6.2",
"tslint": "5.18.0",
"typedoc": "0.14.2",
"typescript": "3.5.3"
@@ -84,6 +84,8 @@
"include": [
"src/protocol/route.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/guards.ts"
],

View File

@@ -15,6 +15,7 @@
/**
* 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}$
* @see http://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
*/

View File

@@ -41,7 +41,7 @@ export function isThing(something: unknown): something is SCThing {
return Object
.values(SCThingType)
.indexOf(type) >= 0;
.indexOf(type as SCThingType) >= 0;
}
/**

View File

@@ -62,6 +62,12 @@ export interface SCThingWithCategories<T, U extends SCThingWithCategoriesSpecifi
*/
export interface SCThingWithCategoriesTranslatableProperties
extends SCThingTranslatableProperties {
/**
* translations of the categories of a thing with categories
*
* @sortable ducet
*/
categories?: string[];
}
/**
@@ -94,6 +100,7 @@ export interface SCThingWithCategoriesSpecificValues {
/**
* Category specific name of a thing
*
* @sortable ducet
* @text
*/
name?: string;

View File

@@ -102,6 +102,8 @@ export interface SCThingWithoutReferences {
uid: SCUuid;
/**
* URL of the thing
*
* @filterable
*/
url?: string;
}
@@ -223,6 +225,7 @@ export interface SCThingTranslatableProperties {
/**
* Translation of the name of the thing
*
* @sortable ducet
* @text
*/
name?: string;

View File

@@ -42,7 +42,7 @@ export interface SCBookWithoutReferences
* @filterable
* @keyword
*/
isbn: string;
isbn?: string;
/**
* Number of pages of a book

View File

@@ -218,15 +218,35 @@ export class SCThingTranslator {
* All the values will be set to the known translations of the property/key name
* @example
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
* @param thing The thing whose property names will be translated
* @param type The type whose property names will be translated
* @param language The language all property names will be translated to
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
*/
public translatedPropertyNames<T extends SCThing>(thing: T,
public translatedPropertyNames<T extends SCThing>(type: SCThingType,
language?: keyof SCTranslations<T>): T | undefined {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
}
/**
* Given a SCThingType this function will translate it
*
* @param type The type that will be translated
* @param language The language the type will be translated to
* @returns Known translation of type parameter
*/
public translatedThingType<T extends unknown>(type: SCThingType,
language?: keyof SCTranslations<T>): string {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
const metaClass = this.getMetaClassInstance(type);
if (typeof metaClass.fieldValueTranslations[targetLanguage] !== 'undefined' &&
typeof metaClass.fieldValueTranslations[targetLanguage].type !== 'undefined') {
return metaClass.fieldValueTranslations[targetLanguage].type as string ;
}
return type;
}
/**

View File

@@ -24,8 +24,7 @@ import {DeclarationReflection, ProjectReflection} from 'typedoc';
import {ArrayType, IntrinsicType, ReferenceType, StringLiteralType, Type, UnionType} from 'typedoc/dist/lib/models';
process.on('unhandledRejection', (err) => {
Logger.error('UNHANDLED REJECTION', err.stack);
process.exit(1);
throw err;
});
/**

View File

@@ -256,20 +256,30 @@ export class MetaTranslationSpec {
@test
public consistencyWithMetaClass() {
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, 'en');
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish.type);
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish.type, 'en');
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
}
@test
public retrieveTranslatedThingType() {
const dishTypeDE = translator.translatedThingType(dish.type);
const dishTypeEN = translator.translatedThingType(dish.type, 'en');
const dishTypeBASE = translatorWithFallback.translatedThingType(dish.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 thingWithoutMetaClass() {
const dishCopy = clone(dish);
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
// this will assign a non existant SCThingType to dishCopy
dishCopy.type = typeNonExistant();
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy);
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy.type);
expect(dishMetaTranslationsDE).to.be.undefined;
}
}