Loading src/core/protocol/routes/search/SearchRequest.ts +7 −1 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -36,6 +37,11 @@ export interface SCSearchRequest extends SCSearchQuery { * 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') */ Loading src/core/types/Map.ts +19 −2 Original line number Diff line number Diff line Loading @@ -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 }; src/core/types/config/Backend.ts +22 −5 Original line number Diff line number Diff line Loading @@ -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'; /** Loading Loading @@ -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 Loading Loading @@ -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 Loading test/resources/SearchRequest.1.json +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ "errorNames": [], "instance": { "query": "*", "context": "default", "filter": { "arguments": { "filters": [ Loading Loading
src/core/protocol/routes/search/SearchRequest.ts +7 −1 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -36,6 +37,11 @@ export interface SCSearchRequest extends SCSearchQuery { * 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') */ Loading
src/core/types/Map.ts +19 −2 Original line number Diff line number Diff line Loading @@ -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 };
src/core/types/config/Backend.ts +22 −5 Original line number Diff line number Diff line Loading @@ -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'; /** Loading Loading @@ -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 Loading Loading @@ -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 Loading
test/resources/SearchRequest.1.json +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ "errorNames": [], "instance": { "query": "*", "context": "default", "filter": { "arguments": { "filters": [ Loading