refactor: reorganize files

This commit is contained in:
2023-03-14 16:59:09 +01:00
parent 58e6b390c2
commit cffad4d148
257 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,321 @@
/*
* Copyright (C) 2019-2022 Open 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 {Polygon} from 'geojson';
import {SCTranslations} from '../general/i18n';
import {SCMap} from '../general/map';
import {SCLanguageSetting, SCSetting, SCUserGroupSetting} from '../things/setting';
import {SCAuthorizationProviderType} from './authorization';
import {SCFeatureConfiguration} from './feature';
/**
* An app configuration menu item
*/
export interface SCAppConfigurationMenuItem {
/**
* Key of authorization provider available in SCConfigFile
* Restricting and enabling the usage of this item
*/
authProvider?: SCAuthorizationProviderType;
/**
* Icon for the menu item
*/
icon: string;
/**
* Route inside the app
*/
route: string;
/**
* Title of the route
*/
title: string;
/**
* Translations for the menu item
*/
translations: SCTranslations<SCAppConfigurationMenuItemTranslationTitle>;
}
/**
* An app configuration menu category
*/
export interface SCAppConfigurationMenuCategory {
/**
* Icon for the menu category
*/
icon: string;
/**
* A list of items that belong to the category
*/
items: SCAppConfigurationMenuItem[];
/**
* Title of the category
*/
title: string;
/**
* Route inside the app
*/
route: string;
/**
* Translations for the menu category
*/
translations: SCTranslations<SCAppConfigurationMenuCategoryTranslationTitle>;
}
/**
* An app configuration
*/
export interface SCAppConfiguration {
/**
* The about page
*
* Mapping route -> page config
*/
aboutPages: SCMap<SCAboutPage>;
/**
* Polygon that encapsulates the main campus
*/
campusPolygon: Polygon;
/**
* Maps of enabled features (plugins and external services)
*/
features: SCFeatureConfiguration;
/**
* A URL where images are available
*/
imageUrl?: string;
/**
* A list of available menu categories in the app
*/
menus: SCAppConfigurationMenuCategory[];
/**
* Name for the app
*/
name: string;
/**
* URL to a file containing the privacy policy
*/
privacyPolicyUrl: string;
/**
* A list of available settings in the app
* !Important! Use provided specific settings, for other settings use general SCSetting
*/
settings: Array<SCUserGroupSetting | SCLanguageSetting | SCSetting>;
/**
* Map of store URLs
*/
storeUrl?: SCAppConfigurationStoreUrl;
/**
* URL where a web instance of the app is available
*/
url?: string;
}
/**
* URLs of published apps
*/
export interface SCAppConfigurationStoreUrl {
/**
* Google Play Store URL
*/
android?: string;
/**
* Apple App Store URL
*/
ios?: string;
/**
* Microsoft Store URL
*/
uwp?: string;
}
/**
* Translatable property of a menu item
*/
export interface SCAppConfigurationMenuItemTranslationTitle {
/**
* Translation of the title of a menu item
*/
title: string;
}
/**
* Translatable property of a menu category
*/
export interface SCAppConfigurationMenuCategoryTranslationTitle {
/**
* Translation of the name of a menu category
*/
title: string;
}
export enum SCAboutPageContentType {
SECTION = 'section',
ROUTER_LINK = 'router link',
TABLE = 'table',
MARKDOWN = 'markdown',
}
export interface SCAboutPageTranslationTitle {
/**
* Translation of the title
*/
title: string;
}
export interface SCAboutPageTranslationValue {
/**
* Translation of the value
*/
value: string;
}
/**
* A (mostly) self-contained section, akin to markdown `# Title`
*/
export interface SCAboutPageSection {
/**
* If the section should be contained in a card
*/
card?: true;
/**
* The content of the section
*/
content: SCAboutPageContent;
/**
* The title of the section
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
/**
* Type
*/
type: SCAboutPageContentType.SECTION;
}
/**
* A router link that can lead to a new page
*
* For external links, prefer markdown `[destination](link)`
*/
export interface SCAboutPageRouterLink {
/**
* Icon of the destination
*/
icon?: string;
/**
* Router link
*/
link: string;
/**
* Title of the destination
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
/**
* Type
*/
type: SCAboutPageContentType.ROUTER_LINK;
}
/**
* A simple table element
*/
export interface SCAboutPageTable {
/**
* Rows of the table
*/
rows: SCAboutPageContent[][];
/**
* Type
*/
type: SCAboutPageContentType.TABLE;
}
/**
* A markdown element
*/
export interface SCAboutPageMarkdown {
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationValue>;
/**
* Type
*/
type: SCAboutPageContentType.MARKDOWN;
/**
* Value (Markdown)
*/
value: string;
}
export type SCAboutPageContent =
| SCAboutPageMarkdown
| SCAboutPageTable
| SCAboutPageSection
| SCAboutPageRouterLink;
/**
* Root of the about page
*/
export interface SCAboutPage {
/**
* Content of the page
*/
content: SCAboutPageContent[];
/**
* Header (title) of the page
*/
title: string;
/**
* Translations
*/
translations: SCTranslations<SCAboutPageTranslationTitle>;
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2021-2022 Open 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;
}

View File

@@ -0,0 +1,192 @@
/*
* Copyright (C) 2019-2022 Open 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, SCRestrictedMap} from '../general/map';
import {SCUuid} from '../general/uuid';
import {SCSearchSortType} from '../protocol/search/sort';
import {SCThingType} from '../things/abstract/thing';
import {SCMonitoringConfiguration} from './monitoring';
/**
* A backend configuration
*/
export interface SCBackendConfiguration {
/**
* The maximum amount of time (milliseconds) an external program can take to provide a response to the backend
*
* This can be used for example for Plugins.
*/
externalRequestTimeout: number;
/**
* A list of hidden SC types
*
* If a type is hidden it won't show in any result unless the type is filtered for
*
*/
hiddenTypes: SCThingType[];
/**
* A list of tags that will be ignored by the mapping generator
*
* The ignored tags should mainly be tags that are irrelevant to the mapping. The tags should include the '@'.
*/
mappingIgnoredTags: string[];
/**
* Maximum number of queries, that can be used in MultiSearchRoute
*/
maxMultiSearchRouteQueries: number;
/**
* Maximum body size for requests
*/
maxRequestBodySize: number;
/**
* Name of university
*/
name: string;
/**
* Namespace of the university for UID generation
*/
namespace: SCUuid;
/**
* Version string of the installed StAppsCore
*/
SCVersion: string;
/**
* A list of sortable fields of each type
*/
sortableFields: SCBackendConfigurationSortableField[];
}
/**
* Description which sort types are supported on which fields of which types
*/
export interface SCBackendConfigurationSortableField {
/**
* Field name which the sorts should be available on
*/
fieldName: string;
/**
* A list of SC types on which this field exists
*
* If no type is given it is assumed it exists on every type
*/
onlyOnTypes?: SCThingType[];
/**
* A list of supported sorts on this field
*/
sortTypes: SCSearchSortType[];
}
/**
* Possible context names to be used by the search request
*/
export type SCSearchContext = 'default' | 'dining' | 'place';
/**
* A boosting configuration for one context
*/
export type SCBackendConfigurationSearchBoostingContext = SCRestrictedMap<
SCSearchContext,
SCBackendConfigurationSearchBoostingType[]
>;
/**
* A boosting configuration for one SCType
*/
export interface SCBackendConfigurationSearchBoostingType {
/**
* The factor of which the scores matching this type should be multiplied by
*/
factor: number;
/**
* Outer-Map:
* Fields of this type that should be boosted if they match a given value
* For nest fields you can use the `.` as a separator. For example `academicTerms.acronym`
*
* Inner-map:
* Value of the field that should be boosted by the given number
* For example `"SS 2019": 2`
*/
fields?: SCMap<SCMap<number>>;
/**
* Type of things the factor should be applied to
*/
type: SCThingType;
}
/**
* Describes which field on which type should be aggregated
*/
export interface SCBackendAggregationConfiguration {
/**
* Field name of field which values should be aggregated
*/
fieldName: string;
/**
* A list of SC types of which the field is on
*
* If the type is not given is is assumed the field exists on every type
*/
onlyOnTypes?: SCThingType[];
}
/**
* The internal backend configuration that is hidden from the app
*/
export interface SCBackendInternalConfiguration {
/**
* A list of configurations for aggregations
*/
aggregations: SCBackendAggregationConfiguration[];
/**
* A list of configurations for search boosting
*
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
* set of results
*/
boostings: SCBackendConfigurationSearchBoostingContext;
/**
* Configuration of the database
*/
database?: SCBackendConfigurationDatabaseConfiguration;
/**
* Configuration for monitoring
*/
monitoring?: SCMonitoringConfiguration;
}
/**
* Configuration of the database
*/
export interface SCBackendConfigurationDatabaseConfiguration extends SCMap<unknown> {
/**
* Name of the database used by the backend
*/
name: string;
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2022 Open 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

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2019-2022 Open 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 {SCLicensePlate} from '../general/namespaces';
import {SCAppConfiguration} from './app';
import {SCAuthorizationProvider, SCAuthorizationProviderType} from './authorization';
import {SCBackendConfiguration, SCBackendInternalConfiguration} from './backend';
/**
* A configuration file that configures app and backend
*
* @validatable
*/
export interface SCConfigFile {
/**
* Configuration for the app that is visible to clients
*/
app: SCAppConfiguration;
/**
* Configuration for the supported authorization providers
*/
auth: {[key in SCAuthorizationProviderType]?: SCAuthorizationProvider};
/**
* Configuration for the backend that is visible to clients
*/
backend: SCBackendConfiguration;
/**
* Configuration that is not visible to clients
*/
internal: SCBackendInternalConfiguration;
/**
* UID of the university, e.g. the license plate
*/
uid: SCLicensePlate;
}

View File

@@ -0,0 +1,164 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* An abstract action that can be executed by a failed watcher
*
* This is extended by actual actions.
*/
export interface SCMonitoringAction {
/**
* Message that is used by the action
*
* Mustache syntax is supported to evaluate the query.
*/
message: string;
/**
* The type of the action
*/
type: 'log' | 'mail';
}
/**
* A log action which can be executed from a failed watcher
*/
export interface SCMonitoringLogAction extends SCMonitoringAction {
/**
* A prefix for the logged messages
*/
prefix: string;
/**
* The type of the action
*/
type: 'log';
}
/**
* A mail task which can be executed from a failed watcher
*/
export interface SCMonitoringMailAction extends SCMonitoringAction {
/**
* A list of addresses to send the mails to
*/
recipients: string[];
/**
* A subject line for all mails
*/
subject: string;
/**
* The type of the action
*/
type: 'mail';
}
/**
* A list of events to describe the execution interval of monitoring triggers
*/
export type SCMonitoringExecutionCalendarEvents = 'hourly' | 'daily' | 'weekly' | 'monthly';
/**
* A trigger which determines the execution time of a watcher
*/
export interface SCMonitoringTrigger {
/**
* A cron like syntax to describe when this trigger should be executed
*/
executionTime: SCMonitoringExecutionCalendarEvents | string;
/**
* A name of the trigger that explains when it executes
*/
name: string;
}
/**
* A condition which is met, when the result length is higher than the minimum length
*/
export interface SCMonitoringMinimumLengthCondition {
/**
* The minimum length
*/
length: number;
/**
* Type of the condition
*/
type: 'MinimumLength';
}
/**
* A condition which is met, when the result length is smaller than the maximum length
*/
export interface SCMonitoringMaximumLengthCondition {
/**
* The maximum length
*/
length: number;
/**
* Type of the condition
*/
type: 'MaximumLength';
}
/**
* A watcher that evaluates a query, when triggered
*/
export interface SCMonitoringWatcher {
/**
* A list of actions that are executed, when the watcher fails
*/
actions: Array<SCMonitoringLogAction | SCMonitoringMailAction>;
/**
* A list of conditions that have to match the result of the query
*
* If not all conditions are met, the watcher will fail and all actions are executed
*/
conditions: Array<SCMonitoringMaximumLengthCondition | SCMonitoringMinimumLengthCondition>;
/**
* A name for the watcher
*/
name: string;
/**
* Query to execute against the database
*/
query: unknown;
/**
* A list of triggers
*/
triggers: SCMonitoringTrigger[];
}
/**
* A complete monitoring configuration for the backend
*/
export interface SCMonitoringConfiguration {
/**
* A list of actions that are executed, when a watcher fails
*/
actions: Array<SCMonitoringMailAction | SCMonitoringLogAction>;
/**
* A list of watches
*/
watchers: SCMonitoringWatcher[];
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2021-2022 Open 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;
}