Compare commits

..

13 Commits

Author SHA1 Message Date
Karl-Philipp Wulfert
9fb0a7c885 0.16.0 2019-04-15 17:41:48 +02:00
Karl-Philipp Wulfert
b5e0b76c24 build: exclude docs from package
Fixes #56
2019-04-15 15:51:25 +02:00
Karl-Philipp Wulfert
a2f44762f9 docs: update changelog 2019-04-09 17:14:55 +02:00
Karl-Philipp Wulfert
d46abbe29b 0.15.0 2019-04-09 17:14:52 +02:00
Rainer Killinger
4986042428 fix: change SCThingMeta getInstance() return value 2019-04-09 14:08:07 +00:00
Michel Jonathan Schmitz
3242411768 feat: provide context based search 2019-04-09 13:47:53 +00:00
Karl-Philipp Wulfert
37e5f6c490 build: update dependencies
Fixes #53
2019-04-09 12:36:22 +02:00
Karl-Philipp Wulfert
623ed613a9 fix: resolve issues with things that can be offered
Fixes #41
2019-04-04 13:47:30 +02:00
Karl-Philipp Wulfert
fd994e2c08 docs: update changelog 2019-04-03 16:23:56 +02:00
Karl-Philipp Wulfert
8dc40dbb00 0.14.0 2019-04-03 16:23:53 +02:00
Wieland Schöbl
c4e30c5fdd docs: add blank line before @param 2019-04-03 15:49:34 +02:00
Wieland Schöbl
81887315f8 feat: add model for plugin register route 2019-04-03 15:17:01 +02:00
Karl-Philipp Wulfert
55687daca9 docs: update changelog 2019-04-02 17:14:45 +02:00
19 changed files with 1191 additions and 2038 deletions

View File

@@ -1,4 +1,3 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org
root = true
@@ -7,11 +6,10 @@ root = true
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = false

29
.gitignore vendored
View File

@@ -20,7 +20,7 @@ coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
@@ -29,14 +29,14 @@ bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
@@ -57,6 +57,29 @@ typings/
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
#DynamoDB Local files
.dynamodb/
########## end of https://github.com/github/gitignore/blob/master/Node.gitignore
# ignore ide files
.idea
.vscode

View File

@@ -1,14 +1,12 @@
# Ignore all files/folders by default
# See https://stackoverflow.com/a/29932318
/*
# Execept this files/folders
!docs
# Except these files/folders
!lib
lib/tsconfig.tsbuildinfo
!LICENSE
!package.json
!package-lock.json
!README.md
!src
test/*
!test/resources/

View File

@@ -1,3 +1,43 @@
# [0.15.0](https://gitlab.com/openstapps/core/compare/v0.14.0...v0.15.0) (2019-04-09)
### Bug Fixes
* change SCThingMeta getInstance() return value ([4986042](https://gitlab.com/openstapps/core/commit/4986042))
* resolve issues with things that can be offered ([623ed61](https://gitlab.com/openstapps/core/commit/623ed61)), closes [#41](https://gitlab.com/openstapps/core/issues/41)
### Features
* provide context based search ([3242411](https://gitlab.com/openstapps/core/commit/3242411))
# [0.14.0](https://gitlab.com/openstapps/core/compare/v0.13.0...v0.14.0) (2019-04-03)
### Features
* add model for plugin register route ([8188731](https://gitlab.com/openstapps/core/commit/8188731))
# [0.13.0](https://gitlab.com/openstapps/core/compare/v0.12.0...v0.13.0) (2019-04-02)
### Bug Fixes
* correct isThing guard ([67868e9](https://gitlab.com/openstapps/core/commit/67868e9))
* update tslint dependencies ([bbe4fca](https://gitlab.com/openstapps/core/commit/bbe4fca))
### Features
* add conditional "maps" for associated types ([c8bda2e](https://gitlab.com/openstapps/core/commit/c8bda2e)), closes [#50](https://gitlab.com/openstapps/core/issues/50)
* provide sample JSON files with the package ([5d1e79d](https://gitlab.com/openstapps/core/commit/5d1e79d)), closes [#46](https://gitlab.com/openstapps/core/issues/46)
# [0.12.0](https://gitlab.com/openstapps/core/compare/v0.11.0...v0.12.0) (2019-03-14)

2740
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.13.0",
"version": "0.16.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -17,7 +17,7 @@
"build": "npm run tslint && npm run compile && npm run pack && npm run schema && npm run documentation",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
"check-configuration": "openstapps-configuration",
"compile": "tsc",
"compile": "rimraf lib && tsc",
"documentation": "typedoc --name \"@openstapps/core\" --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks lib",
"pack": "openstapps-core-tools pack",
"prepublishOnly": "npm ci && npm run build",
@@ -42,24 +42,24 @@
"ts-optchain": "0.1.3"
},
"devDependencies": {
"@openstapps/configuration": "0.8.0",
"@openstapps/core-tools": "0.3.0",
"@openstapps/configuration": "0.11.0",
"@openstapps/core-tools": "0.5.1",
"@openstapps/logger": "0.0.5",
"@types/chai": "4.1.7",
"@types/node": "10.14.4",
"@types/rimraf": "2.0.2",
"async-pool-native": "0.1.0",
"chai": "4.2.0",
"commander": "2.19.0",
"commander": "2.20.0",
"conventional-changelog-cli": "2.0.12",
"mocha": "6.0.2",
"mocha": "6.1.3",
"mocha-typescript": "1.1.17",
"nyc": "13.3.0",
"rimraf": "2.6.3",
"ts-node": "8.0.3",
"ts-node": "8.1.0",
"tslint": "5.15.0",
"typedoc": "0.14.2",
"typescript": "3.4.1"
"typescript": "3.4.3"
},
"nyc": {
"check-coverage": true,

View File

@@ -222,7 +222,7 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
/**
* Set type definiton for singleton instance
*/
protected static _instance: SCThingMeta;
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
@@ -268,8 +268,10 @@ export class SCThingMeta implements SCMetaTranslations<SCThing> {
* Function to retrieve typed singleton instance
*/
public static getInstance<T extends SCThingMeta>(): T {
const typedThis = this as any as typeof SCThingMeta;
return (typedThis._instance || (typedThis._instance = new this())) as T;
if (!this._instance.has(this.name)) {
this._instance.set(this.name, new this());
}
return this._instance.get(this.name) as T;
}
protected constructor() {}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 StApps
* Copyright (C) 2018, 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.
@@ -16,8 +16,8 @@ import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCTranslations} from '../types/i18n';
import {SCInPlace} from '../types/Places';
import {SCISO8601Date} from '../types/Time';
import {SCInPlace} from './../types/Places';
/**
* Default price without distinction
@@ -50,7 +50,17 @@ export interface SCAcademicPriceGroup extends SCPriceGroup {
}
/**
* A thing without references that has a price tag
* A thing without references that can be offered
*/
export interface SCThingThatCanBeOfferedWithoutReferences extends SCThing {
/**
* 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 {
@@ -58,11 +68,6 @@ export interface SCThingThatCanBeOffered<T extends SCPriceGroup>
* List of offers for that thing
*/
offers?: Array<SCThingThatCanBeOfferedOffer<T>>;
/**
* Translations of a thing that can be offered
*/
translations?: SCTranslations<SCThingThatCanBeOfferedTranslatableProperties>;
}
/**

View File

@@ -42,6 +42,7 @@ export abstract class SCError implements SCErrorResponse {
/**
* 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
@@ -66,6 +67,7 @@ export class SCValidationErrorResponse extends SCError {
/**
* Create a SCValidationErrorResponse
*
* @param errors List of validation errors
* @param stack Set to true if a stack trace should be created
*/
@@ -81,6 +83,7 @@ export class SCValidationErrorResponse extends SCError {
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
* Create a SCUnsupportedMediaTypeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -94,6 +97,7 @@ export class SCUnsupportedMediaTypeErrorResponse extends SCError {
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
* Create a SCMethodNotAllowedErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -120,6 +124,7 @@ export class SCRequestBodyTooLargeErrorResponse extends SCError {
export class SCTooManyRequestsErrorResponse extends SCError {
/**
* Create a SCTooManyRequestsErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -133,6 +138,7 @@ export class SCTooManyRequestsErrorResponse extends SCError {
export class SCNotFoundErrorResponse extends SCError {
/**
* Create a SCNotFoundErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {
@@ -140,12 +146,80 @@ export class SCNotFoundErrorResponse extends SCError {
}
}
/**
* An error that is returned when the request is in the right format, but contains parameters that are invalid or not
* acceptable.
*/
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, 406, stack);
}
}
/**
* 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.
*/
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
/**
* Create a PluginAlreadyRegisteredError
*
* @param message contains potential differences in other parameters outside of the name
* @param stack Set to true if a stack trace should be created
*/
constructor(message: string, stack?: boolean) {
super('PluginRegisteringFailedError', message, 409, stack);
}
}
/**
* An error that is returned whenever there is an unexpected error while creating a plugin
*/
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, 500, stack);
}
}
/**
* An error that is returned whenever there is a plugin request that is supposed to register a route, that is already
* registered
* This usually indicates that two **different** plugins use the same route.
*/
export class SCPluginRouteAlreadyRegisteredErrorResponse extends SCError {
/**
* Create a PluginRouteAlreadyRegisteredError
*
* @param registeredName The name by the plugin that has already registered the route previously
* @param registeredUrl The URL by the plugin that has already registered the route previously
* @param stack Set to true if a stack trace should be created
*/
constructor(registeredName: string, registeredUrl: string, stack?: boolean) {
super('PluginRouteAlreadyRegisteredError',
`Already registered by "${registeredName}" under URL "${registeredUrl}".`, 409, stack);
}
}
/**
* An error that is returned whenever there is a syntax error
*/
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
*/
@@ -165,6 +239,7 @@ export class SCInternalServerErrorResponse extends SCError {
/**
* Create a SCInternalServerErrorResponse
*
* @param err 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

View File

@@ -0,0 +1,100 @@
/*
* 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 {Schema} from 'jsonschema';
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse, SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCPluginRouteAlreadyRegisteredErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
} from '../../errors/ErrorResponse';
/**
* Plugin register request
*
* @validatable
*/
export type SCPluginRegisterRequest = AddPlugin | RemovePlugin;
interface AddPlugin {
/**
* The desired action, so whether the plugin should be added or removed
*/
action: 'add';
/**
* The address of the plugin
*/
address: string;
/**
* The name of the plugin
* Just for debugging purposes, to more easily identify conflicts.
*/
name: string;
/**
* How the requests of the plugin looks like, a JSON schema for validation
*/
pluginRequestSchema: Schema;
/**
* How the responses of the plugin looks like, a JSON schema for validation
*/
pluginResponseSchema: Schema;
/**
* The desired route, for example /feedback.
*/
route: string;
}
interface RemovePlugin {
/**
* 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;
}
/**
* Route to register plugins
*/
export class SCPluginRegisterRoute extends SCAbstractRoute {
constructor() {
super();
this.errorNames = [
SCInternalServerErrorResponse,
SCMethodNotAllowedErrorResponse,
SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRouteAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCPluginRouteAlreadyRegisteredErrorResponse,
SCRequestBodyTooLargeErrorResponse,
SCSyntaxErrorResponse,
];
this.method = SCRouteHttpVerbs.POST;
this.requestBodyName = 'SCPluginRegisterRequest';
this.responseBodyName = 'SCPluginRegisterResponse';
this.statusCodeSuccess = 200;
this.urlFragment = '/plugin/register';
}
}

View File

@@ -0,0 +1,26 @@
/*
* 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/>.
*/
/**
* Plugin register response
*
* @validatable
*/
export interface SCPluginRegisterResponse {
/**
* Whether the desired action succeeded or failed (true for success, false if an error occurred)
*/
success: boolean;
}

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
import {SCSearchContext} from '../../../types/config/Backend';
import {SCSearchFilter} from '../../../types/filters/Abstract';
import {SCSearchSort} from '../../../types/sorts/Abstract';
import {
@@ -37,7 +38,12 @@ export interface SCSearchRequest extends SCSearchQuery {
*/
export interface SCSearchQuery {
/**
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
* 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;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* Copyright (C) 2018, 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.
@@ -13,9 +13,12 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicDegree, SCAcademicDegreeMeta} from '../base/AcademicDegree';
import {SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n';
import {SCDateSeriesWithoutReferences} from './DateSeries';
@@ -24,9 +27,8 @@ import {SCOrganization} from './Organization';
/**
* A course of studies without references
*/
export interface SCCourseOfStudiesWithoutReferences extends
SCAcademicDegree,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
export interface SCCourseOfStudiesWithoutReferences extends SCAcademicDegree,
SCThingThatCanBeOfferedWithoutReferences {
/**
* The main language in which the course of studies
* is beeing offered
@@ -64,14 +66,15 @@ export interface SCCourseOfStudiesWithoutReferences extends
*
* @validatable
*/
export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* The department that manages the course of studies
*/
department: SCOrganization;
/**
* The secretary that administers requests and
* The secretary that administers requests and
* questions concerning the course of studies
*/
secretary: SCOrganization;
@@ -81,6 +84,11 @@ export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
*/
startDates?: SCDateSeriesWithoutReferences[];
/**
* Translated fields of a dish
*/
translations?: SCTranslations<SCCourseOfStudiesTranslatableProperties>;
/**
* Type of the course of studies
*/
@@ -88,7 +96,7 @@ export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
}
export interface SCCourseOfStudiesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
extends SCThingThatCanBeOfferedTranslatableProperties {
}
/**
@@ -100,19 +108,19 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat
*/
fieldTranslations = {
de: {
... SCAcademicDegreeMeta.getInstance().fieldTranslations.de,
...SCAcademicDegreeMeta.getInstance().fieldTranslations.de,
},
en: {
... SCAcademicDegreeMeta.getInstance().fieldTranslations.en,
...SCAcademicDegreeMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
fieldValueTranslations = {
de: {
... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de,
modes: {
combination: 'Kombinationsstudiengang',
dual: 'Dualer Studiengang',
@@ -122,7 +130,7 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat
type: 'Studiengang',
},
en: {
... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en,
...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en,
academicDegree: 'Hochschulabschluss',
department: 'Fachbereich',
major: 'Studienfach',
@@ -136,13 +144,13 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat
/**
* Types of (german) course of studies modes
*/
export type SCCourseOfStudiesMode = 'combination' |
'dual' |
'double-degree' |
'standard' ;
export type SCCourseOfStudiesMode = 'combination'
| 'dual'
| 'double-degree'
| 'standard' ;
/**
* Types of (german) course of studies time modes
*/
export type SCCourseOfStudiesTimeMode = 'fulltime' |
'parttime' ;
export type SCCourseOfStudiesTimeMode = 'fulltime'
| 'parttime' ;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 StApps
* Copyright (C) 2018, 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.
@@ -17,6 +17,7 @@ import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
@@ -38,8 +39,7 @@ export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup {
/**
* A date without references
*/
export interface SCDateSeriesWithoutReferences
extends SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
export interface SCDateSeriesWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences {
/**
* Dates of the date series that are initially planned to be held
*/
@@ -76,7 +76,9 @@ export interface SCDateSeriesWithoutReferences
*
* @validatable
*/
export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPlace {
export interface SCDateSeries extends SCDateSeriesWithoutReferences,
SCThingInPlace,
SCThingThatCanBeOffered<SCSportCoursePriceGroup> {
/**
* Event to which the date series belongs
*/
@@ -108,26 +110,26 @@ export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations<
*/
fieldTranslations = {
de: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.de,
...SCThingInPlaceMeta.getInstance().fieldTranslations.de,
},
en: {
... SCThingInPlaceMeta.getInstance().fieldTranslations.en,
...SCThingInPlaceMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
fieldValueTranslations = {
de: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de,
...SCThingInPlaceMeta.getInstance().fieldValueTranslations.de,
dates: 'Einzeltermine',
duration: 'Dauer',
frequency: 'Wiederholung',
type: 'Wiederholungreihe',
},
en: {
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en,
...SCThingInPlaceMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.DateSeries,
},
};

View File

@@ -64,11 +64,6 @@ export interface SCDiff extends SCDiffWithoutReferences {
* Meta information about a diff
*/
export class SCDiffMeta extends SCThingMeta implements SCMetaTranslations<SCDiff> {
/**
* Set type definiton for singleton instance
*/
protected static _instance: SCThingMeta;
/**
* Translations of fields
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 StApps
* Copyright (C) 2018, 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.
@@ -16,6 +16,7 @@ import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from '../base/ThingThatCanBeOffered';
import {
SCThingWithCategoriesSpecificValues,
@@ -29,12 +30,8 @@ import {SCMetaTranslations, SCTranslations} from '../types/i18n';
/**
* A dish without references
*/
export interface SCDishWithoutReferences
extends SCThingWithCategoriesWithoutReferences<
SCDishCategories,
SCThingWithCategoriesSpecificValues
>,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
export interface SCDishWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences,
SCThingWithCategoriesWithoutReferences<SCDishCategories, SCThingWithCategoriesSpecificValues> {
/**
* Additives of the dish
*/
@@ -71,7 +68,8 @@ export interface SCDishWithoutReferences
*
* @validatable
*/
export interface SCDish extends SCDishWithoutReferences {
export interface SCDish extends SCDishWithoutReferences,
SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish)
*/
@@ -173,22 +171,22 @@ export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish
*/
fieldTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
appetizer: 'Vorspeise',
dessert: 'Nachtisch',
@@ -200,8 +198,8 @@ export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish
type: 'Essen',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Dish,
},
};

View File

@@ -15,10 +15,10 @@
/**
* 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> {
@@ -27,3 +27,20 @@ export interface SCMap<T> {
*/
[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
};

View File

@@ -15,7 +15,7 @@
import {SCThingType} from '../../Thing';
import {SCSearchSortType} from '../sorts/Abstract';
import {SCUuid} from '../UUID';
import {SCMap} from './../Map';
import {SCMap, SCRestrictedMap} from './../Map';
import {SCMonitoringConfiguration} from './Monitoring';
/**
@@ -72,7 +72,7 @@ export interface SCBackendConfigurationSortableField {
/**
* 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[];
@@ -84,10 +84,27 @@ export interface SCBackendConfigurationSortableField {
}
/**
* 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 SCBackendConfigurationSearchBoosting {
export interface SCBackendConfigurationSearchBoostingType {
/**
* The factor of which the scores matching this type should be multiplied by
@@ -98,7 +115,7 @@ export interface SCBackendConfigurationSearchBoosting {
* 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`
@@ -143,7 +160,7 @@ export interface SCBackendInternalConfiguration {
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
* set of results
*/
boostings: SCBackendConfigurationSearchBoosting[];
boostings: SCBackendConfigurationSearchBoostingContext;
/**
* Configuration of the database

View File

@@ -2,6 +2,7 @@
"errorNames": [],
"instance": {
"query": "*",
"context": "default",
"filter": {
"arguments": {
"filters": [