mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-17 23:22:54 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a84d12f26 | ||
|
|
b621a12689 | ||
|
|
6ffa4efbaf | ||
|
|
e41169a9c7 | ||
|
|
46194b177b | ||
|
|
ff1f554e0b | ||
|
|
9c424b0f96 | ||
|
|
55b5248660 |
@@ -50,6 +50,21 @@ test:
|
||||
- report
|
||||
- coverage
|
||||
|
||||
package:
|
||||
dependencies:
|
||||
- build
|
||||
tags:
|
||||
- secrecy
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc
|
||||
- npm publish
|
||||
only:
|
||||
- /^v[0-9]+.[0-9]+.[0-9]+$/
|
||||
artifacts:
|
||||
paths:
|
||||
- lib
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
||||
# [0.20.0](https://gitlab.com/openstapps/core/compare/v0.19.0...v0.20.0) (2019-06-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add translations for every SCThing ([f847a2a](https://gitlab.com/openstapps/core/commit/f847a2a))
|
||||
* rename properties floor and message so that they are not identical to SCThingTypes ([78b64ba](https://gitlab.com/openstapps/core/commit/78b64ba))
|
||||
|
||||
|
||||
|
||||
# [0.19.0](https://gitlab.com/openstapps/core/compare/v0.18.0...v0.19.0) (2019-05-17)
|
||||
|
||||
|
||||
|
||||
18
README.md
18
README.md
@@ -29,3 +29,21 @@ To generate a documentation for the routes use the following command.
|
||||
```shell
|
||||
node --require ts-node/register src/cli.ts routes PATH/TO/ROUTES.md
|
||||
```
|
||||
|
||||
### Annotations
|
||||
|
||||
Annotations are used to add additional informations to fields, which are used to autogenerate mappings from the core objects.
|
||||
External dependencies can not be covered by the annotations. Documentation about some of the annotations can be found in: [typedoc](https://typedoc.org/guides/doccomments/)
|
||||
|
||||
| annotation | description | parameters |
|
||||
|-------------------|-------------------------------------------|---------------|
|
||||
| `@aggregatable` | used for generating of aggregations of the field if the core schema is used to put data into a database/key-value store | |
|
||||
| `@float` | number field is interpreted as float | |
|
||||
| `@indexable` | marks the type as indexable if the core schema is used to put data into a database/key-value store| |
|
||||
| `@integer` | number field is interpreted as integer | |
|
||||
| `@keyword` | string field is interpreted as keyword | |
|
||||
| `@sortable` | field is sortable if the core schema is used to put data into a database/key-value store | sort method to be used: ducet, price, distance |
|
||||
| `@text` | string field is interpreted as text | |
|
||||
| `@validatable` | marks the type as validatable if the core schema is used to put data into a database/key-value store | |
|
||||
|
||||
|
||||
|
||||
201
package-lock.json
generated
201
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/core",
|
||||
"version": "0.20.0",
|
||||
"version": "0.21.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -81,9 +81,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@babel/runtime": {
|
||||
"version": "7.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.4.tgz",
|
||||
"integrity": "sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==",
|
||||
"version": "7.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.5.tgz",
|
||||
"integrity": "sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.2"
|
||||
@@ -146,27 +146,62 @@
|
||||
"dev": true
|
||||
},
|
||||
"@openstapps/configuration": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.14.0.tgz",
|
||||
"integrity": "sha512-0eiupryX/yOD76Q/aNgY//0uoJ0v2OEGRunqQjfAXW5humTRH2wUKv89IdqbhqV+w2At0Qlg0xd8SvfSNL43JQ==",
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.18.0.tgz",
|
||||
"integrity": "sha512-Ufi3jzCozVqCymNeaeRzuOHO2Yd5qXJ10uF4xNHk6Q4LFD9NAMMBkYbawkjmecZoNR+Llqs4AnwSxIkuEAxcxA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "10.14.4",
|
||||
"@types/node": "10.14.7",
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/yaml": "1.0.2",
|
||||
"chalk": "2.4.2",
|
||||
"commander": "2.20.0",
|
||||
"semver": "6.0.0",
|
||||
"semver": "6.1.0",
|
||||
"tslint": "5.16.0",
|
||||
"tslint-eslint-rules": "5.4.0",
|
||||
"yaml": "1.5.0"
|
||||
"yaml": "1.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "10.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.4.tgz",
|
||||
"integrity": "sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg==",
|
||||
"version": "10.14.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.7.tgz",
|
||||
"integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A==",
|
||||
"dev": true
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.1.0.tgz",
|
||||
"integrity": "sha512-kCqEOOHoBcFs/2Ccuk4Xarm/KiWRSLEX9CAZF8xkJ6ZPlIoTZ8V5f7J16vYLJqDbR7KrxTJpR2lqjIEm2Qx9cQ==",
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.16.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz",
|
||||
"integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^3.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.13.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.29.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.7.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
|
||||
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -241,26 +276,45 @@
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.1.0.tgz",
|
||||
"integrity": "sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arg": "^4.1.0",
|
||||
"diff": "^3.1.0",
|
||||
"make-error": "^1.1.1",
|
||||
"source-map-support": "^0.5.6",
|
||||
"yn": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@openstapps/logger": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.1.0.tgz",
|
||||
"integrity": "sha512-5z7Yf3WrzayEVNPp1TBoGiCVgPlQtqzOFh0yQ06gac/vFedWLPLBmENGDdRoEKar8bXzghkxDLy6Rvj/8HEQaQ==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.2.1.tgz",
|
||||
"integrity": "sha512-6+F1nxEBuNTrd3hhBxKnvkH8B84HvB/dVmoMP9Pmv2g3mL3pYJ9l2BBGaACDRA7oUCyLpbNQw+4Kf+VdyzOttw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "10.14.6",
|
||||
"@types/nodemailer": "4.6.8",
|
||||
"@types/node": "10.14.7",
|
||||
"@types/nodemailer": "6.1.0",
|
||||
"chalk": "2.4.2",
|
||||
"flatted": "2.0.0",
|
||||
"nodemailer": "6.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "10.14.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.7.tgz",
|
||||
"integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/nodemailer": {
|
||||
"version": "4.6.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-4.6.8.tgz",
|
||||
"integrity": "sha512-IX1P3bxDP1VIdZf6/kIWYNmSejkYm9MOyMEtoDFi4DVzKjJ3kY4GhOcOAKs6lZRjqVVmF9UjPOZXuQczlpZThw==",
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.1.0.tgz",
|
||||
"integrity": "sha512-WysSJ4sGW2Aum1Cs6HFosZdlR3WUzX0XoSLsI53q77gLd4wDfE84OXffZu5/nLIjeKh4SwfTsdrKsgBL9WowMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
@@ -368,9 +422,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.14.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.6.tgz",
|
||||
"integrity": "sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg=="
|
||||
"version": "10.14.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.8.tgz",
|
||||
"integrity": "sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw=="
|
||||
},
|
||||
"@types/nodemailer": {
|
||||
"version": "4.6.5",
|
||||
@@ -692,6 +746,12 @@
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"conditional-type-checks": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/conditional-type-checks/-/conditional-type-checks-1.0.1.tgz",
|
||||
"integrity": "sha512-+O/IE/QGjXzdk4ttJFLRQm8pofQE0KZZmgcamquUGhHfaZt0UTZMlklqW0J9tWO8HQvC70cPahEAVMwSfeqtuQ==",
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog": {
|
||||
"version": "3.1.8",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.8.tgz",
|
||||
@@ -836,9 +896,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog-writer": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.5.tgz",
|
||||
"integrity": "sha512-g/Myp4MaJ1A+f7Ai+SnVhkcWtaHk6flw0SYN7A+vQ+MTu0+gSovQWs4Pg4NtcNUcIztYQ9YHsoxHP+GGQplI7Q==",
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.6.tgz",
|
||||
"integrity": "sha512-ou/sbrplJMM6KQpR5rKFYNVQYesFjN7WpNGdudQSWNi6X+RgyFUcSv871YBYkrUYV9EX8ijMohYVzn9RUb+4ag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"compare-func": "^1.3.1",
|
||||
@@ -848,17 +908,9 @@
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash": "^4.2.1",
|
||||
"meow": "^4.0.0",
|
||||
"semver": "^5.5.0",
|
||||
"semver": "^6.0.0",
|
||||
"split": "^1.0.0",
|
||||
"through2": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.7.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
|
||||
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"conventional-commits-filter": {
|
||||
@@ -872,13 +924,13 @@
|
||||
}
|
||||
},
|
||||
"conventional-commits-parser": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.0.2.tgz",
|
||||
"integrity": "sha512-y5eqgaKR0F6xsBNVSQ/5cI5qIF3MojddSUi1vKIggRkqUTbkqFKH9P5YX/AT1BVZp9DtSzBTIkvjyVLotLsVog==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.0.3.tgz",
|
||||
"integrity": "sha512-KaA/2EeUkO4bKjinNfGUyqPTX/6w9JGshuQRik4r/wJz7rUw3+D3fDG6sZSEqJvKILzKXFQuFkpPLclcsAuZcg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"JSONStream": "^1.0.4",
|
||||
"is-text-path": "^1.0.0",
|
||||
"is-text-path": "^2.0.0",
|
||||
"lodash": "^4.2.1",
|
||||
"meow": "^4.0.0",
|
||||
"split2": "^2.0.0",
|
||||
@@ -1729,6 +1781,11 @@
|
||||
"integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==",
|
||||
"dev": true
|
||||
},
|
||||
"http-status-codes": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/http-status-codes/-/http-status-codes-1.3.2.tgz",
|
||||
"integrity": "sha512-nDUtj0ltIt08tGi2VWSpSzNNFye0v3YSe9lX3lIqLTuVvvRiYCvs4QQBSHo0eomFYw1wlUuofurUAlTm+vHnXg=="
|
||||
},
|
||||
"humanize-string": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/humanize-string/-/humanize-string-2.1.0.tgz",
|
||||
@@ -1884,12 +1941,12 @@
|
||||
}
|
||||
},
|
||||
"is-text-path": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz",
|
||||
"integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-2.0.0.tgz",
|
||||
"integrity": "sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"text-extensions": "^1.0.0"
|
||||
"text-extensions": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"is-utf8": {
|
||||
@@ -3490,9 +3547,9 @@
|
||||
}
|
||||
},
|
||||
"text-extensions": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz",
|
||||
"integrity": "sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-2.0.0.tgz",
|
||||
"integrity": "sha512-F91ZqLgvi1E0PdvmxMgp+gcf6q8fMH7mhdwWfzXnl1k+GbpQDmi8l7DzLC5JTASKbwpY3TfxajAUzAXcv2NmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"through": {
|
||||
@@ -3561,16 +3618,24 @@
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.1.0.tgz",
|
||||
"integrity": "sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A==",
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.2.0.tgz",
|
||||
"integrity": "sha512-m8XQwUurkbYqXrKqr3WHCW310utRNvV5OnRVeISeea7LoCWVcdfeB/Ntl8JYWFh+WRoUAdBgESrzKochQt7sMw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arg": "^4.1.0",
|
||||
"diff": "^3.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"source-map-support": "^0.5.6",
|
||||
"yn": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"diff": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz",
|
||||
"integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"ts-optchain": {
|
||||
@@ -3585,9 +3650,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.16.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz",
|
||||
"integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==",
|
||||
"version": "5.17.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.17.0.tgz",
|
||||
"integrity": "sha512-pflx87WfVoYepTet3xLfDOLDm9Jqi61UXIKePOuca0qoAZyrGWonDG9VTbji58Fy+8gciUn8Bt7y69+KEVjc/w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
@@ -3596,7 +3661,7 @@
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^3.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.13.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
@@ -3631,9 +3696,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.10.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.10.0.tgz",
|
||||
"integrity": "sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q==",
|
||||
"version": "3.13.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.13.0.tgz",
|
||||
"integrity": "sha512-wRtEjVU8Su72sDIDoqno5Scwt8x4eaF0teKO3m4hu8K1QFPnIZMM88CLafs2tapUeWnY9SwwO3bWeOt2uauBcg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
@@ -3696,15 +3761,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz",
|
||||
"integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==",
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz",
|
||||
"integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.5.12",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.12.tgz",
|
||||
"integrity": "sha512-KeQesOpPiZNgVwJj8Ge3P4JYbQHUdZzpx6Fahy6eKAYRSV4zhVmLXoC+JtOeYxcHCHTve8RG1ZGdTvpeOUM26Q==",
|
||||
"version": "3.5.14",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.14.tgz",
|
||||
"integrity": "sha512-dgyjIw8KFK6AyVl5vm2tEqPewv5TKGEiiVFLI1LbF+oHua/Njd8tZk3lIbF1AWU1rNdEg7scaceADb4zqCcWXg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
@@ -3868,12 +3933,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"yaml": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.5.0.tgz",
|
||||
"integrity": "sha512-nKxSWOa7vxAP2pikrGxbkZsG/garQseRiLn9mIDjzwoQsyVy7ZWIpLoARejnINGGLA4fttuzRFFNxxbsztdJgw==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.6.0.tgz",
|
||||
"integrity": "sha512-iZfse3lwrJRoSlfs/9KQ9iIXxs9++RvBFVzAqbbBiFT+giYtyanevreF9r61ZTbGMgWQBxAua3FzJiniiJXWWw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.4.3"
|
||||
"@babel/runtime": "^7.4.5"
|
||||
}
|
||||
},
|
||||
"yargs": {
|
||||
|
||||
27
package.json
27
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/core",
|
||||
"version": "0.20.0",
|
||||
"version": "0.21.0",
|
||||
"description": "StAppsCore - Generalized model of data",
|
||||
"keywords": [
|
||||
"Model",
|
||||
@@ -20,10 +20,13 @@
|
||||
"compile": "rimraf lib && tsc",
|
||||
"documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib",
|
||||
"pack": "openstapps-core-tools pack",
|
||||
"postversion": "npm run changelog",
|
||||
"prepublishOnly": "npm ci && npm run build",
|
||||
"preversion": "npm run prepublishOnly",
|
||||
"push": "git push && git push origin \"v$npm_package_version\"",
|
||||
"schema": "node --max-old-space-size=8192 --stack-size=10240 ./node_modules/.bin/openstapps-core-tools schema src/core lib/schema",
|
||||
"test": "nyc mocha --require ts-node/register --require source-map-support/register --ui mocha-typescript test/*.spec.ts",
|
||||
"tslint": "tslint 'src/**/*.ts'"
|
||||
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
|
||||
},
|
||||
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
||||
"contributors": [
|
||||
@@ -39,31 +42,33 @@
|
||||
"dependencies": {
|
||||
"@types/geojson": "1.0.6",
|
||||
"@types/json-patch": "0.0.30",
|
||||
"@types/node": "10.14.6",
|
||||
"@types/node": "10.14.8",
|
||||
"fast-clone": "1.5.13",
|
||||
"http-status-codes": "1.3.2",
|
||||
"json-patch": "0.7.0",
|
||||
"jsonschema": "1.2.4",
|
||||
"ts-optchain": "0.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@krlwlfrt/async-pool": "0.1.0",
|
||||
"@openstapps/configuration": "0.14.0",
|
||||
"@openstapps/configuration": "0.18.0",
|
||||
"@openstapps/core-tools": "0.6.0",
|
||||
"@openstapps/logger": "0.1.0",
|
||||
"@openstapps/logger": "0.2.1",
|
||||
"@types/chai": "4.1.7",
|
||||
"@types/rimraf": "2.0.2",
|
||||
"chai": "4.2.0",
|
||||
"commander": "2.20.0",
|
||||
"conditional-type-checks": "1.0.1",
|
||||
"conventional-changelog-cli": "2.0.21",
|
||||
"mocha": "6.1.4",
|
||||
"mocha-typescript": "1.1.17",
|
||||
"nyc": "14.1.1",
|
||||
"rimraf": "2.6.3",
|
||||
"source-map-support": "0.5.12",
|
||||
"ts-node": "8.1.0",
|
||||
"tslint": "5.16.0",
|
||||
"ts-node": "8.2.0",
|
||||
"tslint": "5.17.0",
|
||||
"typedoc": "0.14.2",
|
||||
"typescript": "3.4.5"
|
||||
"typescript": "3.5.1"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
@@ -75,7 +80,8 @@
|
||||
"include": [
|
||||
"src/core/Route.ts",
|
||||
"src/core/Thing.ts",
|
||||
"src/core/Translator.ts"
|
||||
"src/core/Translator.ts",
|
||||
"src/core/types/Guards.ts"
|
||||
],
|
||||
"exclude": [],
|
||||
"extension": [
|
||||
@@ -89,6 +95,9 @@
|
||||
},
|
||||
"openstappsConfiguration": {
|
||||
"hasCli": false,
|
||||
"ignoreCiEntries": [
|
||||
"build"
|
||||
],
|
||||
"standardBuild": false,
|
||||
"standardDocumentation": false
|
||||
}
|
||||
|
||||
100109
reflection.json
100109
reflection.json
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/Video';
|
||||
/**
|
||||
* A map of things, from type to meta data
|
||||
*/
|
||||
export const SCClasses: { [K in SCThingType]: any } = {
|
||||
export const SCClasses: { [K in SCThingType]: object } = {
|
||||
/* tslint:enable */
|
||||
'academic event': SCAcademicEventMeta,
|
||||
'article': SCArticleMeta,
|
||||
|
||||
@@ -48,7 +48,8 @@ export enum SCRouteHttpVerbs {
|
||||
/**
|
||||
* The constructor of an error response
|
||||
*/
|
||||
export type SCErrorResponseConstructor = new (...args: any) => SCErrorResponse;
|
||||
// tslint:disable-next-line:no-any
|
||||
export type SCErrorResponseConstructor = new (...args: any[]) => SCErrorResponse;
|
||||
|
||||
/**
|
||||
* A description of a route
|
||||
@@ -94,19 +95,41 @@ export interface SCRoute {
|
||||
* An abstract route
|
||||
*/
|
||||
export abstract class SCAbstractRoute implements SCRoute {
|
||||
/**
|
||||
* @see SCRoute.errorNames
|
||||
*/
|
||||
errorNames: SCErrorResponseConstructor[] = [];
|
||||
/**
|
||||
* @see SCRoute.method
|
||||
*/
|
||||
method: SCRouteHttpVerbs = SCRouteHttpVerbs.GET;
|
||||
/**
|
||||
* @see SCRoute.obligatoryParameters
|
||||
*/
|
||||
obligatoryParameters?: SCMap<string>;
|
||||
/**
|
||||
* @see SCRoute.requestBodyName
|
||||
*/
|
||||
requestBodyName = 'any';
|
||||
/**
|
||||
* @see SCRoute.responseBodyName
|
||||
*/
|
||||
responseBodyName = 'any';
|
||||
/**
|
||||
* @see SCRoute.statusCodeSuccess
|
||||
*/
|
||||
statusCodeSuccess = 200;
|
||||
/**
|
||||
* @see SCRoute.urlFragment
|
||||
*/
|
||||
urlFragment = '/';
|
||||
|
||||
public getUrlFragment(parameters?: SCMap<string>): string {
|
||||
if (typeof parameters === 'undefined') {
|
||||
parameters = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "compiled" URL fragment
|
||||
*
|
||||
* @param parameters Parameters to compile URL fragment with
|
||||
*/
|
||||
public getUrlFragment(parameters: SCMap<string> = {}): string {
|
||||
let obligatoryParameters: string[] = [];
|
||||
|
||||
if (typeof this.obligatoryParameters === 'object') {
|
||||
@@ -126,14 +149,13 @@ export abstract class SCAbstractRoute implements SCRoute {
|
||||
|
||||
const parameter = part.substr(1);
|
||||
|
||||
// @ts-ignore
|
||||
if (typeof parameters[parameter] === 'undefined') {
|
||||
throw new Error(`Parameter '${parameter}' not provided.`);
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return parameters[parameter];
|
||||
}).join('/');
|
||||
})
|
||||
.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,22 +54,29 @@ export enum SCThingType {
|
||||
export interface SCThingWithoutReferences {
|
||||
/**
|
||||
* Alternate names of the thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
alternateNames?: string[];
|
||||
/**
|
||||
* Description of the thing
|
||||
*
|
||||
* @minLength 1
|
||||
* @text
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* URL of an image of the thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
image?: string;
|
||||
/**
|
||||
* Name of the thing
|
||||
*
|
||||
* @minLength 1
|
||||
* @sortable ducet
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
@@ -80,6 +87,9 @@ export interface SCThingWithoutReferences {
|
||||
translations?: SCTranslations<SCThingTranslatableProperties>;
|
||||
/**
|
||||
* Type of the thing
|
||||
*
|
||||
* @sortable ducet
|
||||
* @aggregatable
|
||||
*/
|
||||
type: SCThingType;
|
||||
/**
|
||||
@@ -143,6 +153,8 @@ export interface SCThingRemoteOrigin extends SCThingOrigin {
|
||||
|
||||
/**
|
||||
* Name of the origin
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
|
||||
@@ -200,10 +212,14 @@ export interface SCThingUserOrigin extends SCThingOrigin {
|
||||
export interface SCThingTranslatableProperties {
|
||||
/**
|
||||
* Translation of the description of the thing
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Translation of the name of the thing
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
@@ -218,6 +234,8 @@ export interface SCThingTranslatableProperties {
|
||||
export interface SCThingTranslatablePropertyOrigin {
|
||||
/**
|
||||
* Translation of the name of the origin
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
@@ -271,14 +289,16 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
|
||||
},
|
||||
};
|
||||
|
||||
// tslint:disable:static-this
|
||||
/**
|
||||
* Function to retrieve typed singleton instance
|
||||
*/
|
||||
public static getInstance<T extends SCThingMeta>(): T {
|
||||
if (!this._instance.has(this.name)) {
|
||||
this._instance.set(this.name, new this());
|
||||
if (!SCThingMeta._instance.has(this.name)) {
|
||||
SCThingMeta._instance.set(this.name, new this());
|
||||
}
|
||||
return this._instance.get(this.name) as T;
|
||||
|
||||
return SCThingMeta._instance.get(this.name) as T;
|
||||
}
|
||||
|
||||
protected constructor() {
|
||||
|
||||
@@ -21,6 +21,9 @@ import {SCTranslations} from './types/i18n';
|
||||
import clone = require('fast-clone');
|
||||
import {Defined, OCType} from 'ts-optchain';
|
||||
|
||||
// tslint:disable:no-any
|
||||
const standardCacheSize = 200;
|
||||
|
||||
/**
|
||||
* SCThingTranslator class
|
||||
*/
|
||||
@@ -35,20 +38,19 @@ export class SCThingTranslator {
|
||||
* Property representing the translators base language
|
||||
* This means every translation is given for this language
|
||||
*/
|
||||
private cache: LRUCache<SCThing>;
|
||||
private readonly cache: LRUCache<SCThing>;
|
||||
|
||||
/**
|
||||
* Property providing a mapping from a SCThingType to its known own meta class
|
||||
*/
|
||||
private metaClasses: typeof SCClasses;
|
||||
private readonly metaClasses: typeof SCClasses;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @example
|
||||
* // returns translator instance for german
|
||||
* new SCThingTranslator('de');
|
||||
*/
|
||||
constructor(language: keyof SCTranslations<SCThing>, cacheCapacity: number = 200) {
|
||||
constructor(language: keyof SCTranslations<SCThing>, cacheCapacity: number = standardCacheSize) {
|
||||
this.cache = new LRUCache(cacheCapacity);
|
||||
this._language = language;
|
||||
this.metaClasses = SCClasses;
|
||||
@@ -79,16 +81,19 @@ export class SCThingTranslator {
|
||||
* @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)
|
||||
*/
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
private deeptranslate<T>(data?: T): OCType<T> {
|
||||
const proxy = new Proxy(
|
||||
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
|
||||
{
|
||||
get: (target, key) => {
|
||||
const obj: any = target();
|
||||
|
||||
return this.deeptranslate(obj[key]);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -109,30 +114,34 @@ export class SCThingTranslator {
|
||||
|
||||
// Assigns every property in fieldTranslations to the known base language translation
|
||||
if (typeof metaClass.fieldTranslations.en !== 'undefined') {
|
||||
Object.keys(metaClass.fieldTranslations.en).forEach((key) => {
|
||||
Object.keys(metaClass.fieldTranslations.en)
|
||||
.forEach((key) => {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations.en[key];
|
||||
});
|
||||
}
|
||||
|
||||
// Assigns every property in fieldTranslations to the known translation in given language
|
||||
if (typeof metaClass.fieldTranslations[language] !== 'undefined') {
|
||||
Object.keys(metaClass.fieldTranslations[language]).forEach((key) => {
|
||||
Object.keys(metaClass.fieldTranslations[language])
|
||||
.forEach((key) => {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations[language][key];
|
||||
});
|
||||
}
|
||||
|
||||
return fieldTranslations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns meta class needed for translations given a SCThingType
|
||||
*
|
||||
* @param thingType
|
||||
* @param thingType Type of the thing
|
||||
* @returns An instance of the metaclass
|
||||
*/
|
||||
private getMetaClassInstance(thingType: SCThingType): any {
|
||||
if (thingType in this.metaClasses) {
|
||||
return new (this.metaClasses as any)[thingType]();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -151,10 +160,12 @@ export class SCThingTranslator {
|
||||
return instance;
|
||||
}
|
||||
if (typeof metaClass.fieldValueTranslations[language] !== 'undefined') {
|
||||
Object.keys(metaClass.fieldValueTranslations[language]).forEach((key) => {
|
||||
Object.keys(metaClass.fieldValueTranslations[language])
|
||||
.forEach((key) => {
|
||||
if (metaClass.fieldValueTranslations[language][key] instanceof Object) {
|
||||
// Assigns known translations of subproperties to property in given language (e.g. categories)
|
||||
Object.keys((instance as any)[key]).forEach((subKey) => {
|
||||
Object.keys((instance as any)[key])
|
||||
.forEach((subKey) => {
|
||||
(instance as any)[key][subKey] =
|
||||
metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]];
|
||||
});
|
||||
@@ -164,6 +175,7 @@ export class SCThingTranslator {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -192,6 +204,7 @@ export class SCThingTranslator {
|
||||
}
|
||||
const objTranslated = this.translateWholeThingDestructively(clone(obj));
|
||||
this.cache.putObject(objTranslated);
|
||||
|
||||
return this.deeptranslate(objTranslated[key]);
|
||||
},
|
||||
},
|
||||
@@ -204,13 +217,13 @@ export class SCThingTranslator {
|
||||
* @example
|
||||
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
||||
* @param language The language the object is translated to
|
||||
* @param thingType
|
||||
* @param thingType Type of the thing
|
||||
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
||||
*/
|
||||
public translatedPropertyNames<T extends SCThing>(thing: T,
|
||||
language?: keyof SCTranslations<T>): T | undefined {
|
||||
const targetLanguage = (language) ? language : this.language;
|
||||
// return {...{}, ...this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T};
|
||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||
|
||||
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
|
||||
}
|
||||
|
||||
@@ -224,26 +237,29 @@ export class SCThingTranslator {
|
||||
*/
|
||||
public translateWholeThingDestructively(instance: any,
|
||||
language?: keyof SCTranslations<any>): any {
|
||||
const targetLanguage = (language) ? language : this.language;
|
||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||
let nextInstance = instance;
|
||||
// Recursively call this function on all nested SCThings, arrays and objects
|
||||
Object.keys(instance).forEach((key) => {
|
||||
Object.keys(nextInstance)
|
||||
.forEach((key) => {
|
||||
if (
|
||||
isThing((instance as any)[key]) ||
|
||||
instance[key] instanceof Array ||
|
||||
instance[key] instanceof Object) {
|
||||
instance[key] = this.translateWholeThingDestructively(instance[key], targetLanguage);
|
||||
isThing((nextInstance as any)[key]) ||
|
||||
nextInstance[key] instanceof Array ||
|
||||
nextInstance[key] instanceof Object) {
|
||||
nextInstance[key] = this.translateWholeThingDestructively(nextInstance[key], targetLanguage);
|
||||
}
|
||||
});
|
||||
|
||||
// Spread variable translations given by the connector into thing
|
||||
if (typeof instance.translations !== 'undefined') {
|
||||
if (typeof instance.translations![targetLanguage] !== 'undefined') {
|
||||
instance = {...instance, ...instance.translations![targetLanguage]} as typeof instance;
|
||||
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(instance, targetLanguage);
|
||||
return instance;
|
||||
this.replaceAvailableMetaFieldValueTranslations(nextInstance, targetLanguage);
|
||||
|
||||
return nextInstance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -256,15 +272,14 @@ class LRUCache<T> {
|
||||
/**
|
||||
* Map property that manages cached content
|
||||
*/
|
||||
private entries: Map<string, T> = new Map<string, T>();
|
||||
private readonly entries: Map<string, T> = new Map<string, T>();
|
||||
|
||||
/**
|
||||
* Property representing cache maximum capacity
|
||||
*/
|
||||
private maxEntries: number;
|
||||
private readonly maxEntries: number;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @example
|
||||
* // returns LRUCache instance with a maximum capacity of 500
|
||||
* new LRUCache(500);
|
||||
@@ -307,11 +322,12 @@ class LRUCache<T> {
|
||||
}
|
||||
|
||||
const entry = this.entries.get(key);
|
||||
if (entry) {
|
||||
if (typeof entry !== 'undefined') {
|
||||
// LRU behavior
|
||||
this.entries.delete(key);
|
||||
this.entries.set(key, entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -324,7 +340,8 @@ class LRUCache<T> {
|
||||
public put(key: string, content: T) {
|
||||
if (this.entries.size >= this.maxEntries) {
|
||||
// LRU behavior
|
||||
const keyToDelete = this.entries.keys().next().value;
|
||||
const keyToDelete = this.entries.keys()
|
||||
.next().value;
|
||||
this.entries.delete(keyToDelete);
|
||||
}
|
||||
this.entries.set(key, content);
|
||||
|
||||
@@ -28,12 +28,16 @@ export interface SCAcademicDegreeWithoutReferences
|
||||
/**
|
||||
* The achievable academic degree with academic field specification
|
||||
* (eg. Master of Science)
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
academicDegreewithField: string;
|
||||
|
||||
/**
|
||||
* The achievable academic degree with academic field specification
|
||||
* shorted (eg. M.Sc.).
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
academicDegreewithFieldShort: string;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ export interface SCAcademicTermWithoutReferences
|
||||
extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Short name of the academic term, using the given pattern
|
||||
*
|
||||
* @aggregatable
|
||||
* @keyword
|
||||
*/
|
||||
acronym: string;
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ export interface SCCreativeWorkWithoutReferences
|
||||
|
||||
/**
|
||||
* Keywords of the creative work
|
||||
*
|
||||
* @aggregatable
|
||||
* @keyword
|
||||
*/
|
||||
keywords?: string[];
|
||||
|
||||
@@ -79,6 +82,8 @@ export interface SCCreativeWorkTranslatableProperties
|
||||
extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Translation of the keywords of the creative work
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
keywords?: string[];
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ export interface SCEventWithoutReferences
|
||||
* Maximum number of participants of the event
|
||||
*
|
||||
* A maximum number of people that can participate in the event.
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
maximumParticipants?: number;
|
||||
|
||||
@@ -35,6 +37,8 @@ export interface SCEventWithoutReferences
|
||||
* Remaining attendee capacity of the event
|
||||
*
|
||||
* This number represents the remaining open spots.
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
remainingAttendeeCapacity?: number;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ export interface SCPlaceWithoutReferences
|
||||
|
||||
/**
|
||||
* Opening hours of the place
|
||||
*
|
||||
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||
* @keyword
|
||||
*/
|
||||
openingHours?: string;
|
||||
|
||||
@@ -63,6 +65,9 @@ export interface SCPlace
|
||||
*/
|
||||
export interface SCPlaceWithoutReferencesTranslatableProperties
|
||||
extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Address of a place
|
||||
*/
|
||||
address?: SCPostalAddress;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ import {SCISO8601Date} from '../types/Time';
|
||||
export interface SCPriceGroup {
|
||||
/**
|
||||
* Default price of the thing
|
||||
*
|
||||
* @sortable price
|
||||
* @float
|
||||
*/
|
||||
default: number;
|
||||
}
|
||||
@@ -36,16 +39,25 @@ export interface SCAcademicPriceGroup
|
||||
extends SCPriceGroup {
|
||||
/**
|
||||
* Price for employees
|
||||
*
|
||||
* @sortable price
|
||||
* @float
|
||||
*/
|
||||
employee?: number;
|
||||
|
||||
/**
|
||||
* Price for guests
|
||||
*
|
||||
* @sortable price
|
||||
* @float
|
||||
*/
|
||||
guest?: number;
|
||||
|
||||
/**
|
||||
* Price for students
|
||||
*
|
||||
* @sortable price
|
||||
* @float
|
||||
*/
|
||||
student?: number;
|
||||
}
|
||||
@@ -115,6 +127,8 @@ export interface SCThingThatCanBeOfferedTranslatableProperties
|
||||
extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Availability of an offer
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
'offers[].availability'?: string;
|
||||
}
|
||||
@@ -141,7 +155,10 @@ export type SCThingThatCanBeOfferedAvailability =
|
||||
export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup> implements
|
||||
SCMetaTranslations<SCThingThatCanBeOffered<T>> {
|
||||
|
||||
protected static _instance: any;
|
||||
/**
|
||||
* Instance
|
||||
*/
|
||||
protected static _instance = new Map<string, unknown>();
|
||||
|
||||
/**
|
||||
* Translations of fields
|
||||
@@ -169,12 +186,17 @@ export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup> implements
|
||||
},
|
||||
};
|
||||
|
||||
// tslint:disable:static-this
|
||||
/**
|
||||
* Function to retrieve typed singleton instance (including generics)
|
||||
*/
|
||||
public static getInstance<T extends SCPriceGroup>(): SCThingThatCanBeOfferedMeta<T> {
|
||||
return this._instance || (this._instance = new this<T>());
|
||||
}
|
||||
if (!SCThingThatCanBeOfferedMeta._instance.has(this.name)) {
|
||||
SCThingThatCanBeOfferedMeta._instance.set(this.name, new SCThingThatCanBeOfferedMeta<T>());
|
||||
}
|
||||
|
||||
return SCThingThatCanBeOfferedMeta._instance
|
||||
.get(this.name) as SCThingThatCanBeOfferedMeta<T>;
|
||||
}
|
||||
protected constructor() {}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,15 @@ import {SCMap} from '../types/Map';
|
||||
* A thing without references with categories
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* `T` should be a union type - e.g. `T = 'foo' | 'bar' | 'foobar';`
|
||||
* `T` should be a string literal union type - e.g. `T = 'foo' | 'bar' | 'foobar';`
|
||||
*/
|
||||
export interface SCThingWithCategoriesWithoutReferences<T, U extends SCThingWithCategoriesSpecificValues>
|
||||
extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Categories of a thing with categories
|
||||
*
|
||||
* @sortable ducet
|
||||
* @aggregatable
|
||||
*/
|
||||
categories: T[];
|
||||
|
||||
@@ -72,26 +75,36 @@ export interface SCThingWithCategoriesTranslatableProperties
|
||||
export interface SCThingWithCategoriesSpecificValues {
|
||||
/**
|
||||
* Category specific alternate names of a thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
alternateNames?: string[];
|
||||
|
||||
/**
|
||||
* Category specific description of a thing
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* URL of a category specific image of a thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
image?: string;
|
||||
|
||||
/**
|
||||
* Category specific name of a thing
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Category specific URL of a thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
@@ -103,7 +116,10 @@ export interface SCThingWithCategoriesSpecificValues {
|
||||
export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
|
||||
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
|
||||
|
||||
protected static _instance: any;
|
||||
/**
|
||||
* Instance
|
||||
*/
|
||||
protected static _instance = new Map<string, unknown>();
|
||||
|
||||
/**
|
||||
* Translations of fields
|
||||
@@ -133,11 +149,18 @@ export class SCThingWithCategoriesWithoutReferencesMeta<T, U>
|
||||
},
|
||||
};
|
||||
|
||||
// tslint:disable:static-this
|
||||
/**
|
||||
* Function to retrieve typed singleton instance (including generics)
|
||||
*/
|
||||
public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> {
|
||||
return this._instance || (this._instance = new this<T, U>());
|
||||
if (!SCThingWithCategoriesWithoutReferencesMeta._instance.has(this.name)) {
|
||||
SCThingWithCategoriesWithoutReferencesMeta._instance
|
||||
.set(this.name, new SCThingWithCategoriesWithoutReferencesMeta<T, U>());
|
||||
}
|
||||
|
||||
return SCThingWithCategoriesWithoutReferencesMeta._instance
|
||||
.get(this.name) as SCThingWithCategoriesWithoutReferencesMeta<T, U>;
|
||||
}
|
||||
|
||||
protected constructor() {
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {
|
||||
BAD_GATEWAY,
|
||||
BAD_REQUEST, CONFLICT, INTERNAL_SERVER_ERROR,
|
||||
METHOD_NOT_ALLOWED, NOT_ACCEPTABLE, NOT_FOUND,
|
||||
REQUEST_TOO_LONG,
|
||||
TOO_MANY_REQUESTS,
|
||||
UNSUPPORTED_MEDIA_TYPE,
|
||||
} from 'http-status-codes';
|
||||
import {ValidationError} from 'jsonschema';
|
||||
import {SCPluginMetaData} from '../routes/plugin/PluginRegisterRequest';
|
||||
|
||||
@@ -24,7 +32,7 @@ export interface SCErrorResponse extends Error {
|
||||
/**
|
||||
* Additional data that describes the error
|
||||
*/
|
||||
additionalData?: any;
|
||||
additionalData?: unknown;
|
||||
|
||||
/**
|
||||
* HTTP status code to return this error with
|
||||
@@ -49,7 +57,7 @@ export abstract class SCError implements SCErrorResponse {
|
||||
* @param statusCode HTTP status code to return this error with
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(public name: string, public message: string, public statusCode: number, stack?: boolean) {
|
||||
constructor(public name: string, public message: string, public statusCode: number, stack = false) {
|
||||
// generate stacktrace if needed
|
||||
if (stack) {
|
||||
this.stack = (new Error()).stack;
|
||||
@@ -73,7 +81,7 @@ export class SCValidationErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(errors: ValidationError[], stack?: boolean) {
|
||||
super('ValidationError', 'Validation of request failed', 400, stack);
|
||||
super('ValidationError', 'Validation of request failed', BAD_REQUEST, stack);
|
||||
this.additionalData = errors;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +96,7 @@ export class SCUnsupportedMediaTypeErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('UnsupportedMediaTypeError', 'Unsupported media type', 415, stack);
|
||||
super('UnsupportedMediaTypeError', 'Unsupported media type', UNSUPPORTED_MEDIA_TYPE, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +110,7 @@ export class SCMethodNotAllowedErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('MethodNotAllowedError', 'HTTP method is not allowed on this route', 405, stack);
|
||||
super('MethodNotAllowedError', 'HTTP method is not allowed on this route', METHOD_NOT_ALLOWED, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,10 +120,11 @@ export class SCMethodNotAllowedErrorResponse extends SCError {
|
||||
export class SCRequestBodyTooLargeErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SCRequestBodyTooLargeErrorResponse
|
||||
*
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('RequestBodyTooLargeError', 'The request body is too large.', 413, stack);
|
||||
super('RequestBodyTooLargeError', 'The request body is too large.', REQUEST_TOO_LONG, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +138,12 @@ export class SCTooManyRequestsErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('TooManyRequestsError', 'Too many requests. You can not submit more than 5 queries an once', 429, stack);
|
||||
super(
|
||||
'TooManyRequestsError',
|
||||
'Too many requests. You can not submit more than 5 queries an once',
|
||||
TOO_MANY_REQUESTS,
|
||||
stack,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +157,7 @@ export class SCNotFoundErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('NotFoundError', 'Resource not found', 404, stack);
|
||||
super('NotFoundError', 'Resource not found', NOT_FOUND, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +173,7 @@ export class SCParametersNotAcceptable extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('ParametersNotAcceptable', message, 406, stack);
|
||||
super('ParametersNotAcceptable', message, NOT_ACCEPTABLE, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,8 +196,8 @@ export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
|
||||
* @param plugin Provides meta data of a registered plugin, which is in a conflict with the plugin we want to register
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, plugin: SCPluginMetaData, stack?: boolean) {
|
||||
super('SCPluginAlreadyRegisteredError', message, 409, stack);
|
||||
constructor(message: string, plugin: SCPluginMetaData, stack = false) {
|
||||
super('SCPluginAlreadyRegisteredError', message, CONFLICT, stack);
|
||||
if (stack) {
|
||||
this.additionalData = plugin;
|
||||
}
|
||||
@@ -201,7 +215,7 @@ export class SCPluginRegisteringFailedErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('PluginRegisteringFailedError', message, 500, stack);
|
||||
super('PluginRegisteringFailedError', message, INTERNAL_SERVER_ERROR, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +230,7 @@ export class SCSyntaxErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('SyntaxError', message, 400, stack);
|
||||
super('SyntaxError', message, BAD_REQUEST, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +250,8 @@ export class SCInternalServerErrorResponse extends SCError {
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
* and the internal server error should be displayed to the client
|
||||
*/
|
||||
constructor(err?: Error, stack?: boolean) {
|
||||
super('InternalServerError', 'Internal server error', 502, stack);
|
||||
constructor(err?: Error, stack = false) {
|
||||
super('InternalServerError', 'Internal server error', BAD_GATEWAY, stack);
|
||||
|
||||
if (stack) {
|
||||
this.additionalData = err;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
@@ -47,7 +48,7 @@ export class SCIndexRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCIndexRequest';
|
||||
this.responseBodyName = 'SCIndexResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,13 @@ import {SCBackendConfiguration} from '../../../types/config/Backend';
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCIndexResponse {
|
||||
/**
|
||||
* @see SCAppConfiguration
|
||||
*/
|
||||
app: SCAppConfiguration;
|
||||
|
||||
/**
|
||||
* @see SCBackendConfiguration
|
||||
*/
|
||||
backend: SCBackendConfiguration;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCThings} from '../../../../Classes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
@@ -53,7 +54,7 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
|
||||
};
|
||||
this.requestBodyName = 'SCThingUpdateRequest';
|
||||
this.responseBodyName = 'SCThingUpdateResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/:TYPE/:UID';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCUuid} from '../../../types/UUID';
|
||||
import {
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
|
||||
/**
|
||||
* Request to check the availability of books
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid;
|
||||
@@ -80,7 +82,7 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBookAvailabilityRequest';
|
||||
this.responseBodyName = 'SCBookAvailabilityResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/bookAvailability';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '../../../base/
|
||||
|
||||
/**
|
||||
* List of availabilities of a book
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBookAvailabilityResponse = Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCThingType} from '../../../Thing';
|
||||
import {SCISO8601Date} from '../../../types/Time';
|
||||
@@ -78,7 +79,7 @@ export class SCBulkRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBulkRequest';
|
||||
this.responseBodyName = 'SCBulkResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/bulk';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {CREATED} from 'http-status-codes';
|
||||
import {SCThings} from '../../../../Classes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
|
||||
/**
|
||||
* Request to add a thing to a bulk
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBulkAddRequest = SCThings;
|
||||
@@ -51,7 +53,7 @@ export class SCBulkAddRoute extends SCAbstractRoute {
|
||||
};
|
||||
this.requestBodyName = 'SCBulkAddRequest';
|
||||
this.responseBodyName = 'SCBulkAddResponse';
|
||||
this.statusCodeSuccess = 201;
|
||||
this.statusCodeSuccess = CREATED;
|
||||
this.urlFragment = '/bulk/:UID';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
/**
|
||||
* Response to a request to add a thing to a bulk
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkAddResponse {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {NO_CONTENT} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../../Route';
|
||||
import {
|
||||
SCInternalServerErrorResponse,
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
|
||||
/**
|
||||
* Request to change the bulk state to done (close the bulk process)
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkDoneRequest {
|
||||
@@ -51,7 +53,7 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
|
||||
};
|
||||
this.requestBodyName = 'SCBulkDoneRequest';
|
||||
this.responseBodyName = 'SCBulkDoneResponse';
|
||||
this.statusCodeSuccess = 204;
|
||||
this.statusCodeSuccess = NO_CONTENT;
|
||||
this.urlFragment = '/bulk/:UID/done';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
/**
|
||||
* Response to a request to change the state of a bulk to done
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkDoneResponse {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {NO_CONTENT} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCMessage} from '../../../things/Message';
|
||||
import {
|
||||
@@ -52,7 +53,7 @@ export class SCFeedbackRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCFeedbackRequest';
|
||||
this.responseBodyName = 'SCFeedbackResponse';
|
||||
this.statusCodeSuccess = 204;
|
||||
this.statusCodeSuccess = NO_CONTENT;
|
||||
this.urlFragment = '/feedback';
|
||||
}
|
||||
}
|
||||
@@ -74,7 +75,7 @@ export interface SCFeedbackRequestMetaData {
|
||||
/**
|
||||
* Scope/app state at feedback invocation
|
||||
*/
|
||||
scope: any;
|
||||
scope: unknown;
|
||||
|
||||
/**
|
||||
* Whether or not the feedback is sendable
|
||||
@@ -84,7 +85,7 @@ export interface SCFeedbackRequestMetaData {
|
||||
/**
|
||||
* App state that feedback was invoked from
|
||||
*/
|
||||
state: any;
|
||||
state: unknown;
|
||||
|
||||
/**
|
||||
* User agent
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {Schema} from 'jsonschema';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {
|
||||
@@ -108,7 +109,7 @@ export class SCPluginRegisterRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCPluginRegisterRequest';
|
||||
this.responseBodyName = 'SCPluginRegisterResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/plugin/register';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCMap} from '../../../types/Map';
|
||||
import {
|
||||
@@ -54,7 +55,7 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCMultiSearchRequest';
|
||||
this.responseBodyName = 'SCMultiSearchResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/search/multi';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {OK} from 'http-status-codes';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCSearchContext} from '../../../types/config/Backend';
|
||||
import {SCSearchFilter} from '../../../types/filters/Abstract';
|
||||
@@ -85,7 +86,7 @@ export class SCSearchRoute extends SCAbstractRoute {
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCSearchRequest';
|
||||
this.responseBodyName = 'SCSearchResponse';
|
||||
this.statusCodeSuccess = 200;
|
||||
this.statusCodeSuccess = OK;
|
||||
this.urlFragment = '/search';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,16 @@ export interface SCAcademicEventWithoutReferences
|
||||
SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Majors of the academic event that this event belongs to
|
||||
*
|
||||
* @aggregatable
|
||||
* @keyword
|
||||
*/
|
||||
majors?: string[];
|
||||
|
||||
/**
|
||||
* Original unmapped category from the source of the academic event
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
originalCategory?: string;
|
||||
|
||||
@@ -54,6 +59,7 @@ export interface SCAcademicEventWithoutReferences
|
||||
* An academic event
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCAcademicEvent
|
||||
extends SCEvent, SCAcademicEventWithoutReferences,
|
||||
@@ -95,11 +101,15 @@ export interface SCAcademicEventTranslatableProperties
|
||||
extends SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* Translations of the majors of the academic event that this event belongs to
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
majors?: string[];
|
||||
|
||||
/**
|
||||
* Translation of the original unmapped category from the source of the academic event
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
originalCategory?: string;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ export interface SCArticleWithoutReferences
|
||||
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Article itself as markdown
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
articleBody: string;
|
||||
|
||||
@@ -54,6 +56,7 @@ export interface SCArticleWithoutReferences
|
||||
* An article
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCArticle
|
||||
extends SCCreativeWork, SCArticleWithoutReferences,
|
||||
@@ -81,6 +84,8 @@ export interface SCArticleTranslatableProperties
|
||||
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
|
||||
/**
|
||||
* Translation of the article itself as markdown
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
articleBody?: string[];
|
||||
}
|
||||
|
||||
@@ -30,16 +30,22 @@ export interface SCBookWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences {
|
||||
/**
|
||||
* Edition of a book
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
bookEdition?: string;
|
||||
|
||||
/**
|
||||
* ISBN of a book
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
isbn: string;
|
||||
|
||||
/**
|
||||
* Number of pages of a book
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
numberOfPages?: number;
|
||||
|
||||
@@ -58,6 +64,7 @@ export interface SCBookWithoutReferences
|
||||
* A book
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCBook
|
||||
extends SCCreativeWork, SCBookWithoutReferences {
|
||||
@@ -84,6 +91,8 @@ export interface SCBookTranslatableFields
|
||||
extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties {
|
||||
/**
|
||||
* Translation of an edition of a book
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
bookEdition?: string;
|
||||
}
|
||||
|
||||
@@ -43,11 +43,16 @@ export interface SCBuildingWithoutReferences
|
||||
SCPlaceWithoutReferences {
|
||||
/**
|
||||
* Categories of a building
|
||||
*
|
||||
* @sortable ducet
|
||||
* @aggregatable
|
||||
*/
|
||||
categories: SCBuildingCategories[];
|
||||
|
||||
/**
|
||||
* List of floor names of the place
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
floors?: string[];
|
||||
|
||||
@@ -66,6 +71,7 @@ export interface SCBuildingWithoutReferences
|
||||
* A building
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCBuilding
|
||||
extends SCBuildingWithoutReferences, SCPlace,
|
||||
@@ -83,6 +89,9 @@ export interface SCBuilding
|
||||
|
||||
export interface SCBuildingTranslatableProperties
|
||||
extends SCPlaceWithoutReferencesTranslatableProperties, SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* @see SCBuilding.floors
|
||||
*/
|
||||
floors?: string[];
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface SCCatalogWithoutReferences
|
||||
* Level of the catalog (0 for 'root catalog', 1 for its subcatalog, 2 for its subcatalog etc.)
|
||||
*
|
||||
* Needed for keeping order in catalog inheritance array.
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
level: number;
|
||||
|
||||
@@ -44,7 +46,8 @@ export interface SCCatalogWithoutReferences
|
||||
/**
|
||||
* A catalog
|
||||
*
|
||||
* @validatable
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCCatalog
|
||||
extends SCCatalogWithoutReferences, SCThing,
|
||||
|
||||
@@ -38,6 +38,8 @@ export interface SCCourseOfStudiesWithoutReferences
|
||||
|
||||
/**
|
||||
* Actual major of the course of studies (eg. physics)
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
major: string;
|
||||
|
||||
@@ -66,6 +68,7 @@ export interface SCCourseOfStudiesWithoutReferences
|
||||
* A course of studies
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCCourseOfStudies
|
||||
extends SCCourseOfStudiesWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>, SCAcademicDegree {
|
||||
|
||||
@@ -34,6 +34,8 @@ export interface SCSportCoursePriceGroup
|
||||
extends SCAcademicPriceGroup {
|
||||
/**
|
||||
* Price for alumnis
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
alumni?: number;
|
||||
}
|
||||
@@ -60,6 +62,8 @@ export interface SCDateSeriesWithoutReferences
|
||||
|
||||
/**
|
||||
* Frequency of the date series
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
frequency: string;
|
||||
|
||||
@@ -78,6 +82,7 @@ export interface SCDateSeriesWithoutReferences
|
||||
* A date series
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCDateSeries
|
||||
extends SCDateSeriesWithoutReferences,
|
||||
@@ -167,5 +172,8 @@ export class SCDateSeriesMeta
|
||||
*/
|
||||
export interface SCDateSeriesTranslatableProperties
|
||||
extends SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* @see SCDateSeriesWithoutReferences.frequency
|
||||
*/
|
||||
frequency?: string;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ export interface SCDiffWithoutReferences
|
||||
* A diff
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCDiff
|
||||
extends SCDiffWithoutReferences, SCThing {
|
||||
|
||||
@@ -37,11 +37,16 @@ export interface SCDishWithoutReferences
|
||||
SCThingWithCategoriesWithoutReferences<SCDishCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Additives of the dish
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
additives?: string[];
|
||||
|
||||
/**
|
||||
* Category of the dish
|
||||
*
|
||||
* @sortable ducet
|
||||
* @aggregatable
|
||||
*/
|
||||
categories: SCDishCategories[];
|
||||
|
||||
@@ -70,6 +75,7 @@ export interface SCDishWithoutReferences
|
||||
* A dish
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCDish
|
||||
extends SCDishWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
@@ -104,11 +110,15 @@ export interface SCDishTranslatableProperties
|
||||
export interface SCDishCharacteristic {
|
||||
/**
|
||||
* URL of an image of the characteristic
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
image?: string;
|
||||
|
||||
/**
|
||||
* Name of the characteristic
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
@@ -132,36 +142,50 @@ export type SCDishCategories =
|
||||
export interface SCNutritionInformation {
|
||||
/**
|
||||
* Number of calories contained (in kcal)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
calories?: number;
|
||||
|
||||
/**
|
||||
* Content of carbohydrates (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
carbohydrateContent?: number;
|
||||
|
||||
/**
|
||||
* Content of fat (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
fatContent?: number;
|
||||
|
||||
/**
|
||||
* Content of proteins (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
proteinContent?: number;
|
||||
|
||||
/**
|
||||
* Content of salt (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
saltContent?: number;
|
||||
|
||||
/**
|
||||
* Content of saturated fat (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
saturatedFatContent?: number;
|
||||
|
||||
/**
|
||||
* Content of sugar (in grams)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
sugarContent?: number;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface SCFavoriteWithoutReferences
|
||||
* A favorite
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCFavorite
|
||||
extends SCSaveableThing<SCFavoriteDataTypes>, SCFavoriteWithoutReferences {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace';
|
||||
import {SCThingMeta, SCThingTranslatableProperties, SCThingType, SCThingWithoutReferences} from '../Thing';
|
||||
@@ -26,13 +27,15 @@ export interface SCFloorWithoutReferences
|
||||
extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Floor name in the place it is in e.g. "first floor", "ground floor". This doesn't reference the building name.
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
floorName: string;
|
||||
|
||||
/**
|
||||
* Floor plan
|
||||
*/
|
||||
plan: SCFloorFeatureCollectionWithPlaces<LineString, any>;
|
||||
plan: SCFloorFeatureCollectionWithPlaces<LineString>;
|
||||
|
||||
/**
|
||||
* Translated fields of a floor
|
||||
@@ -49,6 +52,7 @@ export interface SCFloorWithoutReferences
|
||||
* A floor
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCFloor
|
||||
extends SCFloorWithoutReferences, SCThingInPlace {
|
||||
@@ -66,19 +70,19 @@ export interface SCFloor
|
||||
/**
|
||||
* A feature collection
|
||||
*/
|
||||
export interface SCFloorFeatureCollectionWithPlaces<T extends GeometryObject, P = any>
|
||||
extends FeatureCollection<T, P> {
|
||||
export interface SCFloorFeatureCollectionWithPlaces<T extends GeometryObject>
|
||||
extends FeatureCollection<T> {
|
||||
/**
|
||||
* Features of the collection
|
||||
*/
|
||||
features: Array<SCFloorFeatureWithPlace<T, P>>;
|
||||
features: Array<SCFloorFeatureWithPlace<T>>;
|
||||
}
|
||||
|
||||
/***
|
||||
* A feature with a place
|
||||
*/
|
||||
export interface SCFloorFeatureWithPlace<T extends GeometryObject, P = any>
|
||||
extends Feature<T, P> {
|
||||
export interface SCFloorFeatureWithPlace<T extends GeometryObject>
|
||||
extends Feature<T> {
|
||||
/**
|
||||
* The place of the feature
|
||||
*/
|
||||
@@ -92,6 +96,8 @@ export interface SCFloorTranslatableProperties
|
||||
extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Translation of the floor name
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
floorName?: string;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ export interface SCMessageWithoutReferences
|
||||
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody: string;
|
||||
|
||||
@@ -58,6 +60,7 @@ export interface SCMessageWithoutReferences
|
||||
* A message
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCMessage
|
||||
extends SCCreativeWork, SCMessageWithoutReferences {
|
||||
@@ -87,6 +90,8 @@ export interface SCMessageTranslatableProperties
|
||||
extends SCCreativeWorkTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody?: string;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface SCOrganizationWithoutReferences
|
||||
* An organization
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCOrganization
|
||||
extends SCOrganizationWithoutReferences, SCThingInPlace {
|
||||
|
||||
@@ -27,6 +27,8 @@ export interface SCPersonWithoutReferences
|
||||
extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Additional first names of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
additionalName?: string;
|
||||
|
||||
@@ -39,16 +41,22 @@ export interface SCPersonWithoutReferences
|
||||
* The private email address of the person.
|
||||
*
|
||||
* @TJS-format email
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The family name of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
familyName: string;
|
||||
|
||||
/**
|
||||
* The private fax number of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
faxNumber?: string;
|
||||
|
||||
@@ -59,26 +67,36 @@ export interface SCPersonWithoutReferences
|
||||
|
||||
/**
|
||||
* The first name of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
givenName: string;
|
||||
|
||||
/**
|
||||
* Honorific prefix of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
honorificPrefix?: string;
|
||||
|
||||
/**
|
||||
* Honorific suffix of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
honorificSuffix?: string;
|
||||
|
||||
/**
|
||||
* Titles of jobs that the person has.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
jobTitles?: string[];
|
||||
|
||||
/**
|
||||
* The complete name of the person combining all the parts of the name into one.
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
|
||||
@@ -89,6 +107,8 @@ export interface SCPersonWithoutReferences
|
||||
|
||||
/**
|
||||
* The private telephone number of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
telephone?: string;
|
||||
|
||||
@@ -102,6 +122,7 @@ export interface SCPersonWithoutReferences
|
||||
* A person
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPerson
|
||||
extends SCPersonWithoutReferences, SCThing {
|
||||
@@ -210,26 +231,36 @@ export interface SCContactPoint {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export interface SCPointOfInterestWithoutReferences
|
||||
* A point of interest
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPointOfInterest
|
||||
extends SCPointOfInterestWithoutReferences, SCThingInPlace, SCPlace,
|
||||
|
||||
@@ -57,6 +57,8 @@ export interface SCRoomWithoutReferences
|
||||
SCThingWithCategoriesWithoutReferences<SCRoomCategories, SCRoomSpecificValues> {
|
||||
/**
|
||||
* The name of the floor in which the room is in.
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
floorName?: string;
|
||||
|
||||
@@ -82,6 +84,7 @@ export interface SCRoomWithoutReferences
|
||||
* A room
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCRoom
|
||||
extends SCRoomWithoutReferences, SCThingInPlace, SCThingThatAcceptsPayments, SCPlace,
|
||||
@@ -106,6 +109,8 @@ export interface SCRoomSpecificValues
|
||||
extends SCThingWithCategoriesSpecificValues {
|
||||
/**
|
||||
* Category specific opening hours of the room
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
openingHours?: string;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface SCSemesterWithoutReferences
|
||||
* The short name of the semester, using the given pattern.
|
||||
*
|
||||
* @pattern ^(WS|SS) [0-9]{4}(/[0-9]{2})?$
|
||||
* @keyword
|
||||
*/
|
||||
acronym: string;
|
||||
|
||||
@@ -42,6 +43,7 @@ export interface SCSemesterWithoutReferences
|
||||
* A semester
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCSemester
|
||||
extends SCSemesterWithoutReferences, SCAcademicTerm {
|
||||
|
||||
@@ -41,6 +41,8 @@ export interface SCSettingWithoutReferences
|
||||
inputType: SCSettingInputType;
|
||||
/**
|
||||
* The order number this setting should show up in its category list
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
order: number;
|
||||
/**
|
||||
@@ -85,6 +87,7 @@ export enum SCSettingInputType {
|
||||
* A setting with references
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCSetting
|
||||
extends SCSettingWithoutReferences, SCThing,
|
||||
@@ -115,6 +118,8 @@ export type SCSettingValues = SCSettingValue[];
|
||||
export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* The translations of the possible values of a setting
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
values?: string[];
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface SCSportCourseWithoutReferences
|
||||
* A sport course
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCSportCourse
|
||||
extends SCEvent, SCSportCourseWithoutReferences {
|
||||
|
||||
@@ -34,6 +34,8 @@ export interface SCStudyModuleWithoutReferences
|
||||
|
||||
/**
|
||||
* ECTS points (European Credit Transfer System)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
ects: number;
|
||||
|
||||
@@ -44,6 +46,8 @@ export interface SCStudyModuleWithoutReferences
|
||||
|
||||
/**
|
||||
* Majors that this study module is meant for
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
majors: string[];
|
||||
|
||||
@@ -67,6 +71,7 @@ export interface SCStudyModuleWithoutReferences
|
||||
* A study module
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCStudyModule
|
||||
extends SCStudyModuleWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
|
||||
@@ -111,6 +116,8 @@ export interface SCStudyModuleTranslatableProperties
|
||||
extends SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Translations of the majors that this study module is meant for
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
majors?: string[];
|
||||
|
||||
|
||||
@@ -29,13 +29,15 @@ export interface SCTicketWithoutReferences
|
||||
|
||||
/**
|
||||
* Waiting number of the ticket
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
currentTicketNumber: string;
|
||||
|
||||
/**
|
||||
* Service type of the ticket
|
||||
*/
|
||||
serviceType: any;
|
||||
serviceType: string;
|
||||
|
||||
/**
|
||||
* Type of a ticket
|
||||
@@ -47,6 +49,7 @@ export interface SCTicketWithoutReferences
|
||||
* A ticket
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCTicket
|
||||
extends SCTicketWithoutReferences, SCThingInPlace {
|
||||
|
||||
@@ -53,6 +53,7 @@ export interface SCToDoWithoutReferences
|
||||
* A "to do"
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCToDo
|
||||
extends SCToDoWithoutReferences, SCThing, SCThingWithCategories<string, SCThingWithCategoriesSpecificValues> {
|
||||
|
||||
@@ -22,16 +22,22 @@ export interface SCTourWithoutReferences
|
||||
extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Init script for the tour
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
init?: string;
|
||||
|
||||
/**
|
||||
* Steps of a tour
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
steps: SCTourStep[];
|
||||
|
||||
/**
|
||||
* Type of a tour
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
type: SCThingType.Tour;
|
||||
}
|
||||
@@ -40,6 +46,7 @@ export interface SCTourWithoutReferences
|
||||
* A tour
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCTour
|
||||
extends SCTourWithoutReferences, SCThing {
|
||||
@@ -100,6 +107,8 @@ export type SCTourStep =
|
||||
export interface SCTourStepLocation {
|
||||
/**
|
||||
* Location to go to
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
location: string;
|
||||
|
||||
@@ -120,6 +129,8 @@ export interface SCTourStepTooltip {
|
||||
|
||||
/**
|
||||
* Element that the tooltip shall be pointing at or a list of elements to try in the specified order
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
element: string | string[];
|
||||
|
||||
@@ -135,11 +146,15 @@ export interface SCTourStepTooltip {
|
||||
|
||||
/**
|
||||
* Text that the tooltip shall contain
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* How often it shall be retried
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
tries?: number;
|
||||
|
||||
@@ -175,6 +190,8 @@ export interface SCTourStepMenu {
|
||||
export interface SCTourResolvedElement {
|
||||
/**
|
||||
* Element name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
element: string;
|
||||
}
|
||||
@@ -185,6 +202,8 @@ export interface SCTourResolvedElement {
|
||||
export interface SCTourResolvedEvent {
|
||||
/**
|
||||
* Event name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
event: string;
|
||||
}
|
||||
@@ -205,6 +224,8 @@ export interface SCTourResolvedLocation {
|
||||
export interface SCTourResolvedLocationTypeIs {
|
||||
/**
|
||||
* Specific location name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
is: string;
|
||||
}
|
||||
@@ -215,6 +236,8 @@ export interface SCTourResolvedLocationTypeIs {
|
||||
export interface SCTourResolvedLocationTypeMatch {
|
||||
/**
|
||||
* Regex location name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
match: string;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ export interface SCVideoWithoutReferences
|
||||
|
||||
/**
|
||||
* URLs to a thumbnails for the Video
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
thumbnails?: string[];
|
||||
|
||||
@@ -45,6 +47,8 @@ export interface SCVideoWithoutReferences
|
||||
|
||||
/**
|
||||
* A Transcript of the Video
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
transcript?: string;
|
||||
|
||||
@@ -57,6 +61,8 @@ export interface SCVideoWithoutReferences
|
||||
export interface SCVideoSource {
|
||||
/**
|
||||
* Pixel Height of the Video
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
@@ -67,16 +73,22 @@ export interface SCVideoSource {
|
||||
|
||||
/**
|
||||
* Size of the Video File in bytes
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
size?: number;
|
||||
|
||||
/**
|
||||
* URL to the Video File
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Pixel Width of the Video
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
width?: number;
|
||||
}
|
||||
@@ -94,6 +106,8 @@ export interface SCVideoTrack {
|
||||
|
||||
/**
|
||||
* URL to the Track File
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
@@ -102,6 +116,7 @@ export interface SCVideoTrack {
|
||||
* A video
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCVideo
|
||||
extends SCCreativeWork, SCVideoWithoutReferences {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import {Point, Polygon} from 'geojson';
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* unknown WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
@@ -23,12 +23,25 @@ import {SCTranslations} from './i18n';
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isThing(something: any): something is SCThing {
|
||||
return (
|
||||
typeof something === 'object'
|
||||
&& typeof something.type === 'string'
|
||||
&& Object.values(SCThingType).indexOf(something.type) >= 0
|
||||
);
|
||||
export function isThing(something: unknown): something is SCThing {
|
||||
if (typeof something !== 'object' || something === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!('type' in something)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:completed-docs
|
||||
const type = (something as { type: unknown; }).type;
|
||||
|
||||
if (typeof type !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Object
|
||||
.values(SCThingType)
|
||||
.indexOf(type) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +50,8 @@ export function isThing(something: any): something is SCThing {
|
||||
* @param thing Thing to check
|
||||
*/
|
||||
export function isThingWithTranslations(thing: SCThingWithoutReferences)
|
||||
: thing is SCThingWithoutReferences & { translations: SCTranslations<SCThingTranslatableProperties> } {
|
||||
// tslint:disable-next-line:completed-docs
|
||||
: thing is SCThingWithoutReferences & { translations: SCTranslations<SCThingTranslatableProperties>; } {
|
||||
return typeof thing.translations !== 'undefined';
|
||||
}
|
||||
|
||||
@@ -46,12 +60,34 @@ export function isThingWithTranslations(thing: SCThingWithoutReferences)
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isBulkResponse(something: any): something is SCBulkResponse {
|
||||
return typeof something.expiration === 'string'
|
||||
&& typeof something.source === 'string'
|
||||
&& typeof something.state === 'string'
|
||||
&& typeof something.type === 'string'
|
||||
&& typeof something.uid === 'string';
|
||||
export function isBulkResponse(something: unknown): something is SCBulkResponse {
|
||||
if (typeof something !== 'object' || something === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!('expiration' in something)
|
||||
|| !('source' in something)
|
||||
|| !('state' in something)
|
||||
|| !('type' in something)
|
||||
|| !('uid' in something)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const {expiration, source, state, type, uid} = something as {
|
||||
// tslint:disable:completed-docs
|
||||
expiration: unknown;
|
||||
source: unknown;
|
||||
state: unknown;
|
||||
type: unknown;
|
||||
uid: unknown;
|
||||
// tslint:enable
|
||||
};
|
||||
|
||||
return typeof expiration === 'string'
|
||||
&& typeof source === 'string'
|
||||
&& typeof state === 'string'
|
||||
&& typeof type === 'string'
|
||||
&& typeof uid === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,15 +95,20 @@ export function isBulkResponse(something: any): something is SCBulkResponse {
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isSearchResponse(something: any): something is SCSearchResponse {
|
||||
return Array.isArray(something.data)
|
||||
&& Array.isArray(something.facets)
|
||||
&& typeof something.pagination !== 'undefined'
|
||||
&& typeof something.pagination.count === 'number'
|
||||
&& typeof something.pagination.offset === 'number'
|
||||
&& typeof something.pagination.total === 'number'
|
||||
&& typeof something.stats !== 'undefined'
|
||||
&& typeof something.stats.time === 'number';
|
||||
export function isSearchResponse(something: unknown): something is SCSearchResponse {
|
||||
if (!(typeof something === 'object') || something === null) {
|
||||
return false;
|
||||
}
|
||||
const somethingObject = (something as { [key: string]: { [key: string]: string; }; });
|
||||
|
||||
return Array.isArray(somethingObject.data)
|
||||
&& Array.isArray(somethingObject.facets)
|
||||
&& typeof somethingObject.pagination !== 'undefined'
|
||||
&& typeof somethingObject.pagination.count === 'number'
|
||||
&& typeof somethingObject.pagination.offset === 'number'
|
||||
&& typeof somethingObject.pagination.total === 'number'
|
||||
&& typeof somethingObject.stats !== 'undefined'
|
||||
&& typeof somethingObject.stats.time === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,8 +116,11 @@ export function isSearchResponse(something: any): something is SCSearchResponse
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isMultiSearchResponse(something: any): something is SCMultiSearchResponse {
|
||||
return Object.keys(something).reduce((previousOnesAreSearchResponses, key) => {
|
||||
return previousOnesAreSearchResponses && isSearchResponse(something[key]);
|
||||
}, true as boolean);
|
||||
export function isMultiSearchResponse(something: unknown): something is SCMultiSearchResponse {
|
||||
const initialValue = Object.keys(something as { [key: string]: string; }).length > 0 ? true : false;
|
||||
|
||||
return Object.keys(something as { [key: string]: string; })
|
||||
.reduce((previousOnesAreSearchResponses, key) => {
|
||||
return previousOnesAreSearchResponses && isSearchResponse((something as { [key: string]: string; })[key]);
|
||||
}, initialValue as boolean);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import {Polygon} from 'geojson';
|
||||
import {SCSetting} from '../../things/Setting';
|
||||
import {SCTranslations} from '../i18n';
|
||||
@@ -126,11 +127,11 @@ export interface SCAppConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Map of features
|
||||
*/
|
||||
export interface SCAppConfigurationFeature {
|
||||
/**
|
||||
*
|
||||
* Whether or not widgets are enabled
|
||||
*/
|
||||
widgets: boolean;
|
||||
}
|
||||
|
||||
@@ -176,10 +176,9 @@ export interface SCBackendInternalConfiguration {
|
||||
/**
|
||||
* Configuration of the database
|
||||
*/
|
||||
export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<any> {
|
||||
export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<unknown> {
|
||||
/**
|
||||
* Name of the database used by the backend
|
||||
*/
|
||||
name: string;
|
||||
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export interface SCMonitoringWatcher {
|
||||
/**
|
||||
* Query to execute against the database
|
||||
*/
|
||||
query: any;
|
||||
query: unknown;
|
||||
|
||||
/**
|
||||
* A list of triggers
|
||||
|
||||
@@ -48,7 +48,7 @@ export interface SCSearchAbstractFilter<T extends SCSearchAbstractFilterArgument
|
||||
/**
|
||||
* Arguments for the filter instruction
|
||||
*/
|
||||
export type SCSearchAbstractFilterArguments = SCMap<any>;
|
||||
export type SCSearchAbstractFilterArguments = SCMap<unknown>;
|
||||
|
||||
/**
|
||||
* Available filter instructions
|
||||
|
||||
@@ -22,6 +22,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstrac
|
||||
* Filter for documents where it cannot be safely determined that they are not available
|
||||
*/
|
||||
export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAvailabilityFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'availability';
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter}
|
||||
* This filter can be used to combine multiple filters with boolean operations.
|
||||
*/
|
||||
export interface SCSearchBooleanFilter extends SCSearchAbstractFilter<SCBooleanFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'boolean';
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import {Position} from 'geojson';
|
||||
import {SCThingsField} from '../../Classes';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstract';
|
||||
@@ -22,6 +23,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstrac
|
||||
* Filter for documents that are in the given distance of the given location
|
||||
*/
|
||||
export interface SCSearchDistanceFilter extends SCSearchAbstractFilter<SCSearchAbstractFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'distance';
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from './Abstrac
|
||||
* Filters for documents that match the value on the given field
|
||||
*/
|
||||
export interface SCSearchValueFilter extends SCSearchAbstractFilter<SCValueFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'value';
|
||||
}
|
||||
|
||||
|
||||
@@ -714,6 +714,12 @@ type SCRequiredTranslation<T> = {
|
||||
* Interface to be implemented by all Meta classes
|
||||
*/
|
||||
export interface SCMetaTranslations<T> {
|
||||
/**
|
||||
* Field translations
|
||||
*/
|
||||
fieldTranslations: SCRequiredTranslation<T>;
|
||||
fieldValueTranslations: any;
|
||||
/**
|
||||
* Field value translations
|
||||
*/
|
||||
fieldValueTranslations: unknown;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export interface SCSearchAbstractSort<T extends SCSearchAbstractSortArguments> {
|
||||
/**
|
||||
* Map of arguments for the sort instruction
|
||||
*/
|
||||
export interface SCSearchAbstractSortArguments extends SCMap<any> {
|
||||
export interface SCSearchAbstractSortArguments extends SCMap<unknown> {
|
||||
/**
|
||||
* Field to sort by
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import {Position} from 'geojson';
|
||||
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract';
|
||||
|
||||
@@ -19,6 +20,9 @@ import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract';
|
||||
* Sort instruction to sort by distance
|
||||
*/
|
||||
export interface SCDistanceSort extends SCSearchAbstractSort<SCDistanceSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'distance';
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,8 @@ import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract';
|
||||
* Sort instruction for ducet sort
|
||||
*/
|
||||
export interface SCDucetSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'ducet';
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from './Abstract';
|
||||
* Sort instruction to sort by price
|
||||
*/
|
||||
export interface SCPriceSort extends SCSearchAbstractSort<SCPriceSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'price';
|
||||
}
|
||||
|
||||
|
||||
@@ -14,44 +14,129 @@
|
||||
*/
|
||||
import {expect} from 'chai';
|
||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
||||
import {SCBulkResponse} from '../src/core/protocol/routes/bulk/BulkResponse';
|
||||
import {SCMultiSearchResponse} from '../src/core/protocol/routes/search/MultiSearchResponse';
|
||||
import {SCSearchResponse} from '../src/core/protocol/routes/search/SearchResponse';
|
||||
import {SCThingOriginType, SCThingType} from '../src/core/Thing';
|
||||
import {SCDish} from '../src/core/things/Dish';
|
||||
import {isThing} from '../src/core/types/Guards';
|
||||
import {
|
||||
isBulkResponse,
|
||||
isMultiSearchResponse,
|
||||
isSearchResponse,
|
||||
isThing,
|
||||
isThingWithTranslations,
|
||||
} from '../src/core/types/Guards';
|
||||
|
||||
@suite(timeout(10000), slow(5000))
|
||||
export class GuardsSpec {
|
||||
|
||||
static bulkResponse: SCBulkResponse = {
|
||||
expiration: '2009-06-30T18:30:00+02:00 ',
|
||||
source: 'bar',
|
||||
state: 'done',
|
||||
type: SCThingType.Dish,
|
||||
uid: 'foo',
|
||||
};
|
||||
|
||||
static dishWithTranslation: SCDish = {
|
||||
categories: [
|
||||
'appetizer',
|
||||
],
|
||||
name: 'foo',
|
||||
origin: {
|
||||
created: '',
|
||||
type: SCThingOriginType.User,
|
||||
},
|
||||
translations: {
|
||||
de: {
|
||||
name: 'Foo',
|
||||
},
|
||||
},
|
||||
type: SCThingType.Dish,
|
||||
uid: 'bar',
|
||||
};
|
||||
|
||||
static notADish = {
|
||||
categories: [
|
||||
'appetizer',
|
||||
],
|
||||
name: 'foo',
|
||||
origin: {
|
||||
created: '',
|
||||
type: SCThingOriginType.User,
|
||||
},
|
||||
type: 'foobar',
|
||||
uid: 'bar',
|
||||
};
|
||||
|
||||
static searchResponse: SCSearchResponse = {
|
||||
data: [
|
||||
GuardsSpec.dishWithTranslation,
|
||||
],
|
||||
facets: [
|
||||
{
|
||||
buckets: [
|
||||
{
|
||||
count: 1,
|
||||
key: 'key',
|
||||
},
|
||||
],
|
||||
field: 'field',
|
||||
},
|
||||
],
|
||||
pagination: {
|
||||
count: 1,
|
||||
offset: 0,
|
||||
total: 1,
|
||||
},
|
||||
stats: {
|
||||
time: 1,
|
||||
},
|
||||
};
|
||||
|
||||
@test
|
||||
public isBulkResponse() {
|
||||
expect(isBulkResponse(null)).to.be.equal(false);
|
||||
expect(isBulkResponse(GuardsSpec.dishWithTranslation)).to.be.equal(false);
|
||||
expect(isBulkResponse(GuardsSpec.bulkResponse)).to.be.equal(true);
|
||||
}
|
||||
|
||||
@test
|
||||
public isMultiSearchResponse() {
|
||||
const multiSearchResponse: SCMultiSearchResponse = {
|
||||
foo: GuardsSpec.searchResponse,
|
||||
};
|
||||
expect(isMultiSearchResponse(multiSearchResponse)).to.be.equal(true);
|
||||
const notAMultiSearchResponse = {...multiSearchResponse, ...{bar: 'baz'}};
|
||||
expect(isMultiSearchResponse(notAMultiSearchResponse)).to.be.equal(false);
|
||||
delete multiSearchResponse.foo;
|
||||
expect(isMultiSearchResponse(multiSearchResponse)).to.be.equal(false);
|
||||
}
|
||||
|
||||
@test
|
||||
public isSearchResponse() {
|
||||
const notASearchResponse = {...GuardsSpec.searchResponse};
|
||||
delete notASearchResponse.pagination;
|
||||
expect(isSearchResponse(notASearchResponse)).to.be.equal(false);
|
||||
delete notASearchResponse.data;
|
||||
expect(isSearchResponse(notASearchResponse)).to.be.equal(false);
|
||||
expect(isSearchResponse(null)).to.be.equal(false);
|
||||
expect(isSearchResponse(GuardsSpec.searchResponse)).to.be.equal(true);
|
||||
}
|
||||
|
||||
@test
|
||||
public isThing() {
|
||||
const notADish = {
|
||||
categories: [
|
||||
'appetizer',
|
||||
],
|
||||
name: 'foo',
|
||||
origin: {
|
||||
created: '',
|
||||
type: SCThingOriginType.User,
|
||||
},
|
||||
type: 'foobar',
|
||||
uid: 'bar',
|
||||
};
|
||||
|
||||
const dish: SCDish = {
|
||||
categories: [
|
||||
'appetizer',
|
||||
],
|
||||
name: 'foo',
|
||||
origin: {
|
||||
created: '',
|
||||
type: SCThingOriginType.User,
|
||||
},
|
||||
type: SCThingType.Dish,
|
||||
uid: 'bar',
|
||||
};
|
||||
|
||||
expect(isThing('foo')).to.be.equal(false);
|
||||
expect(isThing({type: 'foo'})).to.be.equal(false);
|
||||
expect(isThing(GuardsSpec.notADish)).to.be.equal(false);
|
||||
expect(isThing(GuardsSpec.dishWithTranslation)).to.be.equal(true);
|
||||
}
|
||||
|
||||
expect(isThing(notADish)).to.be.equal(false);
|
||||
|
||||
expect(isThing(dish)).to.be.equal(true);
|
||||
@test
|
||||
public isThingWithTranslations() {
|
||||
const dishWithoutTranslation = {...GuardsSpec.dishWithTranslation};
|
||||
delete dishWithoutTranslation.translations;
|
||||
expect(isThingWithTranslations(dishWithoutTranslation)).to.be.equal(false);
|
||||
expect(isThingWithTranslations(GuardsSpec.dishWithTranslation)).to.be.equal(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ export class SchemaSpec {
|
||||
continue;
|
||||
}
|
||||
|
||||
const type = property.type!;
|
||||
let type = property.type!;
|
||||
|
||||
if (isIntrinsicType(type)) {
|
||||
continue;
|
||||
@@ -212,10 +212,24 @@ export class SchemaSpec {
|
||||
fail(`'${thingName}'#'${property.name}' element type '${elementType.type}' is not handled by this test!`);
|
||||
}
|
||||
} else if (isReferenceType(type)) {
|
||||
expect(SchemaSpec.thingNames).not.to.contain(
|
||||
type.name,
|
||||
`Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`,
|
||||
);
|
||||
do {
|
||||
expect(SchemaSpec.thingNames).not.to.contain(
|
||||
type.name,
|
||||
`Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`,
|
||||
);
|
||||
|
||||
const referencedObject = SchemaSpec.objects[type.name];
|
||||
if (typeof referencedObject !== 'undefined') {
|
||||
const referencedType = referencedObject.type;
|
||||
if (typeof referencedType !== 'undefined') {
|
||||
type = referencedType;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (isReferenceType(type));
|
||||
} else if (isUnionType(type)) {
|
||||
for (const nestedType of type.types) {
|
||||
if (isIntrinsicType(nestedType) || isStringLiteralType(nestedType)) {
|
||||
|
||||
@@ -237,6 +237,7 @@ export class MetaTranslationSpec {
|
||||
public consistencyWithMetaClass() {
|
||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
|
||||
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, '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);
|
||||
}
|
||||
|
||||
344
test/Type.spec.ts
Normal file
344
test/Type.spec.ts
Normal file
@@ -0,0 +1,344 @@
|
||||
import {assert, Has, IsAny, IsNever, NotHas} from 'conditional-type-checks';
|
||||
import {SCThing, SCThingWithoutReferences} from '../src/core/Thing';
|
||||
import {SCAcademicEvent, SCAcademicEventWithoutReferences} from '../src/core/things/AcademicEvent';
|
||||
import {SCArticle, SCArticleWithoutReferences} from '../src/core/things/Article';
|
||||
import {SCBook, SCBookWithoutReferences} from '../src/core/things/Book';
|
||||
import {SCBuilding, SCBuildingWithoutReferences} from '../src/core/things/Building';
|
||||
import {SCCatalog, SCCatalogWithoutReferences} from '../src/core/things/Catalog';
|
||||
import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/core/things/CourseOfStudies';
|
||||
import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/core/things/DateSeries';
|
||||
import {SCDiff, SCDiffWithoutReferences} from '../src/core/things/Diff';
|
||||
import {SCDish, SCDishWithoutReferences} from '../src/core/things/Dish';
|
||||
import {SCFavorite, SCFavoriteWithoutReferences} from '../src/core/things/Favorite';
|
||||
import {SCFloor, SCFloorWithoutReferences} from '../src/core/things/Floor';
|
||||
import {SCMessage, SCMessageWithoutReferences} from '../src/core/things/Message';
|
||||
import {SCOrganization, SCOrganizationWithoutReferences} from '../src/core/things/Organization';
|
||||
import {SCPerson, SCPersonWithoutReferences} from '../src/core/things/Person';
|
||||
import {SCPointOfInterest, SCPointOfInterestWithoutReferences} from '../src/core/things/PointOfInterest';
|
||||
import {SCRoom, SCRoomWithoutReferences} from '../src/core/things/Room';
|
||||
import {SCSemester, SCSemesterWithoutReferences} from '../src/core/things/Semester';
|
||||
import {SCSetting, SCSettingWithoutReferences} from '../src/core/things/Setting';
|
||||
import {SCSportCourse, SCSportCourseWithoutReferences} from '../src/core/things/SportCourse';
|
||||
import {SCStudyModule, SCStudyModuleWithoutReferences} from '../src/core/things/StudyModule';
|
||||
import {SCTicket, SCTicketWithoutReferences} from '../src/core/things/Ticket';
|
||||
import {SCToDo, SCToDoWithoutReferences} from '../src/core/things/ToDo';
|
||||
import {SCTour, SCTourWithoutReferences} from '../src/core/things/Tour';
|
||||
import {SCVideo, SCVideoWithoutReferences} from '../src/core/things/Video';
|
||||
|
||||
/**
|
||||
* Check if E extends T
|
||||
*/
|
||||
type Extends<E, T> = E extends T ? true : false;
|
||||
|
||||
/**
|
||||
* Get type of array elements up to nesting level 3
|
||||
*/
|
||||
type ElementType<T> = T extends any[] ?
|
||||
(T[0] extends any[] ?
|
||||
(T[0][0] extends any[] ?
|
||||
T[0][0][0] : T[0][0]) : T[0]) : T;
|
||||
|
||||
/**
|
||||
* Get types of properties
|
||||
*
|
||||
* - Extracts only the properties which extend object and are not any.
|
||||
* - If type is an array it returns the type of the elements.
|
||||
*/
|
||||
type PropertyTypes<T> = Extract<ElementType<T extends object ?
|
||||
(IsAny<T[keyof T]> extends true ?
|
||||
never : T[keyof T]) : never>
|
||||
, object>;
|
||||
|
||||
/**
|
||||
* Get nested property types
|
||||
*/
|
||||
type PropertyTypesNested<T> = PropertyTypes<T> extends object ? PropertyTypes<PropertyTypes<T>> : PropertyTypes<T>;
|
||||
|
||||
/**
|
||||
* Types of properties of SCDiff
|
||||
*/
|
||||
type SCDiffPropertyTypes = PropertyTypesNested<SCDiff>;
|
||||
assert<NotHas<SCDiffPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDiffPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDiffPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDiffPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDiffWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDiff, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCAcademicEvent
|
||||
*/
|
||||
type SCAcademicEventPropertyTypes = PropertyTypesNested<SCAcademicEvent>;
|
||||
assert<NotHas<SCAcademicEventPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCAcademicEventPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCAcademicEventPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCAcademicEventPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCAcademicEventWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCAcademicEvent, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCArticle
|
||||
*/
|
||||
type SCArticlePropertyTypes = PropertyTypesNested<SCArticle>;
|
||||
assert<NotHas<SCArticlePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCArticlePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCArticlePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCArticlePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCArticleWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCArticle, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCBook
|
||||
*/
|
||||
type SCBookPropertyTypes = PropertyTypesNested<SCBook>;
|
||||
assert<NotHas<SCBookPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCBookPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCBookPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCBookPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCBookWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCBook, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCBuilding
|
||||
*/
|
||||
type SCBuildingPropertyTypes = PropertyTypesNested<SCBuilding>;
|
||||
assert<NotHas<SCBuildingPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCBuildingPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCBuildingPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCBuildingPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCBuildingWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCBuilding, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCCatalog
|
||||
*/
|
||||
type SCCatalogPropertyTypes = PropertyTypesNested<SCCatalog>;
|
||||
assert<NotHas<SCCatalogPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCCatalogPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCCatalogPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCCatalogPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCCatalogWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCCatalog, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCCourseOfStudies
|
||||
*/
|
||||
type SCCourseOfStudiesPropertyTypes = PropertyTypesNested<SCCourseOfStudies>;
|
||||
assert<NotHas<SCCourseOfStudiesPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCCourseOfStudiesPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCCourseOfStudiesPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCCourseOfStudiesPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCCourseOfStudiesWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCCourseOfStudies, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCDateSeries
|
||||
*/
|
||||
type SCDateSeriesPropertyTypes = PropertyTypesNested<SCDateSeries>;
|
||||
assert<NotHas<SCDateSeriesPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDateSeriesPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDateSeriesPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDateSeriesPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDateSeriesWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDateSeries, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCDish
|
||||
*/
|
||||
type SCDishPropertyTypes = PropertyTypesNested<SCDish>;
|
||||
assert<NotHas<SCDishPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDishPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDishPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDishPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDishWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDish, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCFavorite
|
||||
*/
|
||||
type SCFavoritePropertyTypes = PropertyTypesNested<SCFavorite>;
|
||||
assert<NotHas<SCFavoritePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCFavoritePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCFavoritePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCFavoritePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCFavoriteWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCFavorite, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCFloor
|
||||
*/
|
||||
type SCFloorPropertyTypes = PropertyTypesNested<SCFloor>;
|
||||
assert<NotHas<SCFloorPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCFloorPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCFloorPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCFloorPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCFloorWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCFloor, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCMessage
|
||||
*/
|
||||
type SCMessagePropertyTypes = PropertyTypesNested<SCMessage>;
|
||||
assert<NotHas<SCMessagePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCMessagePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCMessagePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCMessagePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCMessageWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCMessage, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCOrganization
|
||||
*/
|
||||
type SCOrganizationPropertyTypes = PropertyTypesNested<SCOrganization>;
|
||||
assert<NotHas<SCOrganizationPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCOrganizationPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCOrganizationPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCOrganizationPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCOrganizationWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCOrganization, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCPerson
|
||||
*/
|
||||
type SCPersonPropertyTypes = PropertyTypesNested<SCPerson>;
|
||||
assert<NotHas<SCPersonPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCPersonPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCPersonPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCPersonPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCPersonWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCPerson, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCPointOfInterest
|
||||
*/
|
||||
type SCPointOfInterestPropertyTypes = PropertyTypesNested<SCPointOfInterest>;
|
||||
assert<NotHas<SCPointOfInterestPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCPointOfInterestPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCPointOfInterestPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCPointOfInterestPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCPointOfInterestWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCPointOfInterest, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCRoom
|
||||
*/
|
||||
type SCRoomPropertyTypes = PropertyTypesNested<SCRoom>;
|
||||
assert<NotHas<SCRoomPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCRoomPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCRoomPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCRoomPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCRoomWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCRoom, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSemester
|
||||
*/
|
||||
type SCSemesterPropertyTypes = PropertyTypesNested<SCSemester>;
|
||||
assert<NotHas<SCSemesterPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSemesterPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSemesterPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSemesterPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSemesterWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSemester, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSetting
|
||||
*/
|
||||
type SCSettingPropertyTypes = PropertyTypesNested<SCSetting>;
|
||||
assert<NotHas<SCSettingPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSettingPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSettingPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSettingPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSettingWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSetting, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSportCourse
|
||||
*/
|
||||
type SCSportCoursePropertyTypes = PropertyTypesNested<SCSportCourse>;
|
||||
assert<NotHas<SCSportCoursePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSportCoursePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSportCoursePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSportCoursePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSportCourseWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSportCourse, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCStudyModule
|
||||
*/
|
||||
type SCStudyModulePropertyTypes = PropertyTypesNested<SCStudyModule>;
|
||||
assert<NotHas<SCStudyModulePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCStudyModulePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCStudyModulePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCStudyModulePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCStudyModuleWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCStudyModule, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCTicket
|
||||
*/
|
||||
type SCTicketPropertyTypes = PropertyTypesNested<SCTicket>;
|
||||
assert<NotHas<SCTicketPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCTicketPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCTicketPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCTicketPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCTicketWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCTicket, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCToDo
|
||||
*/
|
||||
type SCToDoPropertyTypes = PropertyTypesNested<SCToDo>;
|
||||
assert<NotHas<SCToDoPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCToDoPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCToDoPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCToDoPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCToDoWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCToDo, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCToDo
|
||||
*/
|
||||
type SCTourPropertyTypes = PropertyTypesNested<SCTour>;
|
||||
assert<NotHas<SCTourPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCTourPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCTourPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCTourPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCTourWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCTour, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCVideo
|
||||
*/
|
||||
type SCVideoPropertyTypes = PropertyTypesNested<SCVideo>;
|
||||
assert<NotHas<SCVideoPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCVideoPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCVideoPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCVideoPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCVideoWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCVideo, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Dummy interface, to check if union types still resolve to any if one of the members is any
|
||||
*/
|
||||
interface Foo {
|
||||
bar: SCPerson;
|
||||
foo: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type that is unfortunately never - blame TypeScript
|
||||
*/
|
||||
type UnfortunatelyNever = PropertyTypesNested<Foo>;
|
||||
assert<IsNever<UnfortunatelyNever>>(true);
|
||||
|
||||
/**
|
||||
* Flat property types
|
||||
*/
|
||||
type FlatPropertyTypes<T> = T[keyof T];
|
||||
|
||||
/**
|
||||
* Type that is unfortunately any - blame TypeScript
|
||||
*/
|
||||
type UnfortunatelyAny = FlatPropertyTypes<Foo>;
|
||||
assert<IsAny<UnfortunatelyAny>>(true);
|
||||
@@ -28,9 +28,7 @@
|
||||
"name": "Prüfungsamt - Team 2",
|
||||
"floorName": "0"
|
||||
},
|
||||
"serviceType": {
|
||||
"name": "Prüfungsamt"
|
||||
},
|
||||
"serviceType": "Prüfungsamt",
|
||||
"origin": {
|
||||
"indexed": "2018-09-11T12:30:00Z",
|
||||
"name": "Dummy",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "./node_modules/@openstapps/configuration/tslint.json",
|
||||
"rules": {
|
||||
"no-empty-interface": false
|
||||
"no-empty-interface": false,
|
||||
"file-name-casing": [false, "camel-case"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user