Compare commits

..

28 Commits

Author SHA1 Message Date
Rainer Killinger
6fd8c5adf3 0.64.0 2022-03-21 11:05:25 +01:00
Rainer Killinger
db24b41d99 test: adjust HDS samples to production version 2022-03-21 11:00:11 +01:00
Rainer Killinger
b1fcd22ab2 refactor: update dependencies 2022-03-17 12:44:59 +01:00
Rainer Killinger
268588fb6f docs: update changelog 2022-01-24 14:47:04 +01:00
Rainer Killinger
d3048a12d8 0.63.0 2022-01-24 14:47:02 +01:00
Rainer Killinger
e14993114f fix: add auth object to index route 2022-01-24 14:45:17 +01:00
Rainer Killinger
4237f6ad60 docs: update changelog 2022-01-21 17:15:16 +01:00
Rainer Killinger
e7c1000bc4 0.62.0 2022-01-21 17:15:14 +01:00
Rainer Killinger
e0adb2332e fix: add missing lastPublished to SCCreativeWork 2022-01-21 17:14:16 +01:00
Rainer Killinger
e5696b23e7 docs: update changelog 2022-01-21 15:07:16 +01:00
Rainer Killinger
659d0974f7 0.61.0 2022-01-21 15:07:14 +01:00
Rainer Killinger
e8304eeeb4 refactor: remove unused auth provider properties 2022-01-21 15:06:11 +01:00
Rainer Killinger
dca9d26c66 docs: update changelog 2022-01-21 12:29:55 +01:00
Rainer Killinger
852e0f5373 0.60.0 2022-01-21 12:29:52 +01:00
Rainer Killinger
26dd531d24 refactor: split up SCUserConfiguration type 2022-01-21 12:22:13 +01:00
Rainer Killinger
52bdf93356 docs: update changelog 2022-01-20 14:20:17 +01:00
Rainer Killinger
7509610145 0.59.0 2022-01-20 14:20:15 +01:00
Rainer Killinger
972cdf392d refactor: make config auth provides be optional 2022-01-20 14:18:50 +01:00
Rainer Killinger
4f758f7d0c docs: update changelog 2022-01-18 15:13:06 +01:00
Rainer Killinger
980e899807 0.58.0 2022-01-18 15:13:04 +01:00
Rainer Killinger
d1c5bb9595 refactor: use SCMap for feature configurations 2022-01-18 15:12:05 +01:00
Rainer Killinger
dc9c0f528f docs: update changelog 2022-01-18 11:06:18 +01:00
Rainer Killinger
66d64e0858 0.57.0 2022-01-18 11:06:16 +01:00
Rainer Killinger
06339786c2 refactor: update dependencies 2022-01-18 11:01:01 +01:00
Rainer Killinger
8ed68481fa refactor: rename urlFragment in routes 2022-01-18 09:50:46 +01:00
Rainer Killinger
e26042957c refactor: remodel features in app config 2022-01-18 09:50:44 +01:00
Rainer Killinger
7553620a5d feat: extend config to describe auth providers 2022-01-18 09:50:00 +01:00
Rainer Killinger
322c001e70 docs: update changelog 2021-12-17 10:35:53 +01:00
27 changed files with 705 additions and 392 deletions

View File

@@ -1,3 +1,50 @@
# [0.63.0](https://gitlab.com/openstapps/core/compare/v0.62.0...v0.63.0) (2022-01-24)
### Bug Fixes
* add auth object to index route ([e149931](https://gitlab.com/openstapps/core/commit/e14993114f0ec370775010eee4ad0d302a0beebb))
# [0.62.0](https://gitlab.com/openstapps/core/compare/v0.61.0...v0.62.0) (2022-01-21)
### Bug Fixes
* add missing lastPublished to SCCreativeWork ([e0adb23](https://gitlab.com/openstapps/core/commit/e0adb2332ec24ce388c4c008b51b7aa941948532))
# [0.61.0](https://gitlab.com/openstapps/core/compare/v0.60.0...v0.61.0) (2022-01-21)
# [0.60.0](https://gitlab.com/openstapps/core/compare/v0.59.0...v0.60.0) (2022-01-21)
# [0.59.0](https://gitlab.com/openstapps/core/compare/v0.58.0...v0.59.0) (2022-01-20)
# [0.58.0](https://gitlab.com/openstapps/core/compare/v0.57.0...v0.58.0) (2022-01-18)
# [0.57.0](https://gitlab.com/openstapps/core/compare/v0.56.0...v0.57.0) (2022-01-18)
### Features
* extend config to describe auth providers ([7553620](https://gitlab.com/openstapps/core/commit/7553620a5d330ebfb66461afeab700e36bd37165))
# [0.56.0](https://gitlab.com/openstapps/core/compare/v0.55.0...v0.56.0) (2021-12-17)
# [0.55.0](https://gitlab.com/openstapps/core/compare/v0.54.0...v0.55.0) (2021-12-15)

706
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.56.0",
"version": "0.64.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -45,14 +45,14 @@
"Wieland Schöbl"
],
"dependencies": {
"@openstapps/core-tools": "0.28.0",
"@openstapps/core-tools": "0.29.0",
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/json-schema": "7.0.9",
"@types/node": "14.18.0",
"@types/json-schema": "7.0.10",
"@types/node": "14.18.3",
"fast-clone": "1.5.13",
"fast-deep-equal": "3.1.3",
"http-status-codes": "2.1.4",
"http-status-codes": "2.2.0",
"json-patch": "0.7.0",
"json-schema": "0.4.0",
"ts-optchain": "0.1.8"
@@ -63,19 +63,19 @@
"@openstapps/logger": "0.8.0",
"@testdeck/mocha": "0.2.0",
"@types/chai": "4.3.0",
"@types/lodash": "4.14.178",
"@types/mocha": "9.0.0",
"@types/lodash": "4.14.180",
"@types/mocha": "9.1.0",
"@types/rimraf": "3.0.2",
"chai": "4.3.4",
"chai": "4.3.6",
"conditional-type-checks": "1.0.5",
"conventional-changelog-cli": "2.1.1",
"conventional-changelog-cli": "2.2.2",
"lodash": "4.17.21",
"mocha": "9.1.3",
"mocha": "9.2.2",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"source-map-support": "0.5.21",
"surge": "0.23.0",
"ts-node": "10.4.0",
"surge": "0.23.1",
"ts-node": "10.7.0",
"tslint": "6.1.3",
"typedoc": "0.21.6",
"typescript": "4.3.5"

View File

@@ -17,6 +17,7 @@ import {Polygon} from 'geojson';
import {SCTranslations} from '../general/i18n';
import {SCMap} from '../general/map';
import {SCLanguageSetting, SCSetting, SCUserGroupSetting} from '../things/setting';
import {SCFeatureConfiguration} from './feature';
/**
* An app configuration menu item
@@ -94,9 +95,9 @@ export interface SCAppConfiguration {
campusPolygon: Polygon;
/**
* A list of features to en- or disable
* Maps of enabled features (plugins and external services)
*/
features: SCAppConfigurationFeature;
features: SCFeatureConfiguration;
/**
* A URL where images are available
@@ -135,16 +136,6 @@ export interface SCAppConfiguration {
url?: string;
}
/**
* Map of features
*/
export interface SCAppConfigurationFeature {
/**
* Whether or not widgets are enabled
*/
widgets: boolean;
}
/**
* URLs of published apps
*/

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCUserConfigurationMap} from './user';
/**
* Supported authorization provider types
*
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-1.3.1
* @see https://github.com/gbv/paia
*/
export type SCAuthorizationProviderType = 'default' | 'paia' ;
/**
* An authorization provider complete configuration
*/
export interface SCAuthorizationProvider {
/**
* An authorization provider client configuration
*/
client: SCAuthorizationProviderClient;
/**
* An authorization provider endpoints configuration
*/
endpoints: SCAuthorizationProviderEndpoints;
}
/**
* An authorization provider client configuration
*/
export interface SCAuthorizationProviderClient {
/**
* Client ID
*/
clientId: string;
/**
* Scopes to request
*/
scopes: string;
/**
* Main url to reach authorization provider
*/
url: string;
}
/**
* An authorization provider endpoints configuration
*/
export interface SCAuthorizationProviderEndpoints {
/**
* URL to start authentication flow
*/
authorization: string;
/**
* URL to end current session
*/
endSession?: string;
/**
* Mapping of how to create SCUser from userinfo endpoint response (using JSONPath syntax)
*
* @see https://www.npmjs.com/package/jsonpath
*/
mapping: SCUserConfigurationMap;
/**
* URL to revoke a token
*/
revoke?: string;
/**
* URL to get access Token
*/
token: string;
/**
* URL to general user info endpoint
*/
userinfo: string;
}

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

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMap} from '../general/map';
import {SCAuthorizationProviderType} from './authorization';
export interface SCFeatureConfiguration {
/**
* Map of extern services mapped by their name (statically)
*/
extern?: SCMap<SCFeatureConfigurationExtern>;
/**
* Map of plugins registered with the backend mapped by their name.
*/
plugins?: SCMap<SCFeatureConfigurationPlugin>;
}
export interface SCFeatureConfigurationPlugin {
/**
* URL path registered with the backend
*/
urlPath: string;
}
export interface SCFeatureConfigurationExtern {
/**
* Key of authorization provider available in SCConfigFile
*/
authProvider?: SCAuthorizationProviderType;
/**
* URL of extern service
*/
url: string;
}

View File

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

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

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* User configuration keys mapped to string type while including their requiredness
*/
export type SCUserConfigurationMap = { [K in keyof SCUserConfigurationOptional]?: string } & { [K in keyof SCUserConfigurationRequired]: string };
/**
* A user configuration
*/
export type SCUserConfiguration = SCUserConfigurationRequired & SCUserConfigurationOptional;
/**
* A user configurations required properties
*/
interface SCUserConfigurationRequired {
/**
* ID given to the user
*/
id: string;
/**
* The complete name of the user combining all the parts of the name into one
*/
name: string;
}
/**
* A user configurations optional properties
*/
interface SCUserConfigurationOptional {
/**
* User's e-mail
*/
email?: string;
/**
* User's family name
*/
familyName?: string;
/**
* User's given name
*/
givenName?: string;
/**
* Role assigned to the user
*/
role?: string;
/**
* Student ID given to the user
*/
studentId?: string;
}

View File

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

View File

@@ -89,6 +89,6 @@ export class SCBookAvailabilityRoute extends SCAbstractRoute {
this.requestBodyName = 'SCBookAvailabilityRequest';
this.responseBodyName = 'SCBookAvailabilityResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/bookAvailability';
this.urlPath = '/bookAvailability';
}
}

View File

@@ -60,6 +60,6 @@ export class SCBulkAddRoute extends SCAbstractRoute {
this.requestBodyName = 'SCBulkAddRequest';
this.responseBodyName = 'SCBulkAddResponse';
this.statusCodeSuccess = StatusCodes.CREATED;
this.urlFragment = '/bulk/:UID';
this.urlPath = '/bulk/:UID';
}
}

View File

@@ -60,6 +60,6 @@ export class SCBulkDoneRoute extends SCAbstractRoute {
this.requestBodyName = 'SCBulkDoneRequest';
this.responseBodyName = 'SCBulkDoneResponse';
this.statusCodeSuccess = StatusCodes.NO_CONTENT;
this.urlFragment = '/bulk/:UID/done';
this.urlPath = '/bulk/:UID/done';
}
}

View File

@@ -99,6 +99,6 @@ export class SCBulkRoute extends SCAbstractRoute {
this.requestBodyName = 'SCBulkRequest';
this.responseBodyName = 'SCBulkResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/bulk';
this.urlPath = '/bulk';
}
}

View File

@@ -60,7 +60,7 @@ export class SCFeedbackRoute extends SCAbstractRoute {
this.requestBodyName = 'SCFeedbackRequest';
this.responseBodyName = 'SCFeedbackResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/feedback';
this.urlPath = '/feedback';
}
}

View File

@@ -14,6 +14,7 @@
*/
import {StatusCodes} from 'http-status-codes';
import {SCAppConfiguration} from '../../config/app';
import {SCAuthorizationProvider, SCAuthorizationProviderType} from '../../config/authorization';
import {SCBackendConfiguration} from '../../config/backend';
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
@@ -42,6 +43,11 @@ export interface SCIndexResponse {
*/
app: SCAppConfiguration;
/**
* @see SCAuthorizationProvider
*/
auth: { [key in SCAuthorizationProviderType]?: SCAuthorizationProvider; };
/**
* @see SCBackendConfiguration
*/
@@ -66,6 +72,6 @@ export class SCIndexRoute extends SCAbstractRoute {
this.requestBodyName = 'SCIndexRequest';
this.responseBodyName = 'SCIndexResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/';
this.urlPath = '/';
}
}

View File

@@ -123,6 +123,6 @@ export class SCPluginRegisterRoute extends SCAbstractRoute {
this.requestBodyName = 'SCPluginRegisterRequest';
this.responseBodyName = 'SCPluginRegisterResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/plugin/register';
this.urlPath = '/plugin/register';
}
}

View File

@@ -64,6 +64,6 @@ export class SCMultiSearchRoute extends SCAbstractRoute {
this.requestBodyName = 'SCMultiSearchRequest';
this.responseBodyName = 'SCMultiSearchResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/search/multi';
this.urlPath = '/search/multi';
}
}

View File

@@ -57,6 +57,6 @@ export class SCSearchRoute extends SCAbstractRoute {
this.requestBodyName = 'SCSearchRequest';
this.responseBodyName = 'SCSearchResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/search';
this.urlPath = '/search';
}
}

View File

@@ -61,6 +61,6 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
this.requestBodyName = 'SCThingUpdateRequest';
this.responseBodyName = 'SCThingUpdateResponse';
this.statusCodeSuccess = StatusCodes.OK;
this.urlFragment = '/:TYPE/:UID';
this.urlPath = '/:TYPE/:UID';
}
}

View File

@@ -71,6 +71,13 @@ export interface SCCreativeWorkWithoutReferences
*/
keywords?: string[];
/**
* Date (in text form) the creative work was most recently
*
* @keyword
*/
lastPublished?: string;
/**
* Translated fields of the creative work
*/

View File

@@ -16,13 +16,13 @@
}
],
"firstPublished": "2008",
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB198305427",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB198305427",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB198305427",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
},
"isPartOf": {
"uid": "bc5e5399-a24c-5c01-9c1b-0c8b83272087",

View File

@@ -16,13 +16,13 @@
}
],
"firstPublished": "2002",
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB107025590",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB107025590",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB107025590",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
},
"isPartOf": {
"uid": "f84c1851-042e-542f-ba7a-158b32dfb82f",

View File

@@ -16,6 +16,7 @@
}
],
"firstPublished": "[ca. 1991]",
"lastPublished": "2000 Q1",
"publications": [
{
"uid": "603a6574-8910-588a-9e83-cd26e6988c74",
@@ -27,13 +28,13 @@
"name": "VDI"
}
],
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB022992618",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB022992618",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB022992618",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
}
},
"schema": "SCBook"

View File

@@ -27,7 +27,7 @@
"name": "Belles Lettres"
}
],
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB102248788",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB102248788",
"ISBNs": [
"2251760385"
],
@@ -36,7 +36,7 @@
"name": "HeBIS HDS",
"originalId": "HEB102248788",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
}
},
"schema": "SCBook"

View File

@@ -22,13 +22,13 @@
"ISSNs": [
"0024-6085"
],
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB046847146",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB046847146",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB046847146",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
}
},
"schema": "SCPeriodical"

View File

@@ -19,13 +19,13 @@
"name": "Frankfurter Allg. Zeitung"
}
],
"sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB048624853",
"sameAs": "https://ubffm.hds.hebis.de/Record/HEB048624853",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "HeBIS HDS",
"originalId": "HEB048624853",
"type": "remote",
"url": "https://hds2.hebis.de/ubffm/"
"url": "https://ubffm.hds.hebis.de"
}
},
"schema": "SCPeriodical"

View File

@@ -21,26 +21,26 @@ import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update';
@suite(timeout(10000), slow(5000))
export class RoutesSpec {
@test
public bulkAddRouteUrlFragment() {
public bulkAddRouteUrlPath() {
const bulkAddRoute = new SCBulkAddRoute();
expect(bulkAddRoute.getUrlFragment({
expect(bulkAddRoute.getUrlPath({
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
})).to.equal('/bulk/540862f3-ea30-5b8f-8678-56b4dc217140');
}
@test
public bulkRouteUrlFragment() {
public bulkRouteUrlPath() {
const bulkRoute = new SCBulkRoute();
expect(bulkRoute.getUrlFragment()).to.equal('/bulk');
expect(bulkRoute.getUrlPath()).to.equal('/bulk');
}
@test
public thingUpdateRouteUrlFragment() {
public thingUpdateRouteUrlPath() {
const thingUpdateRoute = new SCThingUpdateRoute();
expect(thingUpdateRoute.getUrlFragment({
expect(thingUpdateRoute.getUrlPath({
TYPE: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
})).to.equal('/dish/540862f3-ea30-5b8f-8678-56b4dc217140');
@@ -51,7 +51,7 @@ export class RoutesSpec {
const thingUpdateRoute = new SCThingUpdateRoute();
const fn = () => {
thingUpdateRoute.getUrlFragment({
thingUpdateRoute.getUrlPath({
FOO: 'bar',
TYPE: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
@@ -66,7 +66,7 @@ export class RoutesSpec {
const thingUpdateRoute = new SCThingUpdateRoute();
const fn = () => {
thingUpdateRoute.getUrlFragment({
thingUpdateRoute.getUrlPath({
TYPO: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
});