mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-09 16:22:27 +00:00
refactor: reorganize files
This commit is contained in:
321
packages/core/src/config/app.ts
Normal file
321
packages/core/src/config/app.ts
Normal 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>;
|
||||
}
|
||||
96
packages/core/src/config/authorization.ts
Normal file
96
packages/core/src/config/authorization.ts
Normal 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;
|
||||
}
|
||||
192
packages/core/src/config/backend.ts
Normal file
192
packages/core/src/config/backend.ts
Normal 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;
|
||||
}
|
||||
48
packages/core/src/config/feature.ts
Normal file
48
packages/core/src/config/feature.ts
Normal 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;
|
||||
}
|
||||
50
packages/core/src/config/file.ts
Normal file
50
packages/core/src/config/file.ts
Normal 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;
|
||||
}
|
||||
164
packages/core/src/config/monitoring.ts
Normal file
164
packages/core/src/config/monitoring.ts
Normal 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[];
|
||||
}
|
||||
66
packages/core/src/config/user.ts
Normal file
66
packages/core/src/config/user.ts
Normal 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;
|
||||
}
|
||||
730
packages/core/src/general/i18n.ts
Normal file
730
packages/core/src/general/i18n.ts
Normal file
@@ -0,0 +1,730 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* An Language
|
||||
*/
|
||||
export interface SCLanguage {
|
||||
/**
|
||||
* The two letter ISO 639-1 Code of the Language
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
code: SCLanguageCode;
|
||||
|
||||
/**
|
||||
* The Fulltext name of the Language
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
name: SCLanguageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of possible languages in english
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/ISO_639-1
|
||||
*/
|
||||
export type SCLanguageName =
|
||||
| 'afar'
|
||||
| 'abkhazian'
|
||||
| 'avestan'
|
||||
| 'afrikaans'
|
||||
| 'akan'
|
||||
| 'amharic'
|
||||
| 'aragonese'
|
||||
| 'arabic'
|
||||
| 'assamese'
|
||||
| 'avaric'
|
||||
| 'aymara'
|
||||
| 'azerbaijani'
|
||||
| 'bashkir'
|
||||
| 'belarusian'
|
||||
| 'bulgarian'
|
||||
| 'bihari languages'
|
||||
| 'bislama'
|
||||
| 'bambara'
|
||||
| 'bengali'
|
||||
| 'tibetan'
|
||||
| 'breton'
|
||||
| 'bosnian'
|
||||
| 'catalan; valencian'
|
||||
| 'chechen'
|
||||
| 'chamorro'
|
||||
| 'corsican'
|
||||
| 'cree'
|
||||
| 'czech'
|
||||
| 'church slavic; old slavonic; church slavonic; old bulgarian; old church slavonic'
|
||||
| 'chuvash'
|
||||
| 'welsh'
|
||||
| 'danish'
|
||||
| 'german'
|
||||
| 'divehi; dhivehi; maldivian'
|
||||
| 'dzongkha'
|
||||
| 'ewe'
|
||||
| 'greek, modern (1453-)'
|
||||
| 'english'
|
||||
| 'esperanto'
|
||||
| 'spanish; castilian'
|
||||
| 'estonian'
|
||||
| 'basque'
|
||||
| 'persian'
|
||||
| 'fulah'
|
||||
| 'finnish'
|
||||
| 'fijian'
|
||||
| 'filipino'
|
||||
| 'faroese'
|
||||
| 'french'
|
||||
| 'western frisian'
|
||||
| 'irish'
|
||||
| 'gaelic; scottish gaelic'
|
||||
| 'galician'
|
||||
| 'guarani'
|
||||
| 'gujarati'
|
||||
| 'manx'
|
||||
| 'hausa'
|
||||
| 'hebrew'
|
||||
| 'hindi'
|
||||
| 'hiri motu'
|
||||
| 'croatian'
|
||||
| 'haitian; haitian creole'
|
||||
| 'hungarian'
|
||||
| 'armenian'
|
||||
| 'herero'
|
||||
| 'interlingua (international auxiliary language association)'
|
||||
| 'indonesian'
|
||||
| 'interlingue; occidental'
|
||||
| 'igbo'
|
||||
| 'sichuan yi; nuosu'
|
||||
| 'inupiaq'
|
||||
| 'ido'
|
||||
| 'icelandic'
|
||||
| 'italian'
|
||||
| 'inuktitut'
|
||||
| 'japanese'
|
||||
| 'javanese'
|
||||
| 'georgian'
|
||||
| 'kongo'
|
||||
| 'kikuyu; gikuyu'
|
||||
| 'kuanyama; kwanyama'
|
||||
| 'kazakh'
|
||||
| 'kalaallisut; greenlandic'
|
||||
| 'central khmer'
|
||||
| 'kannada'
|
||||
| 'korean'
|
||||
| 'kanuri'
|
||||
| 'kashmiri'
|
||||
| 'kurdish'
|
||||
| 'komi'
|
||||
| 'cornish'
|
||||
| 'kirghiz; kyrgyz'
|
||||
| 'latin'
|
||||
| 'luxembourgish; letzeburgesch'
|
||||
| 'ganda'
|
||||
| 'limburgan; limburger; limburgish'
|
||||
| 'lingala'
|
||||
| 'lao'
|
||||
| 'lithuanian'
|
||||
| 'luba-katanga'
|
||||
| 'latvian'
|
||||
| 'malagasy'
|
||||
| 'marshallese'
|
||||
| 'maori'
|
||||
| 'macedonian'
|
||||
| 'malayalam'
|
||||
| 'mongolian'
|
||||
| 'marathi'
|
||||
| 'malay'
|
||||
| 'maltese'
|
||||
| 'burmese'
|
||||
| 'nauru'
|
||||
| 'bokmål, norwegian; norwegian bokmål'
|
||||
| 'ndebele, north; north ndebele'
|
||||
| 'nepali'
|
||||
| 'ndonga'
|
||||
| 'dutch; flemish'
|
||||
| 'norwegian nynorsk; nynorsk, norwegian'
|
||||
| 'norwegian'
|
||||
| 'ndebele, south; south ndebele'
|
||||
| 'navajo; navaho'
|
||||
| 'chichewa; chewa; nyanja'
|
||||
| 'occitan (post 1500); provençal'
|
||||
| 'ojibwa'
|
||||
| 'oromo'
|
||||
| 'oriya'
|
||||
| 'ossetian; ossetic'
|
||||
| 'panjabi; punjabi'
|
||||
| 'pali'
|
||||
| 'polish'
|
||||
| 'pushto; pashto'
|
||||
| 'portuguese'
|
||||
| 'quechua'
|
||||
| 'romansh'
|
||||
| 'rundi'
|
||||
| 'romanian; moldavian; moldovan'
|
||||
| 'russian'
|
||||
| 'kinyarwanda'
|
||||
| 'sanskrit'
|
||||
| 'sardinian'
|
||||
| 'sindhi'
|
||||
| 'northern sami'
|
||||
| 'sango'
|
||||
| 'sinhala; sinhalese'
|
||||
| 'slovak'
|
||||
| 'slovenian'
|
||||
| 'samoan'
|
||||
| 'shona'
|
||||
| 'somali'
|
||||
| 'albanian'
|
||||
| 'serbian'
|
||||
| 'swati'
|
||||
| 'sotho, southern'
|
||||
| 'sundanese'
|
||||
| 'swedish'
|
||||
| 'swahili'
|
||||
| 'tamil'
|
||||
| 'telugu'
|
||||
| 'tajik'
|
||||
| 'thai'
|
||||
| 'tigrinya'
|
||||
| 'turkmen'
|
||||
| 'tagalog'
|
||||
| 'tswana'
|
||||
| 'tonga (tonga islands)'
|
||||
| 'turkish'
|
||||
| 'tsonga'
|
||||
| 'tatar'
|
||||
| 'twi'
|
||||
| 'tahitian'
|
||||
| 'uighur; uyghur'
|
||||
| 'ukrainian'
|
||||
| 'urdu'
|
||||
| 'uzbek'
|
||||
| 'venda'
|
||||
| 'vietnamese'
|
||||
| 'volapük'
|
||||
| 'walloon'
|
||||
| 'wolof'
|
||||
| 'xhosa'
|
||||
| 'yiddish'
|
||||
| 'yoruba'
|
||||
| 'zhuang; chuang'
|
||||
| 'chinese'
|
||||
| 'zulu';
|
||||
|
||||
/**
|
||||
* A List of all possible Languages as ISO 639-1 Codes
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
||||
*/
|
||||
export type SCLanguageCode =
|
||||
| 'aa'
|
||||
| 'ab'
|
||||
| 'ae'
|
||||
| 'af'
|
||||
| 'ak'
|
||||
| 'am'
|
||||
| 'an'
|
||||
| 'ar'
|
||||
| 'as'
|
||||
| 'av'
|
||||
| 'ay'
|
||||
| 'az'
|
||||
| 'ba'
|
||||
| 'be'
|
||||
| 'bg'
|
||||
| 'bh'
|
||||
| 'bi'
|
||||
| 'bm'
|
||||
| 'bn'
|
||||
| 'bo'
|
||||
| 'br'
|
||||
| 'bs'
|
||||
| 'ca'
|
||||
| 'ce'
|
||||
| 'ch'
|
||||
| 'co'
|
||||
| 'cr'
|
||||
| 'cs'
|
||||
| 'cu'
|
||||
| 'cv'
|
||||
| 'cy'
|
||||
| 'da'
|
||||
| 'de'
|
||||
| 'dv'
|
||||
| 'dz'
|
||||
| 'ee'
|
||||
| 'el'
|
||||
| 'en'
|
||||
| 'eo'
|
||||
| 'es'
|
||||
| 'et'
|
||||
| 'eu'
|
||||
| 'fa'
|
||||
| 'ff'
|
||||
| 'fi'
|
||||
| 'fj'
|
||||
| 'fl'
|
||||
| 'fo'
|
||||
| 'fr'
|
||||
| 'fy'
|
||||
| 'ga'
|
||||
| 'gd'
|
||||
| 'gl'
|
||||
| 'gn'
|
||||
| 'gu'
|
||||
| 'gv'
|
||||
| 'ha'
|
||||
| 'he'
|
||||
| 'hi'
|
||||
| 'ho'
|
||||
| 'hr'
|
||||
| 'ht'
|
||||
| 'hu'
|
||||
| 'hy'
|
||||
| 'hz'
|
||||
| 'ia'
|
||||
| 'id'
|
||||
| 'ia'
|
||||
| 'ig'
|
||||
| 'ii'
|
||||
| 'ik'
|
||||
| 'io'
|
||||
| 'is'
|
||||
| 'it'
|
||||
| 'iu'
|
||||
| 'ja'
|
||||
| 'jv'
|
||||
| 'ka'
|
||||
| 'kg'
|
||||
| 'ki'
|
||||
| 'kj'
|
||||
| 'kk'
|
||||
| 'kl'
|
||||
| 'km'
|
||||
| 'kn'
|
||||
| 'ko'
|
||||
| 'kr'
|
||||
| 'ks'
|
||||
| 'ku'
|
||||
| 'kv'
|
||||
| 'kw'
|
||||
| 'ky'
|
||||
| 'la'
|
||||
| 'lb'
|
||||
| 'lg'
|
||||
| 'li'
|
||||
| 'ln'
|
||||
| 'lo'
|
||||
| 'lt'
|
||||
| 'lu'
|
||||
| 'lv'
|
||||
| 'mg'
|
||||
| 'mh'
|
||||
| 'mi'
|
||||
| 'mk'
|
||||
| 'ml'
|
||||
| 'mn'
|
||||
| 'mr'
|
||||
| 'ms'
|
||||
| 'mt'
|
||||
| 'my'
|
||||
| 'na'
|
||||
| 'nb'
|
||||
| 'nd'
|
||||
| 'ne'
|
||||
| 'ng'
|
||||
| 'nl'
|
||||
| 'nn'
|
||||
| 'no'
|
||||
| 'nr'
|
||||
| 'nv'
|
||||
| 'ny'
|
||||
| 'oc'
|
||||
| 'oj'
|
||||
| 'om'
|
||||
| 'or'
|
||||
| 'os'
|
||||
| 'pa'
|
||||
| 'pi'
|
||||
| 'pl'
|
||||
| 'ps'
|
||||
| 'pt'
|
||||
| 'qu'
|
||||
| 'rm'
|
||||
| 'rn'
|
||||
| 'ro'
|
||||
| 'ru'
|
||||
| 'rw'
|
||||
| 'sa'
|
||||
| 'sc'
|
||||
| 'sd'
|
||||
| 'se'
|
||||
| 'sg'
|
||||
| 'si'
|
||||
| 'sk'
|
||||
| 'sl'
|
||||
| 'sm'
|
||||
| 'sn'
|
||||
| 'so'
|
||||
| 'sq'
|
||||
| 'sr'
|
||||
| 'ss'
|
||||
| 'st'
|
||||
| 'su'
|
||||
| 'sv'
|
||||
| 'sw'
|
||||
| 'ta'
|
||||
| 'te'
|
||||
| 'tg'
|
||||
| 'th'
|
||||
| 'ti'
|
||||
| 'tk'
|
||||
| 'tl'
|
||||
| 'tn'
|
||||
| 'to'
|
||||
| 'tr'
|
||||
| 'ts'
|
||||
| 'tt'
|
||||
| 'tw'
|
||||
| 'ty'
|
||||
| 'ug'
|
||||
| 'uk'
|
||||
| 'ur'
|
||||
| 'uz'
|
||||
| 've'
|
||||
| 'vi'
|
||||
| 'vo'
|
||||
| 'wa'
|
||||
| 'wo'
|
||||
| 'xh'
|
||||
| 'yi'
|
||||
| 'yo'
|
||||
| 'za'
|
||||
| 'zh'
|
||||
| 'zu';
|
||||
|
||||
/**
|
||||
* A list of possible nationalities
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
||||
*/
|
||||
export type SCNationality =
|
||||
| 'Afghanistan'
|
||||
| 'Åland Islands'
|
||||
| 'Albania'
|
||||
| 'Algeria'
|
||||
| 'American Samoa'
|
||||
| 'Andorra'
|
||||
| 'Angola'
|
||||
| 'Anguilla'
|
||||
| 'Antarctica'
|
||||
| 'Antigua and Barbuda'
|
||||
| 'Argentina'
|
||||
| 'Armenia'
|
||||
| 'Aruba'
|
||||
| 'Australia'
|
||||
| 'Austria'
|
||||
| 'Azerbaijan'
|
||||
| 'Bahamas'
|
||||
| 'Bahrain'
|
||||
| 'Bangladesh'
|
||||
| 'Barbados'
|
||||
| 'Belarus'
|
||||
| 'Belgium'
|
||||
| 'Belize'
|
||||
| 'Benin'
|
||||
| 'Bermuda'
|
||||
| 'Bhutan'
|
||||
| 'Bolivia (Plurinational State of)'
|
||||
| 'Bonaire, Sint Eustatius and Saba'
|
||||
| 'Bosnia and Herzegovina'
|
||||
| 'Botswana'
|
||||
| 'Bouvet Island'
|
||||
| 'Brazil'
|
||||
| 'British Indian Ocean Territory'
|
||||
| 'Brunei Darussalam'
|
||||
| 'Bulgaria'
|
||||
| 'Burkina Faso'
|
||||
| 'Burundi'
|
||||
| 'Cambodia'
|
||||
| 'Cameroon'
|
||||
| 'Canada'
|
||||
| 'Cabo Verde'
|
||||
| 'Cayman Islands'
|
||||
| 'Central African Republic'
|
||||
| 'Chad'
|
||||
| 'Chile'
|
||||
| 'China'
|
||||
| 'Christmas Island'
|
||||
| 'Cocos (Keeling) Islands'
|
||||
| 'Colombia'
|
||||
| 'Comoros'
|
||||
| 'Congo'
|
||||
| 'Congo (Democratic Republic of the)'
|
||||
| 'Cook Islands'
|
||||
| 'Costa Rica'
|
||||
| "Côte d'Ivoire"
|
||||
| 'Croatia'
|
||||
| 'Cuba'
|
||||
| 'Curaçao'
|
||||
| 'Cyprus'
|
||||
| 'Czech Republic'
|
||||
| 'Denmark'
|
||||
| 'Djibouti'
|
||||
| 'Dominica'
|
||||
| 'Dominican Republic'
|
||||
| 'Ecuador'
|
||||
| 'Egypt'
|
||||
| 'El Salvador'
|
||||
| 'Equatorial Guinea'
|
||||
| 'Eritrea'
|
||||
| 'Estonia'
|
||||
| 'Ethiopia'
|
||||
| 'Falkland Islands (Malvinas)'
|
||||
| 'Faroe Islands'
|
||||
| 'Fiji'
|
||||
| 'Finland'
|
||||
| 'France'
|
||||
| 'French Guiana'
|
||||
| 'French Polynesia'
|
||||
| 'French Southern Territories'
|
||||
| 'Gabon'
|
||||
| 'Gambia'
|
||||
| 'Georgia'
|
||||
| 'Germany'
|
||||
| 'Ghana'
|
||||
| 'Gibraltar'
|
||||
| 'Greece'
|
||||
| 'Greenland'
|
||||
| 'Grenada'
|
||||
| 'Guadeloupe'
|
||||
| 'Guam'
|
||||
| 'Guatemala'
|
||||
| 'Guernsey'
|
||||
| 'Guinea'
|
||||
| 'Guinea-Bissau'
|
||||
| 'Guyana'
|
||||
| 'Haiti'
|
||||
| 'Heard Island and McDonald Islands'
|
||||
| 'Holy See'
|
||||
| 'Honduras'
|
||||
| 'Hong Kong'
|
||||
| 'Hungary'
|
||||
| 'Iceland'
|
||||
| 'India'
|
||||
| 'Indonesia'
|
||||
| 'Iran (Islamic Republic of)'
|
||||
| 'Iraq'
|
||||
| 'Ireland'
|
||||
| 'Isle of Man'
|
||||
| 'Israel'
|
||||
| 'Italy'
|
||||
| 'Jamaica'
|
||||
| 'Japan'
|
||||
| 'Jersey'
|
||||
| 'Jordan'
|
||||
| 'Kazakhstan'
|
||||
| 'Kenya'
|
||||
| 'Kiribati'
|
||||
| "Korea (Democratic People's Republic of)"
|
||||
| 'Korea (Republic of)'
|
||||
| 'Kuwait'
|
||||
| 'Kyrgyzstan'
|
||||
| "Lao People's Democratic Republic"
|
||||
| 'Latvia'
|
||||
| 'Lebanon'
|
||||
| 'Lesotho'
|
||||
| 'Liberia'
|
||||
| 'Libya'
|
||||
| 'Liechtenstein'
|
||||
| 'Lithuania'
|
||||
| 'Luxembourg'
|
||||
| 'Macao'
|
||||
| 'Macedonia (the former Yugoslav Republic of)'
|
||||
| 'Madagascar'
|
||||
| 'Malawi'
|
||||
| 'Malaysia'
|
||||
| 'Maldives'
|
||||
| 'Mali'
|
||||
| 'Malta'
|
||||
| 'Marshall Islands'
|
||||
| 'Martinique'
|
||||
| 'Mauritania'
|
||||
| 'Mauritius'
|
||||
| 'Mayotte'
|
||||
| 'Mexico'
|
||||
| 'Micronesia (Federated States of)'
|
||||
| 'Moldova (Republic of)'
|
||||
| 'Monaco'
|
||||
| 'Mongolia'
|
||||
| 'Montenegro'
|
||||
| 'Montserrat'
|
||||
| 'Morocco'
|
||||
| 'Mozambique'
|
||||
| 'Myanmar'
|
||||
| 'Namibia'
|
||||
| 'Nauru'
|
||||
| 'Nepal'
|
||||
| 'Netherlands'
|
||||
| 'New Caledonia'
|
||||
| 'New Zealand'
|
||||
| 'Nicaragua'
|
||||
| 'Niger'
|
||||
| 'Nigeria'
|
||||
| 'Niue'
|
||||
| 'Norfolk Island'
|
||||
| 'Northern Mariana Islands'
|
||||
| 'Norway'
|
||||
| 'Oman'
|
||||
| 'Pakistan'
|
||||
| 'Palau'
|
||||
| 'Palestine, State of'
|
||||
| 'Panama'
|
||||
| 'Papua New Guinea'
|
||||
| 'Paraguay'
|
||||
| 'Peru'
|
||||
| 'Philippines'
|
||||
| 'Pitcairn'
|
||||
| 'Poland'
|
||||
| 'Portugal'
|
||||
| 'Puerto Rico'
|
||||
| 'Qatar'
|
||||
| 'Réunion'
|
||||
| 'Romania'
|
||||
| 'Russian Federation'
|
||||
| 'Rwanda'
|
||||
| 'Saint Barthélemy'
|
||||
| 'Saint Helena, Ascension and Tristan da Cunha'
|
||||
| 'Saint Kitts and Nevis'
|
||||
| 'Saint Lucia'
|
||||
| 'Saint Martin (French part)'
|
||||
| 'Saint Pierre and Miquelon'
|
||||
| 'Saint Vincent and the Grenadines'
|
||||
| 'Samoa'
|
||||
| 'San Marino'
|
||||
| 'Sao Tome and Principe'
|
||||
| 'Saudi Arabia'
|
||||
| 'Senegal'
|
||||
| 'Serbia'
|
||||
| 'Seychelles'
|
||||
| 'Sierra Leone'
|
||||
| 'Singapore'
|
||||
| 'Sint Maarten (Dutch part)'
|
||||
| 'Slovakia'
|
||||
| 'Slovenia'
|
||||
| 'Solomon Islands'
|
||||
| 'Somalia'
|
||||
| 'South Africa'
|
||||
| 'South Georgia and the South Sandwich Islands'
|
||||
| 'South Sudan'
|
||||
| 'Spain'
|
||||
| 'Sri Lanka'
|
||||
| 'Sudan'
|
||||
| 'Suriname'
|
||||
| 'Svalbard and Jan Mayen'
|
||||
| 'Swaziland'
|
||||
| 'Sweden'
|
||||
| 'Switzerland'
|
||||
| 'Syrian Arab Republic'
|
||||
| 'Taiwan, Province of China'
|
||||
| 'Tajikistan'
|
||||
| 'Tanzania, United Republic of'
|
||||
| 'Thailand'
|
||||
| 'Timor-Leste'
|
||||
| 'Togo'
|
||||
| 'Tokelau'
|
||||
| 'Tonga'
|
||||
| 'Trinidad and Tobago'
|
||||
| 'Tunisia'
|
||||
| 'Turkey'
|
||||
| 'Turkmenistan'
|
||||
| 'Turks and Caicos Islands'
|
||||
| 'Tuvalu'
|
||||
| 'Uganda'
|
||||
| 'Ukraine'
|
||||
| 'United Arab Emirates'
|
||||
| 'United Kingdom of Great Britain and Northern Ireland'
|
||||
| 'United States of America'
|
||||
| 'United States Minor Outlying Islands'
|
||||
| 'Uruguay'
|
||||
| 'Uzbekistan'
|
||||
| 'Vanuatu'
|
||||
| 'Venezuela (Bolivarian Republic of)'
|
||||
| 'Viet Nam'
|
||||
| 'Virgin Islands (British)'
|
||||
| 'Virgin Islands (U.S.)'
|
||||
| 'Wallis and Futuna'
|
||||
| 'Western Sahara'
|
||||
| 'Yemen'
|
||||
| 'Zambia'
|
||||
| 'Zimbabwe';
|
||||
|
||||
/**
|
||||
* Translations for specific languages
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
||||
*/
|
||||
export interface SCTranslations<T> {
|
||||
/**
|
||||
* German translations
|
||||
*/
|
||||
de?: T;
|
||||
|
||||
/**
|
||||
* English translations
|
||||
*/
|
||||
en?: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type to represent requiredness of translation properties.
|
||||
* Will be changed from RecursivePartial to RecursiveRequired in the future.
|
||||
* (Source: https://stackoverflow.com/a/51365037)
|
||||
*/
|
||||
type RecursivePartial<T> = {
|
||||
[P in keyof T]-?: T[P] extends Array<infer U>
|
||||
? Array<RecursivePartial<U>>
|
||||
: T[P] extends object
|
||||
? RecursivePartial<T[P]>
|
||||
: T[P];
|
||||
};
|
||||
|
||||
/**
|
||||
* Type to recursively map keys in <T> to a string value (used for translation)
|
||||
*/
|
||||
type SCRequiredTranslationKeys<T> = {
|
||||
[key in keyof RecursivePartial<T>]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Type that allows mapping from available keys of SCTranslations to SCRequiredTranslationKeys
|
||||
*/
|
||||
type SCRequiredTranslation<T> = {
|
||||
[key in keyof SCTranslations<T>]: SCRequiredTranslationKeys<T>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface to be implemented by all Meta classes
|
||||
*/
|
||||
export interface SCMetaTranslations<T> {
|
||||
/**
|
||||
* Field translations
|
||||
*/
|
||||
fieldTranslations: SCRequiredTranslation<T>;
|
||||
/**
|
||||
* Field value translations
|
||||
*/
|
||||
fieldValueTranslations: unknown;
|
||||
}
|
||||
46
packages/core/src/general/map.ts
Normal file
46
packages/core/src/general/map.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Capsulation for a map with a string as key with values of type `T`
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
|
||||
*
|
||||
* @typeparam T Can be any type.
|
||||
*/
|
||||
export interface SCMap<T> {
|
||||
/**
|
||||
* One value for each key
|
||||
*/
|
||||
[key: string]: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricted map with keys, limited to values of `U`, and corresponding values of type `T`
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
|
||||
* Also note, that this is a type not an interface
|
||||
*
|
||||
* @typeparam U Must be a type the `in` operator can be applied to and contains only strings or numbers
|
||||
* @typeparam T Can be any type
|
||||
*/
|
||||
export type SCRestrictedMap<U extends string | number, T> = {
|
||||
/**
|
||||
* One value for each key
|
||||
*/
|
||||
[key in U]: T;
|
||||
};
|
||||
814
packages/core/src/general/namespaces.ts
Normal file
814
packages/core/src/general/namespaces.ts
Normal file
@@ -0,0 +1,814 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* The license plate of a university e.g. the UID of the university
|
||||
*/
|
||||
export type SCLicensePlate =
|
||||
| 'ac-kf'
|
||||
| 'ac-fk'
|
||||
| 'ac-fh'
|
||||
| 'ac-hm'
|
||||
| 'ac-th'
|
||||
| 'dn-fh'
|
||||
| 'aa-fh'
|
||||
| 'sig-f2'
|
||||
| 'su-ah'
|
||||
| 'rd-vf'
|
||||
| 'am-f2'
|
||||
| 'am-fh'
|
||||
| 'an-fh'
|
||||
| 'ik-fh'
|
||||
| 'ab-fh'
|
||||
| 'asl-vf'
|
||||
| 'a-hm'
|
||||
| 'a-u'
|
||||
| 'a-fh'
|
||||
| 'hef-fh'
|
||||
| 'hg-hs'
|
||||
| 'su-if'
|
||||
| 'cw-ih'
|
||||
| 'tbb-dh'
|
||||
| 'eu-vf'
|
||||
| 'los-pf'
|
||||
| 'esw-pf'
|
||||
| 'ba-u'
|
||||
| 'bt-kh'
|
||||
| 'bt-u'
|
||||
| 'gap-kh'
|
||||
| 'wr-vf'
|
||||
| 'pb-f2'
|
||||
| 'b-ah'
|
||||
| 'b-am'
|
||||
| 'b-fs'
|
||||
| 'b-ab'
|
||||
| 'b-pf'
|
||||
| 'b-tf'
|
||||
| 'b-mu'
|
||||
| 'b-dk'
|
||||
| 'b-p2'
|
||||
| 'b-bs'
|
||||
| 'b-eh'
|
||||
| 'b-hw'
|
||||
| 'b-es'
|
||||
| 'b-em'
|
||||
| 'b-ec'
|
||||
| 'b-ef'
|
||||
| 'b-vf'
|
||||
| 'b-gb'
|
||||
| 'b-hs'
|
||||
| 'b-pk'
|
||||
| 'b-mh'
|
||||
| 'b-ft'
|
||||
| 'b-p3'
|
||||
| 'b-fb'
|
||||
| 'b-wt'
|
||||
| 'b-u2'
|
||||
| 'b-u'
|
||||
| 'b-v2'
|
||||
| 'b-fw'
|
||||
| 'b-p4'
|
||||
| 'b-ih'
|
||||
| 'b-kf'
|
||||
| 'b-mf'
|
||||
| 'b-dh'
|
||||
| 'b-pu'
|
||||
| 'b-ph'
|
||||
| 'b-qh'
|
||||
| 'b-ot'
|
||||
| 'b-fh'
|
||||
| 'b-su'
|
||||
| 'b-tk'
|
||||
| 'b-tc'
|
||||
| 'b-hk'
|
||||
| 'b-wb'
|
||||
| 'b-fp'
|
||||
| 'b-v3'
|
||||
| 'b-fu'
|
||||
| 'b-h3'
|
||||
| 'b-hm'
|
||||
| 'b-kh'
|
||||
| 'b-h4'
|
||||
| 'b-f3'
|
||||
| 'b-f5'
|
||||
| 'b-f2'
|
||||
| 'b-tu'
|
||||
| 'ber-vf'
|
||||
| 'bbg-fh'
|
||||
| 'bbg-hs'
|
||||
| 'w-k2'
|
||||
| 'bi-kh'
|
||||
| 'bc-fh'
|
||||
| 'bi-du'
|
||||
| 'bi-fm'
|
||||
| 'pb-f4'
|
||||
| 'bi-u'
|
||||
| 'bi-fh'
|
||||
| 'bi-vf'
|
||||
| 'wm-hs'
|
||||
| 'mz-fh'
|
||||
| 'tr-f2'
|
||||
| 'bo-eb'
|
||||
| 'bo-fh'
|
||||
| 'bo-f1'
|
||||
| 'bo-fg'
|
||||
| 'bo-hm'
|
||||
| 'bo-f3'
|
||||
| 'bo-kf'
|
||||
| 'bo-u'
|
||||
| 'bn-sg'
|
||||
| 'bn-pf'
|
||||
| 'bn-vf'
|
||||
| 'bn-fh'
|
||||
| 'bn-u'
|
||||
| 'bot-fh'
|
||||
| 'brb-vf'
|
||||
| 'brb-fh'
|
||||
| 'bs-fh'
|
||||
| 'bs-hk'
|
||||
| 'bs-tu'
|
||||
| 'hb-ah'
|
||||
| 'hb-hi'
|
||||
| 'hb-fh'
|
||||
| 'hb-iu'
|
||||
| 'hb-hk'
|
||||
| 'hb-u'
|
||||
| 'hb-vf'
|
||||
| 'hb-h'
|
||||
| 'ka-pu'
|
||||
| 'bm-eu'
|
||||
| 'bm-fb'
|
||||
| 'std-hs'
|
||||
| 'std-fh'
|
||||
| 'cw-fh'
|
||||
| 'cw-hs'
|
||||
| 'ce-pf'
|
||||
| 'c-tu'
|
||||
| 'c-th'
|
||||
| 'gs-tu'
|
||||
| 'co-fh'
|
||||
| 'co-hs'
|
||||
| 'co-f2'
|
||||
| 'cb-fh'
|
||||
| 'cb-tu'
|
||||
| 'da-kf'
|
||||
| 'da-vf'
|
||||
| 'da-fh'
|
||||
| 'da-pf'
|
||||
| 'da-tu'
|
||||
| 'da-v2'
|
||||
| 'deg-fh'
|
||||
| 'de-fh'
|
||||
| 'dt-fl'
|
||||
| 'lip-h2'
|
||||
| 'lip-hm'
|
||||
| 'dt-hm'
|
||||
| 'da-v3'
|
||||
| 'dh-fh'
|
||||
| 'do-fh'
|
||||
| 'do-mh'
|
||||
| 'do-is'
|
||||
| 'do-pf'
|
||||
| 'do-u'
|
||||
| 'do-hm'
|
||||
| 'do-vf'
|
||||
| 'dd-ec'
|
||||
| 'dd-fh'
|
||||
| 'dd-hs'
|
||||
| 'dd-ak'
|
||||
| 'dd-ph'
|
||||
| 'dd-pf'
|
||||
| 'dd-pu'
|
||||
| 'dd-hl'
|
||||
| 'dd-ht'
|
||||
| 'dd-hk'
|
||||
| 'dd-ma'
|
||||
| 'dd-hm'
|
||||
| 'dd-p2'
|
||||
| 'dd-p3'
|
||||
| 'dd-tu'
|
||||
| 'dd-hv'
|
||||
| 'd-iu'
|
||||
| 'du-hm'
|
||||
| 'du-pf'
|
||||
| 'du-ug'
|
||||
| 'du-vf'
|
||||
| 'du-u'
|
||||
| 'd-am'
|
||||
| 'd-eb'
|
||||
| 'd-ff'
|
||||
| 'd-pf'
|
||||
| 'd-fh'
|
||||
| 'd-vf'
|
||||
| 'd-hk'
|
||||
| 'd-hm'
|
||||
| 'd-u'
|
||||
| 'bar-fh'
|
||||
| 'ew-fh'
|
||||
| 'eck-fh'
|
||||
| 'ld-vf'
|
||||
| 'ei-u'
|
||||
| 'pi-f2'
|
||||
| 'ol-f2'
|
||||
| 'hvl-hs'
|
||||
| 'hvl-fh'
|
||||
| 'emd-fh'
|
||||
| 'ed-pf'
|
||||
| 'ef-fh'
|
||||
| 'ef-mh'
|
||||
| 'ef-pf'
|
||||
| 'ef-kh'
|
||||
| 'ef-u'
|
||||
| 'ef-ph'
|
||||
| 'er-u'
|
||||
| 'e-fh'
|
||||
| 'e-p2'
|
||||
| 'e-pf'
|
||||
| 'e-uk'
|
||||
| 'e-u'
|
||||
| 'e-ug'
|
||||
| 'e-hm'
|
||||
| 'es-ft'
|
||||
| 'es-fs'
|
||||
| 'fl-fh'
|
||||
| 'fl-ph'
|
||||
| 'fl-u'
|
||||
| 'f-hb'
|
||||
| 'f-ms'
|
||||
| 'f-u'
|
||||
| 'f-v2'
|
||||
| 'f-fh'
|
||||
| 'f-hk'
|
||||
| 'f-hm'
|
||||
| 'f-kh'
|
||||
| 'f-pf'
|
||||
| 'f-vf'
|
||||
| 'ff-eu'
|
||||
| 'fg-u'
|
||||
| 'fr-fh'
|
||||
| 'fr-kf'
|
||||
| 'fr-u'
|
||||
| 'fr-hm'
|
||||
| 'fr-ph'
|
||||
| 'fb-fh'
|
||||
| 'hal-kh'
|
||||
| 'fn-dh'
|
||||
| 'fn-u'
|
||||
| 'fd-fh'
|
||||
| 'fd-kh'
|
||||
| 'ffb-vf'
|
||||
| 'vs-fh'
|
||||
| 'wi-f2'
|
||||
| 'ul-f2'
|
||||
| 'ge-f3'
|
||||
| 'ge-fh'
|
||||
| 'ge-f2'
|
||||
| 'ge-vf'
|
||||
| 'g-pf'
|
||||
| 'ger-u'
|
||||
| 'gi-ft'
|
||||
| 'gi-fh'
|
||||
| 'gi-vf'
|
||||
| 'gi-u'
|
||||
| 'gp-fh'
|
||||
| 'zi-hw'
|
||||
| 'gth-vf'
|
||||
| 'g-hs'
|
||||
| 'goe-fh'
|
||||
| 'goe-u'
|
||||
| 'goe-pf'
|
||||
| 'gw-u'
|
||||
| 'nb-u'
|
||||
| 'gw-u2'
|
||||
| 'gw-u1'
|
||||
| 'hgw-u'
|
||||
| 'gue-fh'
|
||||
| 'gue-vf'
|
||||
| 'pb-f3'
|
||||
| 'gt-pf'
|
||||
| 'ww-vf'
|
||||
| 'ha-ug'
|
||||
| 'ha-fh'
|
||||
| 'ha-f2'
|
||||
| 'ha-vf'
|
||||
| 'hbs-fh'
|
||||
| 'hbs-vf'
|
||||
| 'hal-eh'
|
||||
| 'hal-hk'
|
||||
| 'hal-ph'
|
||||
| 'hal-u'
|
||||
| 'hal-u2'
|
||||
| 'koet-ph'
|
||||
| 'hal-uw'
|
||||
| 'hh-am'
|
||||
| 'hh-bs'
|
||||
| 'hh-pf'
|
||||
| 'hh-bc'
|
||||
| 'hh-ef'
|
||||
| 'hh-fh'
|
||||
| 'hh-hu'
|
||||
| 'hh-ub'
|
||||
| 'hh-ff'
|
||||
| 'hh-vf'
|
||||
| 'hh-fi'
|
||||
| 'hh-ba'
|
||||
| 'hh-ib'
|
||||
| 'hh-mf'
|
||||
| 'hh-ms'
|
||||
| 'hh-hf'
|
||||
| 'hh-u'
|
||||
| 'hh-hs'
|
||||
| 'hh-uk'
|
||||
| 'hh-fs'
|
||||
| 'hh-hk'
|
||||
| 'hh-hm'
|
||||
| 'hh-tu'
|
||||
| 'hm-hs'
|
||||
| 'ham-f2'
|
||||
| 'ham-fh'
|
||||
| 'h-fg'
|
||||
| 'h-fh'
|
||||
| 'h-hm'
|
||||
| 'h-vf'
|
||||
| 'h-la'
|
||||
| 'h-u'
|
||||
| 'h-fb'
|
||||
| 'h-kf'
|
||||
| 'h-mh'
|
||||
| 'h-f3'
|
||||
| 'h-pf'
|
||||
| 'h-ti'
|
||||
| 'hei-fh'
|
||||
| 'hd-hm'
|
||||
| 'hd-ph'
|
||||
| 'hd-kh'
|
||||
| 'hd-u'
|
||||
| 'hd-fh'
|
||||
| 'hdh-dh'
|
||||
| 'hn-dh'
|
||||
| 'hn-bs'
|
||||
| 'hn-fh'
|
||||
| 'hn-f2'
|
||||
| 'su-f3'
|
||||
| 'su-k2'
|
||||
| 'he-hk'
|
||||
| 'sta-v2'
|
||||
| 'hi-fg'
|
||||
| 'hi-fs'
|
||||
| 'hi-fh'
|
||||
| 'hi-v2'
|
||||
| 'hi-vf'
|
||||
| 'hi-u'
|
||||
| 'hi-v3'
|
||||
| 'ho-fh'
|
||||
| 'ho-f2'
|
||||
| 'ho-vf'
|
||||
| 's-u2'
|
||||
| 'ww-fh'
|
||||
| 'hol-fh'
|
||||
| 'fds-dh'
|
||||
| 'hx-fh'
|
||||
| 'lip-h3'
|
||||
| 'hx-ug'
|
||||
| 'tr-f3'
|
||||
| 'mz-f5'
|
||||
| 'wi-f5'
|
||||
| 'wi-f4'
|
||||
| 'rued-pf'
|
||||
| 'ik-tu'
|
||||
| 'il-th'
|
||||
| 'in-fh'
|
||||
| 'in-u'
|
||||
| 'mk-ts'
|
||||
| 'mk-fh'
|
||||
| 'rv-pf'
|
||||
| 'j-fh'
|
||||
| 'j-u'
|
||||
| 'kl-fh'
|
||||
| 'kl-u'
|
||||
| 'wes-fh'
|
||||
| 'ka-dh'
|
||||
| 'ka-fh'
|
||||
| 'ka-pf'
|
||||
| 'ka-u'
|
||||
| 'ka-hk'
|
||||
| 'ka-hg'
|
||||
| 'ka-hm'
|
||||
| 'ka-ph'
|
||||
| 'ks-cv'
|
||||
| 'ks-pf'
|
||||
| 'ks-fh'
|
||||
| 'ks-ms'
|
||||
| 'ks-u3'
|
||||
| 'ks-ug'
|
||||
| 'ks-vf'
|
||||
| 'ks-u2'
|
||||
| 'og-vf'
|
||||
| 'ke-fh'
|
||||
| 'ki-u'
|
||||
| 'ki-fh'
|
||||
| 'ki-f2'
|
||||
| 'ki-f6'
|
||||
| 'ki-hk'
|
||||
| 'ki-f3'
|
||||
| 'ki-f4'
|
||||
| 'ki-f5'
|
||||
| 'ki-ph'
|
||||
| 'kle-fh'
|
||||
| 'ko-fh'
|
||||
| 'ko-u3'
|
||||
| 'ko-u'
|
||||
| 'ko-vf'
|
||||
| 'k-iu'
|
||||
| 'k-cb'
|
||||
| 'k-fm'
|
||||
| 'k-fp'
|
||||
| 'k-kf'
|
||||
| 'k-mf'
|
||||
| 'k-p2'
|
||||
| 'k-u'
|
||||
| 'k-fb'
|
||||
| 'k-u2'
|
||||
| 'k-fh'
|
||||
| 'k-vf'
|
||||
| 'k-hk'
|
||||
| 'k-hm'
|
||||
| 'k-pf'
|
||||
| 'k-v2'
|
||||
| 'k-f2'
|
||||
| 'kw-fh'
|
||||
| 'kn-fh'
|
||||
| 'kn-f2'
|
||||
| 'kn-u'
|
||||
| 'koet-fh'
|
||||
| 'koet-th'
|
||||
| 'koet-u'
|
||||
| 'kr-fh'
|
||||
| 'og-fw'
|
||||
| 'ld-u'
|
||||
| 'la-fh'
|
||||
| 'da-v4'
|
||||
| 'ler-fh'
|
||||
| 'l-fb'
|
||||
| 'l-f2'
|
||||
| 'l-kh'
|
||||
| 'l-h3'
|
||||
| 'l-hh'
|
||||
| 'l-hm'
|
||||
| 'l-h2'
|
||||
| 'l-ph'
|
||||
| 'l-hs'
|
||||
| 'l-ht'
|
||||
| 'l-th'
|
||||
| 'l-u'
|
||||
| 'mer-th'
|
||||
| 'lev-pf'
|
||||
| 'lev-fh'
|
||||
| 'fg-fh'
|
||||
| 'lip-f2'
|
||||
| 'lip-h1'
|
||||
| 'lip-fh'
|
||||
| 'so-f2'
|
||||
| 'loe-dh'
|
||||
| 'hl-fh'
|
||||
| 'hl-vf'
|
||||
| 'hl-f3'
|
||||
| 'hl-uk'
|
||||
| 'hl-u'
|
||||
| 'hl-f2'
|
||||
| 'hl-hm'
|
||||
| 'lb-v2'
|
||||
| 'lb-fh'
|
||||
| 'lb-ph'
|
||||
| 'lb-p2'
|
||||
| 'lb-vf'
|
||||
| 'lu-fh'
|
||||
| 'lu-kf'
|
||||
| 'lg-u'
|
||||
| 'lg-fh'
|
||||
| 'md-f2'
|
||||
| 'md-fh'
|
||||
| 'md-tu'
|
||||
| 'md-f3'
|
||||
| 'md-mh'
|
||||
| 'md-ph'
|
||||
| 'md-u'
|
||||
| 'mz-f4'
|
||||
| 'mz-u2'
|
||||
| 'mz-vf'
|
||||
| 'mz-f3'
|
||||
| 'mz-f2'
|
||||
| 'mz-u'
|
||||
| 'mz-kf'
|
||||
| 'ma-dh'
|
||||
| 'ma-fg'
|
||||
| 'ma-ft'
|
||||
| 'ma-ba'
|
||||
| 'ma-v3'
|
||||
| 'ma-v2'
|
||||
| 'ma-hm'
|
||||
| 'ma-fs'
|
||||
| 'ma-u'
|
||||
| 'mr-eh'
|
||||
| 'mr-fh'
|
||||
| 'mr-u'
|
||||
| 're-pf'
|
||||
| 'myk-vf'
|
||||
| 'mgn-vf'
|
||||
| 'mei-fh'
|
||||
| 'mei-fv'
|
||||
| 'mei-f2'
|
||||
| 'sk-hs'
|
||||
| 'hal-fh'
|
||||
| 'hsk-fh'
|
||||
| 'me-fh'
|
||||
| 'rt-hs'
|
||||
| 'mi-fh'
|
||||
| 'c-fh'
|
||||
| 'mw-ht'
|
||||
| 'hc-ih'
|
||||
| 'mtw-ht'
|
||||
| 'mg-fh'
|
||||
| 'z-fh'
|
||||
| 'mos-dh'
|
||||
| 'mh-fh'
|
||||
| 'm-am'
|
||||
| 'm-b2'
|
||||
| 'm-bw'
|
||||
| 'm-ea'
|
||||
| 'm-vf'
|
||||
| 'm-as'
|
||||
| 'm-mf'
|
||||
| 'm-hk'
|
||||
| 'm-hs'
|
||||
| 'm-fh'
|
||||
| 'm-kf'
|
||||
| 'm-hm'
|
||||
| 'm-kh'
|
||||
| 'm-hp'
|
||||
| 'm-fp'
|
||||
| 'm-tu'
|
||||
| 'm-u'
|
||||
| 'gap-ks'
|
||||
| 'm-u2'
|
||||
| 'm-t2'
|
||||
| 'ms-ph'
|
||||
| 'ms-kf'
|
||||
| 'ms-u'
|
||||
| 'ms-fh'
|
||||
| 'ms-vf'
|
||||
| 'ms-hk'
|
||||
| 'ms-hm'
|
||||
| 'ms-kh'
|
||||
| 'ms-v2'
|
||||
| 'nmb-kh'
|
||||
| 'nb-fh'
|
||||
| 'm-ah'
|
||||
| 'm-k3'
|
||||
| 'ne-eu'
|
||||
| 'ne-hs'
|
||||
| 'ne-pf'
|
||||
| 'nu-fh'
|
||||
| 'h-f2'
|
||||
| 'ndh-fh'
|
||||
| 'coe-vf'
|
||||
| 'n-kf'
|
||||
| 'n-hm'
|
||||
| 'n-hk'
|
||||
| 'n-k1'
|
||||
| 'n-k2'
|
||||
| 'n-k3'
|
||||
| 'n-fh'
|
||||
| 'n-u'
|
||||
| 'nt-fh'
|
||||
| 'nt-f3'
|
||||
| 'gp-f2'
|
||||
| 'gr-kh'
|
||||
| 'hg-kh'
|
||||
| 'wi-eb'
|
||||
| 'of-hk'
|
||||
| 'fr-f2'
|
||||
| 'ol-fh'
|
||||
| 'ol-pf'
|
||||
| 'ol-u'
|
||||
| 'os-f2'
|
||||
| 'os-fh'
|
||||
| 'os-f3'
|
||||
| 'os-u'
|
||||
| 'os-kf'
|
||||
| 'ver-fh'
|
||||
| 'pb-fh'
|
||||
| 'pb-kf'
|
||||
| 'pb-kh'
|
||||
| 'pb-ug'
|
||||
| 'pb-f1'
|
||||
| 'pb-u2'
|
||||
| 'pa-u'
|
||||
| 'pf-fg'
|
||||
| 'pf-fh'
|
||||
| 'ps-fh'
|
||||
| 'pl-fh'
|
||||
| 'p-bs'
|
||||
| 'p-f2'
|
||||
| 'p-sh'
|
||||
| 'p-pf'
|
||||
| 'p-u'
|
||||
| 'p-fh'
|
||||
| 'p-hf'
|
||||
| 'brb-f2'
|
||||
| 'dd-f2'
|
||||
| 'rv-fh'
|
||||
| 'rv-dh'
|
||||
| 'r-kh'
|
||||
| 'r-u'
|
||||
| 'r-fh'
|
||||
| 'rd-v2'
|
||||
| 'ko-f2'
|
||||
| 'rd-bf'
|
||||
| 'rd-fh'
|
||||
| 'rt-fh'
|
||||
| 'rt-ts'
|
||||
| 'rt-ft'
|
||||
| 'su-f2'
|
||||
| 'st-mh'
|
||||
| 'bc-f2'
|
||||
| 'rie-fh'
|
||||
| 'shg-vf'
|
||||
| 'ro-fh'
|
||||
| 'ros-hm'
|
||||
| 'ros-im'
|
||||
| 'hro-hu'
|
||||
| 'hro-u'
|
||||
| 'hro-hm'
|
||||
| 'rof-vf'
|
||||
| 'nol-fh'
|
||||
| 'tue-fh'
|
||||
| 'wi-f3'
|
||||
| 'sb-f2'
|
||||
| 'sb-hm'
|
||||
| 'sb-hs'
|
||||
| 'sb-vf'
|
||||
| 'sb-hk'
|
||||
| 'sb-fh'
|
||||
| 'sb-kf'
|
||||
| 'sb-u'
|
||||
| 'sz-fh'
|
||||
| 'sm-fh'
|
||||
| 'aa-fg'
|
||||
| 'aa-ph'
|
||||
| 'sha-ht'
|
||||
| 'sha-kh'
|
||||
| 'sad-pf'
|
||||
| 'ru-fh'
|
||||
| 'wue-f2'
|
||||
| 'lds-bc'
|
||||
| 'sn-hm'
|
||||
| 'hd-vf'
|
||||
| 'sfb-fh'
|
||||
| 'si-pf'
|
||||
| 'si-ug'
|
||||
| 'sig-fh'
|
||||
| 'so-fh'
|
||||
| 'so-vf'
|
||||
| 'so-ug'
|
||||
| 'sp-u'
|
||||
| 'su-fh'
|
||||
| 'su-kh'
|
||||
| 'sta-vf'
|
||||
| 'st-fh'
|
||||
| 'sdl-fh'
|
||||
| 'hst-fh'
|
||||
| 'hst-f2'
|
||||
| 'sr-fh'
|
||||
| 'og-fh'
|
||||
| 's-dp'
|
||||
| 's-dh'
|
||||
| 's-f2'
|
||||
| 's-im'
|
||||
| 's-kf'
|
||||
| 's-u'
|
||||
| 's-va'
|
||||
| 's-wh'
|
||||
| 's-hk'
|
||||
| 's-fh'
|
||||
| 's-fb'
|
||||
| 's-hm'
|
||||
| 's-mf'
|
||||
| 's-f3'
|
||||
| 's-th'
|
||||
| 'ue-fh'
|
||||
| 'k-v3'
|
||||
| 'k-f3'
|
||||
| 'tr-fh'
|
||||
| 'tr-kh'
|
||||
| 'tr-u'
|
||||
| 'an-f2'
|
||||
| 'tut-hm'
|
||||
| 'tue-u'
|
||||
| 'tut-f3'
|
||||
| 'ul-fh'
|
||||
| 'ul-f4'
|
||||
| 'ul-u'
|
||||
| 'myk-kh'
|
||||
| 'vec-fh'
|
||||
| 'vec-u'
|
||||
| 'vec-kf'
|
||||
| 'bo-f2'
|
||||
| 'vs-vf'
|
||||
| 'vs-dh'
|
||||
| 'vs-f2'
|
||||
| 'ros-hs'
|
||||
| 'ro-vf'
|
||||
| 'pi-fh'
|
||||
| 'fs-fh'
|
||||
| 'we-hm'
|
||||
| 'we-u'
|
||||
| 'we-vf'
|
||||
| 'we-th'
|
||||
| 'kn-ph'
|
||||
| 'rv-ph'
|
||||
| 'wsf-pf'
|
||||
| 'wr-fh'
|
||||
| 'wr-v2'
|
||||
| 'qlb-vf'
|
||||
| 'ldk-fh'
|
||||
| 'wi-bs'
|
||||
| 'wi-v1'
|
||||
| 'wi-fh'
|
||||
| 'wi-vf'
|
||||
| 'kw-th'
|
||||
| 'whv-fh'
|
||||
| 'hwi-fh'
|
||||
| 'wis-th'
|
||||
| 'wis-fh'
|
||||
| 'en-u'
|
||||
| 'wf-fh'
|
||||
| 'wob-fh'
|
||||
| 'wo-fh'
|
||||
| 'w-hm'
|
||||
| 'w-kh'
|
||||
| 'w-ug'
|
||||
| 'w-vf'
|
||||
| 'wue-hm'
|
||||
| 'wue-u'
|
||||
| 'wue-fh'
|
||||
| 'wue-f3'
|
||||
| 'zi-ht'
|
||||
| 'zi-ih'
|
||||
| 'zi-th'
|
||||
| 'zw-fh'
|
||||
| 'z-t3'
|
||||
| 'z-t2'
|
||||
| 'z-pf'
|
||||
| 'z-hs'
|
||||
| 'z-ph'
|
||||
| 'z-th'
|
||||
| 'z-tu'
|
||||
| 'z-ht'
|
||||
| 'rc-hs'
|
||||
| 'z-p2';
|
||||
|
||||
/**
|
||||
* Namespaces for universities for UUID generation
|
||||
*/
|
||||
export const SCNamespaces: {[id in SCLicensePlate]?: string} = {
|
||||
/**
|
||||
* Namespace for Hochschule Aschaffenburg
|
||||
*/
|
||||
'ab-fh': 'b28746bb-e95e-4d4d-bf21-1c0a3bb7e83e',
|
||||
/**
|
||||
* Namespace for Technische Universität Berlin
|
||||
*/
|
||||
'b-tu': '909a8cbc-8520-456c-b474-ef1525f14209',
|
||||
/**
|
||||
* Namespace for Goethe-Universität Frankfurt am Main
|
||||
*/
|
||||
'f-u': 'fa256ea6-942d-4ead-96da-5d7678e9e965',
|
||||
/**
|
||||
* Namespace for Hochschule Fulda
|
||||
*/
|
||||
'fd-fh': 'f1aa9ac0-ed3d-493b-987c-f98aeeba154b',
|
||||
/**
|
||||
* Namespace for Technische Hochschule Mittelhessen
|
||||
*/
|
||||
'gi-fh': 'f599f1d1-5b76-4654-a394-d37680d75e22',
|
||||
/**
|
||||
* Namespace for Justus-Liebig-Universität Gießen
|
||||
*/
|
||||
'gi-u': '9884e6f2-cbbb-4341-8d30-5ba3f1514927',
|
||||
/**
|
||||
* Namespace for Universität Kassel
|
||||
*/
|
||||
'ks-ug': '277fe8f6-dbc9-4ec2-9f87-d30e0dc347af',
|
||||
};
|
||||
37
packages/core/src/general/time.ts
Normal file
37
packages/core/src/general/time.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* An ISO8601 date
|
||||
*
|
||||
* @pattern ^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])(T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])([\.,][0-9]{0,7})?(Z|[+-](?:2[0-3]|[01][0-9])(:?[0-5][0-9])?)?)?$
|
||||
* @see https://gist.github.com/philipashlock/8830168
|
||||
* @date
|
||||
*/
|
||||
export type SCISO8601Date = string;
|
||||
|
||||
/**
|
||||
* An ISO8601 duration
|
||||
*
|
||||
* @pattern ^(R\d*\/)?P(?:\d+(?:\.\d+)?Y)?(?:\d+(?:\.\d+)?M)?(?:\d+(?:\.\d+)?W)?(?:\d+(?:\.\d+)?D)?(?:T(?:\d+(?:\.\d+)?H)?(?:\d+(?:\.\d+)?M)?(?:\d+(?:\.\d+)?S)?)?$
|
||||
* @see https://gist.github.com/philipashlock/8830168
|
||||
*/
|
||||
export type SCISO8601Duration = string;
|
||||
|
||||
/**
|
||||
* An ISO8601 time
|
||||
*
|
||||
* @pattern ^(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])$
|
||||
*/
|
||||
export type SCISO8601Time = string;
|
||||
22
packages/core/src/general/uuid.ts
Normal file
22
packages/core/src/general/uuid.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* Universally unique identifier of the thing
|
||||
*
|
||||
* @filterable
|
||||
* @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
|
||||
* @see http://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
|
||||
*/
|
||||
export type SCUuid = string;
|
||||
132
packages/core/src/guards.ts
Normal file
132
packages/core/src/guards.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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
|
||||
* unknown 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 {SCTranslations} from './general/i18n';
|
||||
import {SCBulkResponse} from './protocol/routes/bulk-request';
|
||||
import {SCSearchResponse} from './protocol/routes/search';
|
||||
import {SCMultiSearchResponse} from './protocol/routes/search-multi';
|
||||
import {
|
||||
SCThing,
|
||||
SCThingTranslatableProperties,
|
||||
SCThingType,
|
||||
SCThingWithoutReferences,
|
||||
} from './things/abstract/thing';
|
||||
|
||||
/**
|
||||
* Type guard to check if something is a SCThing
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isThing(something: unknown): something is SCThing {
|
||||
if (typeof something !== 'object' || something === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!('type' in something)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const type = (something as {type: unknown}).type;
|
||||
|
||||
if (typeof type !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Object.values(SCThingType).includes(type as SCThingType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if translations exist
|
||||
*
|
||||
* @param thing Thing to check
|
||||
*/
|
||||
export function isThingWithTranslations(
|
||||
thing: SCThingWithoutReferences,
|
||||
): thing is SCThingWithoutReferences & {translations: SCTranslations<SCThingTranslatableProperties>} {
|
||||
return thing.translations !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if something is a bulk response
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
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 {
|
||||
expiration: unknown;
|
||||
source: unknown;
|
||||
state: unknown;
|
||||
type: unknown;
|
||||
uid: unknown;
|
||||
};
|
||||
|
||||
return (
|
||||
typeof expiration === 'string' &&
|
||||
typeof source === 'string' &&
|
||||
typeof state === 'string' &&
|
||||
typeof type === 'string' &&
|
||||
typeof uid === 'string'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if something is a search response
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
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) &&
|
||||
somethingObject.pagination !== undefined &&
|
||||
typeof somethingObject.pagination.count === 'number' &&
|
||||
typeof somethingObject.pagination.offset === 'number' &&
|
||||
typeof somethingObject.pagination.total === 'number' &&
|
||||
somethingObject.stats !== undefined &&
|
||||
typeof somethingObject.stats.time === 'number'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if something is a multi search response
|
||||
*
|
||||
* @param something Something to check
|
||||
*/
|
||||
export function isMultiSearchResponse(something: unknown): something is SCMultiSearchResponse {
|
||||
const initialValue = Object.keys(something as {[key: string]: string}).length > 0 ? true : false;
|
||||
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
return Object.keys(something as {[key: string]: string}).reduce((previousOnesAreSearchResponses, key) => {
|
||||
return previousOnesAreSearchResponses && isSearchResponse((something as {[key: string]: string})[key]);
|
||||
}, initialValue as boolean);
|
||||
}
|
||||
252
packages/core/src/meta.ts
Normal file
252
packages/core/src/meta.ts
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* 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 {SCThingType} from './things/abstract/thing';
|
||||
import {
|
||||
SCAcademicEvent,
|
||||
SCAcademicEventMeta,
|
||||
SCAcademicEventWithoutReferences,
|
||||
} from './things/academic-event';
|
||||
import {SCArticle, SCArticleMeta, SCArticleWithoutReferences} from './things/article';
|
||||
import {SCAssessment, SCAssessmentMeta, SCAssessmentWithoutReferences} from './things/assessment';
|
||||
import {SCBook, SCBookMeta, SCBookWithoutReferences} from './things/book';
|
||||
import {SCBuilding, SCBuildingMeta, SCBuildingWithoutReferences} from './things/building';
|
||||
import {SCCatalog, SCCatalogMeta, SCCatalogWithoutReferences} from './things/catalog';
|
||||
import {SCContactPoint, SCContactPointMeta, SCContactPointWithoutReferences} from './things/contact-point';
|
||||
import {
|
||||
SCCourseOfStudy,
|
||||
SCCourseOfStudyMeta,
|
||||
SCCourseOfStudyWithoutReferences,
|
||||
} from './things/course-of-study';
|
||||
import {SCDateSeries, SCDateSeriesMeta, SCDateSeriesWithoutReferences} from './things/date-series';
|
||||
import {SCDiff, SCDiffMeta, SCDiffWithoutReferences} from './things/diff';
|
||||
import {SCDish, SCDishMeta, SCDishWithoutReferences} from './things/dish';
|
||||
import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/favorite';
|
||||
import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/floor';
|
||||
import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/message';
|
||||
import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/organization';
|
||||
import {SCPeriodical, SCPeriodicalMeta, SCPeriodicalWithoutReferences} from './things/periodical';
|
||||
import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/person';
|
||||
import {
|
||||
SCPointOfInterest,
|
||||
SCPointOfInterestMeta,
|
||||
SCPointOfInterestWithoutReferences,
|
||||
} from './things/point-of-interest';
|
||||
import {
|
||||
SCPublicationEvent,
|
||||
SCPublicationEventMeta,
|
||||
SCPublicationEventWithoutReferences,
|
||||
} from './things/publication-event';
|
||||
import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/room';
|
||||
import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/semester';
|
||||
import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/setting';
|
||||
import {SCSportCourse, SCSportCourseMeta, SCSportCourseWithoutReferences} from './things/sport-course';
|
||||
import {SCStudyModule, SCStudyModuleMeta, SCStudyModuleWithoutReferences} from './things/study-module';
|
||||
import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/ticket';
|
||||
import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/todo';
|
||||
import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/tour';
|
||||
import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/video';
|
||||
|
||||
/**
|
||||
* A map of things, from type to meta data
|
||||
*/
|
||||
export const SCClasses: {[K in SCThingType]: object} = {
|
||||
'assessment': SCAssessmentMeta,
|
||||
'academic event': SCAcademicEventMeta,
|
||||
'article': SCArticleMeta,
|
||||
'book': SCBookMeta,
|
||||
'building': SCBuildingMeta,
|
||||
'catalog': SCCatalogMeta,
|
||||
'contact point': SCContactPointMeta,
|
||||
'course of study': SCCourseOfStudyMeta,
|
||||
'date series': SCDateSeriesMeta,
|
||||
'diff': SCDiffMeta,
|
||||
'dish': SCDishMeta,
|
||||
'favorite': SCFavoriteMeta,
|
||||
'floor': SCFloorMeta,
|
||||
'message': SCMessageMeta,
|
||||
'organization': SCOrganizationMeta,
|
||||
'periodical': SCPeriodicalMeta,
|
||||
'person': SCPersonMeta,
|
||||
'point of interest': SCPointOfInterestMeta,
|
||||
'publication event': SCPublicationEventMeta,
|
||||
'room': SCRoomMeta,
|
||||
'semester': SCSemesterMeta,
|
||||
'setting': SCSettingMeta,
|
||||
'sport course': SCSportCourseMeta,
|
||||
'study module': SCStudyModuleMeta,
|
||||
'ticket': SCTicketMeta,
|
||||
'todo': SCToDoMeta,
|
||||
'tour': SCTourMeta,
|
||||
'video': SCVideoMeta,
|
||||
};
|
||||
|
||||
export type SCIndexableThings =
|
||||
| SCAssessment
|
||||
| SCAcademicEvent
|
||||
| SCArticle
|
||||
| SCBook
|
||||
| SCBuilding
|
||||
| SCCatalog
|
||||
| SCContactPoint
|
||||
| SCCourseOfStudy
|
||||
| SCDateSeries
|
||||
| SCDish
|
||||
| SCFloor
|
||||
| SCMessage
|
||||
| SCOrganization
|
||||
| SCPeriodical
|
||||
| SCPerson
|
||||
| SCPointOfInterest
|
||||
| SCPublicationEvent
|
||||
| SCRoom
|
||||
| SCSemester
|
||||
| SCSportCourse
|
||||
| SCStudyModule
|
||||
| SCTicket
|
||||
| SCToDo
|
||||
| SCTour
|
||||
| SCVideo;
|
||||
|
||||
/**
|
||||
* An object that exists in the StAppsCore
|
||||
*/
|
||||
export type SCThings = SCIndexableThings | SCDiff | SCFavorite | SCSetting;
|
||||
|
||||
/**
|
||||
* A field of a thing
|
||||
*/
|
||||
export type SCThingsField = keyof SCThings | string;
|
||||
|
||||
/**
|
||||
* Thing without references for a thing
|
||||
*/
|
||||
export type SCAssociatedThingWithoutReferences<THING extends SCThings> = THING extends SCAssessment
|
||||
? SCAssessmentWithoutReferences
|
||||
: THING extends SCAcademicEvent
|
||||
? SCAcademicEventWithoutReferences
|
||||
: THING extends SCArticle
|
||||
? SCArticleWithoutReferences
|
||||
: THING extends SCBook
|
||||
? SCBookWithoutReferences
|
||||
: THING extends SCBuilding
|
||||
? SCBuildingWithoutReferences
|
||||
: THING extends SCCatalog
|
||||
? SCCatalogWithoutReferences
|
||||
: THING extends SCContactPoint
|
||||
? SCContactPointWithoutReferences
|
||||
: THING extends SCCourseOfStudy
|
||||
? SCCourseOfStudyWithoutReferences
|
||||
: THING extends SCDateSeries
|
||||
? SCDateSeriesWithoutReferences
|
||||
: THING extends SCDiff
|
||||
? SCDiffWithoutReferences
|
||||
: THING extends SCDish
|
||||
? SCDishWithoutReferences
|
||||
: THING extends SCFavorite
|
||||
? SCFavoriteWithoutReferences
|
||||
: THING extends SCFloor
|
||||
? SCFloorWithoutReferences
|
||||
: THING extends SCMessage
|
||||
? SCMessageWithoutReferences
|
||||
: THING extends SCOrganization
|
||||
? SCOrganizationWithoutReferences
|
||||
: THING extends SCPeriodical
|
||||
? SCPeriodicalWithoutReferences
|
||||
: THING extends SCPerson
|
||||
? SCPersonWithoutReferences
|
||||
: THING extends SCPointOfInterest
|
||||
? SCPointOfInterestWithoutReferences
|
||||
: THING extends SCPublicationEvent
|
||||
? SCPublicationEventWithoutReferences
|
||||
: THING extends SCRoom
|
||||
? SCRoomWithoutReferences
|
||||
: THING extends SCSemester
|
||||
? SCSemesterWithoutReferences
|
||||
: THING extends SCSetting
|
||||
? SCSettingWithoutReferences
|
||||
: THING extends SCSportCourse
|
||||
? SCSportCourseWithoutReferences
|
||||
: THING extends SCStudyModule
|
||||
? SCStudyModuleWithoutReferences
|
||||
: THING extends SCTicket
|
||||
? SCTicketWithoutReferences
|
||||
: THING extends SCToDo
|
||||
? SCToDoWithoutReferences
|
||||
: THING extends SCTour
|
||||
? SCTourWithoutReferences
|
||||
: THING extends SCVideo
|
||||
? SCVideoWithoutReferences
|
||||
: never;
|
||||
|
||||
/**
|
||||
* Thing for a thing without references
|
||||
*/
|
||||
export type SCAssociatedThing<THING extends SCThings> = THING extends SCAssessmentWithoutReferences
|
||||
? SCAssessment
|
||||
: THING extends SCAcademicEventWithoutReferences
|
||||
? SCAcademicEvent
|
||||
: THING extends SCArticleWithoutReferences
|
||||
? SCArticle
|
||||
: THING extends SCBookWithoutReferences
|
||||
? SCBook
|
||||
: THING extends SCBuildingWithoutReferences
|
||||
? SCBuilding
|
||||
: THING extends SCCatalogWithoutReferences
|
||||
? SCCatalog
|
||||
: THING extends SCContactPointWithoutReferences
|
||||
? SCContactPoint
|
||||
: THING extends SCCourseOfStudyWithoutReferences
|
||||
? SCCourseOfStudy
|
||||
: THING extends SCDateSeriesWithoutReferences
|
||||
? SCDateSeries
|
||||
: THING extends SCDiffWithoutReferences
|
||||
? SCDiff
|
||||
: THING extends SCDishWithoutReferences
|
||||
? SCDish
|
||||
: THING extends SCFavoriteWithoutReferences
|
||||
? SCFavorite
|
||||
: THING extends SCFloorWithoutReferences
|
||||
? SCFloor
|
||||
: THING extends SCMessageWithoutReferences
|
||||
? SCMessage
|
||||
: THING extends SCOrganizationWithoutReferences
|
||||
? SCOrganization
|
||||
: THING extends SCPeriodicalWithoutReferences
|
||||
? SCPeriodical
|
||||
: THING extends SCPersonWithoutReferences
|
||||
? SCPerson
|
||||
: THING extends SCPointOfInterestWithoutReferences
|
||||
? SCPointOfInterest
|
||||
: THING extends SCPublicationEventWithoutReferences
|
||||
? SCPublicationEvent
|
||||
: THING extends SCRoomWithoutReferences
|
||||
? SCRoom
|
||||
: THING extends SCSemesterWithoutReferences
|
||||
? SCSemester
|
||||
: THING extends SCSettingWithoutReferences
|
||||
? SCSetting
|
||||
: THING extends SCSportCourseWithoutReferences
|
||||
? SCSportCourse
|
||||
: THING extends SCStudyModuleWithoutReferences
|
||||
? SCStudyModule
|
||||
: THING extends SCTicketWithoutReferences
|
||||
? SCTicket
|
||||
: THING extends SCToDoWithoutReferences
|
||||
? SCToDo
|
||||
: THING extends SCTourWithoutReferences
|
||||
? SCTour
|
||||
: THING extends SCVideoWithoutReferences
|
||||
? SCVideo
|
||||
: never;
|
||||
57
packages/core/src/protocol/error.ts
Normal file
57
packages/core/src/protocol/error.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A generic error that can be returned by the backend if somethings fails during the processing of a request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCErrorResponse extends Error {
|
||||
/**
|
||||
* Additional data that describes the error
|
||||
*/
|
||||
additionalData?: unknown;
|
||||
|
||||
/**
|
||||
* HTTP status code to return this error with
|
||||
*/
|
||||
statusCode: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* An error that can be created by the backend during the processing of a request
|
||||
*/
|
||||
export abstract class SCError implements SCErrorResponse {
|
||||
/**
|
||||
* Call stack of the error
|
||||
*/
|
||||
stack?: string;
|
||||
|
||||
/**
|
||||
* Instatiate an SCError
|
||||
*
|
||||
* @param name Name of the error
|
||||
* @param message Message of the error
|
||||
* @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 = false) {
|
||||
// generate stacktrace if needed
|
||||
if (stack) {
|
||||
// eslint-disable-next-line unicorn/error-message
|
||||
this.stack = new Error().stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
packages/core/src/protocol/errors/internal-server-error.ts
Normal file
43
packages/core/src/protocol/errors/internal-server-error.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned, when an internal server error occurred
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCInternalServerErrorResponse extends SCError {
|
||||
/**
|
||||
* Internal error that occurred. If the stack is disabled this error is not set for security reasons
|
||||
*/
|
||||
additionalData?: Error;
|
||||
|
||||
/**
|
||||
* Create a SCInternalServerErrorResponse
|
||||
*
|
||||
* @param error Internal server error
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
* and the internal server error should be displayed to the client
|
||||
*/
|
||||
constructor(error?: Error, stack = false) {
|
||||
super('InternalServerError', 'Internal server error', StatusCodes.BAD_GATEWAY, stack);
|
||||
|
||||
if (stack) {
|
||||
this.additionalData = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
packages/core/src/protocol/errors/method-not-allowed.ts
Normal file
37
packages/core/src/protocol/errors/method-not-allowed.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned, when the used HTTP method is not allowed on the requested route
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCMethodNotAllowedErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SCMethodNotAllowedErrorResponse
|
||||
*
|
||||
* @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',
|
||||
StatusCodes.METHOD_NOT_ALLOWED,
|
||||
stack,
|
||||
);
|
||||
}
|
||||
}
|
||||
32
packages/core/src/protocol/errors/not-found.ts
Normal file
32
packages/core/src/protocol/errors/not-found.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned when the requested route or resource was not found
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCNotFoundErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SCNotFoundErrorResponse
|
||||
*
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('NotFoundError', 'Resource not found', StatusCodes.NOT_FOUND, stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned when the request is in the right format, but contains parameters that are invalid or not
|
||||
* acceptable.
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCParametersNotAcceptable extends SCError {
|
||||
/**
|
||||
* Create a ParametersNotAcceptable
|
||||
*
|
||||
* @param message contains more details to what you did wrong
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('ParametersNotAcceptable', message, StatusCodes.NOT_ACCEPTABLE, stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
import {SCPluginMetaData} from '../routes/plugin-register';
|
||||
|
||||
/**
|
||||
* An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin
|
||||
* running at the same time.
|
||||
* This usually indicates that there is more than one instance a plugin running.
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
|
||||
/**
|
||||
* Meta data of a registered plugin, which is in a conflict with the plugin we want to register.
|
||||
* If the stack is disabled this is not set for security reasons
|
||||
*/
|
||||
additionalData?: SCPluginMetaData;
|
||||
|
||||
/**
|
||||
* Create a SCPluginAlreadyRegisteredError
|
||||
*
|
||||
* @param message Provide further information why an already registered plugin matches the one we want to register
|
||||
* @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 = false) {
|
||||
super('SCPluginAlreadyRegisteredError', message, StatusCodes.CONFLICT, stack);
|
||||
if (stack) {
|
||||
this.additionalData = plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned whenever there is an unexpected error while creating a plugin
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCPluginRegisteringFailedErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a PluginRegisteringFailedError
|
||||
*
|
||||
* @param message Describes what went wrong wile registering the plugin
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('PluginRegisteringFailedError', message, StatusCodes.INTERNAL_SERVER_ERROR, stack);
|
||||
}
|
||||
}
|
||||
32
packages/core/src/protocol/errors/request-body-too-large.ts
Normal file
32
packages/core/src/protocol/errors/request-body-too-large.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned, when the request body is too large.
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
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.', StatusCodes.REQUEST_TOO_LONG, stack);
|
||||
}
|
||||
}
|
||||
33
packages/core/src/protocol/errors/syntax-error.ts
Normal file
33
packages/core/src/protocol/errors/syntax-error.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned whenever there is a syntax error
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCSyntaxErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SyntaxError
|
||||
*
|
||||
* @param message Describes the syntax error
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(message: string, stack?: boolean) {
|
||||
super('SyntaxError', message, StatusCodes.BAD_REQUEST, stack);
|
||||
}
|
||||
}
|
||||
37
packages/core/src/protocol/errors/too-many-requests.ts
Normal file
37
packages/core/src/protocol/errors/too-many-requests.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned, when to many request are submitted at once
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCTooManyRequestsErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SCTooManyRequestsErrorResponse
|
||||
*
|
||||
* @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',
|
||||
StatusCodes.TOO_MANY_REQUESTS,
|
||||
stack,
|
||||
);
|
||||
}
|
||||
}
|
||||
32
packages/core/src/protocol/errors/unsupported-media-type.ts
Normal file
32
packages/core/src/protocol/errors/unsupported-media-type.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned when the content type of the request is not supported
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
|
||||
/**
|
||||
* Create a SCUnsupportedMediaTypeErrorResponse
|
||||
*
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(stack?: boolean) {
|
||||
super('UnsupportedMediaTypeError', 'Unsupported media type', StatusCodes.UNSUPPORTED_MEDIA_TYPE, stack);
|
||||
}
|
||||
}
|
||||
40
packages/core/src/protocol/errors/validation.ts
Normal file
40
packages/core/src/protocol/errors/validation.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 {ValidationError} from '@openstapps/core-tools/lib/types/validator';
|
||||
import {StatusCodes} from 'http-status-codes';
|
||||
import {SCError} from '../error';
|
||||
|
||||
/**
|
||||
* An error that is returned when the validation of a request fails
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export class SCValidationErrorResponse extends SCError {
|
||||
/**
|
||||
* List of validatation errors
|
||||
*/
|
||||
additionalData: ValidationError[];
|
||||
|
||||
/**
|
||||
* Create a SCValidationErrorResponse
|
||||
*
|
||||
* @param errors List of validation errors
|
||||
* @param stack Set to true if a stack trace should be created
|
||||
*/
|
||||
constructor(errors: ValidationError[], stack?: boolean) {
|
||||
super('ValidationError', 'Validation of request failed', StatusCodes.BAD_REQUEST, stack);
|
||||
this.additionalData = errors;
|
||||
}
|
||||
}
|
||||
289
packages/core/src/protocol/route.ts
Normal file
289
packages/core/src/protocol/route.ts
Normal file
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* 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} from '../general/map';
|
||||
import {SCErrorResponse} from './error';
|
||||
import {SCIndexRequest, SCIndexResponse, SCIndexRoute} from './routes';
|
||||
import {
|
||||
SCBookAvailabilityRequest,
|
||||
SCBookAvailabilityResponse,
|
||||
SCBookAvailabilityRoute,
|
||||
} from './routes/book-availability';
|
||||
import {SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute} from './routes/bulk-add';
|
||||
import {SCBulkDoneRequest, SCBulkDoneResponse, SCBulkDoneRoute} from './routes/bulk-done';
|
||||
import {SCBulkRequest, SCBulkResponse, SCBulkRoute} from './routes/bulk-request';
|
||||
import {SCFeedbackRequest, SCFeedbackResponse, SCFeedbackRoute} from './routes/feedback';
|
||||
import {SCSearchRequest, SCSearchResponse, SCSearchRoute} from './routes/search';
|
||||
import {SCMultiSearchRequest, SCMultiSearchResponse, SCMultiSearchRoute} from './routes/search-multi';
|
||||
import {SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute} from './routes/thing-update';
|
||||
import {SCRatingRequest, SCRatingResponse, SCRatingRoute} from './routes/rating';
|
||||
|
||||
/**
|
||||
* Possible Verbs for HTTP requests
|
||||
*/
|
||||
export enum SCRouteHttpVerbs {
|
||||
GET = 'GET',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor of an error response
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type SCErrorResponseConstructor = new (...arguments_: any[]) => SCErrorResponse;
|
||||
|
||||
/**
|
||||
* A description of a route
|
||||
*/
|
||||
export interface SCRoute {
|
||||
/**
|
||||
* A map of names of possible errors that can be returned by the route with their appropriate status codes
|
||||
*/
|
||||
errorNames: SCErrorResponseConstructor[];
|
||||
|
||||
/**
|
||||
* HTTP verb to use to request the route
|
||||
*/
|
||||
method: SCRouteHttpVerbs;
|
||||
|
||||
/**
|
||||
* Map of obligatory parameters and their type that have to be set via the requested path
|
||||
*/
|
||||
obligatoryParameters?: SCMap<string>;
|
||||
|
||||
/**
|
||||
* Name of the type of the request body
|
||||
*/
|
||||
requestBodyName: string;
|
||||
|
||||
/**
|
||||
* Name of the type of the response body
|
||||
*/
|
||||
responseBodyName: string;
|
||||
|
||||
/**
|
||||
* Status code for success
|
||||
*/
|
||||
statusCodeSuccess: number;
|
||||
|
||||
/**
|
||||
* URL path of the route
|
||||
*/
|
||||
urlPath: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.urlPath
|
||||
*/
|
||||
urlPath = '/';
|
||||
|
||||
/**
|
||||
* Get "compiled" URL path
|
||||
*
|
||||
* @param parameters Parameters to compile URL path with
|
||||
*/
|
||||
public getUrlPath(parameters: SCMap<string> = {}): string {
|
||||
let obligatoryParameters: string[] = [];
|
||||
|
||||
if (typeof this.obligatoryParameters === 'object') {
|
||||
obligatoryParameters = Object.keys(this.obligatoryParameters);
|
||||
}
|
||||
|
||||
if (Object.keys(parameters).length > obligatoryParameters.length) {
|
||||
throw new Error('Extraneous parameters provided.');
|
||||
}
|
||||
|
||||
return this.urlPath
|
||||
.split('/')
|
||||
.map(part => {
|
||||
if (part.indexOf(':') !== 0) {
|
||||
return part;
|
||||
}
|
||||
|
||||
const parameter = part.slice(1);
|
||||
|
||||
if (parameters[parameter] === undefined) {
|
||||
throw new TypeError(`Parameter '${parameter}' not provided.`);
|
||||
}
|
||||
|
||||
return parameters[parameter];
|
||||
})
|
||||
.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible requests
|
||||
*/
|
||||
export type SCRequests =
|
||||
| SCBookAvailabilityRequest
|
||||
| SCBulkRequest
|
||||
| SCBulkAddRequest
|
||||
| SCBulkDoneRequest
|
||||
| SCFeedbackRequest
|
||||
| SCRatingRequest
|
||||
| SCIndexRequest
|
||||
| SCMultiSearchRequest
|
||||
| SCSearchRequest
|
||||
| SCThingUpdateRequest;
|
||||
|
||||
/**
|
||||
* Possible responses
|
||||
*/
|
||||
export type SCResponses =
|
||||
| SCBookAvailabilityResponse
|
||||
| SCBulkResponse
|
||||
| SCBulkAddResponse
|
||||
| SCBulkDoneResponse
|
||||
| SCFeedbackResponse
|
||||
| SCRatingResponse
|
||||
| SCIndexResponse
|
||||
| SCMultiSearchResponse
|
||||
| SCSearchResponse
|
||||
| SCThingUpdateResponse;
|
||||
|
||||
/**
|
||||
* Associated response for a request
|
||||
*/
|
||||
export type SCAssociatedResponse<REQUEST> = REQUEST extends SCBookAvailabilityRequest
|
||||
? SCBookAvailabilityResponse
|
||||
: REQUEST extends SCBulkRequest
|
||||
? SCBulkResponse
|
||||
: REQUEST extends SCBulkAddRequest
|
||||
? SCBulkAddResponse
|
||||
: REQUEST extends SCBulkDoneRequest
|
||||
? SCBulkDoneResponse
|
||||
: REQUEST extends SCFeedbackRequest
|
||||
? SCFeedbackResponse
|
||||
: REQUEST extends SCRatingRequest
|
||||
? SCRatingResponse
|
||||
: REQUEST extends SCIndexRequest
|
||||
? SCIndexResponse
|
||||
: REQUEST extends SCMultiSearchRequest
|
||||
? SCMultiSearchResponse
|
||||
: REQUEST extends SCSearchRequest
|
||||
? SCSearchResponse
|
||||
: REQUEST extends SCThingUpdateRequest
|
||||
? SCThingUpdateResponse
|
||||
: never;
|
||||
|
||||
/**
|
||||
* Associated request for a response
|
||||
*/
|
||||
export type SCAssociatedRequest<RESPONSE> = RESPONSE extends SCBookAvailabilityResponse
|
||||
? SCBookAvailabilityRequest
|
||||
: RESPONSE extends SCBulkResponse
|
||||
? SCBulkRequest
|
||||
: RESPONSE extends SCBulkAddResponse
|
||||
? SCBulkAddRequest
|
||||
: RESPONSE extends SCBulkDoneResponse
|
||||
? SCBulkDoneRequest
|
||||
: RESPONSE extends SCFeedbackResponse
|
||||
? SCFeedbackRequest
|
||||
: RESPONSE extends SCRatingResponse
|
||||
? SCRatingRequest
|
||||
: RESPONSE extends SCIndexResponse
|
||||
? SCIndexRequest
|
||||
: RESPONSE extends SCMultiSearchResponse
|
||||
? SCMultiSearchRequest
|
||||
: RESPONSE extends SCSearchResponse
|
||||
? SCSearchRequest
|
||||
: RESPONSE extends SCThingUpdateResponse
|
||||
? SCThingUpdateRequest
|
||||
: never;
|
||||
|
||||
/**
|
||||
* Associated request for a route
|
||||
*/
|
||||
export type SCAssignedRequest<ROUTE extends SCAbstractRoute> = ROUTE extends SCBookAvailabilityRoute
|
||||
? SCBookAvailabilityRequest
|
||||
: ROUTE extends SCBulkRoute
|
||||
? SCBulkRequest
|
||||
: ROUTE extends SCBulkAddRoute
|
||||
? SCBulkAddRequest
|
||||
: ROUTE extends SCBulkDoneRoute
|
||||
? SCBulkDoneRequest
|
||||
: ROUTE extends SCFeedbackRoute
|
||||
? SCFeedbackRequest
|
||||
: ROUTE extends SCRatingRoute
|
||||
? SCRatingRequest
|
||||
: ROUTE extends SCIndexRoute
|
||||
? SCIndexRequest
|
||||
: ROUTE extends SCMultiSearchRoute
|
||||
? SCMultiSearchRequest
|
||||
: ROUTE extends SCSearchRoute
|
||||
? SCSearchRequest
|
||||
: ROUTE extends SCThingUpdateRoute
|
||||
? SCThingUpdateRequest
|
||||
: never;
|
||||
|
||||
/**
|
||||
* Associated response for a route
|
||||
*/
|
||||
export type SCAssignedResponse<ROUTE extends SCAbstractRoute> = ROUTE extends SCBookAvailabilityRoute
|
||||
? SCBookAvailabilityResponse
|
||||
: ROUTE extends SCBulkRoute
|
||||
? SCBulkResponse
|
||||
: ROUTE extends SCBulkAddRoute
|
||||
? SCBulkAddResponse
|
||||
: ROUTE extends SCBulkDoneRoute
|
||||
? SCBulkDoneResponse
|
||||
: ROUTE extends SCFeedbackRoute
|
||||
? SCFeedbackResponse
|
||||
: ROUTE extends SCRatingRoute
|
||||
? SCRatingResponse
|
||||
: ROUTE extends SCIndexRoute
|
||||
? SCIndexResponse
|
||||
: ROUTE extends SCMultiSearchRoute
|
||||
? SCMultiSearchResponse
|
||||
: ROUTE extends SCSearchRoute
|
||||
? SCSearchResponse
|
||||
: ROUTE extends SCThingUpdateRoute
|
||||
? SCThingUpdateResponse
|
||||
: never;
|
||||
97
packages/core/src/protocol/routes/book-availability.ts
Normal file
97
packages/core/src/protocol/routes/book-availability.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCUuid} from '../../general/uuid';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOfferedOffer,
|
||||
} from '../../things/abstract/thing-that-can-be-offered';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Request to check the availability of books
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid;
|
||||
|
||||
/**
|
||||
* Availability request by ISBN
|
||||
*/
|
||||
export interface SCBookAvailabilityRequestByIsbn {
|
||||
/**
|
||||
* ISBN of the book to check availability for
|
||||
*/
|
||||
isbn: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Availability request by UUID
|
||||
*/
|
||||
export interface SCBookAvailabilityRequestByUuid {
|
||||
/**
|
||||
* UID of the book to check availability for
|
||||
*/
|
||||
uid: SCUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of availabilities of a book
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBookAvailabilityResponse = Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
|
||||
|
||||
/**
|
||||
* Route for book availability
|
||||
*
|
||||
* This checks if a book is available in a library.
|
||||
*
|
||||
* **Example**:
|
||||
*
|
||||
* `POST https://example.com/bookAvailability`
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "isbn": "978-3-16-148410-0"
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export class SCBookAvailabilityRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBookAvailabilityRequest';
|
||||
this.responseBodyName = 'SCBookAvailabilityResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/bookAvailability';
|
||||
}
|
||||
}
|
||||
64
packages/core/src/protocol/routes/bulk-add.ts
Normal file
64
packages/core/src/protocol/routes/bulk-add.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCThings} from '../../meta';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Request to add a thing to a bulk
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBulkAddRequest = SCThings;
|
||||
|
||||
/**
|
||||
* Response to a request to add a thing to a bulk
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkAddResponse {}
|
||||
|
||||
/**
|
||||
* Route for indexing SC things in a bulk
|
||||
*/
|
||||
export class SCBulkAddRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.obligatoryParameters = {
|
||||
UID: 'SCUuid',
|
||||
};
|
||||
this.requestBodyName = 'SCBulkAddRequest';
|
||||
this.responseBodyName = 'SCBulkAddResponse';
|
||||
this.statusCodeSuccess = StatusCodes.CREATED;
|
||||
this.urlPath = '/bulk/:UID';
|
||||
}
|
||||
}
|
||||
63
packages/core/src/protocol/routes/bulk-done.ts
Normal file
63
packages/core/src/protocol/routes/bulk-done.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Request to change the bulk state to done (close the bulk process)
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkDoneRequest {}
|
||||
|
||||
/**
|
||||
* Response to a request to change the state of a bulk to done
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkDoneResponse {}
|
||||
|
||||
/**
|
||||
* Route for closing bulks
|
||||
*/
|
||||
export class SCBulkDoneRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.obligatoryParameters = {
|
||||
UID: 'SCUuid',
|
||||
};
|
||||
this.requestBodyName = 'SCBulkDoneRequest';
|
||||
this.responseBodyName = 'SCBulkDoneResponse';
|
||||
this.statusCodeSuccess = StatusCodes.NO_CONTENT;
|
||||
this.urlPath = '/bulk/:UID/done';
|
||||
}
|
||||
}
|
||||
103
packages/core/src/protocol/routes/bulk-request.ts
Normal file
103
packages/core/src/protocol/routes/bulk-request.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCISO8601Date} from '../../general/time';
|
||||
import {SCUuid} from '../../general/uuid';
|
||||
import {SCThingType} from '../../things/abstract/thing';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* A bulk request
|
||||
*
|
||||
* Parameters to be sent to request a new bulk.
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCBulkRequest = SCBulkParameters;
|
||||
|
||||
/**
|
||||
* Parameters for a bulk
|
||||
*/
|
||||
export interface SCBulkParameters {
|
||||
/**
|
||||
* Expiration of bulk
|
||||
*
|
||||
* If the date is hit and the bulk is not done, it will be deleted and all data removed.
|
||||
* Defaults to one hour.
|
||||
*/
|
||||
expiration?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Source of data for this bulk
|
||||
*
|
||||
* A short "description" of the source of the data to identify it inside the database.
|
||||
* A second bulk with the same source overrides the data of the first bulk once it is done.
|
||||
*/
|
||||
source: string;
|
||||
|
||||
/**
|
||||
* Type of things that are indexed in this bulk.
|
||||
*
|
||||
*/
|
||||
type: SCThingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requested Bulk from backend
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCBulkResponse extends SCBulkParameters {
|
||||
/**
|
||||
* State of bulk
|
||||
*
|
||||
* The state is `in progress` while it accepts things to be added to the bulk.
|
||||
* The state is `done` once it is closed.
|
||||
*/
|
||||
state: 'in progress' | 'done';
|
||||
|
||||
/**
|
||||
* Universally unique identifier of the bulk
|
||||
*/
|
||||
uid: SCUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route for bulk creation
|
||||
*/
|
||||
export class SCBulkRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCBulkRequest';
|
||||
this.responseBodyName = 'SCBulkResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/bulk';
|
||||
}
|
||||
}
|
||||
104
packages/core/src/protocol/routes/feedback.ts
Normal file
104
packages/core/src/protocol/routes/feedback.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCMessage} from '../../things/message';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* User feedback
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCFeedbackRequest extends SCMessage {
|
||||
/**
|
||||
* Meta data that helps to understand the feedback
|
||||
*/
|
||||
metaData?: SCFeedbackRequestMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* A response to a feedback request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCFeedbackResponse {}
|
||||
|
||||
/**
|
||||
* Route for feedback submission
|
||||
*/
|
||||
export class SCFeedbackRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCFeedbackRequest';
|
||||
this.responseBodyName = 'SCFeedbackResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/feedback';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request Meta Data
|
||||
*/
|
||||
export interface SCFeedbackRequestMetaData {
|
||||
/**
|
||||
* Whether or not the user enabled the debug mode
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Platform identifier
|
||||
*/
|
||||
platform: string;
|
||||
|
||||
/**
|
||||
* Scope/app state at feedback invocation
|
||||
*/
|
||||
scope: unknown;
|
||||
|
||||
/**
|
||||
* Whether or not the feedback is sendable
|
||||
*/
|
||||
sendable?: boolean;
|
||||
|
||||
/**
|
||||
* App state that feedback was invoked from
|
||||
*/
|
||||
state: unknown;
|
||||
|
||||
/**
|
||||
* User agent
|
||||
*/
|
||||
userAgent: string;
|
||||
|
||||
/**
|
||||
* StApps version string
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
76
packages/core/src/protocol/routes/index.ts
Normal file
76
packages/core/src/protocol/routes/index.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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 {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';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Index request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCIndexRequest {}
|
||||
|
||||
/**
|
||||
* A response to an index request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCIndexResponse {
|
||||
/**
|
||||
* @see SCAppConfiguration
|
||||
*/
|
||||
app: SCAppConfiguration;
|
||||
|
||||
/**
|
||||
* @see SCAuthorizationProvider
|
||||
*/
|
||||
auth: {[key in SCAuthorizationProviderType]?: SCAuthorizationProvider};
|
||||
|
||||
/**
|
||||
* @see SCBackendConfiguration
|
||||
*/
|
||||
backend: SCBackendConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route to request meta information about the deployment
|
||||
*/
|
||||
export class SCIndexRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCIndexRequest';
|
||||
this.responseBodyName = 'SCIndexResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/';
|
||||
}
|
||||
}
|
||||
128
packages/core/src/protocol/routes/plugin-register.ts
Normal file
128
packages/core/src/protocol/routes/plugin-register.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {JSONSchema7} from 'json-schema';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||
import {SCParametersNotAcceptable} from '../errors/parameters-not-acceptable';
|
||||
import {SCPluginAlreadyRegisteredErrorResponse} from '../errors/plugin-already-registered';
|
||||
import {SCPluginRegisteringFailedErrorResponse} from '../errors/plugin-registering-failed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Plugin register request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove;
|
||||
|
||||
/**
|
||||
* Plugin request for adding a plugin registration to the backend
|
||||
*/
|
||||
export interface SCPluginAdd {
|
||||
/**
|
||||
* The desired action, so whether the plugin should be added or removed
|
||||
*/
|
||||
action: 'add';
|
||||
|
||||
/**
|
||||
* Plugin information needed for its registration
|
||||
*/
|
||||
plugin: SCPluginMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin request for removing a plugin registration from the backend
|
||||
*/
|
||||
export interface SCPluginRemove {
|
||||
/**
|
||||
* The desired action, so whether the plugin should be added or removed
|
||||
*/
|
||||
action: 'remove';
|
||||
|
||||
/**
|
||||
* The route of the plugin you want to remove
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin meta data - contains needed information for a plugin registration
|
||||
*/
|
||||
export interface SCPluginMetaData {
|
||||
/**
|
||||
* The address of the plugin, to which the backend routes the requests
|
||||
*/
|
||||
address: string;
|
||||
|
||||
/**
|
||||
* The name of the plugin (for debugging purposes, to more easily identify conflicts)
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* How the requests of the plugin looks like, a JSON schema for validation
|
||||
*/
|
||||
requestSchema: JSONSchema7;
|
||||
|
||||
/**
|
||||
* How the responses of the plugin looks like, a JSON schema for validation
|
||||
*/
|
||||
responseSchema: JSONSchema7;
|
||||
|
||||
/**
|
||||
* The desired route, for example /feedback.
|
||||
*/
|
||||
route: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin register response
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCPluginRegisterResponse {
|
||||
/**
|
||||
* Whether the desired action succeeded or failed (true for success, false if an error occurred)
|
||||
*/
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route to register plugins
|
||||
*/
|
||||
export class SCPluginRegisterRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCParametersNotAcceptable,
|
||||
SCPluginAlreadyRegisteredErrorResponse,
|
||||
SCPluginRegisteringFailedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCPluginRegisterRequest';
|
||||
this.responseBodyName = 'SCPluginRegisterResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/plugin/register';
|
||||
}
|
||||
}
|
||||
77
packages/core/src/protocol/routes/rating.ts
Normal file
77
packages/core/src/protocol/routes/rating.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2023 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
import {SCThing} from '../../things/abstract/thing';
|
||||
import {SCUserGroupSetting} from '../../things/setting';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
|
||||
/**
|
||||
* User rating from the app
|
||||
* Plugin needs to define its own rating request to hit the target rating system.
|
||||
* That request should extend this one and contain timestamp and other needed data.
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCRatingRequest {
|
||||
/**
|
||||
* Number of rating stars
|
||||
*/
|
||||
rating: 1 | 2 | 3 | 4 | 5;
|
||||
|
||||
/**
|
||||
* User's group in the app
|
||||
*/
|
||||
userGroup: SCUserGroupSetting['value'];
|
||||
|
||||
/**
|
||||
* UID of the thing that is rated
|
||||
*/
|
||||
uid: SCThing['uid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* A response to a rating request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCRatingResponse {}
|
||||
|
||||
/**
|
||||
* Route for rating submission
|
||||
*/
|
||||
export class SCRatingRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCRatingRequest';
|
||||
this.responseBodyName = 'SCRatingResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/rating';
|
||||
}
|
||||
}
|
||||
69
packages/core/src/protocol/routes/search-multi.ts
Normal file
69
packages/core/src/protocol/routes/search-multi.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCMap} from '../../general/map';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCTooManyRequestsErrorResponse} from '../errors/too-many-requests';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
import {SCSearchQuery} from '../search/query';
|
||||
import {SCSearchResult} from '../search/result';
|
||||
|
||||
/**
|
||||
* A multi search request
|
||||
*
|
||||
* This is a map of [[SCSearchRequest]]s indexed by name.
|
||||
*
|
||||
* **CAUTION: This is limited to an amount of queries. Currently this limit is 5.**
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCMultiSearchRequest = SCMap<SCSearchQuery>;
|
||||
|
||||
/**
|
||||
* A multi search response
|
||||
*
|
||||
* This is a map of [[SCSearchResponse]]s indexed by name
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCMultiSearchResponse = SCMap<SCSearchResult>;
|
||||
|
||||
/**
|
||||
* Route for submission of multiple search requests at once
|
||||
*/
|
||||
export class SCMultiSearchRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCTooManyRequestsErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCMultiSearchRequest';
|
||||
this.responseBodyName = 'SCMultiSearchResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/search/multi';
|
||||
}
|
||||
}
|
||||
60
packages/core/src/protocol/routes/search.ts
Normal file
60
packages/core/src/protocol/routes/search.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
import {SCSearchQuery} from '../search/query';
|
||||
import {SCSearchResult} from '../search/result';
|
||||
|
||||
/**
|
||||
* A search request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCSearchRequest = SCSearchQuery;
|
||||
|
||||
/**
|
||||
* A search response
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCSearchResponse = SCSearchResult;
|
||||
|
||||
/**
|
||||
* Route for searching things
|
||||
*/
|
||||
export class SCSearchRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.POST;
|
||||
this.requestBodyName = 'SCSearchRequest';
|
||||
this.responseBodyName = 'SCSearchResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/search';
|
||||
}
|
||||
}
|
||||
65
packages/core/src/protocol/routes/thing-update.ts
Normal file
65
packages/core/src/protocol/routes/thing-update.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 {StatusCodes} from 'http-status-codes';
|
||||
import {SCThings} from '../../meta';
|
||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||
import {SCRequestBodyTooLargeErrorResponse} from '../errors/request-body-too-large';
|
||||
import {SCSyntaxErrorResponse} from '../errors/syntax-error';
|
||||
import {SCUnsupportedMediaTypeErrorResponse} from '../errors/unsupported-media-type';
|
||||
import {SCValidationErrorResponse} from '../errors/validation';
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../route';
|
||||
|
||||
/**
|
||||
* Request to update an existing thing
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export type SCThingUpdateRequest = SCThings;
|
||||
|
||||
/**
|
||||
* Response for an entity update request
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCThingUpdateResponse {}
|
||||
|
||||
/**
|
||||
* Route for updating existing things
|
||||
*/
|
||||
export class SCThingUpdateRoute extends SCAbstractRoute {
|
||||
constructor() {
|
||||
super();
|
||||
this.errorNames = [
|
||||
SCInternalServerErrorResponse,
|
||||
SCMethodNotAllowedErrorResponse,
|
||||
SCNotFoundErrorResponse,
|
||||
SCRequestBodyTooLargeErrorResponse,
|
||||
SCSyntaxErrorResponse,
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
SCValidationErrorResponse,
|
||||
];
|
||||
this.method = SCRouteHttpVerbs.PUT;
|
||||
this.obligatoryParameters = {
|
||||
TYPE: 'SCThingType',
|
||||
UID: 'SCUuid',
|
||||
};
|
||||
this.requestBodyName = 'SCThingUpdateRequest';
|
||||
this.responseBodyName = 'SCThingUpdateResponse';
|
||||
this.statusCodeSuccess = StatusCodes.OK;
|
||||
this.urlPath = '/:TYPE/:UID';
|
||||
}
|
||||
}
|
||||
51
packages/core/src/protocol/search/facet.ts
Normal file
51
packages/core/src/protocol/search/facet.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThingsField} from '../../meta';
|
||||
import {SCThingType} from '../../things/abstract/thing';
|
||||
|
||||
/**
|
||||
* A search facet
|
||||
*/
|
||||
export interface SCFacet {
|
||||
/**
|
||||
* Buckets for the aggregation
|
||||
*/
|
||||
buckets: SCFacetBucket[];
|
||||
|
||||
/**
|
||||
* Field of the aggregation
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* Type of the aggregation
|
||||
*/
|
||||
onlyOnType?: SCThingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* A bucket of a facet
|
||||
*/
|
||||
export interface SCFacetBucket {
|
||||
/**
|
||||
* Count of matching search results
|
||||
*/
|
||||
count: number;
|
||||
|
||||
/**
|
||||
* Key of a bucket
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
68
packages/core/src/protocol/search/filter.ts
Normal file
68
packages/core/src/protocol/search/filter.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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} from '../../general/map';
|
||||
/**
|
||||
* All available filter types
|
||||
*/
|
||||
import {SCSearchAvailabilityFilter} from './filters/availability';
|
||||
import {SCSearchBooleanFilter} from './filters/boolean';
|
||||
import {SCSearchDistanceFilter} from './filters/distance';
|
||||
import {SCGeoFilter} from './filters/geo';
|
||||
import {SCSearchDateRangeFilter, SCSearchNumericRangeFilter} from './filters/range';
|
||||
import {SCSearchValueFilter} from './filters/value';
|
||||
|
||||
/**
|
||||
* Filter instruction types
|
||||
*/
|
||||
export type SCSearchFilterType =
|
||||
| 'availability'
|
||||
| 'boolean'
|
||||
| 'distance'
|
||||
| 'value'
|
||||
| 'date range'
|
||||
| 'numeric range'
|
||||
| 'geo';
|
||||
|
||||
/**
|
||||
* Structure of a filter instruction
|
||||
*/
|
||||
export interface SCSearchAbstractFilter<T extends SCSearchAbstractFilterArguments> {
|
||||
/**
|
||||
* Arguments of filter
|
||||
*/
|
||||
arguments: T;
|
||||
|
||||
/**
|
||||
* Type of filter
|
||||
*/
|
||||
type: SCSearchFilterType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for the filter instruction
|
||||
*/
|
||||
export type SCSearchAbstractFilterArguments = SCMap<unknown>;
|
||||
|
||||
/**
|
||||
* Available filter instructions
|
||||
*/
|
||||
export type SCSearchFilter =
|
||||
| SCSearchAvailabilityFilter
|
||||
| SCSearchBooleanFilter
|
||||
| SCSearchDistanceFilter
|
||||
| SCSearchValueFilter
|
||||
| SCSearchNumericRangeFilter
|
||||
| SCSearchDateRangeFilter
|
||||
| SCGeoFilter;
|
||||
49
packages/core/src/protocol/search/filters/availability.ts
Normal file
49
packages/core/src/protocol/search/filters/availability.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019-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 {SCISO8601Date} from '../../../general/time';
|
||||
import {SCThingsField} from '../../../meta';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
|
||||
|
||||
/**
|
||||
* An availability filter
|
||||
*
|
||||
* 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';
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for filter instruction by availability
|
||||
*/
|
||||
export interface SCAvailabilityFilterArguments extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* Field which marks availability range
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* If set, the provided time will apply to the full hour, day, week, etc.
|
||||
*/
|
||||
scope?: 's' | 'm' | 'H' | 'd' | 'w' | 'M' | 'y';
|
||||
|
||||
/**
|
||||
* Time to check. Defaults current time if not set
|
||||
*/
|
||||
time?: SCISO8601Date;
|
||||
}
|
||||
42
packages/core/src/protocol/search/filters/boolean.ts
Normal file
42
packages/core/src/protocol/search/filters/boolean.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments, SCSearchFilter} from '../filter';
|
||||
|
||||
/**
|
||||
* A boolean filter
|
||||
*
|
||||
* This filter can be used to combine multiple filters with boolean operations.
|
||||
*/
|
||||
export interface SCSearchBooleanFilter extends SCSearchAbstractFilter<SCBooleanFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'boolean';
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for boolean filters
|
||||
*/
|
||||
export interface SCBooleanFilterArguments extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* A list of filter to apply the boolean operation to
|
||||
*/
|
||||
filters: SCSearchFilter[];
|
||||
|
||||
/**
|
||||
* Boolean operation to apply to the filters
|
||||
*/
|
||||
operation: 'and' | 'not' | 'or';
|
||||
}
|
||||
49
packages/core/src/protocol/search/filters/distance.ts
Normal file
49
packages/core/src/protocol/search/filters/distance.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 {Position} from 'geojson';
|
||||
import {SCThingsField} from '../../../meta';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
|
||||
|
||||
/**
|
||||
* A distance filter
|
||||
*
|
||||
* Filter for documents that are in the given distance of the given location
|
||||
*/
|
||||
export interface SCSearchDistanceFilter extends SCSearchAbstractFilter<SCDistanceFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'distance';
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for distance filters
|
||||
*/
|
||||
export interface SCDistanceFilterArguments extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* Distance in meters to filter from given location
|
||||
*/
|
||||
distance: number;
|
||||
|
||||
/**
|
||||
* Field which contains the location you want to filter
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* Position to calculate the distance to
|
||||
*/
|
||||
position: Position;
|
||||
}
|
||||
72
packages/core/src/protocol/search/filters/geo.ts
Normal file
72
packages/core/src/protocol/search/filters/geo.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 {Polygon, Position} from 'geojson';
|
||||
import {SCThingsField} from '../../../meta';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
|
||||
|
||||
/**
|
||||
* A geo filter
|
||||
*
|
||||
* Filter for documents that are in relation to some geo data
|
||||
*/
|
||||
export interface SCGeoFilter extends SCSearchAbstractFilter<SCGeoFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'geo';
|
||||
}
|
||||
|
||||
/**
|
||||
* A rectangular geo shape, representing the top-left and bottom-right corners
|
||||
*
|
||||
* This is an extension of the Geojson type
|
||||
* http://geojson.org/geojson-spec.html
|
||||
*/
|
||||
export interface Envelope {
|
||||
/**
|
||||
* The top-left and bottom-right corners of the bounding box
|
||||
*/
|
||||
coordinates: [Position, Position];
|
||||
|
||||
/**
|
||||
* The type of the geometry
|
||||
*/
|
||||
type: 'envelope';
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for filter instruction by geo data
|
||||
*/
|
||||
export interface SCGeoFilterArguments extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* Field on which to filter
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* Geo data to check up on
|
||||
*/
|
||||
shape: Polygon | Envelope;
|
||||
|
||||
/**
|
||||
* Spatial relation between the provided shape and the shape of the field.
|
||||
*
|
||||
* intersects - both shapes intersect (default)
|
||||
* disjoint - both shapes don't intersect
|
||||
* within - the search shape contains the field shape
|
||||
* contains - the search shape is contained in the field shape
|
||||
*/
|
||||
spatialRelation?: 'intersects' | 'disjoint' | 'within' | 'contains';
|
||||
}
|
||||
122
packages/core/src/protocol/search/filters/range.ts
Normal file
122
packages/core/src/protocol/search/filters/range.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2020-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 {SCThingsField} from '../../../meta';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
|
||||
|
||||
/**
|
||||
* A date range filter
|
||||
*
|
||||
* Filter for documents with a date field that satisfies the given constraints
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
|
||||
*/
|
||||
export interface SCSearchDateRangeFilter extends SCSearchAbstractFilter<SCDateRangeFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'date range';
|
||||
}
|
||||
|
||||
/**
|
||||
* A distance filter
|
||||
*
|
||||
* Filter for documents with a numeric field that satisfies the given constraints
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
|
||||
*/
|
||||
export interface SCSearchNumericRangeFilter extends SCSearchAbstractFilter<SCNumericRangeFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'numeric range';
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for date range filters
|
||||
*
|
||||
* Filter uses a plain string to allow for date math expressions
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/date-math-expressions.html
|
||||
*/
|
||||
export interface SCDateRangeFilterArguments extends SCRangeFilterArguments<string> {
|
||||
/**
|
||||
* Optional date format specifier
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
|
||||
*/
|
||||
format?: string;
|
||||
|
||||
/**
|
||||
* Optional timezone specifier
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_time_zone_in_range_queries
|
||||
*/
|
||||
timeZone?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for numeric range filters
|
||||
*/
|
||||
export type SCNumericRangeFilterArguments = SCRangeFilterArguments<number>;
|
||||
|
||||
/**
|
||||
* Additional arguments for range filters
|
||||
*
|
||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
|
||||
*/
|
||||
export interface SCRangeFilterArguments<T> extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* Bounds of the range
|
||||
*/
|
||||
bounds: Bounds<T>;
|
||||
|
||||
/**
|
||||
* Field where the filter will be applied
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* Relation when searching on other range fields
|
||||
*
|
||||
* Intersects (Default): Both search and field range intersect
|
||||
* Within: Search range is within the field range
|
||||
* Contains: Search range contains the field range
|
||||
*/
|
||||
relation?: 'intersects' | 'within' | 'contains';
|
||||
}
|
||||
|
||||
export interface Bounds<T> {
|
||||
/**
|
||||
* The lower bound
|
||||
*/
|
||||
lowerBound?: Bound<T>;
|
||||
|
||||
/**
|
||||
* The upper bound
|
||||
*/
|
||||
upperBound?: Bound<T>;
|
||||
}
|
||||
|
||||
export interface Bound<T> {
|
||||
/**
|
||||
* Limit of the bound
|
||||
*/
|
||||
limit: T;
|
||||
|
||||
/**
|
||||
* Bound mode
|
||||
*/
|
||||
mode: 'inclusive' | 'exclusive';
|
||||
}
|
||||
38
packages/core/src/protocol/search/filters/value.ts
Normal file
38
packages/core/src/protocol/search/filters/value.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThingsField} from '../../../meta';
|
||||
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
|
||||
|
||||
/**
|
||||
* Filters for documents that match the value on the given field
|
||||
*/
|
||||
export interface SCSearchValueFilter extends SCSearchAbstractFilter<SCValueFilterArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractFilter.type
|
||||
*/
|
||||
type: 'value';
|
||||
}
|
||||
|
||||
export interface SCValueFilterArguments extends SCSearchAbstractFilterArguments {
|
||||
/**
|
||||
* Field to filter for a value.
|
||||
*/
|
||||
field: SCThingsField;
|
||||
|
||||
/**
|
||||
* Value to filter. One or more values has to match the field exactly.
|
||||
*/
|
||||
value: string | string[];
|
||||
}
|
||||
52
packages/core/src/protocol/search/query.ts
Normal file
52
packages/core/src/protocol/search/query.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSearchContext} from '../../config/backend';
|
||||
import {SCSearchFilter} from './filter';
|
||||
import {SCSearchSort} from './sort';
|
||||
|
||||
/**
|
||||
* A search query
|
||||
*/
|
||||
export interface SCSearchQuery {
|
||||
/**
|
||||
* The context name from where the search query was initiated
|
||||
*/
|
||||
context?: SCSearchContext;
|
||||
|
||||
/**
|
||||
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
|
||||
*/
|
||||
filter?: SCSearchFilter;
|
||||
|
||||
/**
|
||||
* Number of things to skip in result set (paging)
|
||||
*/
|
||||
from?: number;
|
||||
|
||||
/**
|
||||
* A term to search for
|
||||
*/
|
||||
query?: string;
|
||||
|
||||
/**
|
||||
* Number of things to have in the result set (paging)
|
||||
*/
|
||||
size?: number;
|
||||
|
||||
/**
|
||||
* A list of sorting parameters to order the result set by
|
||||
*/
|
||||
sort?: SCSearchSort[];
|
||||
}
|
||||
71
packages/core/src/protocol/search/result.ts
Normal file
71
packages/core/src/protocol/search/result.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThings} from '../../meta';
|
||||
import {SCFacet} from './facet';
|
||||
|
||||
/**
|
||||
* A search response
|
||||
*/
|
||||
export interface SCSearchResult {
|
||||
/**
|
||||
* Data (any data object)
|
||||
*/
|
||||
data: SCThings[];
|
||||
|
||||
/**
|
||||
* Facets (aggregations over all matching data)
|
||||
*/
|
||||
facets: SCFacet[];
|
||||
|
||||
/**
|
||||
* Pagination information
|
||||
*/
|
||||
pagination: SCSearchResultPagination;
|
||||
|
||||
/**
|
||||
* Stats of the search engine
|
||||
*/
|
||||
stats: SCSearchResultSearchEngineStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores information about Pagination
|
||||
*/
|
||||
export interface SCSearchResultPagination {
|
||||
/**
|
||||
* Count of given data. Same as data.length
|
||||
*/
|
||||
count: number;
|
||||
|
||||
/**
|
||||
* Offset of data on all matching data. Given by [[SCSearchQuery.from]]
|
||||
*/
|
||||
offset: number;
|
||||
|
||||
/**
|
||||
* Number of total matching data
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Statistics of search engine
|
||||
*/
|
||||
export interface SCSearchResultSearchEngineStats {
|
||||
/**
|
||||
* Response time of the search engine in ms
|
||||
*/
|
||||
time: number;
|
||||
}
|
||||
60
packages/core/src/protocol/search/sort.ts
Normal file
60
packages/core/src/protocol/search/sort.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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} from '../../general/map';
|
||||
import {SCThingsField} from '../../meta';
|
||||
import {SCDistanceSort} from './sorts/distance';
|
||||
import {SCDucetSort} from './sorts/ducet';
|
||||
import {SCGenericSort} from './sorts/generic';
|
||||
import {SCPriceSort} from './sorts/price';
|
||||
|
||||
/**
|
||||
* Abstract sort instruction
|
||||
*/
|
||||
export interface SCSearchAbstractSort<T extends SCSearchAbstractSortArguments> {
|
||||
/**
|
||||
* Map of arguments for the sort instruction
|
||||
*/
|
||||
arguments: T;
|
||||
|
||||
/**
|
||||
* Direction of the sort instruction: `asc`ending or `desc`ending.
|
||||
*/
|
||||
order: 'asc' | 'desc';
|
||||
|
||||
/**
|
||||
* Type of the sort instruction
|
||||
*/
|
||||
type: SCSearchSortType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of arguments for the sort instruction
|
||||
*/
|
||||
export interface SCSearchAbstractSortArguments extends SCMap<unknown> {
|
||||
/**
|
||||
* Field to sort by
|
||||
*/
|
||||
field: SCThingsField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of a sort instruction
|
||||
*/
|
||||
export type SCSearchSortType = 'distance' | 'price' | 'ducet' | 'generic';
|
||||
|
||||
/**
|
||||
* A sort instruction
|
||||
*/
|
||||
export type SCSearchSort = SCDistanceSort | SCPriceSort | SCDucetSort | SCGenericSort;
|
||||
36
packages/core/src/protocol/search/sorts/distance.ts
Normal file
36
packages/core/src/protocol/search/sorts/distance.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 {Position} from 'geojson';
|
||||
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
|
||||
|
||||
/**
|
||||
* Sort instruction to sort by distance
|
||||
*/
|
||||
export interface SCDistanceSort extends SCSearchAbstractSort<SCDistanceSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'distance';
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for sort instruction to sort by distance
|
||||
*/
|
||||
export interface SCDistanceSortArguments extends SCSearchAbstractSortArguments {
|
||||
/**
|
||||
* Position to calculate distances to
|
||||
*/
|
||||
position: Position;
|
||||
}
|
||||
25
packages/core/src/protocol/search/sorts/ducet.ts
Normal file
25
packages/core/src/protocol/search/sorts/ducet.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
|
||||
|
||||
/**
|
||||
* Sort instruction for ducet sort
|
||||
*/
|
||||
export interface SCDucetSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'ducet';
|
||||
}
|
||||
25
packages/core/src/protocol/search/sorts/generic.ts
Normal file
25
packages/core/src/protocol/search/sorts/generic.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
|
||||
|
||||
/**
|
||||
* Sort instruction for generic sort such as date
|
||||
*/
|
||||
export interface SCGenericSort extends SCSearchAbstractSort<SCSearchAbstractSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'generic';
|
||||
}
|
||||
36
packages/core/src/protocol/search/sorts/price.ts
Normal file
36
packages/core/src/protocol/search/sorts/price.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSportCoursePriceGroup} from '../../../things/date-series';
|
||||
import {SCSearchAbstractSort, SCSearchAbstractSortArguments} from '../sort';
|
||||
|
||||
/**
|
||||
* Sort instruction to sort by price
|
||||
*/
|
||||
export interface SCPriceSort extends SCSearchAbstractSort<SCPriceSortArguments> {
|
||||
/**
|
||||
* @see SCSearchAbstractSort.type
|
||||
*/
|
||||
type: 'price';
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional arguments for sort instruction to sort by price
|
||||
*/
|
||||
export interface SCPriceSortArguments extends SCSearchAbstractSortArguments {
|
||||
/**
|
||||
* University role to sort price for
|
||||
*/
|
||||
universityRole: keyof SCSportCoursePriceGroup;
|
||||
}
|
||||
85
packages/core/src/things/abstract/academic-degree.ts
Normal file
85
packages/core/src/things/abstract/academic-degree.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../../general/i18n';
|
||||
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* An academic degree without references
|
||||
*/
|
||||
export interface SCAcademicDegreeWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* The achievable academic degree
|
||||
*
|
||||
* @filterable
|
||||
* @sortable ducet
|
||||
*/
|
||||
academicDegree: string;
|
||||
|
||||
/**
|
||||
* The achievable academic degree with academic field specification
|
||||
* (eg. Master of Science)
|
||||
*
|
||||
*/
|
||||
academicDegreewithField?: string;
|
||||
|
||||
/**
|
||||
* The achievable academic degree with academic field specification
|
||||
* shorted (eg. M.Sc.).
|
||||
*
|
||||
*/
|
||||
academicDegreewithFieldShort?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An academic degree
|
||||
*/
|
||||
export interface SCAcademicDegree extends SCAcademicDegreeWithoutReferences, SCThing {
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about academic degrees
|
||||
*/
|
||||
export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslations<SCAcademicDegree> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
academicDegree: 'Abschlussgrad',
|
||||
academicDegreewithField: 'Abschlussbezeichnung',
|
||||
academicDegreewithFieldShort: 'Abschlussbezeichnung (kurz)',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
academicDegree: 'academic degree',
|
||||
academicDegreewithField: 'acedemic degree and discipline',
|
||||
academicDegreewithFieldShort: 'acedemic degree and discipline (short)',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
105
packages/core/src/things/abstract/academic-term.ts
Normal file
105
packages/core/src/things/abstract/academic-term.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../../general/i18n';
|
||||
import {SCISO8601Date} from '../../general/time';
|
||||
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* An academic term without references
|
||||
*/
|
||||
export interface SCAcademicTermWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Short name of the academic term, using the given pattern
|
||||
*
|
||||
* @aggregatable
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
acronym: string;
|
||||
|
||||
/**
|
||||
* End date of the academic term
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
endDate: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* End date of lectures in the academic term
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
eventsEndDate?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Start date of lectures in the academic term
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
eventsStartDate?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Start date of the academic term
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
startDate: SCISO8601Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* An academic term
|
||||
*/
|
||||
export interface SCAcademicTerm extends SCAcademicTermWithoutReferences, SCThing {
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about academic terms
|
||||
*/
|
||||
export class SCAcademicTermWithoutReferencesMeta extends SCThingMeta implements SCMetaTranslations<SCThing> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
acronym: 'Akronym',
|
||||
endDate: 'Enddatum',
|
||||
eventsEndDate: 'Enddatum der Veranstaltungen',
|
||||
eventsStartDate: 'Startdatum der Veranstaltungen',
|
||||
startDate: 'Startdatum',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
acronym: 'acronym',
|
||||
endDate: 'end date',
|
||||
eventsEndDate: 'end date of events',
|
||||
eventsStartDate: 'start date of events',
|
||||
startDate: 'start date',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
179
packages/core/src/things/abstract/creative-work.ts
Normal file
179
packages/core/src/things/abstract/creative-work.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* 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 {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||
import {SCISO8601Date} from '../../general/time';
|
||||
import {SCOrganizationWithoutReferences} from '../organization';
|
||||
import {SCPersonWithoutReferences} from '../person';
|
||||
import {SCPublicationEventWithoutReferences} from '../publication-event';
|
||||
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* A creative work without references
|
||||
*/
|
||||
export interface SCCreativeWorkWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Languages this creative work is available in
|
||||
*/
|
||||
availableLanguages?: SCLanguageCode[];
|
||||
|
||||
/**
|
||||
* Date the creative work was published
|
||||
*/
|
||||
datePublished?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Edition of a creative work (e.g. the book edition or edition of an article)
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
edition?: string;
|
||||
|
||||
/**
|
||||
* Date (in text form) the creative work was published for the first time
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
firstPublished?: string;
|
||||
|
||||
/**
|
||||
* Languages this creative work is written/recorded/... in
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
inLanguage?: SCLanguageCode;
|
||||
|
||||
/**
|
||||
* Keywords of the creative work
|
||||
*
|
||||
* @aggregatable
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
keywords?: string[];
|
||||
|
||||
/**
|
||||
* Date (in text form) the creative work was most recently
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
lastPublished?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of the creative work
|
||||
*/
|
||||
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A creative work
|
||||
*/
|
||||
export interface SCCreativeWork extends SCCreativeWorkWithoutReferences, SCThing {
|
||||
/**
|
||||
* Authors of the creative work
|
||||
*/
|
||||
authors?: SCPersonWithoutReferences[];
|
||||
|
||||
/**
|
||||
* A creative work to which the creative work belongs
|
||||
*/
|
||||
isPartOf?: SCCreativeWorkWithoutReferences;
|
||||
|
||||
/**
|
||||
* List of events at which the creative work was published
|
||||
*/
|
||||
publications?: SCPublicationEventWithoutReferences[];
|
||||
|
||||
/**
|
||||
* List of publishers of the creative work
|
||||
*/
|
||||
publishers?: Array<SCPersonWithoutReferences | SCOrganizationWithoutReferences>;
|
||||
|
||||
/**
|
||||
* A text representing on organization on whose behalf the creator was working
|
||||
*/
|
||||
sourceOrganization?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of the creative work
|
||||
*/
|
||||
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of creative works
|
||||
*/
|
||||
export interface SCCreativeWorkTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Translation of the keywords of the creative work
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
keywords?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about creative works
|
||||
*/
|
||||
export class SCCreativeWorkMeta extends SCThingMeta implements SCMetaTranslations<SCCreativeWork> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
name: 'Titel',
|
||||
authors: 'beteiligte Personen',
|
||||
availableLanguages: 'verfügbare Übersetzungen',
|
||||
datePublished: 'Veröffentlichungsdatum',
|
||||
edition: 'Ausgabe',
|
||||
firstPublished: 'erste Veröffentlichung',
|
||||
inLanguage: 'Inhaltssprache',
|
||||
isPartOf: 'erschienen in',
|
||||
keywords: 'Schlagwörter',
|
||||
lastPublished: 'aktuellste Veröffentlichung',
|
||||
publishers: 'Verleger',
|
||||
publications: 'Veröffentlichungen',
|
||||
sourceOrganization: 'Körperschaft',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
name: 'title',
|
||||
authors: 'involved persons',
|
||||
availableLanguages: 'available languages',
|
||||
datePublished: 'release date',
|
||||
edition: 'edition',
|
||||
firstPublished: 'first published',
|
||||
inLanguage: 'content language',
|
||||
isPartOf: 'published in',
|
||||
keywords: 'keywords',
|
||||
lastPublished: 'last published',
|
||||
publishers: 'publishers',
|
||||
publications: 'publications',
|
||||
sourceOrganization: 'corporation',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
118
packages/core/src/things/abstract/event.ts
Normal file
118
packages/core/src/things/abstract/event.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../../general/i18n';
|
||||
import {SCCatalogWithoutReferences} from '../catalog';
|
||||
import {SCPersonWithoutReferences} from '../person';
|
||||
import {SCSemesterWithoutReferences} from '../semester';
|
||||
import {SCCreativeWorkWithoutReferences} from './creative-work';
|
||||
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* An event without references
|
||||
*/
|
||||
export interface SCEventWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Maximum number of participants of the event
|
||||
*
|
||||
* A maximum number of people that can participate in the event.
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
maximumParticipants?: number;
|
||||
|
||||
/**
|
||||
* Remaining attendee capacity of the event
|
||||
*
|
||||
* This number represents the remaining open spots.
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
remainingAttendeeCapacity?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* An event
|
||||
*/
|
||||
export interface SCEvent extends SCEventWithoutReferences, SCThing {
|
||||
/**
|
||||
* Academic terms that an event belongs to, e.g. semester(s).
|
||||
*/
|
||||
academicTerms?: SCSemesterWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Catalogs to which an event belongs
|
||||
*/
|
||||
catalogs?: SCCatalogWithoutReferences[];
|
||||
|
||||
/**
|
||||
* A list of creative works that are associated with this event
|
||||
*
|
||||
* This can be recommended books, CDs that can be bought, etc.
|
||||
*/
|
||||
creativeWorks?: SCCreativeWorkWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Organizers of the event
|
||||
*/
|
||||
organizers?: SCPersonWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Performers of the event
|
||||
*/
|
||||
performers?: SCPersonWithoutReferences[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about events
|
||||
*/
|
||||
export class SCEventMeta extends SCThingMeta implements SCMetaTranslations<SCEvent> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
academicTerms: 'Semester',
|
||||
catalogs: 'Verzeichnis',
|
||||
creativeWorks: 'begleitende Werke',
|
||||
maximumParticipants: 'maximale Anzahl an Teilnehmern',
|
||||
organizers: 'Origanisatoren',
|
||||
performers: 'Vortragende',
|
||||
remainingAttendeeCapacity: 'verfügbare Anzahl an Teilnehmern',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
academicTerms: 'academic terms',
|
||||
catalogs: 'catalogs',
|
||||
creativeWorks: 'related material',
|
||||
maximumParticipants: 'maximum participants',
|
||||
organizers: 'organizers',
|
||||
performers: 'performers',
|
||||
remainingAttendeeCapacity: 'remaining attendee capacity',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
183
packages/core/src/things/abstract/place.ts
Normal file
183
packages/core/src/things/abstract/place.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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 {Point, Polygon} from 'geojson';
|
||||
import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||
import {SCBuildingWithoutReferences} from '../building';
|
||||
import {SCPointOfInterestWithoutReferences} from '../point-of-interest';
|
||||
import {SCRoomWithoutReferences} from '../room';
|
||||
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* Positional information
|
||||
*/
|
||||
export interface SCGeoInformation {
|
||||
/**
|
||||
* Center point of a place
|
||||
*/
|
||||
point: Point;
|
||||
/**
|
||||
* Shape of a place
|
||||
*/
|
||||
polygon?: Polygon;
|
||||
}
|
||||
|
||||
/**
|
||||
* A postal address
|
||||
*/
|
||||
export interface SCPostalAddress {
|
||||
/**
|
||||
* Country of the address
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
addressCountry: string;
|
||||
|
||||
/**
|
||||
* City of the address
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
addressLocality: string;
|
||||
|
||||
/**
|
||||
* State of the address
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
addressRegion?: string;
|
||||
|
||||
/**
|
||||
* Zip code of the address
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
postalCode: string;
|
||||
|
||||
/**
|
||||
* Optional post box number
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
postOfficeBoxNumber?: string;
|
||||
|
||||
/**
|
||||
* Street of the address - with house number!
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
streetAddress: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A place without references
|
||||
*/
|
||||
export interface SCPlaceWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Address of the place
|
||||
*/
|
||||
address?: SCPostalAddress;
|
||||
|
||||
/**
|
||||
* Positional information of the place
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* Can not be a GeometryCollection because ElasticSearch does not allow distance filtering/sorting on other types
|
||||
*/
|
||||
geo: SCGeoInformation;
|
||||
|
||||
/**
|
||||
* Opening hours of the place
|
||||
*
|
||||
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||
* @keyword
|
||||
*/
|
||||
openingHours?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of a place
|
||||
*/
|
||||
translations?: SCTranslations<SCPlaceWithoutReferencesTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A place
|
||||
*/
|
||||
export interface SCPlace extends SCPlaceWithoutReferences, SCThing {
|
||||
/**
|
||||
* Translated fields of a place
|
||||
*/
|
||||
translations?: SCTranslations<SCPlaceWithoutReferencesTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a place without references
|
||||
*/
|
||||
export interface SCPlaceWithoutReferencesTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Address of a place
|
||||
*/
|
||||
address?: SCPostalAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about creative works
|
||||
*/
|
||||
export class SCPlaceWithoutReferencesMeta
|
||||
extends SCThingMeta
|
||||
implements SCMetaTranslations<SCPlaceWithoutReferences>
|
||||
{
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
address: 'Adresse',
|
||||
geo: 'Geoinformation',
|
||||
openingHours: 'Öffnungszeiten',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
address: 'address',
|
||||
geo: 'geographic information',
|
||||
openingHours: 'opening hours',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Something that is or happens in a place
|
||||
*
|
||||
* !Important!
|
||||
* This is not a SCThing.
|
||||
*/
|
||||
export interface SCInPlace {
|
||||
/**
|
||||
* Place the thing is or happens in
|
||||
*/
|
||||
inPlace?: SCBuildingWithoutReferences | SCPointOfInterestWithoutReferences | SCRoomWithoutReferences;
|
||||
}
|
||||
66
packages/core/src/things/abstract/range.ts
Normal file
66
packages/core/src/things/abstract/range.ts
Normal 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/>.
|
||||
*/
|
||||
import {SCISO8601Date} from '../../general/time';
|
||||
|
||||
/**
|
||||
* Date Range
|
||||
*
|
||||
* CAUTION: Changing the name requires changes in the core-tools premaps
|
||||
*/
|
||||
export type SCISO8601DateRange = SCRange<SCISO8601Date>;
|
||||
|
||||
/**
|
||||
* Generic range type
|
||||
*/
|
||||
export type SCRange<T> =
|
||||
| {
|
||||
/**
|
||||
* Greater than value
|
||||
*/
|
||||
gt?: never;
|
||||
|
||||
/**
|
||||
* Greater or equal to value
|
||||
*/
|
||||
gte?: T;
|
||||
|
||||
/**
|
||||
* Greater than value
|
||||
*/
|
||||
lt?: never;
|
||||
|
||||
/**
|
||||
* Greater or equal to value
|
||||
*/
|
||||
lte?: T;
|
||||
}
|
||||
| {
|
||||
gt?: T;
|
||||
gte?: never;
|
||||
lt?: T;
|
||||
lte?: never;
|
||||
}
|
||||
| {
|
||||
gt?: T;
|
||||
gte?: never;
|
||||
lt?: never;
|
||||
lte?: T;
|
||||
}
|
||||
| {
|
||||
gt?: never;
|
||||
gte?: T;
|
||||
lt?: T;
|
||||
lte?: never;
|
||||
};
|
||||
35
packages/core/src/things/abstract/saveable-thing.ts
Normal file
35
packages/core/src/things/abstract/saveable-thing.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 {SCIndexableThings} from '../../meta';
|
||||
import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
|
||||
*/
|
||||
export type SCSaveableThingWithoutReferences = SCThingWithoutReferences;
|
||||
|
||||
/**
|
||||
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
|
||||
*/
|
||||
export interface SCSaveableThing extends SCSaveableThingWithoutReferences, SCThing {
|
||||
/**
|
||||
* The contained data
|
||||
*/
|
||||
data: SCIndexableThings;
|
||||
/**
|
||||
* Type of the origin
|
||||
*/
|
||||
origin: SCThingUserOrigin;
|
||||
}
|
||||
55
packages/core/src/things/abstract/thing-in-place.ts
Normal file
55
packages/core/src/things/abstract/thing-in-place.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../../general/i18n';
|
||||
import {SCInPlace} from './place';
|
||||
import {SCThing, SCThingMeta} from './thing';
|
||||
|
||||
/**
|
||||
* A thing that is or happens in a place
|
||||
*/
|
||||
export interface SCThingInPlace extends SCThing, SCInPlace {
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about thing in a place
|
||||
*/
|
||||
export class SCThingInPlaceMeta extends SCThingMeta implements SCMetaTranslations<SCThingInPlace> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
inPlace: 'Ort',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
inPlace: 'location',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../../general/i18n';
|
||||
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* Types of payment that are accepted at a place.
|
||||
*/
|
||||
export type SCThingThatAcceptsPaymentsAcceptedPayments = 'cash' | 'credit' | 'cafeteria card';
|
||||
|
||||
/**
|
||||
* A thing without references that accepts payments
|
||||
*/
|
||||
export interface SCThingThatAcceptsPaymentsWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Accepted payments of the place
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
paymentsAccepted?: SCThingThatAcceptsPaymentsAcceptedPayments[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing that accepts payments
|
||||
*/
|
||||
export interface SCThingThatAcceptsPayments extends SCThingThatAcceptsPaymentsWithoutReferences, SCThing {
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a thing without references that accepts payments
|
||||
*/
|
||||
export class SCThingThatAcceptsPaymentsWithoutReferencesMeta
|
||||
extends SCThingMeta
|
||||
implements SCMetaTranslations<SCThingThatAcceptsPaymentsWithoutReferences>
|
||||
{
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
paymentsAccepted: 'Bezahlmethoden',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
paymentsAccepted: 'accepted payment methods',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
paymentsAccepted: {
|
||||
'cafeteria card': 'Mensakarte',
|
||||
'cash': 'Bar',
|
||||
'credit': 'Kreditkarte',
|
||||
},
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
173
packages/core/src/things/abstract/thing-that-can-be-offered.ts
Normal file
173
packages/core/src/things/abstract/thing-that-can-be-offered.ts
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||
import {SCOrganizationWithoutReferences} from '../organization';
|
||||
import {SCPersonWithoutReferences} from '../person';
|
||||
import {SCInPlace} from './place';
|
||||
import {SCISO8601DateRange} from './range';
|
||||
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* Default price without distinction
|
||||
*/
|
||||
export interface SCPriceGroup {
|
||||
/**
|
||||
* Default price of the thing
|
||||
*
|
||||
* @sortable price
|
||||
* @float
|
||||
*/
|
||||
default: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price distinctions for academic context
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing without references that can be offered
|
||||
*/
|
||||
export interface SCThingThatCanBeOfferedWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Translations of a thing that can be offered
|
||||
*/
|
||||
translations?: SCTranslations<SCThingThatCanBeOfferedTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing that can be offered
|
||||
*/
|
||||
export interface SCThingThatCanBeOffered<T extends SCPriceGroup>
|
||||
extends SCThing,
|
||||
SCThingThatCanBeOfferedWithoutReferences {
|
||||
/**
|
||||
* List of offers for that thing
|
||||
*/
|
||||
offers?: Array<SCThingThatCanBeOfferedOffer<T>>;
|
||||
|
||||
/**
|
||||
* Translations of a thing that can be offered
|
||||
*/
|
||||
translations?: SCTranslations<SCThingThatCanBeOfferedTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offer of a thing
|
||||
*/
|
||||
export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> extends SCInPlace {
|
||||
/**
|
||||
* Availability of an offer
|
||||
*/
|
||||
availability: SCThingThatCanBeOfferedAvailability;
|
||||
|
||||
/**
|
||||
* The time when the thing is available.
|
||||
*/
|
||||
availabilityRange?: SCISO8601DateRange;
|
||||
|
||||
/**
|
||||
* List of prices that are distinct for specific groups
|
||||
*/
|
||||
prices?: T;
|
||||
|
||||
/**
|
||||
* Provider of an offer
|
||||
*/
|
||||
provider: SCThingThatCanBeOfferedProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a thing that can be offered
|
||||
*/
|
||||
export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Availability of an offer
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
'offers[].availability'?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity responsible for the offer
|
||||
*/
|
||||
export type SCThingThatCanBeOfferedProvider = SCOrganizationWithoutReferences | SCPersonWithoutReferences;
|
||||
|
||||
/**
|
||||
* Availability of an Offer
|
||||
*/
|
||||
export type SCThingThatCanBeOfferedAvailability =
|
||||
| 'in stock'
|
||||
| 'out of stock'
|
||||
| 'online only'
|
||||
| 'limited availability';
|
||||
|
||||
/**
|
||||
* Meta information about a thing without references that accepts payments
|
||||
*/
|
||||
export class SCThingThatCanBeOfferedMeta<T extends SCPriceGroup>
|
||||
implements SCMetaTranslations<SCThingThatCanBeOffered<T>>
|
||||
{
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
offers: 'Angebote',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
offers: 'offers',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
150
packages/core/src/things/abstract/thing-with-categories.ts
Normal file
150
packages/core/src/things/abstract/thing-with-categories.ts
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||
import {SCMap} from '../../general/map';
|
||||
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
|
||||
|
||||
/**
|
||||
* A thing without references with categories
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* `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
|
||||
* @filterable
|
||||
*/
|
||||
categories: T[];
|
||||
|
||||
/**
|
||||
* Use this to explicitly override general opening hours brought in scope by openingHoursSpecification or openingHours
|
||||
*
|
||||
* A map from categories to their specific values.
|
||||
*/
|
||||
categorySpecificValues?: SCMap<U>;
|
||||
|
||||
/**
|
||||
* Translated fields of a thing with categories
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing with categories
|
||||
*/
|
||||
export interface SCThingWithCategories<T, U extends SCThingWithCategoriesSpecificValues>
|
||||
extends SCThing,
|
||||
SCThingWithCategoriesWithoutReferences<T, U> {
|
||||
/**
|
||||
* Translated fields of a thing with categories
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a thing with categories
|
||||
*/
|
||||
export interface SCThingWithCategoriesTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* translations of the categories of a thing with categories
|
||||
*
|
||||
* @sortable ducet
|
||||
*/
|
||||
categories?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Category specific values of a thing with categories
|
||||
*
|
||||
* This interface contains properties that can be specific to a certain category.
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @sortable ducet
|
||||
* @text
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Category specific URL of a thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a thing without references that accepts payments
|
||||
* It intentionally does not extend the SCThingMeta implementation to be able to include generics.
|
||||
*/
|
||||
export class SCThingWithCategoriesWithoutReferencesMeta<T, U extends SCThingWithCategoriesSpecificValues>
|
||||
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>>
|
||||
{
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
categories: 'Kategorien',
|
||||
categorySpecificValues: 'besondere Kategorien',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
categories: 'categories',
|
||||
categorySpecificValues: 'category with specific values',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
},
|
||||
};
|
||||
}
|
||||
313
packages/core/src/things/abstract/thing.ts
Normal file
313
packages/core/src/things/abstract/thing.ts
Normal file
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../../general/i18n';
|
||||
import {SCMap} from '../../general/map';
|
||||
import {SCISO8601Date} from '../../general/time';
|
||||
import {SCUuid} from '../../general/uuid';
|
||||
import {SCOrganizationWithoutReferences} from '../organization';
|
||||
import {SCPersonWithoutReferences} from '../person';
|
||||
|
||||
/**
|
||||
* Types a thing can be
|
||||
*/
|
||||
export enum SCThingType {
|
||||
Assessment = 'assessment',
|
||||
AcademicEvent = 'academic event',
|
||||
Article = 'article',
|
||||
Book = 'book',
|
||||
Periodical = 'periodical',
|
||||
Building = 'building',
|
||||
Catalog = 'catalog',
|
||||
ContactPoint = 'contact point',
|
||||
CourseOfStudy = 'course of study',
|
||||
DateSeries = 'date series',
|
||||
Diff = 'diff',
|
||||
Dish = 'dish',
|
||||
Favorite = 'favorite',
|
||||
Floor = 'floor',
|
||||
Message = 'message',
|
||||
Organization = 'organization',
|
||||
Person = 'person',
|
||||
PointOfInterest = 'point of interest',
|
||||
PublicationEvent = 'publication event',
|
||||
Room = 'room',
|
||||
Semester = 'semester',
|
||||
Setting = 'setting',
|
||||
SportCourse = 'sport course',
|
||||
StudyModule = 'study module',
|
||||
Ticket = 'ticket',
|
||||
ToDo = 'todo',
|
||||
Tour = 'tour',
|
||||
Video = 'video',
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing without references
|
||||
*/
|
||||
export interface SCThingWithoutReferences {
|
||||
/**
|
||||
* Alternate names of the thing
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
alternateNames?: string[];
|
||||
|
||||
/**
|
||||
* Description of the thing
|
||||
*
|
||||
* @minLength 1
|
||||
* @text
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The identifier property represents any kind of additional identifier for any kind of SCThing
|
||||
*
|
||||
* E.g. GTIN codes, UUIDs, Database IDs etc.
|
||||
*/
|
||||
identifiers?: SCMap<string>;
|
||||
|
||||
/**
|
||||
* URL of an image of the thing
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
image?: string;
|
||||
|
||||
/**
|
||||
* Name of the thing
|
||||
*
|
||||
* @filterable
|
||||
* @minLength 1
|
||||
* @sortable ducet
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* URL of a reference Web page that unambiguously indicates the item's identity
|
||||
*
|
||||
* E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website.
|
||||
*/
|
||||
sameAs?: string;
|
||||
|
||||
/**
|
||||
* Translations of specific values of the object
|
||||
*
|
||||
* Take precedence over "main" value for selected languages.
|
||||
*/
|
||||
translations?: SCTranslations<SCThingTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the thing
|
||||
*
|
||||
* @sortable ducet
|
||||
* @filterable
|
||||
* @aggregatable global
|
||||
*/
|
||||
type: SCThingType;
|
||||
|
||||
/**
|
||||
* Universally unique identifier of the thing
|
||||
*/
|
||||
uid: SCUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thing
|
||||
*/
|
||||
export interface SCThing extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Origin of the thing
|
||||
*/
|
||||
origin: SCThingRemoteOrigin | SCThingUserOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible types of an origin
|
||||
*/
|
||||
export enum SCThingOriginType {
|
||||
Remote = 'remote',
|
||||
User = 'user',
|
||||
}
|
||||
|
||||
/**
|
||||
* Origin of a thing
|
||||
*/
|
||||
export interface SCThingOrigin {
|
||||
/**
|
||||
* Maintainer of the origin
|
||||
*
|
||||
* e.g. restaurant of a dish
|
||||
*/
|
||||
maintainer?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
|
||||
|
||||
/**
|
||||
* When the thing was modified last in the origin
|
||||
*/
|
||||
modified?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Type of the origin
|
||||
*/
|
||||
type: SCThingOriginType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote origin of a thing
|
||||
*/
|
||||
export interface SCThingRemoteOrigin extends SCThingOrigin {
|
||||
/**
|
||||
* When the thing was indexed last from the origin
|
||||
*/
|
||||
indexed: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Name of the origin
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Original ID of the thing in the origin
|
||||
*/
|
||||
originalId?: string;
|
||||
|
||||
/**
|
||||
* Entity that is responsible for the entity
|
||||
*
|
||||
* e.g. an organizer for an event
|
||||
*/
|
||||
responsibleEntity?: SCPersonWithoutReferences | SCOrganizationWithoutReferences;
|
||||
|
||||
/**
|
||||
* Type of the origin
|
||||
*/
|
||||
type: SCThingOriginType.Remote;
|
||||
|
||||
/**
|
||||
* Main URL of the origin
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* User origin of a thing (data created through user interaction)
|
||||
*/
|
||||
export interface SCThingUserOrigin extends SCThingOrigin {
|
||||
/**
|
||||
* When the thing was created
|
||||
*/
|
||||
created: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* If it is deleted or not, defaults to false
|
||||
*/
|
||||
deleted?: boolean;
|
||||
|
||||
/**
|
||||
* Type of the origin
|
||||
*/
|
||||
type: SCThingOriginType.User;
|
||||
|
||||
/**
|
||||
* When the saved thing was last updated with the latest state (e.g. from the backend)
|
||||
*/
|
||||
updated?: SCISO8601Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of things
|
||||
*/
|
||||
export interface SCThingTranslatableProperties {
|
||||
/**
|
||||
* Translation of the description of the thing
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Translation of the name of the thing
|
||||
*
|
||||
* @sortable ducet
|
||||
* @text
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Origin of the thing
|
||||
*/
|
||||
origin?: SCThingTranslatablePropertyOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable property of an origin
|
||||
*/
|
||||
export interface SCThingTranslatablePropertyOrigin {
|
||||
/**
|
||||
* Translation of the name of the origin
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about things
|
||||
*/
|
||||
export class SCThingMeta implements SCMetaTranslations<SCThing> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
alternateNames: 'alternative Namen',
|
||||
description: 'Beschreibung',
|
||||
identifiers: 'Alternative Identifikation',
|
||||
image: 'Bild',
|
||||
name: 'Name',
|
||||
origin: 'Ursprung',
|
||||
sameAs: 'ursprünglicher Link',
|
||||
translations: 'Übersetzungen',
|
||||
type: 'Typ',
|
||||
uid: 'Identifikation',
|
||||
},
|
||||
en: {
|
||||
alternateNames: 'alternate names',
|
||||
description: 'description',
|
||||
identifiers: 'alternative identification',
|
||||
image: 'image',
|
||||
name: 'name',
|
||||
origin: 'origin',
|
||||
sameAs: 'original link',
|
||||
translations: 'translations',
|
||||
type: 'type',
|
||||
uid: 'identification',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
type: 'Ding',
|
||||
},
|
||||
en: {
|
||||
type: 'Thing',
|
||||
},
|
||||
};
|
||||
}
|
||||
18
packages/core/src/things/abstract/user-groups.ts
Normal file
18
packages/core/src/things/abstract/user-groups.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* Types of data consumers
|
||||
*/
|
||||
export type SCUserGroup = 'students' | 'employees' | 'guests';
|
||||
186
packages/core/src/things/academic-event.ts
Normal file
186
packages/core/src/things/academic-event.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* An academic event without references
|
||||
*/
|
||||
export interface SCAcademicEventWithoutReferences
|
||||
extends SCEventWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Majors of the academic event that this event belongs to
|
||||
*
|
||||
* @aggregatable
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
majors?: string[];
|
||||
|
||||
/**
|
||||
* Original unmapped category from the source of the academic event
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
originalCategory?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of an academic event
|
||||
*/
|
||||
translations?: SCTranslations<SCAcademicEventTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an academic event
|
||||
*/
|
||||
type: SCThingType.AcademicEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* An academic event
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCAcademicEvent
|
||||
extends SCEvent,
|
||||
SCAcademicEventWithoutReferences,
|
||||
SCThingWithCategories<SCAcademicEventCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Translated fields of an academic event
|
||||
*/
|
||||
translations?: SCTranslations<SCAcademicEventTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an academic event
|
||||
*/
|
||||
type: SCThingType.AcademicEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories of academic events
|
||||
*/
|
||||
export type SCAcademicEventCategories =
|
||||
| 'lecture'
|
||||
| 'seminar'
|
||||
| 'integrated course'
|
||||
| 'written exam'
|
||||
| 'oral exam'
|
||||
| 'tutorial'
|
||||
| 'project'
|
||||
| 'colloquium'
|
||||
| 'practicum'
|
||||
| 'introductory class'
|
||||
| 'course'
|
||||
| 'practicum introduction'
|
||||
| 'excursion'
|
||||
| 'exercise'
|
||||
| 'special';
|
||||
|
||||
/**
|
||||
* Translatable properties of an academic event
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about academic events
|
||||
*/
|
||||
export class SCAcademicEventMeta extends SCThingMeta implements SCMetaTranslations<SCAcademicEvent> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAcademicEventCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
majors: 'Hauptfächer',
|
||||
originalCategory: 'ursprüngliche Kategorie',
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAcademicEventCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
majors: 'majors',
|
||||
originalCategory: 'original category',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAcademicEventCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'colloquium': 'Kolloquium',
|
||||
'course': 'Kurs',
|
||||
'excursion': 'Exkursion',
|
||||
'exercise': 'Übung',
|
||||
'integrated course': 'Integrierter Kurs',
|
||||
'introductory class': 'Einführungsveranstaltung',
|
||||
'lecture': 'Vorlesung',
|
||||
'oral exam': 'mündliche Prüfung',
|
||||
'practicum': 'Praktikum',
|
||||
'practicum introduction': 'Einführungspraktikum',
|
||||
'project': 'Projekt',
|
||||
'seminar': 'Seminar',
|
||||
'special': 'Sonderveranstalltung',
|
||||
'tutorial': 'Tutorium',
|
||||
'written exam': 'Schriftilche Prüfung',
|
||||
},
|
||||
type: 'akademische Veranstaltung',
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAcademicEventCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.AcademicEvent,
|
||||
},
|
||||
};
|
||||
}
|
||||
183
packages/core/src/things/article.ts
Normal file
183
packages/core/src/things/article.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
import {SCPeriodicalWithoutReferences} from './periodical';
|
||||
|
||||
/**
|
||||
* Categories of an article
|
||||
*/
|
||||
export type SCArticleCategories = 'unipedia' | 'article' | 'eArticle';
|
||||
|
||||
/**
|
||||
* An article without references
|
||||
*/
|
||||
export interface SCArticleWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCArticleCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Article itself as markdown
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
articleBody?: string;
|
||||
|
||||
/**
|
||||
* Categories of an article
|
||||
*/
|
||||
categories: SCArticleCategories[];
|
||||
|
||||
/**
|
||||
* Translated fields of an article
|
||||
*/
|
||||
translations?: SCTranslations<SCArticleTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an article
|
||||
*/
|
||||
type: SCThingType.Article;
|
||||
}
|
||||
|
||||
/**
|
||||
* An article
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCArticle
|
||||
extends SCCreativeWork,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCArticleWithoutReferences {
|
||||
/**
|
||||
* A periodical to which this article belongs
|
||||
*/
|
||||
isPartOf?: SCPeriodicalWithoutReferences;
|
||||
/**
|
||||
* Additional information about how to find the article inside of its "parent" (which is provided in 'isPartOf')
|
||||
* e.g. "40, 2011, S. 2-3"
|
||||
*/
|
||||
reference?: string;
|
||||
/**
|
||||
* Translated fields of an article
|
||||
*/
|
||||
translations?: SCTranslations<SCArticleTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an article
|
||||
*/
|
||||
type: SCThingType.Article;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of an article
|
||||
*/
|
||||
export interface SCArticleTranslatableProperties
|
||||
extends SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCCreativeWorkTranslatableProperties {
|
||||
/**
|
||||
* Translation of the article itself as markdown
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
articleBody?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about an article
|
||||
*/
|
||||
export class SCArticleMeta extends SCThingMeta implements SCMetaTranslations<SCArticle> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCArticleCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
categories: 'Format',
|
||||
reference: 'Referenz',
|
||||
articleBody: 'Artikelinhalt',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCArticleCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
categories: 'format',
|
||||
reference: 'reference',
|
||||
articleBody: 'article body',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCArticleCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
article: 'Artikel',
|
||||
eArticle: 'E-Aufsatz',
|
||||
unipedia: 'Unipedia',
|
||||
},
|
||||
type: 'Artikel',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCArticleCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.Article,
|
||||
categories: {
|
||||
article: 'article',
|
||||
eArticle: 'E-Article',
|
||||
unipedia: 'unipedia',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
174
packages/core/src/things/assessment.ts
Normal file
174
packages/core/src/things/assessment.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
import {SCCourseOfStudyWithoutReferences} from './course-of-study';
|
||||
|
||||
/**
|
||||
* Categories of assessments
|
||||
*/
|
||||
export type SCAssessmentCategories = 'university assessment';
|
||||
|
||||
/**
|
||||
* An assessment without references
|
||||
*
|
||||
*/
|
||||
export interface SCAssessmentWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<
|
||||
SCAssessmentCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
> {
|
||||
/**
|
||||
* Number of attempts
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
attempt?: number;
|
||||
|
||||
/**
|
||||
* Date assessment was taken or graded
|
||||
*/
|
||||
date?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* ECTS (credit-points)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
ects?: number;
|
||||
|
||||
/**
|
||||
* Grade
|
||||
*/
|
||||
grade: string;
|
||||
|
||||
/**
|
||||
* Current status
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of an assessment
|
||||
*/
|
||||
translations?: SCTranslations<SCAssessmentTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an assessment
|
||||
*/
|
||||
type: SCThingType.Assessment;
|
||||
}
|
||||
|
||||
/**
|
||||
* An assessment
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCAssessment
|
||||
extends SCAssessmentWithoutReferences,
|
||||
SCThing,
|
||||
SCThingWithCategories<SCAssessmentCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Course of study the assessment was taken for
|
||||
*/
|
||||
courseOfStudy?: SCCourseOfStudyWithoutReferences;
|
||||
|
||||
/**
|
||||
* An array of assessments from the 'level 0' (root) assessment to the direct parent
|
||||
*/
|
||||
superAssessments?: SCAssessmentWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated fields of an assessment
|
||||
*/
|
||||
translations?: SCTranslations<SCAssessmentTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an assessment
|
||||
*/
|
||||
type: SCThingType.Assessment;
|
||||
}
|
||||
|
||||
export interface SCAssessmentTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* @see SCAssessmentWithoutReferences.status
|
||||
*/
|
||||
status?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Study module meta data
|
||||
*/
|
||||
export class SCAssessmentMeta extends SCThingMeta implements SCMetaTranslations<SCAssessment> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAssessmentCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
attempt: 'Versuch',
|
||||
courseOfStudy: 'Studiengang',
|
||||
date: 'Datum',
|
||||
ects: 'ECTS-Punkte',
|
||||
grade: 'Note',
|
||||
status: 'Status',
|
||||
superAssessments: 'übergeordnete Prüfungen',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAssessmentCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
attempt: 'attempt',
|
||||
courseOfStudy: 'course of study',
|
||||
date: 'date',
|
||||
ects: 'ECTS points',
|
||||
grade: 'grade',
|
||||
status: 'status',
|
||||
superAssessments: 'parent assessments',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAssessmentCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
type: 'Prüfung',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCAssessmentCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.Assessment,
|
||||
},
|
||||
};
|
||||
}
|
||||
228
packages/core/src/things/book.ts
Normal file
228
packages/core/src/things/book.ts
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* Categories of a book
|
||||
*/
|
||||
export type SCBookCategories =
|
||||
| 'audio'
|
||||
| 'audiobook'
|
||||
| 'book'
|
||||
| 'cd'
|
||||
| 'dvd'
|
||||
| 'eAudiobook'
|
||||
| 'ebook'
|
||||
| 'ePhoto'
|
||||
| 'hierarchy'
|
||||
| 'kit'
|
||||
| 'manuscript'
|
||||
| 'map'
|
||||
| 'microfilm'
|
||||
| 'musicalscore'
|
||||
| 'photo'
|
||||
| 'physicalobject'
|
||||
| 'retro'
|
||||
| 'sensorimage'
|
||||
| 'unknown'
|
||||
| 'video';
|
||||
|
||||
/**
|
||||
* A book without references
|
||||
*/
|
||||
export interface SCBookWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCBookCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Categories of a book
|
||||
*/
|
||||
categories: SCBookCategories[];
|
||||
|
||||
/**
|
||||
* ISBNs of a book
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
ISBNs?: string[];
|
||||
|
||||
/**
|
||||
* Number of pages of a book
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
numberOfPages?: number;
|
||||
|
||||
/**
|
||||
* Translated properties of a book
|
||||
*/
|
||||
translations?: SCTranslations<SCBookTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of a book
|
||||
*/
|
||||
type: SCThingType.Book;
|
||||
}
|
||||
|
||||
/**
|
||||
* A book
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCBook
|
||||
extends SCCreativeWork,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCBookWithoutReferences {
|
||||
/**
|
||||
* Translated properties of a book
|
||||
*/
|
||||
translations?: SCTranslations<SCBookTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of a book
|
||||
*/
|
||||
type: SCThingType.Book;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a book
|
||||
*/
|
||||
export interface SCBookTranslatableFields
|
||||
extends SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCCreativeWorkTranslatableProperties {}
|
||||
|
||||
/**
|
||||
* Meta information about a book
|
||||
*/
|
||||
export class SCBookMeta extends SCThingMeta implements SCMetaTranslations<SCBook> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBookCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
categories: 'Format',
|
||||
ISBNs: 'ISBN',
|
||||
numberOfPages: 'Seitenanzahl',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBookCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
categories: 'format',
|
||||
ISBNs: 'ISBN',
|
||||
numberOfPages: 'number of pages',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBookCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
audio: 'Tonträger',
|
||||
audiobook: 'Hörbuch',
|
||||
book: 'Buch',
|
||||
cd: 'CD',
|
||||
dvd: 'DVD',
|
||||
eAudiobook: 'E-Hörbuch',
|
||||
ebook: 'E-Book',
|
||||
ePhoto: 'E-Photo',
|
||||
hierarchy: 'mehrteiliges Werk',
|
||||
kit: 'Medienkombination',
|
||||
manuscript: 'Handschrift',
|
||||
map: 'Karte',
|
||||
microfilm: 'Mikrofilm, Mikrofiche',
|
||||
musicalscore: 'Noten',
|
||||
photo: 'Abbildung',
|
||||
physicalobject: 'Objekt',
|
||||
retro: 'Retro (Buch)',
|
||||
sensorimage: 'Blindenschrift',
|
||||
unknown: 'Unbekannt',
|
||||
video: 'Film',
|
||||
},
|
||||
type: 'Buch',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBookCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
type: SCThingType.Book,
|
||||
categories: {
|
||||
audio: 'audio material',
|
||||
audiobook: 'audiobook',
|
||||
book: 'book',
|
||||
cd: 'CD',
|
||||
dvd: 'DVD',
|
||||
eAudiobook: 'E-Audiobook',
|
||||
ebook: 'E-Book',
|
||||
ePhoto: 'E-Photo',
|
||||
hierarchy: 'multipart item',
|
||||
kit: 'media combination',
|
||||
manuscript: 'manuscript',
|
||||
map: 'map',
|
||||
microfilm: 'microfilm, microfiche',
|
||||
musicalscore: 'sheet music',
|
||||
photo: 'illustration',
|
||||
physicalobject: 'object',
|
||||
retro: 'retro (book)',
|
||||
sensorimage: 'braille',
|
||||
unknown: 'unknown',
|
||||
video: 'film',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
150
packages/core/src/things/building.ts
Normal file
150
packages/core/src/things/building.ts
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCPlace,
|
||||
SCPlaceWithoutReferences,
|
||||
SCPlaceWithoutReferencesMeta,
|
||||
SCPlaceWithoutReferencesTranslatableProperties,
|
||||
} from './abstract/place';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
export type SCBuildingCategories =
|
||||
| 'cafe'
|
||||
| 'education'
|
||||
| 'library'
|
||||
| 'office'
|
||||
| 'canteen'
|
||||
| 'student canteen'
|
||||
| 'restaurant'
|
||||
| 'restroom';
|
||||
|
||||
export interface SCBuildingWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
|
||||
SCPlaceWithoutReferences {
|
||||
/**
|
||||
* List of floor names of the place
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
floors?: string[];
|
||||
|
||||
/**
|
||||
* Translated fields of a building
|
||||
*/
|
||||
translations?: SCTranslations<SCBuildingTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the building
|
||||
*/
|
||||
type: SCThingType.Building;
|
||||
}
|
||||
|
||||
/**
|
||||
* A building
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCBuilding
|
||||
extends SCBuildingWithoutReferences,
|
||||
SCPlace,
|
||||
SCThingWithCategories<SCBuildingCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Translated fields of a building
|
||||
*/
|
||||
translations?: SCTranslations<SCBuildingTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the building
|
||||
*/
|
||||
type: SCThingType.Building;
|
||||
}
|
||||
|
||||
export interface SCBuildingTranslatableProperties
|
||||
extends SCPlaceWithoutReferencesTranslatableProperties,
|
||||
SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* @see SCBuilding.floors
|
||||
*/
|
||||
floors?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a place
|
||||
*/
|
||||
export class SCBuildingMeta extends SCThingMeta implements SCMetaTranslations<SCBuilding> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBuildingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
|
||||
floors: 'Etagen',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBuildingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
|
||||
floors: 'floors',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBuildingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'cafe': 'Café',
|
||||
'canteen': 'Kantine',
|
||||
'education': 'Bildung',
|
||||
'library': 'Bibliothek',
|
||||
'office': 'Büro',
|
||||
'restaurant': 'Restaurant',
|
||||
'restroom': 'Toilette',
|
||||
'student canteen': 'Mensa',
|
||||
},
|
||||
type: 'Gebäude',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCBuildingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Building,
|
||||
},
|
||||
};
|
||||
}
|
||||
140
packages/core/src/things/catalog.ts
Normal file
140
packages/core/src/things/catalog.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCAcademicTermWithoutReferences} from './abstract/academic-term';
|
||||
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* A catalog without references
|
||||
*/
|
||||
export interface SCCatalogWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @filterable
|
||||
* @integer
|
||||
*/
|
||||
level: number;
|
||||
|
||||
/**
|
||||
* Type of a catalog
|
||||
*/
|
||||
type: SCThingType.Catalog;
|
||||
}
|
||||
|
||||
/**
|
||||
* A catalog
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCCatalog
|
||||
extends SCCatalogWithoutReferences,
|
||||
SCThing,
|
||||
SCThingWithCategories<SCCatalogCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Academic term that a catalog belongs to (e.g. semester)
|
||||
*/
|
||||
academicTerm?: SCAcademicTermWithoutReferences;
|
||||
|
||||
/**
|
||||
* The direct parent of a catalog
|
||||
*/
|
||||
superCatalog?: SCCatalogWithoutReferences;
|
||||
|
||||
/**
|
||||
* An array of catalogs from the 'level 0' (root) catalog to the direct parent
|
||||
*/
|
||||
superCatalogs?: SCCatalogWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated fields of a catalog
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a catalog
|
||||
*/
|
||||
type: SCThingType.Catalog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog meta data
|
||||
*/
|
||||
export class SCCatalogMeta extends SCThingMeta implements SCMetaTranslations<SCCatalog> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCCatalogCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
academicTerm: 'Semester',
|
||||
level: 'Ebene',
|
||||
superCatalog: 'übergeordnetes Verzeichniss',
|
||||
superCatalogs: 'übergeordnete Verzeichnisse',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCCatalogCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
academicTerm: 'academic term',
|
||||
level: 'level',
|
||||
superCatalog: 'parent catalog',
|
||||
superCatalogs: 'parent catalogs',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCCatalogCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'university events': 'Universitätsveranstaltung',
|
||||
},
|
||||
type: 'Verzeichnis',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCCatalogCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.Catalog,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories of catalogs
|
||||
*/
|
||||
export type SCCatalogCategories = 'university events';
|
||||
126
packages/core/src/things/contact-point.ts
Normal file
126
packages/core/src/things/contact-point.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
import {SCRoomWithoutReferences} from './room';
|
||||
|
||||
/**
|
||||
* A contact point without references
|
||||
*/
|
||||
export interface SCContactPointWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* E-mail at the work location
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* Fax number at the work location
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
faxNumber?: string;
|
||||
|
||||
/**
|
||||
* Office hours for contacting someone at the work location
|
||||
*
|
||||
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||
* @keyword
|
||||
*/
|
||||
officeHours?: string;
|
||||
|
||||
/**
|
||||
* Contact number at the work location
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
telephone?: string;
|
||||
|
||||
/**
|
||||
* Type of a contact point
|
||||
*/
|
||||
type: SCThingType.ContactPoint;
|
||||
|
||||
/**
|
||||
* URL at the work location
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A contact point
|
||||
*
|
||||
* @see http://schema.org/ContactPoint
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCContactPoint extends SCContactPointWithoutReferences, SCThing {
|
||||
/**
|
||||
* Exact place where work is performed
|
||||
*/
|
||||
areaServed?: SCRoomWithoutReferences;
|
||||
|
||||
/**
|
||||
* Type of a contact point
|
||||
*/
|
||||
type: SCThingType.ContactPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a contact point
|
||||
*/
|
||||
export class SCContactPointMeta extends SCThingMeta implements SCMetaTranslations<SCContactPoint> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
areaServed: 'Arbeitsraum',
|
||||
email: 'E-Mail-Addresse',
|
||||
faxNumber: 'Faxnummer',
|
||||
officeHours: 'Sprechzeiten',
|
||||
telephone: 'Telefonnummer',
|
||||
url: 'Link',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
areaServed: 'location',
|
||||
email: 'email address',
|
||||
faxNumber: 'fax number',
|
||||
officeHours: 'office hours',
|
||||
telephone: 'telephone number',
|
||||
url: 'link',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
type: 'Kontaktinformation',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.ContactPoint,
|
||||
},
|
||||
};
|
||||
}
|
||||
184
packages/core/src/things/course-of-study.ts
Normal file
184
packages/core/src/things/course-of-study.ts
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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 {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCAcademicDegree,
|
||||
SCAcademicDegreeMeta,
|
||||
SCAcademicDegreeWithoutReferences,
|
||||
} from './abstract/academic-degree';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {SCDateSeriesWithoutReferences} from './date-series';
|
||||
import {SCOrganizationWithoutReferences} from './organization';
|
||||
|
||||
/**
|
||||
* A course of study without references
|
||||
*/
|
||||
export interface SCCourseOfStudyWithoutReferences
|
||||
extends SCAcademicDegreeWithoutReferences,
|
||||
SCThingThatCanBeOfferedWithoutReferences {
|
||||
/**
|
||||
* The main language in which the course of study
|
||||
* is beeing offered
|
||||
*/
|
||||
mainLanguage?: SCLanguage;
|
||||
|
||||
/**
|
||||
* The modes the course of study is offered in
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
mode?: SCCourseOfStudyMode;
|
||||
|
||||
/**
|
||||
* The time modes the course of study is offered in
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
timeMode?: SCCourseOfStudyTimeMode;
|
||||
|
||||
/**
|
||||
* Translated fields of a dish
|
||||
*/
|
||||
translations?: SCTranslations<SCCourseOfStudyTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the course of study
|
||||
*/
|
||||
type: SCThingType.CourseOfStudy;
|
||||
}
|
||||
|
||||
/**
|
||||
* A course of study
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCCourseOfStudy
|
||||
extends SCCourseOfStudyWithoutReferences,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCAcademicDegree {
|
||||
/**
|
||||
* The department that manages the course of study
|
||||
*/
|
||||
department?: SCOrganizationWithoutReferences;
|
||||
|
||||
/**
|
||||
* The secretary that administers requests and
|
||||
* questions concerning the course of study
|
||||
*/
|
||||
secretary?: SCOrganizationWithoutReferences;
|
||||
|
||||
/**
|
||||
* Dates at which the course of study is planned to start
|
||||
*/
|
||||
startDates?: SCDateSeriesWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated fields of a course of study
|
||||
*/
|
||||
translations?: SCTranslations<SCCourseOfStudyTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the course of study
|
||||
*/
|
||||
type: SCThingType.CourseOfStudy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a course of study
|
||||
*/
|
||||
export type SCCourseOfStudyTranslatableProperties = SCThingThatCanBeOfferedTranslatableProperties;
|
||||
|
||||
/**
|
||||
* Meta information about a course of study
|
||||
*/
|
||||
export class SCCourseOfStudyMeta extends SCThingMeta implements SCMetaTranslations<SCCourseOfStudy> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCAcademicDegreeMeta().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
department: 'Fachbereich',
|
||||
mainLanguage: 'Unterrichtssprache',
|
||||
mode: 'Studiengangsart',
|
||||
secretary: 'Sekretariat',
|
||||
startDates: 'Startdatum',
|
||||
timeMode: 'Zeitmodell',
|
||||
},
|
||||
en: {
|
||||
...new SCAcademicDegreeMeta().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
department: 'department',
|
||||
mainLanguage: 'main language',
|
||||
mode: 'mode',
|
||||
secretary: 'secretary',
|
||||
startDates: 'start dates',
|
||||
timeMode: 'time mode',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCAcademicDegreeMeta().fieldValueTranslations.de,
|
||||
modes: {
|
||||
'combination': 'Kombinationsstudiengang',
|
||||
'double-degree': 'Doppelstudium',
|
||||
'dual': 'duales Studium',
|
||||
'standard': 'Studium',
|
||||
},
|
||||
timeMode: {
|
||||
fulltime: 'Vollzeitstudiengang',
|
||||
parttime: 'Teilzeitstudiengang',
|
||||
},
|
||||
type: 'Studiengang',
|
||||
},
|
||||
en: {
|
||||
...new SCAcademicDegreeMeta().fieldValueTranslations.en,
|
||||
modes: {
|
||||
'combination': 'combination course of study',
|
||||
'double-degree': 'double degree course of study',
|
||||
'dual': 'dual course of study',
|
||||
'standard': 'course of study',
|
||||
},
|
||||
timeMode: {
|
||||
fulltime: 'full-time',
|
||||
parttime: 'part-time',
|
||||
},
|
||||
type: SCThingType.CourseOfStudy,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of (german) course of study modes
|
||||
*/
|
||||
export type SCCourseOfStudyMode = 'combination' | 'dual' | 'double-degree' | 'standard';
|
||||
|
||||
/**
|
||||
* Types of (german) course of study time modes
|
||||
*/
|
||||
export type SCCourseOfStudyTimeMode = 'fulltime' | 'parttime';
|
||||
162
packages/core/src/things/date-series.ts
Normal file
162
packages/core/src/things/date-series.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date, SCISO8601Duration} from '../general/time';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {SCAcademicEventWithoutReferences} from './academic-event';
|
||||
import {SCPersonWithoutReferences} from './person';
|
||||
import {SCSportCourseWithoutReferences} from './sport-course';
|
||||
|
||||
/**
|
||||
* Price groups for sport courses
|
||||
*/
|
||||
export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup {
|
||||
/**
|
||||
* Price for alumnis
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
alumni?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A date without references
|
||||
*/
|
||||
export interface SCDateSeriesWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences {
|
||||
/**
|
||||
* Dates of the date series that are initially planned to be held
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
dates: SCISO8601Date[];
|
||||
|
||||
/**
|
||||
* Duration of the date series
|
||||
*/
|
||||
duration: SCISO8601Duration;
|
||||
|
||||
/**
|
||||
* Dates that where initially planned to be held but are cancelled
|
||||
*/
|
||||
exceptions?: SCISO8601Date[];
|
||||
|
||||
/**
|
||||
* Frequency of the date series
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
repeatFrequency?: SCISO8601Duration;
|
||||
|
||||
/**
|
||||
* Translated properties
|
||||
*/
|
||||
translations?: SCTranslations<SCDateSeriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a date series
|
||||
*/
|
||||
type: SCThingType.DateSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* A date series
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCDateSeries
|
||||
extends SCDateSeriesWithoutReferences,
|
||||
SCThingInPlace,
|
||||
SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
|
||||
/**
|
||||
* Event to which the date series belongs
|
||||
*/
|
||||
event: SCAcademicEventWithoutReferences | SCSportCourseWithoutReferences;
|
||||
|
||||
/**
|
||||
* Performers of the date series
|
||||
*/
|
||||
performers?: SCPersonWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated properties
|
||||
*/
|
||||
translations?: SCTranslations<SCDateSeriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a date series
|
||||
*/
|
||||
type: SCThingType.DateSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a date series
|
||||
*/
|
||||
export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations<SCDateSeries> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>().fieldTranslations.de,
|
||||
dates: 'Einzeltermine',
|
||||
duration: 'Dauer',
|
||||
event: 'Event',
|
||||
exceptions: 'Ausnahmen',
|
||||
repeatFrequency: 'Frequenz',
|
||||
performers: 'Vortragende',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>().fieldTranslations.en,
|
||||
dates: 'dates',
|
||||
duration: 'duration',
|
||||
event: 'event',
|
||||
exceptions: 'exceptions',
|
||||
repeatFrequency: 'frequency',
|
||||
performers: 'performers',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>().fieldValueTranslations.de,
|
||||
type: 'Terminserie',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCSportCoursePriceGroup>().fieldValueTranslations.en,
|
||||
type: SCThingType.DateSeries,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of date series'
|
||||
*/
|
||||
export type SCDateSeriesTranslatableProperties = SCThingThatCanBeOfferedTranslatableProperties;
|
||||
104
packages/core/src/things/diff.ts
Normal file
104
packages/core/src/things/diff.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 * as jsonpatch from 'json-patch';
|
||||
import {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {SCIndexableThings} from '../meta';
|
||||
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* A diff without references
|
||||
*/
|
||||
export interface SCDiffWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Action of the diff
|
||||
*/
|
||||
action: 'changed' | 'removed';
|
||||
|
||||
/**
|
||||
* Diff patch. Only when action === 'changed'
|
||||
*/
|
||||
changes?: jsonpatch.OpPatch[];
|
||||
|
||||
/**
|
||||
* Creation date of the diff.
|
||||
*/
|
||||
dateCreated: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Type of a diff
|
||||
*/
|
||||
type: SCThingType.Diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* A diff
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCDiff extends SCDiffWithoutReferences, SCThing {
|
||||
/**
|
||||
* Original object the diff was generated on
|
||||
*/
|
||||
object: SCIndexableThings;
|
||||
|
||||
/**
|
||||
* Type of a diff
|
||||
*/
|
||||
type: SCThingType.Diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a diff
|
||||
*/
|
||||
export class SCDiffMeta extends SCThingMeta implements SCMetaTranslations<SCDiff> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
action: 'Aktion',
|
||||
changes: 'Änderungen',
|
||||
dateCreated: 'Erstellungsdatum',
|
||||
object: 'Objekt',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
action: 'action',
|
||||
changes: 'changes',
|
||||
dateCreated: 'date created',
|
||||
object: 'object',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
action: {
|
||||
changed: 'geändert',
|
||||
removed: 'gelöscht',
|
||||
},
|
||||
type: 'Unterschied',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Diff,
|
||||
},
|
||||
};
|
||||
}
|
||||
272
packages/core/src/things/dish.ts
Normal file
272
packages/core/src/things/dish.ts
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* A dish without references
|
||||
*/
|
||||
export interface SCDishWithoutReferences
|
||||
extends SCThingThatCanBeOfferedWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCDishCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Additives of the dish
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
additives?: string[];
|
||||
|
||||
/**
|
||||
* Characteristics of the dish
|
||||
*/
|
||||
characteristics?: SCDishCharacteristic[];
|
||||
|
||||
/**
|
||||
* Nutrition information (calories and nutrients with amounts)
|
||||
*/
|
||||
nutrition?: SCNutritionInformation;
|
||||
|
||||
/**
|
||||
* Section of the restaurant menu to which the dish belongs
|
||||
*/
|
||||
menuSection?: SCMenuSection;
|
||||
|
||||
/**
|
||||
* Translated fields of a dish
|
||||
*/
|
||||
translations?: SCTranslations<SCDishTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a dish
|
||||
*/
|
||||
type: SCThingType.Dish;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dish
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCDish
|
||||
extends SCDishWithoutReferences,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCThingWithCategories<SCDishCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish)
|
||||
*/
|
||||
dishAddOns?: SCDishWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated fields of a dish
|
||||
*/
|
||||
translations?: SCTranslations<SCDishTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a dish
|
||||
*/
|
||||
type: SCThingType.Dish;
|
||||
}
|
||||
|
||||
export interface SCDishTranslatableProperties
|
||||
extends SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Additives of the dish
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
additives?: string[];
|
||||
/**
|
||||
* Characteristics of the dish
|
||||
*/
|
||||
characteristics?: SCDishCharacteristic[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Composition of properties of a food characteristic
|
||||
*/
|
||||
export interface SCDishCharacteristic {
|
||||
/**
|
||||
* URL of an image of the characteristic
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
image?: string;
|
||||
|
||||
/**
|
||||
* Name of the characteristic
|
||||
*
|
||||
* @filterable
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of categories for dishes
|
||||
*/
|
||||
export type SCDishCategories = 'appetizer' | 'salad' | 'main dish' | 'dessert' | 'soup' | 'side dish';
|
||||
|
||||
/**
|
||||
* Type definition for SCNutritionInformation
|
||||
*
|
||||
* @see https://schema.org/NutritionInformation
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
export interface SCMenuSection {
|
||||
/**
|
||||
* Name of the menu section (mostly to be used as a section title)
|
||||
*/
|
||||
name: 'breakfast' | 'lunch' | 'dinner';
|
||||
|
||||
/**
|
||||
* The time span when the dishes from the sections are available.
|
||||
*
|
||||
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||
*/
|
||||
servingHours?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a dish
|
||||
*/
|
||||
export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
additives: 'Allergene und Zusatzstoffe',
|
||||
characteristics: 'Merkmale',
|
||||
dishAddOns: 'Beilagen',
|
||||
nutrition: 'Nährwertangaben',
|
||||
menuSection: 'Menüabschnitt',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
additives: 'additives and allergens',
|
||||
characteristics: 'characteristics',
|
||||
dishAddOns: 'side dishes',
|
||||
nutrition: 'nutrition information',
|
||||
menuSection: 'menu section',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'appetizer': 'Vorspeise',
|
||||
'dessert': 'Nachtisch',
|
||||
'main dish': 'Hauptgericht',
|
||||
'salad': 'Salat',
|
||||
'side dish': 'Beilage',
|
||||
'soup': 'Suppe',
|
||||
},
|
||||
type: 'Essen',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
type: SCThingType.Dish,
|
||||
},
|
||||
};
|
||||
}
|
||||
43
packages/core/src/things/favorite.ts
Normal file
43
packages/core/src/things/favorite.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 {SCSaveableThing, SCSaveableThingWithoutReferences} from './abstract/saveable-thing';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* A favorite without references
|
||||
*/
|
||||
export interface SCFavoriteWithoutReferences extends SCSaveableThingWithoutReferences {
|
||||
/**
|
||||
* Type of a favorite
|
||||
*/
|
||||
type: SCThingType.Favorite;
|
||||
}
|
||||
|
||||
/**
|
||||
* A favorite
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCFavorite extends SCSaveableThing {
|
||||
/**
|
||||
* Type of a favorite
|
||||
*/
|
||||
type: SCThingType.Favorite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a favorite
|
||||
*/
|
||||
export class SCFavoriteMeta extends SCThingMeta {}
|
||||
139
packages/core/src/things/floor.ts
Normal file
139
packages/core/src/things/floor.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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 {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson';
|
||||
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCThingMeta,
|
||||
SCThingTranslatableProperties,
|
||||
SCThingType,
|
||||
SCThingWithoutReferences,
|
||||
} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
|
||||
import {SCRoomWithoutReferences} from './room';
|
||||
|
||||
/**
|
||||
* A floor without references
|
||||
*/
|
||||
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>;
|
||||
|
||||
/**
|
||||
* Translated fields of a floor
|
||||
*/
|
||||
translations?: SCTranslations<SCFloorTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a floor
|
||||
*/
|
||||
type: SCThingType.Floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* A floor
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace {
|
||||
/**
|
||||
* Translated fields of a floor
|
||||
*/
|
||||
translations?: SCTranslations<SCFloorTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a floor
|
||||
*/
|
||||
type: SCThingType.Floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* A feature collection
|
||||
*/
|
||||
export interface SCFloorFeatureCollectionWithPlaces<T extends GeometryObject> extends FeatureCollection<T> {
|
||||
/**
|
||||
* Features of the collection
|
||||
*/
|
||||
features: Array<SCFloorFeatureWithPlace<T>>;
|
||||
}
|
||||
|
||||
/***
|
||||
* A feature with a place
|
||||
*/
|
||||
export interface SCFloorFeatureWithPlace<T extends GeometryObject>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
extends Feature<T, any> {
|
||||
/**
|
||||
* The place of the feature
|
||||
*/
|
||||
place?: SCRoomWithoutReferences | SCPointOfInterestWithoutReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a floor
|
||||
*/
|
||||
export interface SCFloorTranslatableProperties extends SCThingTranslatableProperties {
|
||||
/**
|
||||
* Translation of the floor name
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
floorName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about floors
|
||||
*/
|
||||
export class SCFloorMeta extends SCThingMeta implements SCMetaTranslations<SCFloor> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
floorName: 'Etagenbezeichnung',
|
||||
plan: 'Grundriss',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
floorName: 'floor name',
|
||||
plan: 'plan',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.de,
|
||||
type: 'Etage',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Floor,
|
||||
},
|
||||
};
|
||||
}
|
||||
186
packages/core/src/things/message.ts
Normal file
186
packages/core/src/things/message.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered';
|
||||
import {
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
import {SCUserGroup} from './abstract/user-groups';
|
||||
import {SCOrganizationWithoutReferences} from './organization';
|
||||
|
||||
/**
|
||||
* Categories of a message
|
||||
*/
|
||||
export type SCMessageCategories = 'news';
|
||||
|
||||
/**
|
||||
* A message without references
|
||||
*/
|
||||
export interface SCMessageWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCMessageCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Organizational unit for which the message is intended
|
||||
*/
|
||||
audienceOrganizations?: SCOrganizationWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Roles for which the message is intended
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
audiences: SCUserGroup[];
|
||||
|
||||
/**
|
||||
* Categories of a message
|
||||
*/
|
||||
categories: SCMessageCategories[];
|
||||
|
||||
/**
|
||||
* When the message was created
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
dateCreated?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody: string;
|
||||
|
||||
/**
|
||||
* An index for applying a custom sorting of multiple messages
|
||||
*/
|
||||
sequenceIndex?: number;
|
||||
|
||||
/**
|
||||
* Translated fields of a message
|
||||
*/
|
||||
translations?: SCTranslations<SCMessageTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a message
|
||||
*/
|
||||
type: SCThingType.Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences {
|
||||
/**
|
||||
* Translated fields of a message
|
||||
*/
|
||||
translations?: SCTranslations<SCMessageTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a message
|
||||
*/
|
||||
type: SCThingType.Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a message
|
||||
*/
|
||||
export interface SCMessageTranslatableProperties
|
||||
extends SCCreativeWorkTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about messages
|
||||
*/
|
||||
export class SCMessageMeta extends SCThingMeta implements SCMetaTranslations<SCMessage> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCMessageCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
audienceOrganizations: 'Zielgruppenorganisationen',
|
||||
audiences: 'Zielgruppen',
|
||||
dateCreated: 'Erstellungsdatum',
|
||||
messageBody: 'Nachrichteninhalt',
|
||||
sequenceIndex: 'Sequenzindex',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCMessageCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
audienceOrganizations: 'audience organizations',
|
||||
audiences: 'audiences',
|
||||
dateCreated: 'date created',
|
||||
messageBody: 'message body',
|
||||
sequenceIndex: 'sequence index',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCMessageCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
audiences: {
|
||||
employees: 'Angestellte',
|
||||
guests: 'Gäste',
|
||||
students: 'Studenten',
|
||||
},
|
||||
categories: {
|
||||
news: 'Neuigkeiten',
|
||||
},
|
||||
type: 'Nachricht',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCMessageCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.Message,
|
||||
},
|
||||
};
|
||||
}
|
||||
79
packages/core/src/things/organization.ts
Normal file
79
packages/core/src/things/organization.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {SCContactPointWithoutReferences} from './contact-point';
|
||||
|
||||
/**
|
||||
* An organization without references
|
||||
*/
|
||||
export interface SCOrganizationWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Type of an organization
|
||||
*/
|
||||
type: SCThingType.Organization;
|
||||
}
|
||||
|
||||
/**
|
||||
* An organization
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCOrganization extends SCOrganizationWithoutReferences, SCThingInPlace {
|
||||
/**
|
||||
* A list of contact points concerning the organization
|
||||
*/
|
||||
contactPoints?: SCContactPointWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Type of an organization
|
||||
*/
|
||||
type: SCThingType.Organization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about an organization
|
||||
*/
|
||||
export class SCOrganizationMeta extends SCThingMeta implements SCMetaTranslations<SCOrganization> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
contactPoints: 'Kontaktinformationen',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
contactPoints: 'contact details',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.de,
|
||||
type: 'Einrichtung',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Organization,
|
||||
},
|
||||
};
|
||||
}
|
||||
162
packages/core/src/things/periodical.ts
Normal file
162
packages/core/src/things/periodical.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* Categories of a periodical
|
||||
*/
|
||||
export type SCPeriodicalCategories = 'journal' | 'electronic';
|
||||
|
||||
/**
|
||||
* A periodical without references
|
||||
*/
|
||||
export interface SCPeriodicalWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCPeriodicalCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Categories of a periodical
|
||||
*/
|
||||
categories: SCPeriodicalCategories[];
|
||||
/**
|
||||
* A list of ISSNs of a periodical
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
ISSNs?: string[];
|
||||
|
||||
/**
|
||||
* Translated properties of a periodical
|
||||
*/
|
||||
translations?: SCTranslations<SCPeriodicalTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of a periodical
|
||||
*/
|
||||
type: SCThingType.Periodical;
|
||||
}
|
||||
|
||||
/**
|
||||
* A publication published at regular intervals (e.g. a magazine or newspaper)
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPeriodical
|
||||
extends SCCreativeWork,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCPeriodicalWithoutReferences {
|
||||
/**
|
||||
* Translated properties of a periodical
|
||||
*/
|
||||
translations?: SCTranslations<SCPeriodicalTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of a periodical
|
||||
*/
|
||||
type: SCThingType.Periodical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a periodical
|
||||
*/
|
||||
export interface SCPeriodicalTranslatableFields
|
||||
extends SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCCreativeWorkTranslatableProperties {}
|
||||
|
||||
/**
|
||||
* Meta information about a periodical
|
||||
*/
|
||||
export class SCPeriodicalMeta extends SCThingMeta implements SCMetaTranslations<SCPeriodical> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPeriodicalCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
categories: 'Format',
|
||||
ISSNs: 'ISSN',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPeriodicalCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
categories: 'format',
|
||||
ISSNs: 'ISSN',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPeriodicalCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
type: 'Periodikum',
|
||||
categories: {
|
||||
electronic: 'E-Journal',
|
||||
journal: 'Zeitschrift',
|
||||
},
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPeriodicalCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
type: 'periodical',
|
||||
categories: {
|
||||
electronic: 'E-Journal',
|
||||
journal: 'journal',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
234
packages/core/src/things/person.ts
Normal file
234
packages/core/src/things/person.ts
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCNationality} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
import {SCBuildingWithoutReferences} from './building';
|
||||
import {SCContactPointWithoutReferences} from './contact-point';
|
||||
import {SCOrganizationWithoutReferences} from './organization';
|
||||
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
|
||||
import {SCRoomWithoutReferences} from './room';
|
||||
|
||||
/**
|
||||
* A person without references
|
||||
*/
|
||||
export interface SCPersonWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Additional first names of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
additionalName?: string;
|
||||
|
||||
/**
|
||||
* The birth date of the person.
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
birthDate?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* The private email address of the person.
|
||||
*
|
||||
* @TJS-format email
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The family name of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
familyName?: string;
|
||||
|
||||
/**
|
||||
* The private fax number of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
faxNumber?: string;
|
||||
|
||||
/**
|
||||
* The gender of the person.
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
gender?: SCPersonGender;
|
||||
|
||||
/**
|
||||
* The first name of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
givenName?: string;
|
||||
|
||||
/**
|
||||
* Honorific prefix of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
honorificPrefix?: string;
|
||||
|
||||
/**
|
||||
* Honorific suffix of the person.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
honorificSuffix?: string;
|
||||
|
||||
/**
|
||||
* Titles of jobs that the person has.
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
jobTitles?: string[];
|
||||
|
||||
/**
|
||||
* The complete name of the person combining all the parts of the name into one.
|
||||
*
|
||||
* @filterable
|
||||
* @text
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The nationality of the person.
|
||||
*/
|
||||
nationality?: SCNationality;
|
||||
|
||||
/**
|
||||
* The private telephone number of the person.
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
telephone?: string;
|
||||
|
||||
/**
|
||||
* Type of a person
|
||||
*/
|
||||
type: SCThingType.Person;
|
||||
}
|
||||
|
||||
/**
|
||||
* A person
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPerson extends SCPersonWithoutReferences, SCThing {
|
||||
/**
|
||||
* Organization the person works for
|
||||
*/
|
||||
affiliations?: SCOrganizationWithoutReferences[];
|
||||
|
||||
/**
|
||||
* A list of homes of the person
|
||||
*/
|
||||
homeLocations?: Array<
|
||||
SCBuildingWithoutReferences | SCPointOfInterestWithoutReferences | SCRoomWithoutReferences
|
||||
>;
|
||||
|
||||
/**
|
||||
* Type of a person
|
||||
*/
|
||||
type: SCThingType.Person;
|
||||
|
||||
/**
|
||||
* Locations where the person performs her/his work
|
||||
*/
|
||||
workLocations?: SCContactPointWithoutReferences[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a person
|
||||
*/
|
||||
export class SCPersonMeta extends SCThingMeta implements SCMetaTranslations<SCPerson> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
additionalName: 'Zusatzname',
|
||||
affiliations: 'Zugehörigkeiten',
|
||||
birthDate: 'Geburtsdatum',
|
||||
email: 'E-Mail',
|
||||
familyName: 'Nachname',
|
||||
faxNumber: 'Faxnummer',
|
||||
gender: 'Geschlecht',
|
||||
givenName: 'Vorname',
|
||||
homeLocations: 'Heimatstandorte',
|
||||
honorificPrefix: 'Ehrentitel',
|
||||
honorificSuffix: 'Ehrentitel (Suffix)',
|
||||
jobTitles: 'Berufsbezeichnungen',
|
||||
nationality: 'Staatsangehörigkeit',
|
||||
telephone: 'Telefonnummer',
|
||||
workLocations: 'Arbeitsstandorte',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
additionalName: 'additional name',
|
||||
affiliations: 'affiliations',
|
||||
birthDate: 'birth date',
|
||||
contactDetails: 'contact details',
|
||||
email: 'email',
|
||||
familyName: 'family name',
|
||||
faxNumber: 'fax',
|
||||
gender: 'gender',
|
||||
givenName: 'given name',
|
||||
homeLocations: 'home locations',
|
||||
honorificPrefix: 'honorific title',
|
||||
honorificSuffix: 'honorific title (suffix)',
|
||||
jobTitles: 'job titles',
|
||||
nationality: 'nationality',
|
||||
telephone: 'telephone',
|
||||
workLocations: 'work locations',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
gender: {
|
||||
female: 'weiblich',
|
||||
inter: 'divers',
|
||||
male: 'männlich',
|
||||
undefined: 'undefiniert',
|
||||
},
|
||||
type: 'Person',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Person,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gender of a person
|
||||
*/
|
||||
export type SCPersonGender = 'male' | 'female' | 'inter' | 'undefined';
|
||||
133
packages/core/src/things/point-of-interest.ts
Normal file
133
packages/core/src/things/point-of-interest.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* A point of interest without references
|
||||
*/
|
||||
export interface SCPointOfInterestWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<
|
||||
SCPointOfInterestCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>,
|
||||
SCPlaceWithoutReferences {
|
||||
/**
|
||||
* Translated properties of a point of interest
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a point of interest
|
||||
*/
|
||||
type: SCThingType.PointOfInterest;
|
||||
}
|
||||
|
||||
/**
|
||||
* A point of interest
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPointOfInterest
|
||||
extends SCPointOfInterestWithoutReferences,
|
||||
SCThingInPlace,
|
||||
SCPlace,
|
||||
SCThingWithCategories<SCPointOfInterestCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Translated properties of a point of interest
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a point of interest
|
||||
*/
|
||||
type: SCThingType.PointOfInterest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories of a point of interest
|
||||
*/
|
||||
export type SCPointOfInterestCategories =
|
||||
| 'computer'
|
||||
| 'validator'
|
||||
| 'card charger'
|
||||
| 'printer'
|
||||
| 'disabled access';
|
||||
|
||||
/**
|
||||
* Meta information about points of interest
|
||||
*/
|
||||
export class SCPointOfInterestMeta extends SCThingMeta implements SCMetaTranslations<SCPointOfInterest> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPointOfInterestCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPointOfInterestCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPointOfInterestCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'card charger': 'Kartenaufwerter',
|
||||
'computer': 'Computer',
|
||||
'disabled access': 'barrierefreier Zugang',
|
||||
'printer': 'Drucker',
|
||||
'validator': 'Validierer',
|
||||
},
|
||||
type: 'Sonderziel',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCPointOfInterestCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.PointOfInterest,
|
||||
},
|
||||
};
|
||||
}
|
||||
100
packages/core/src/things/publication-event.ts
Normal file
100
packages/core/src/things/publication-event.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event';
|
||||
import {SCThingMeta, SCThingTranslatableProperties, SCThingType} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* An publication event without references
|
||||
*/
|
||||
export interface SCPublicationEventWithoutReferences extends SCEventWithoutReferences {
|
||||
/**
|
||||
* All the locations related to the event (e.g. where a creative work was published)
|
||||
*/
|
||||
locations?: string[];
|
||||
|
||||
/**
|
||||
* An organization (or a person) that is publishing at the event
|
||||
*/
|
||||
publisher?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of an publication event
|
||||
*/
|
||||
translations?: SCTranslations<SCPublicationEventTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an publication event
|
||||
*/
|
||||
type: SCThingType.PublicationEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* An publication event
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCPublicationEvent extends SCEvent, SCPublicationEventWithoutReferences {
|
||||
/**
|
||||
* Translated fields of an publication event
|
||||
*/
|
||||
translations?: SCTranslations<SCPublicationEventTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of an publication event
|
||||
*/
|
||||
type: SCThingType.PublicationEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of an publication event
|
||||
*/
|
||||
export type SCPublicationEventTranslatableProperties = SCThingTranslatableProperties;
|
||||
|
||||
/**
|
||||
* Meta information about publication events
|
||||
*/
|
||||
export class SCPublicationEventMeta extends SCThingMeta implements SCMetaTranslations<SCPublicationEvent> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldTranslations.de,
|
||||
locations: 'Erscheinungsorte',
|
||||
publisher: 'Verlag',
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldTranslations.en,
|
||||
locations: 'places of publication',
|
||||
publisher: 'publisher',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldValueTranslations.de,
|
||||
type: 'Veröffentlichung',
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldValueTranslations.en,
|
||||
type: 'publication event',
|
||||
},
|
||||
};
|
||||
}
|
||||
196
packages/core/src/things/room.ts
Normal file
196
packages/core/src/things/room.ts
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCMap} from '../general/map';
|
||||
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place';
|
||||
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {
|
||||
SCThingThatAcceptsPayments,
|
||||
SCThingThatAcceptsPaymentsWithoutReferences,
|
||||
SCThingThatAcceptsPaymentsWithoutReferencesMeta,
|
||||
} from './abstract/thing-that-accepts-payments';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* Categories of a room
|
||||
*/
|
||||
export type SCRoomCategories =
|
||||
| 'cafe'
|
||||
| 'canteen'
|
||||
| 'computer'
|
||||
| 'education'
|
||||
| 'laboratory'
|
||||
| 'learn'
|
||||
| 'library'
|
||||
| 'lounge'
|
||||
| 'office'
|
||||
| 'restaurant'
|
||||
| 'restroom'
|
||||
| 'student canteen'
|
||||
| 'student union';
|
||||
|
||||
/**
|
||||
* A room without references
|
||||
*/
|
||||
export interface SCRoomWithoutReferences
|
||||
extends SCPlaceWithoutReferences,
|
||||
SCThingThatAcceptsPaymentsWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCRoomCategories, SCRoomSpecificValues> {
|
||||
/**
|
||||
* The name of the floor in which the room is in.
|
||||
*
|
||||
* @filterable
|
||||
* @text
|
||||
*/
|
||||
floorName?: string;
|
||||
|
||||
/**
|
||||
* The inventory of the place/room as a list of items and their quantity.
|
||||
*/
|
||||
inventory?: SCMap<number>;
|
||||
|
||||
/**
|
||||
* Translations of specific values of the object
|
||||
*
|
||||
* Take precedence over "main" value for selected languages.
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the room
|
||||
*/
|
||||
type: SCThingType.Room;
|
||||
}
|
||||
|
||||
/**
|
||||
* A room
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCRoom
|
||||
extends SCRoomWithoutReferences,
|
||||
SCThingInPlace,
|
||||
SCThingThatAcceptsPayments,
|
||||
SCPlace,
|
||||
SCThingWithCategories<SCRoomCategories, SCRoomSpecificValues> {
|
||||
/**
|
||||
* Translations of specific values of the object
|
||||
*
|
||||
* Take precedence over "main" value for selected languages.
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the room
|
||||
*/
|
||||
type: SCThingType.Room;
|
||||
}
|
||||
|
||||
/**
|
||||
* Category specific values of a room
|
||||
*/
|
||||
export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValues {
|
||||
/**
|
||||
* Category specific opening hours of the room
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
openingHours?: string;
|
||||
|
||||
/**
|
||||
* Category specific service hours of the room (e.g. cooked food serving hours)
|
||||
*
|
||||
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
|
||||
* @keyword
|
||||
*/
|
||||
serviceHours?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a place
|
||||
*/
|
||||
export class SCRoomMeta extends SCThingMeta implements SCMetaTranslations<SCRoom> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.de,
|
||||
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta().fieldTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories, SCRoomSpecificValues>()
|
||||
.fieldTranslations.de,
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
floorName: 'Etagenbezeichnung',
|
||||
inventory: 'Bestand',
|
||||
serviceHours: 'Servicezeiten',
|
||||
},
|
||||
en: {
|
||||
...new SCPlaceWithoutReferencesMeta().fieldTranslations.en,
|
||||
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta().fieldTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories, SCRoomSpecificValues>()
|
||||
.fieldTranslations.en,
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
floorName: 'floor name',
|
||||
inventory: 'inventory',
|
||||
serviceHours: 'service hours',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.de,
|
||||
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta().fieldValueTranslations.de,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories, SCRoomSpecificValues>()
|
||||
.fieldValueTranslations.de,
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.de,
|
||||
categories: {
|
||||
'cafe': 'Café',
|
||||
'canteen': 'Kantine',
|
||||
'computer': 'PC-Pool',
|
||||
'education': 'Bildung',
|
||||
'laboratory': 'Labor',
|
||||
'learn': 'Lernen',
|
||||
'library': 'Bibliothek',
|
||||
'lounge': 'Lounge',
|
||||
'office': 'Büro',
|
||||
'restaurant': 'Restaurant',
|
||||
'restroom': 'Toilette',
|
||||
'student canteen': 'Mensa',
|
||||
'student union': 'Studentenvereinigung',
|
||||
},
|
||||
type: 'Raum',
|
||||
},
|
||||
en: {
|
||||
...new SCPlaceWithoutReferencesMeta().fieldValueTranslations.en,
|
||||
...new SCThingThatAcceptsPaymentsWithoutReferencesMeta().fieldValueTranslations.en,
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<SCRoomCategories, SCRoomSpecificValues>()
|
||||
.fieldValueTranslations.en,
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Room,
|
||||
},
|
||||
};
|
||||
}
|
||||
94
packages/core/src/things/semester.ts
Normal file
94
packages/core/src/things/semester.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {
|
||||
SCAcademicTerm,
|
||||
SCAcademicTermWithoutReferences,
|
||||
SCAcademicTermWithoutReferencesMeta,
|
||||
} from './abstract/academic-term';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* A semester without references
|
||||
*/
|
||||
export interface SCSemesterWithoutReferences extends SCAcademicTermWithoutReferences {
|
||||
/**
|
||||
* The short name of the semester, using the given pattern.
|
||||
*
|
||||
* @filterable
|
||||
* @pattern ^(WS|SS|WiSe|SoSe) [0-9]{4}(/[0-9]{2})?$
|
||||
* @keyword
|
||||
*/
|
||||
acronym: string;
|
||||
|
||||
/**
|
||||
* Type of the semester
|
||||
*/
|
||||
type: SCThingType.Semester;
|
||||
}
|
||||
|
||||
/**
|
||||
* A semester
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCSemester extends SCSemesterWithoutReferences, SCAcademicTerm {
|
||||
/**
|
||||
* Type of the semester
|
||||
*/
|
||||
type: SCThingType.Semester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a semester
|
||||
*/
|
||||
export class SCSemesterMeta extends SCThingMeta implements SCMetaTranslations<SCSemester> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCAcademicTermWithoutReferencesMeta().fieldTranslations.de,
|
||||
acronym: 'Abkürzung',
|
||||
endDate: 'Ende',
|
||||
eventsEndDate: 'Vorlesungsschluss',
|
||||
eventsStartDate: 'Vorlesungsbeginn',
|
||||
startDate: 'Beginn',
|
||||
},
|
||||
en: {
|
||||
...new SCAcademicTermWithoutReferencesMeta().fieldTranslations.en,
|
||||
acronym: 'acronym',
|
||||
endDate: 'end date',
|
||||
eventsEndDate: 'semester ending',
|
||||
eventsStartDate: 'semester beginning',
|
||||
startDate: 'start date',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCAcademicTermWithoutReferencesMeta().fieldValueTranslations.de,
|
||||
type: 'Semester',
|
||||
},
|
||||
en: {
|
||||
...new SCAcademicTermWithoutReferencesMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Semester,
|
||||
},
|
||||
};
|
||||
}
|
||||
236
packages/core/src/things/setting.ts
Normal file
236
packages/core/src/things/setting.ts
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* 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 {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
import {SCUserGroup} from './abstract/user-groups';
|
||||
|
||||
/**
|
||||
* A setting without references
|
||||
*/
|
||||
export interface SCSettingWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* The default value of a setting
|
||||
*/
|
||||
defaultValue: SCSettingValue | SCSettingValues;
|
||||
/**
|
||||
* The input type of this setting
|
||||
*/
|
||||
inputType: SCSettingInputType;
|
||||
/**
|
||||
* The order number this setting should show up in its category list
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
order: number;
|
||||
/**
|
||||
* Translated fields of a setting
|
||||
*/
|
||||
translations?: SCTranslations<SCSettingValueTranslatableProperties>;
|
||||
/**
|
||||
* The type of this model
|
||||
*/
|
||||
type: SCThingType.Setting;
|
||||
/**
|
||||
* The key of a value of a setting
|
||||
*/
|
||||
value?: SCSettingValue | SCSettingValues;
|
||||
/**
|
||||
* The possible values of a setting
|
||||
*/
|
||||
values?: SCSettingValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of categories for settings
|
||||
*/
|
||||
export type SCSettingCategories = 'profile' | 'privacy' | 'credentials' | 'others';
|
||||
|
||||
/**
|
||||
* The types of input/value a setting object can carry
|
||||
*/
|
||||
export enum SCSettingInputType {
|
||||
SingleChoice = 'single choice',
|
||||
MultipleChoice = 'multiple choice',
|
||||
Number = 'number',
|
||||
Text = 'text',
|
||||
Password = 'password',
|
||||
}
|
||||
|
||||
/**
|
||||
* A setting with references
|
||||
*
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCSetting
|
||||
extends SCSettingWithoutReferences,
|
||||
SCThing,
|
||||
SCThingWithCategories<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Translated fields of a setting
|
||||
*/
|
||||
translations?: SCTranslations<SCSettingValueTranslatableProperties>;
|
||||
/**
|
||||
* The type of this model
|
||||
*/
|
||||
type: SCThingType.Setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type a value of a setting can have
|
||||
*/
|
||||
export type SCSettingValue = string | number | boolean;
|
||||
|
||||
/**
|
||||
* The type of multiple values a setting can have
|
||||
*/
|
||||
export type SCSettingValues = SCSettingValue[];
|
||||
|
||||
/**
|
||||
* Translatable properties of a setting
|
||||
*/
|
||||
export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* The translations of the possible values of a setting
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
values?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about settings
|
||||
*/
|
||||
export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCSetting> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.de,
|
||||
defaultValue: 'Standard Wert',
|
||||
inputType: 'Eingabetyp',
|
||||
order: 'Position',
|
||||
value: 'Wert',
|
||||
values: 'Werte',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldTranslations.en,
|
||||
defaultValue: 'default value',
|
||||
inputType: 'input type',
|
||||
order: 'position',
|
||||
value: 'value',
|
||||
values: 'values',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
credentials: 'Anmeldedaten',
|
||||
others: 'Andere',
|
||||
privacy: 'Privatsphäre',
|
||||
profile: 'Profil',
|
||||
},
|
||||
inputType: {
|
||||
'multiple choice': 'mehrfach Auswahl',
|
||||
'number': 'Zahl',
|
||||
'password': 'Passwort',
|
||||
'single choice': 'einfache Auswahl',
|
||||
'text': 'Text',
|
||||
},
|
||||
type: 'Einstellung',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<
|
||||
SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues
|
||||
>().fieldValueTranslations.en,
|
||||
type: SCThingType.Setting,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A user group setting
|
||||
*/
|
||||
export interface SCUserGroupSetting extends SCSetting {
|
||||
/**
|
||||
* Exact categories of the setting
|
||||
*/
|
||||
categories: ['profile'];
|
||||
/**
|
||||
* The default value of the setting
|
||||
*/
|
||||
defaultValue: SCUserGroup;
|
||||
/**
|
||||
* Specific name of the setting
|
||||
*/
|
||||
name: 'group';
|
||||
/**
|
||||
* Chosen value of the setting
|
||||
*/
|
||||
value?: SCUserGroup;
|
||||
/**
|
||||
* The possible values of the setting
|
||||
*/
|
||||
values: SCUserGroup[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A language setting
|
||||
*/
|
||||
export interface SCLanguageSetting extends SCSetting {
|
||||
/**
|
||||
* Exact categories of the setting
|
||||
*/
|
||||
categories: ['profile'];
|
||||
/**
|
||||
* The default value of the setting
|
||||
*/
|
||||
defaultValue: SCLanguageCode;
|
||||
/**
|
||||
* Specific name of the setting
|
||||
*/
|
||||
name: 'language';
|
||||
/**
|
||||
* Chosen value of the setting
|
||||
*/
|
||||
value?: SCLanguageCode;
|
||||
/**
|
||||
* The possible values of the setting
|
||||
*/
|
||||
values: SCLanguageCode[];
|
||||
}
|
||||
71
packages/core/src/things/sport-course.ts
Normal file
71
packages/core/src/things/sport-course.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* A sport course without references
|
||||
*/
|
||||
export interface SCSportCourseWithoutReferences extends SCEventWithoutReferences {
|
||||
/**
|
||||
* Type of a sport course
|
||||
*/
|
||||
type: SCThingType.SportCourse;
|
||||
}
|
||||
|
||||
/**
|
||||
* A sport course
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCSportCourse extends SCEvent, SCSportCourseWithoutReferences {
|
||||
/**
|
||||
* Type of a sport course
|
||||
*/
|
||||
type: SCThingType.SportCourse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a sport course
|
||||
*/
|
||||
export class SCSportCourseMeta extends SCThingMeta implements SCMetaTranslations<SCSportCourse> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldTranslations.de,
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldTranslations.en,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCEventMeta().fieldValueTranslations.de,
|
||||
type: 'Sportkurs',
|
||||
},
|
||||
en: {
|
||||
...new SCEventMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.SportCourse,
|
||||
},
|
||||
};
|
||||
}
|
||||
196
packages/core/src/things/study-module.ts
Normal file
196
packages/core/src/things/study-module.ts
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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 {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCMap} from '../general/map';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {SCAcademicEventWithoutReferences} from './academic-event';
|
||||
import {SCOrganizationWithoutReferences} from './organization';
|
||||
import {SCPersonWithoutReferences} from './person';
|
||||
|
||||
/**
|
||||
* A study module without references
|
||||
*/
|
||||
export interface SCStudyModuleWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences {
|
||||
/**
|
||||
* ECTS points (European Credit Transfer System)
|
||||
*
|
||||
* @float
|
||||
*/
|
||||
ects: number;
|
||||
|
||||
/**
|
||||
* The language in which the study module is offered
|
||||
*/
|
||||
language: SCLanguage;
|
||||
|
||||
/**
|
||||
* Majors that this study module is meant for
|
||||
*
|
||||
* @filterable
|
||||
* @keyword
|
||||
*/
|
||||
majors: string[];
|
||||
|
||||
/**
|
||||
* Represents the modules necessity for each given major (of the major property)
|
||||
*/
|
||||
necessity: SCMap<SCStudyModuleNecessity>;
|
||||
|
||||
/**
|
||||
* Translated fields of a study module
|
||||
*/
|
||||
translations?: SCTranslations<SCStudyModuleTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the study module
|
||||
*/
|
||||
type: SCThingType.StudyModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* A study module
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCStudyModule
|
||||
extends SCStudyModuleWithoutReferences,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
|
||||
/**
|
||||
* Academic events that make up a study module
|
||||
*/
|
||||
academicEvents: SCAcademicEventWithoutReferences[];
|
||||
|
||||
/**
|
||||
* The faculty that manages and curates the study module
|
||||
*/
|
||||
faculty: SCOrganizationWithoutReferences;
|
||||
|
||||
/**
|
||||
* Study modules needed for each others fulfillment
|
||||
*/
|
||||
partnerModules?: SCStudyModuleWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Study modules required beforehand
|
||||
*/
|
||||
requiredModules?: SCStudyModuleWithoutReferences[];
|
||||
|
||||
/**
|
||||
* The secretary that administers requests and
|
||||
* questions concerning the study module by eg. students
|
||||
*/
|
||||
secretary: SCOrganizationWithoutReferences | SCPersonWithoutReferences;
|
||||
|
||||
/**
|
||||
* Translated fields of a study module
|
||||
*/
|
||||
translations?: SCTranslations<SCStudyModuleTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the study module
|
||||
*/
|
||||
type: SCThingType.StudyModule;
|
||||
}
|
||||
|
||||
export interface SCStudyModuleTranslatableProperties extends SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Translations of the majors that this study module is meant for
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
majors?: string[];
|
||||
|
||||
/**
|
||||
* Translations of the modules necessity for each given major (of the major property)
|
||||
*/
|
||||
necessity: SCMap<SCStudyModuleNecessity>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a modules necessity (in a major) as it may be required, optional or
|
||||
* is in a pool of n optional modules were m out of them have to be taken/completed.
|
||||
* Hence the elective option.
|
||||
*/
|
||||
export enum SCStudyModuleNecessity {
|
||||
Required = 'required',
|
||||
Elective = 'elective',
|
||||
Optional = 'optional',
|
||||
}
|
||||
|
||||
/**
|
||||
* Study module meta data
|
||||
*/
|
||||
export class SCStudyModuleMeta extends SCThingMeta implements SCMetaTranslations<SCStudyModule> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
academicEvents: 'Veranstaltungen',
|
||||
ects: 'ECTS-Punkte',
|
||||
faculty: 'Fachbereich',
|
||||
language: 'Unterrichtssprache',
|
||||
majors: 'Fachrichtungen',
|
||||
necessity: 'Erforderlichkeit',
|
||||
partnerModules: 'Partnermodule',
|
||||
requiredModules: 'Benötigte Module',
|
||||
secretary: 'Sekretariat',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
academicEvents: 'academic events',
|
||||
ects: 'ECTS points',
|
||||
faculty: 'faculty',
|
||||
language: 'teaching language',
|
||||
majors: 'majors',
|
||||
necessity: 'necessity',
|
||||
partnerModules: 'partner modules',
|
||||
requiredModules: 'required modules',
|
||||
secretary: 'secretary',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
necessity: {
|
||||
elective: 'Wahlfach',
|
||||
optional: 'optional',
|
||||
required: 'benötigt',
|
||||
},
|
||||
type: 'Studiengangmodul',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
type: SCThingType.StudyModule,
|
||||
},
|
||||
};
|
||||
}
|
||||
95
packages/core/src/things/ticket.ts
Normal file
95
packages/core/src/things/ticket.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCISO8601Duration} from '../general/time';
|
||||
import {SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
|
||||
/**
|
||||
* A ticket without references
|
||||
*/
|
||||
export interface SCTicketWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Approximate wait time
|
||||
*/
|
||||
approxWaitingTime: SCISO8601Duration;
|
||||
|
||||
/**
|
||||
* Waiting number of the ticket
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
currentTicketNumber: string;
|
||||
|
||||
/**
|
||||
* Service type of the ticket
|
||||
*/
|
||||
serviceType: string;
|
||||
|
||||
/**
|
||||
* Type of a ticket
|
||||
*/
|
||||
type: SCThingType.Ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ticket
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace {
|
||||
/**
|
||||
* Type of a ticket
|
||||
*/
|
||||
type: SCThingType.Ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a ticket
|
||||
*/
|
||||
export class SCTicketMeta extends SCThingMeta implements SCMetaTranslations<SCTicket> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.de,
|
||||
approxWaitingTime: 'ungefähre Wartezeit',
|
||||
currentTicketNumber: 'aktuelle Ticketnummer',
|
||||
serviceType: 'Service Kategorie',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldTranslations.en,
|
||||
approxWaitingTime: 'approximate waiting time',
|
||||
currentTicketNumber: 'current ticket number',
|
||||
serviceType: 'type of service',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.de,
|
||||
type: 'Ticket',
|
||||
},
|
||||
en: {
|
||||
...new SCThingInPlaceMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Ticket,
|
||||
},
|
||||
};
|
||||
}
|
||||
123
packages/core/src/things/todo.ts
Normal file
123
packages/core/src/things/todo.ts
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {SCThing, SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* A "to do" without references
|
||||
*/
|
||||
export interface SCToDoWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<string, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Whether or not the "to do" is already done
|
||||
*/
|
||||
done: boolean;
|
||||
|
||||
/**
|
||||
* A date when the "to do" is due
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
dueDate?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Priority of the "to do"
|
||||
*/
|
||||
priority: SCToDoPriority;
|
||||
|
||||
/**
|
||||
* Type of the "to do"
|
||||
*/
|
||||
type: SCThingType.ToDo;
|
||||
}
|
||||
|
||||
/**
|
||||
* A "to do"
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCToDo
|
||||
extends SCToDoWithoutReferences,
|
||||
SCThing,
|
||||
SCThingWithCategories<string, SCThingWithCategoriesSpecificValues> {
|
||||
/**
|
||||
* Translated fields of a thing with categories
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the "to do"
|
||||
*/
|
||||
type: SCThingType.ToDo;
|
||||
}
|
||||
|
||||
/**
|
||||
* A priority of a "to do"
|
||||
*/
|
||||
export enum SCToDoPriority {
|
||||
LOW = 0,
|
||||
NORMAL = 2,
|
||||
HIGH = 5,
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about todo
|
||||
*/
|
||||
export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations<SCToDo> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<string, SCThingWithCategoriesSpecificValues>()
|
||||
.fieldTranslations.de,
|
||||
done: 'Erledigt',
|
||||
dueDate: 'Fälligkeitsdatum',
|
||||
priority: 'Priorität',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<string, SCThingWithCategoriesSpecificValues>()
|
||||
.fieldTranslations.en,
|
||||
done: 'done',
|
||||
dueDate: 'due date',
|
||||
priority: 'priority',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<string, SCThingWithCategoriesSpecificValues>()
|
||||
.fieldValueTranslations.de,
|
||||
type: 'ToDo',
|
||||
},
|
||||
en: {
|
||||
...new SCThingWithCategoriesWithoutReferencesMeta<string, SCThingWithCategoriesSpecificValues>()
|
||||
.fieldValueTranslations.en,
|
||||
type: SCThingType.ToDo,
|
||||
},
|
||||
};
|
||||
}
|
||||
244
packages/core/src/things/tour.ts
Normal file
244
packages/core/src/things/tour.ts
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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 {SCMetaTranslations} from '../general/i18n';
|
||||
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
|
||||
|
||||
/**
|
||||
* A tour without references
|
||||
*/
|
||||
export interface SCTourWithoutReferences extends SCThingWithoutReferences {
|
||||
/**
|
||||
* Init script for the tour
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
init?: string;
|
||||
|
||||
/**
|
||||
* Steps of a tour
|
||||
*/
|
||||
steps: SCTourStep[];
|
||||
|
||||
/**
|
||||
* Type of a tour
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
type: SCThingType.Tour;
|
||||
}
|
||||
|
||||
/**
|
||||
* A tour
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCTour extends SCTourWithoutReferences, SCThing {
|
||||
/**
|
||||
* Type of a tour
|
||||
*/
|
||||
type: SCThingType.Tour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a tour
|
||||
*/
|
||||
export class SCTourMeta extends SCThingMeta implements SCMetaTranslations<SCTour> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldTranslations.de,
|
||||
init: 'Initiales Skript',
|
||||
steps: 'Schritte',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldTranslations.en,
|
||||
init: 'initial script',
|
||||
steps: 'steps',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCThingMeta().fieldValueTranslations.de,
|
||||
type: 'Tour',
|
||||
},
|
||||
en: {
|
||||
...new SCThingMeta().fieldValueTranslations.en,
|
||||
type: SCThingType.Tour,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A step in a tour
|
||||
*/
|
||||
export type SCTourStep = SCTourStepMenu | SCTourStepLocation | SCTourStepTooltip;
|
||||
|
||||
/**
|
||||
* A location of a tour step
|
||||
*/
|
||||
export interface SCTourStepLocation {
|
||||
/**
|
||||
* Location to go to
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
location: string;
|
||||
|
||||
/**
|
||||
* Type of the step
|
||||
*/
|
||||
type: 'location';
|
||||
}
|
||||
|
||||
/**
|
||||
* A tooltip in a tour step
|
||||
*/
|
||||
export interface SCTourStepTooltip {
|
||||
/**
|
||||
* Whether the tooltip may fail or not
|
||||
*/
|
||||
canFail?: boolean;
|
||||
|
||||
/**
|
||||
* Element that the tooltip shall be pointing at or a list of elements to try in the specified order
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
element: string | string[];
|
||||
|
||||
/**
|
||||
* Position of the tooltip
|
||||
*/
|
||||
position?: 'bottom' | 'left' | 'right' | 'top';
|
||||
|
||||
/**
|
||||
* How the step shall be resolved
|
||||
*/
|
||||
resolved?: SCTourResolvedElement | SCTourResolvedEvent | SCTourResolvedLocation | SCTourResolvedMenu;
|
||||
|
||||
/**
|
||||
* Text that the tooltip shall contain
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* How often it shall be retried
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
tries?: number;
|
||||
|
||||
/**
|
||||
* Type of the step
|
||||
*/
|
||||
type: 'tooltip';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu interaction of a tour step
|
||||
*/
|
||||
export interface SCTourStepMenu {
|
||||
/**
|
||||
* The action that needs to be completed on the menu
|
||||
*/
|
||||
action: 'close';
|
||||
|
||||
/**
|
||||
* The side of the menu that the step refers to
|
||||
*/
|
||||
side: 'right';
|
||||
|
||||
/**
|
||||
* The type of the step
|
||||
*/
|
||||
type: 'menu';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by an element
|
||||
*/
|
||||
export interface SCTourResolvedElement {
|
||||
/**
|
||||
* Element name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
element: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by an event
|
||||
*/
|
||||
export interface SCTourResolvedEvent {
|
||||
/**
|
||||
* Event name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
event: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by a location
|
||||
*/
|
||||
export interface SCTourResolvedLocation {
|
||||
/**
|
||||
* Matching location
|
||||
*/
|
||||
location: SCTourResolvedLocationTypeIs | SCTourResolvedLocationTypeMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by a location for a specific location
|
||||
*/
|
||||
export interface SCTourResolvedLocationTypeIs {
|
||||
/**
|
||||
* Specific location name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
is: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by a location for a specific location
|
||||
*/
|
||||
export interface SCTourResolvedLocationTypeMatch {
|
||||
/**
|
||||
* Regex location name
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
match: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tour step resolved by interacting with a menu
|
||||
*/
|
||||
export interface SCTourResolvedMenu {
|
||||
/**
|
||||
* Menu location
|
||||
*/
|
||||
menu: 'open-left' | 'open-right';
|
||||
}
|
||||
230
packages/core/src/things/video.ts
Normal file
230
packages/core/src/things/video.ts
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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 {SCLanguage, SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Duration} from '../general/time';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {
|
||||
SCAcademicPriceGroup,
|
||||
SCThingThatCanBeOffered,
|
||||
SCThingThatCanBeOfferedMeta,
|
||||
SCThingThatCanBeOfferedTranslatableProperties,
|
||||
SCThingThatCanBeOfferedWithoutReferences,
|
||||
} from './abstract/thing-that-can-be-offered';
|
||||
import {SCPersonWithoutReferences} from './person';
|
||||
|
||||
/**
|
||||
* A video without references
|
||||
*/
|
||||
export interface SCVideoWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences,
|
||||
SCThingThatCanBeOfferedWithoutReferences {
|
||||
/**
|
||||
* The Duration of the Video
|
||||
*/
|
||||
duration?: SCISO8601Duration;
|
||||
|
||||
/**
|
||||
* Downloadable/Streamable Files of the Video
|
||||
*/
|
||||
sources?: SCVideoSource[];
|
||||
|
||||
/**
|
||||
* URLs to a thumbnails for the Video
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
thumbnails?: string[];
|
||||
|
||||
/**
|
||||
* Track Files for the Video
|
||||
*/
|
||||
tracks?: SCVideoTrack;
|
||||
|
||||
/**
|
||||
* A Transcript of the Video
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
transcript?: string;
|
||||
|
||||
/**
|
||||
* Translated fields of a video
|
||||
*/
|
||||
translations?: SCTranslations<SCVideoTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of an Video
|
||||
*/
|
||||
type: SCThingType.Video;
|
||||
}
|
||||
|
||||
export interface SCVideoSource {
|
||||
/**
|
||||
* Pixel Height of the Video
|
||||
*
|
||||
* @integer
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
/**
|
||||
* MIME-Type of the source File
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
mimeType: SCVideoMimeType;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
export interface SCVideoTrack {
|
||||
/**
|
||||
* Language of the Subtitle
|
||||
*/
|
||||
language: SCLanguage;
|
||||
|
||||
/**
|
||||
* Content Type of the Track File
|
||||
*
|
||||
* @filterable
|
||||
*/
|
||||
type: SCVideoTrackTypes;
|
||||
|
||||
/**
|
||||
* URL to the Track File
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A video
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCVideo
|
||||
extends SCCreativeWork,
|
||||
SCThingThatCanBeOffered<SCAcademicPriceGroup>,
|
||||
SCVideoWithoutReferences {
|
||||
/**
|
||||
* Persons acting in the Video
|
||||
*/
|
||||
actors?: SCPersonWithoutReferences[];
|
||||
|
||||
/**
|
||||
* Translated fields of a video
|
||||
*/
|
||||
translations?: SCTranslations<SCVideoTranslatableFields>;
|
||||
|
||||
/**
|
||||
* Type of a video
|
||||
*/
|
||||
type: SCThingType.Video;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translatable properties of a video
|
||||
*/
|
||||
export interface SCVideoTranslatableFields
|
||||
extends SCCreativeWorkTranslatableProperties,
|
||||
SCThingThatCanBeOfferedTranslatableProperties {}
|
||||
|
||||
/**
|
||||
* Meta information about a video
|
||||
*/
|
||||
export class SCVideoMeta extends SCThingMeta implements SCMetaTranslations<SCVideo> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.de,
|
||||
actors: 'Darsteller',
|
||||
duration: 'Dauer',
|
||||
sources: 'Quellen',
|
||||
thumbnails: 'Vorschaubilder',
|
||||
tracks: 'Spuren',
|
||||
transcript: 'Transkript',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldTranslations.en,
|
||||
actors: 'actors',
|
||||
duration: 'duration',
|
||||
sources: 'sources',
|
||||
thumbnails: 'thumbnails',
|
||||
tracks: 'tracks',
|
||||
transcript: 'transcript',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.de,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.de,
|
||||
type: 'Video',
|
||||
},
|
||||
en: {
|
||||
...new SCCreativeWorkMeta().fieldValueTranslations.en,
|
||||
...new SCThingThatCanBeOfferedMeta<SCAcademicPriceGroup>().fieldValueTranslations.en,
|
||||
type: SCThingType.Video,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Video Encoding Formats
|
||||
*/
|
||||
export type SCVideoMimeType =
|
||||
| 'video/mp4'
|
||||
| 'video/ogg'
|
||||
| 'video/webm'
|
||||
| 'application/vnd.apple.mpegurl'
|
||||
| 'application/dash+xml';
|
||||
|
||||
/**
|
||||
* Video Track Types
|
||||
*/
|
||||
export type SCVideoTrackTypes = 'closed captions' | 'chapters' | 'description' | 'metadata' | 'subtitles';
|
||||
409
packages/core/src/translator.ts
Normal file
409
packages/core/src/translator.ts
Normal file
@@ -0,0 +1,409 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/*
|
||||
* 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 equal = require('fast-deep-equal/es6');
|
||||
import clone = require('rfdc');
|
||||
import {Defined, TSOCType} from 'ts-optchain';
|
||||
import {SCLanguageCode} from './general/i18n';
|
||||
import {isThing} from './guards';
|
||||
import {SCClasses} from './meta';
|
||||
import {SCThing, SCThingType} from './things/abstract/thing';
|
||||
|
||||
// eslint disable @typescript-eslint/no-explicit-any
|
||||
const standardCacheSize = 200;
|
||||
|
||||
/**
|
||||
* SCThingTranslator class
|
||||
*/
|
||||
export class SCThingTranslator {
|
||||
/**
|
||||
* Getter for language property
|
||||
*/
|
||||
get language(): SCLanguageCode {
|
||||
return this._language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for language property. Also flushes translation cache
|
||||
*
|
||||
* @param language The language the translator instance will use from now on
|
||||
*/
|
||||
set language(language: SCLanguageCode) {
|
||||
if (language !== this._language) {
|
||||
this.cache.flush();
|
||||
}
|
||||
this._language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property representing the translators target language
|
||||
*/
|
||||
private _language: SCLanguageCode;
|
||||
|
||||
/**
|
||||
* LRU cache containing already translated SCThings
|
||||
*/
|
||||
private readonly cache: LRUCache<SCThing>;
|
||||
|
||||
/**
|
||||
* Property providing a mapping from a SCThingType to its known own meta class
|
||||
*/
|
||||
private readonly metaClasses: typeof SCClasses;
|
||||
|
||||
/**
|
||||
* LRU cache containing SCThings translations have been provided for
|
||||
*/
|
||||
private readonly sourceCache: LRUCache<SCThing>;
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns translator instance for german
|
||||
* new SCThingTranslator('de');
|
||||
*/
|
||||
constructor(language: SCLanguageCode, cacheCapacity: number = standardCacheSize) {
|
||||
this.cache = new LRUCache(cacheCapacity);
|
||||
this.sourceCache = new LRUCache(cacheCapacity);
|
||||
this._language = language;
|
||||
this.metaClasses = SCClasses;
|
||||
|
||||
// Initalize all meta classes once
|
||||
if (typeof (this.metaClasses as any)[Object.keys(this.metaClasses)[0]] === 'function') {
|
||||
for (const metaClass of Object.keys(this.metaClasses)) {
|
||||
(this.metaClasses as any)[metaClass] = new (SCClasses as any)[metaClass]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get field value translation recursively
|
||||
*
|
||||
* @param data The intermediate object / primitive returned by the Proxys get() method
|
||||
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||
*/
|
||||
private deeptranslate<T>(data?: T): TSOCType<T> {
|
||||
const proxy = new Proxy(
|
||||
((defaultValue?: Defined<T>) => (data == undefined ? defaultValue : data)) as TSOCType<T>,
|
||||
{
|
||||
get: (target, key) => {
|
||||
const object: any = target();
|
||||
|
||||
return this.deeptranslate(object[key]);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies only known field translations of the given SCThings meta class to an instance
|
||||
*
|
||||
* @param thingType The type of thing that will be translated
|
||||
* @param language The language the thing property values are translated to
|
||||
* @returns The thing with all known meta values translated
|
||||
*/
|
||||
private getAllMetaFieldTranslations(thingType: SCThingType, language: SCLanguageCode): object | undefined {
|
||||
const fieldTranslations = {};
|
||||
const metaClass = this.getMetaClassInstance(thingType);
|
||||
if (metaClass === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Assigns every property in fieldTranslations to the known base language translation
|
||||
if (metaClass.fieldTranslations.en !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldTranslations.en)) {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations.en[key];
|
||||
}
|
||||
}
|
||||
|
||||
// Assigns every property in fieldTranslations to the known translation in given language
|
||||
if (metaClass.fieldTranslations[language] !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldTranslations[language])) {
|
||||
(fieldTranslations as any)[key] = metaClass.fieldTranslations[language][key];
|
||||
}
|
||||
}
|
||||
|
||||
return fieldTranslations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns meta class needed for translations given a SCThingType
|
||||
*
|
||||
* @param thingType Type of the thing
|
||||
* @returns An instance of the metaclass
|
||||
*/
|
||||
private getMetaClassInstance(thingType: SCThingType): any {
|
||||
if (thingType in this.metaClasses) {
|
||||
return this.metaClasses[thingType];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies known field value translations of the given SCThings meta class to an instance
|
||||
* Translated values overwrite current values inplace (destructive)
|
||||
*
|
||||
* @param instance The thing / object that will be translated
|
||||
* @param language The language the thing / object is translated to
|
||||
* @returns The thing with translated meta field values
|
||||
*/
|
||||
private replaceAvailableMetaFieldValueTranslations(instance: any, language: SCLanguageCode): any {
|
||||
const metaClass = this.getMetaClassInstance(instance.type);
|
||||
if (metaClass === undefined) {
|
||||
return instance;
|
||||
}
|
||||
if (metaClass.fieldValueTranslations[language] !== undefined) {
|
||||
for (const key of Object.keys(metaClass.fieldValueTranslations[language])) {
|
||||
if (
|
||||
metaClass.fieldValueTranslations[language][key] instanceof Object &&
|
||||
(instance as any)[key] instanceof Object
|
||||
) {
|
||||
// Assigns known translations of subproperties to property in given language (e.g. categories)
|
||||
for (const subKey of Object.keys((instance as any)[key])) {
|
||||
(instance as any)[key][subKey] =
|
||||
metaClass.fieldValueTranslations[language][key][(instance as any)[key][subKey]];
|
||||
}
|
||||
} else if (
|
||||
metaClass.fieldValueTranslations[language][key] instanceof Object &&
|
||||
typeof (instance as any)[key] === 'string'
|
||||
) {
|
||||
// Assigns known translations of enum to property in given language (e.g. SCSettingInputType)
|
||||
(instance as any)[key] = metaClass.fieldValueTranslations[language][key][(instance as any)[key]];
|
||||
} else {
|
||||
// Assigns property to known translation of fieldValueTranslations in given language
|
||||
(instance as any)[key] = metaClass.fieldValueTranslations[language][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively translates the given object in-place
|
||||
* Translated values overwrite current values (destructive)
|
||||
*
|
||||
* @param instance The thing / object that will be translated
|
||||
* @returns The thing translated
|
||||
*/
|
||||
private translateThingInPlaceDestructively<T>(instance: T): T {
|
||||
const targetLanguage = this.language;
|
||||
|
||||
let nextInstance = instance as any;
|
||||
// Recursively call this function on all nested SCThings, arrays and objects
|
||||
for (const key of Object.keys(nextInstance)) {
|
||||
if (
|
||||
isThing(nextInstance[key]) ||
|
||||
Array.isArray(nextInstance[key]) ||
|
||||
nextInstance[key] instanceof Object
|
||||
) {
|
||||
nextInstance[key] = this.translateThingInPlaceDestructively(nextInstance[key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Spread variable translations given by the connector into thing
|
||||
if (nextInstance.translations?.[targetLanguage] !== undefined) {
|
||||
nextInstance = {...nextInstance, ...nextInstance.translations![targetLanguage]} as T;
|
||||
}
|
||||
// Spread known translations from meta classes into (partly) translated thing
|
||||
this.replaceAvailableMetaFieldValueTranslations(nextInstance, targetLanguage);
|
||||
|
||||
return nextInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively translates the given object in-place
|
||||
* Translated values overwrite current values (destructive)
|
||||
*
|
||||
* @param thing The thing / object that will be translated
|
||||
* @returns The thing translated
|
||||
*/
|
||||
public translate<T extends SCThing>(thing: T): T {
|
||||
if (equal(this.sourceCache.get(thing), thing)) {
|
||||
const cachedInstance = this.cache.get(thing);
|
||||
if (cachedInstance !== undefined) {
|
||||
return cachedInstance as T;
|
||||
}
|
||||
}
|
||||
const translatedInstance = this.translateThingInPlaceDestructively(clone()(thing));
|
||||
delete translatedInstance.translations;
|
||||
this.cache.putObject(translatedInstance);
|
||||
this.sourceCache.putObject(thing);
|
||||
|
||||
return translatedInstance as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get field value translation recursively
|
||||
*
|
||||
* @example
|
||||
* const dish: SCDish = {...};
|
||||
* translator.translate(dish).offers[0].inPlace.categories[1]());
|
||||
* // or
|
||||
* const dishTranslatedAccess = translator.translate(dish);
|
||||
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
|
||||
* // undoing the TSOCType<T>
|
||||
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
|
||||
* @param thing Top level object that gets passed through the recursion
|
||||
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||
*/
|
||||
public translatedAccess<T extends SCThing>(thing: T): TSOCType<T> {
|
||||
return new Proxy(
|
||||
((defaultValue?: Defined<T>) => (thing == undefined ? defaultValue : thing)) as TSOCType<T>,
|
||||
{
|
||||
get: (target, key) => {
|
||||
const object: any = target();
|
||||
if (equal(this.sourceCache.get(thing), thing)) {
|
||||
const objectTranslatedFromCache = this.cache.get(thing);
|
||||
if (objectTranslatedFromCache !== undefined) {
|
||||
return this.deeptranslate((objectTranslatedFromCache as any)[key]);
|
||||
}
|
||||
}
|
||||
const objectTranslated = this.translateThingInPlaceDestructively(clone()(object));
|
||||
this.cache.putObject(objectTranslated);
|
||||
this.sourceCache.putObject(thing);
|
||||
|
||||
return this.deeptranslate(objectTranslated[key]);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SCThingType this function returns an object with the same basic structure as the corresponding SCThing
|
||||
* All the values will be set to the known translations of the property/key name
|
||||
*
|
||||
* @example
|
||||
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudy>(SCThingType.CourseOfStudy);
|
||||
* @param type The type whose property names will be translated
|
||||
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
||||
*/
|
||||
public translatedPropertyNames<T extends SCThing>(type: SCThingType): T | undefined {
|
||||
return this.getAllMetaFieldTranslations(type, this.language) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SCThingType and a corresponding property name it returns the known property value translation
|
||||
* Access pattern to the meta object containing the translation can be thought of as type.field[key] with key being optional
|
||||
*
|
||||
* @example
|
||||
* const singleValueTranslation = translator.translatedPropertyValue(SCThingType.Dish, 'categories', 'main dish');
|
||||
* @param type The type for whose property values a translation is required
|
||||
* @param field The property for which a translation is required
|
||||
* @param key If specified tries to access the field with this key
|
||||
* @returns Known translation for the property
|
||||
*/
|
||||
public translatedPropertyValue(type: SCThingType, field: string, key?: string): string | undefined {
|
||||
const fieldValueTranslations =
|
||||
this.getMetaClassInstance(type).fieldValueTranslations[this.language] ??
|
||||
this.getMetaClassInstance(type).fieldValueTranslations.en;
|
||||
const fieldTranslation = fieldValueTranslations?.[field];
|
||||
|
||||
return fieldTranslation?.[key ?? ''] ?? key ?? fieldTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LRUCache class
|
||||
* Small last recently used cache intended to get used by SCThingTranslator
|
||||
*/
|
||||
class LRUCache<T> {
|
||||
/**
|
||||
* Map property that manages cached content
|
||||
*/
|
||||
private readonly entries: Map<string, T> = new Map<string, T>();
|
||||
|
||||
/**
|
||||
* Property representing cache maximum capacity
|
||||
*/
|
||||
private readonly maxEntries: number;
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns LRUCache instance with a maximum capacity of 500
|
||||
* new LRUCache(500);
|
||||
*/
|
||||
constructor(maxEntries: number) {
|
||||
this.maxEntries = maxEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes cache / removes all entries
|
||||
*/
|
||||
public flush() {
|
||||
this.entries.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content from cache by key
|
||||
*/
|
||||
public get(somethingOrKey: string): T | undefined;
|
||||
|
||||
/**
|
||||
* Get content from cache by another objects uid
|
||||
*/
|
||||
public get<U extends SCThing>(something: U): T | undefined;
|
||||
|
||||
/**
|
||||
* Get content from cache by key or by another objects uid
|
||||
*
|
||||
* @param somethingOrKey The key which maps to the cached content or an object for which content has been cached
|
||||
* @returns If available the content connected to the key or somethingOrKey.uid property
|
||||
*/
|
||||
public get<U extends SCThing>(somethingOrKey: string | U): T | undefined {
|
||||
let key: string;
|
||||
if (typeof somethingOrKey === 'string') {
|
||||
key = somethingOrKey;
|
||||
} else if (isThing(somethingOrKey)) {
|
||||
key = somethingOrKey.uid;
|
||||
} else {
|
||||
throw new Error(`Passed argument ${somethingOrKey} cannot be key in LRUCache`);
|
||||
}
|
||||
|
||||
const entry = this.entries.get(key);
|
||||
if (entry !== undefined) {
|
||||
// LRU behavior
|
||||
this.entries.delete(key);
|
||||
this.entries.set(key, entry);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place content in cache by key
|
||||
*
|
||||
* @param key The key for which content should be cached
|
||||
* @param content The content that should be cached
|
||||
*/
|
||||
public put(key: string, content: T) {
|
||||
if (this.entries.size >= this.maxEntries) {
|
||||
// LRU behavior
|
||||
const keyToDelete = this.entries.keys().next().value;
|
||||
this.entries.delete(keyToDelete);
|
||||
}
|
||||
this.entries.set(key, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Place content in cache by another objects uid
|
||||
*
|
||||
* @param something The object that should be cached under something.uid
|
||||
*/
|
||||
public putObject<U extends SCThing>(something: U) {
|
||||
this.put(something.uid, something as any as T);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user