refactor: refactor SCThingTypes from union-type to enum. SCThingType-type-attributes are now string-type-attributes.

This commit is contained in:
Michel Jonathan Schmitz
2018-12-05 18:51:28 +01:00
parent 641eff15b8
commit f9056eeb33
25 changed files with 134 additions and 192 deletions

View File

@@ -23,29 +23,31 @@ import {SCUuid} from './types/UUID';
/**
* Types a thing can be
*/
export type SCThingTypes = 'article'
| 'academic event'
| 'book'
| 'building'
| 'catalog'
| 'course of studies'
| 'date series'
| 'diff'
| 'dish'
| 'favorite'
| 'floor'
| 'message'
| 'offer'
| 'organization'
| 'person'
| 'point of interest'
| 'room'
| 'semester'
| 'setting'
| 'sport course'
| 'ticket'
| 'tour'
| 'video';
export enum SCThingType {
AcademicEvent = 'academic event',
Article = 'article',
Book = 'book',
Building = 'building',
Catalog = 'catalog',
CourseOfStudies = 'course of studies',
DateSeries = 'date series',
Diff = 'diff',
Dish = 'dish',
Favorite = 'favorite',
Floor = 'floor',
Message = 'message',
Offer = 'offer', // Currently not in use
Organization = 'organization',
Person = 'person',
PointOfInterest = 'point of interest',
Room = 'room',
Semester = 'semester',
Setting = 'setting',
SportCourse = 'sport course',
Ticket = 'ticket',
Tour = 'tour',
Video = 'video',
}
/**
* A thing
@@ -84,7 +86,7 @@ export interface SCThing {
/**
* Type of the thing
*/
type: SCThingTypes;
type: string;
/**
* Universally unique identifier of the thing
*/

View File

@@ -13,7 +13,6 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAbstractRoute} from '../../../Route';
import {SCThingTypes} from '../../../Thing';
import {SCISO8601Date} from '../../../types/Time';
/**
@@ -45,9 +44,11 @@ export interface SCBulkParameters {
source: string;
/**
* Type of things that are indexed in this bulk
* Type of things that are indexed in this bulk.
*
* String is an element of the SCThingType enumeration.
*/
type: SCThingTypes;
type: string;
}
/**

View File

@@ -18,14 +18,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* Type of an academic event
*/
export type SCAcademicEventType = 'academic event';
/**
* An academic event without references
*/
@@ -51,7 +46,7 @@ export interface SCAcademicEventWithoutReferences
/**
* Type of an academic event
*/
type: SCAcademicEventType;
type: SCThingType.AcademicEvent;
}
export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferences {
@@ -63,7 +58,7 @@ export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferenc
/**
* Type of an academic event
*/
type: SCAcademicEventType;
type: SCThingType.AcademicEvent;
}
/**

View File

@@ -22,14 +22,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* Type of an article
*/
export type SCArticleType = 'article';
/**
* An article without references
*/
@@ -50,7 +45,7 @@ export interface SCArticleWithoutReferences
/**
* Type of an article
*/
type: SCArticleType;
type: SCThingType.Article;
}
/**
@@ -65,7 +60,7 @@ export interface SCArticle extends SCCreativeWork, SCArticleWithoutReferences {
/**
* Type of an article
*/
type: SCArticleType;
type: SCThingType.Article;
}
/**

View File

@@ -18,15 +18,10 @@ import {
SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork';
import {SCThingWithCategoriesTranslatableProperties} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCPersonWithoutReferences} from './Person';
/**
* Type of a book
*/
export type SCBookType = 'book';
/**
* A book without references
*/
@@ -54,7 +49,7 @@ export interface SCBookWithoutReferences extends SCCreativeWorkWithoutReferences
/**
* Type of a book
*/
type: SCBookType;
type: SCThingType.Book;
}
/**
@@ -74,7 +69,7 @@ export interface SCBook extends SCCreativeWork, SCBookWithoutReferences {
/**
* Type of a book
*/
type: SCBookType;
type: SCThingType.Book;
}
/**

View File

@@ -18,11 +18,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
export type SCBuildingType = 'building';
export type SCBuildingCategories =
'cafe'
| 'education'
@@ -55,10 +53,14 @@ export interface SCBuildingWithoutReferences
/**
* Type of the building
*/
type: SCBuildingType;
type: SCThingType.Building;
}
export interface SCBuilding extends SCBuildingWithoutReferences {
/**
* Type of the building
*/
type: SCThingType.Building;
}
/**

View File

@@ -14,12 +14,7 @@
*/
import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm';
import {SCThingWithCategoriesSpecificValues, SCThingWithCategoriesWithoutReferences} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
/**
* Type of a catalog
*/
export type SCCatalogType = 'catalog';
import {SCThingMeta, SCThingType} from '../Thing';
/**
* A catalog without references
@@ -37,7 +32,7 @@ export interface SCCatalogWithoutReferences
/**
* Type of a catalog
*/
type: SCCatalogType;
type: SCThingType.Catalog;
}
/**
@@ -58,6 +53,11 @@ export interface SCCatalog extends SCCatalogWithoutReferences {
* An array of catalogs from the 'level 0' (root) catalog to the direct parent
*/
superCatalogs?: SCCatalogWithoutReferences[];
/**
* Type of a catalog
*/
type: SCThingType.Catalog;
}
/**

View File

@@ -16,16 +16,11 @@ import {SCAcademicDegree} from '../base/AcademicDegree';
import {SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage, SCTranslations} from '../types/i18n';
import {SCDateSeriesWithoutReferences} from './DateSeries';
import {SCOrganization} from './Organization';
/**
* Type of a course of studies
*/
export type SCCourseOfStudiesType = 'course of studies';
/**
* A course of studies without references
*/
@@ -61,7 +56,7 @@ export interface SCCourseOfStudiesWithoutReferences extends
/**
* Type of the course of studies
*/
type: SCCourseOfStudiesType;
type: SCThingType.CourseOfStudies;
}
/**
@@ -83,6 +78,11 @@ export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences {
* Dates at which the course of studies is planned to start
*/
startDates?: SCDateSeriesWithoutReferences[];
/**
* Type of the course of studies
*/
type: SCThingType.CourseOfStudies;
}
export interface SCCourseOfStudiesTranslatableProperties

View File

@@ -18,18 +18,13 @@ import {
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
} from '../base/ThingThatCanBeOffered';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCISO8601Date, SCISO8601Duration} from '../types/Time';
import {SCAcademicEventWithoutReferences} from './AcademicEvent';
import {SCPersonWithoutReferences} from './Person';
import {SCSportCourseWithoutReferences} from './SportCourse';
/**
* Type of a date series
*/
export type SCDateSeriesType = 'date series';
/**
* Price groups for sport courses
*/
@@ -73,7 +68,7 @@ export interface SCDateSeriesWithoutReferences
/**
* Type of a date series
*/
type: SCDateSeriesType;
type: SCThingType.DateSeries;
}
/**
@@ -99,7 +94,7 @@ export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPl
/**
* Type of a date series
*/
type: SCDateSeriesType;
type: SCThingType.DateSeries;
}
/**

View File

@@ -13,14 +13,9 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingsWithoutDiff} from '../Classes';
import {SCThing, SCThingMeta} from '../Thing';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCISO8601Date} from '../types/Time';
/**
* Type of a diff
*/
export type SCDiffType = 'diff';
/**
* A diff without references
*/
@@ -43,7 +38,7 @@ export interface SCDiffWithoutReferences extends SCThing {
/**
* Type of a diff
*/
type: SCDiffType;
type: SCThingType.Diff;
}
/**
@@ -54,6 +49,11 @@ export interface SCDiff extends SCDiffWithoutReferences {
* Original object the diff was generated on
*/
object: SCThingsWithoutDiff;
/**
* Type of a diff
*/
type: SCThingType.Diff;
}
/**

View File

@@ -23,14 +23,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* Type of a dish
*/
export type SCDishType = 'dish';
/**
* A dish without references
*/
@@ -66,7 +61,7 @@ export interface SCDishWithoutReferences
/**
* Type of a dish
*/
type: SCDishType;
type: SCThingType.Dish;
}
/**
@@ -86,7 +81,7 @@ export interface SCDish extends SCDishWithoutReferences, SCThingInPlace {
/**
* Type of a dish
*/
type: SCDishType;
type: SCThingType.Dish;
}
export interface SCDishTranslatableProperties

View File

@@ -12,7 +12,7 @@
* 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 {SCThing, SCThingMeta} from '../Thing';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCISO8601Date} from '../types/Time';
import {SCAcademicEventWithoutReferences} from './AcademicEvent';
import {SCArticleWithoutReferences} from './Article';
@@ -23,11 +23,6 @@ import {SCPointOfInterestWithoutReferences} from './PointOfInterest';
import {SCRoomWithoutReferences} from './Room';
import {SCSportCourseWithoutReferences} from './SportCourse';
/**
* Type of a favorite
*/
export type SCFavoriteType = 'favorite';
/**
* A favorite without references
*/
@@ -50,7 +45,7 @@ export interface SCFavoriteWithoutReferences extends SCThing {
/**
* Type of a favorite
*/
type: SCFavoriteType;
type: SCThingType.Favorite;
}
/**
@@ -69,6 +64,11 @@ export interface SCFavorite extends SCFavoriteWithoutReferences {
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences
| SCSportCourseWithoutReferences;
/**
* Type of a favorite
*/
type: SCThingType.Favorite;
}
/**

View File

@@ -14,16 +14,11 @@
*/
import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson';
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCPointOfInterestWithoutReferences} from './PointOfInterest';
import {SCRoomWithoutReferences} from './Room';
/**
* Type of a floor
*/
export type SCFloorType = 'floor';
/**
* A floor without references
*/
@@ -46,7 +41,7 @@ export interface SCFloorWithoutReferences extends SCThing {
/**
* Type of a floor
*/
type: SCFloorType;
type: SCThingType.Floor;
}
/**
@@ -61,7 +56,7 @@ export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace {
/**
* Type of a floor
*/
type: SCFloorType;
type: SCThingType.Floor;
}
/**

View File

@@ -18,15 +18,10 @@ import {
SCCreativeWorkWithoutReferences,
} from '../base/CreativeWork';
import {SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/**
* Type of a message
*/
export type SCMessageType = 'message';
/**
* A message without references
*/
@@ -54,7 +49,7 @@ export interface SCMessageWithoutReferences extends SCCreativeWorkWithoutReferen
/**
* Type of a message
*/
type: SCMessageType;
type: SCThingType.Message;
}
/**
@@ -69,7 +64,7 @@ export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences {
/**
* Type of a message
*/
type: SCMessageType;
type: SCThingType.Message;
}
/**

View File

@@ -13,12 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta} from '../Thing';
/**
* Type of an organization
*/
export type SCOrganizationType = 'organization';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
/**
* An organization without references
@@ -27,7 +22,7 @@ export interface SCOrganizationWithoutReferences extends SCThing {
/**
* Type of an organization
*/
type: SCOrganizationType;
type: SCThingType.Organization;
}
/**
@@ -37,7 +32,7 @@ export interface SCOrganization extends SCOrganizationWithoutReferences, SCThing
/**
* Type of an organization
*/
type: SCOrganizationType;
type: SCThingType.Organization;
}
/**

View File

@@ -12,7 +12,7 @@
* 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 {SCThing, SCThingMeta} from '../Thing';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCNationality} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
import {SCBuildingWithoutReferences} from './Building';
@@ -20,11 +20,6 @@ import {SCOrganizationWithoutReferences} from './Organization';
import {SCPointOfInterestWithoutReferences} from './PointOfInterest';
import {SCRoomWithoutReferences} from './Room';
/**
* Type of a person
*/
export type SCPersonType = 'person';
/**
* A person without references
*/
@@ -99,7 +94,7 @@ export interface SCPersonWithoutReferences extends SCThing {
/**
* Type of a person
*/
type: SCPersonType;
type: SCThingType.Person;
}
/**
@@ -118,6 +113,11 @@ export interface SCPerson extends SCPersonWithoutReferences {
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences>;
/**
* Type of a person
*/
type: SCThingType.Person;
/**
* Locations where the person performs her/his work
*/

View File

@@ -19,14 +19,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* Type of a point of interest
*/
export type SCPointOfInterestType = 'point of interest';
/**
* A point of interest without references
*/
@@ -42,7 +37,7 @@ export interface SCPointOfInterestWithoutReferences
/**
* Type of a point of interest
*/
type: SCPointOfInterestType;
type: SCThingType.PointOfInterest;
}
/**
@@ -57,7 +52,7 @@ export interface SCPointOfInterest extends SCPointOfInterestWithoutReferences, S
/**
* Type of a point of interest
*/
type: SCPointOfInterestType;
type: SCThingType.PointOfInterest;
}
/**

View File

@@ -20,14 +20,9 @@ import {
SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* Type of a room
*/
export type SCRoomType = 'room';
/**
* Categories of a room
*/
@@ -70,7 +65,7 @@ export interface SCRoomWithoutReferences
/**
* Type of the room
*/
type: SCRoomType;
type: SCThingType.Room;
}
/**
@@ -87,7 +82,7 @@ export interface SCRoom extends SCRoomWithoutReferences, SCThingInPlace {
/**
* Type of the room
*/
type: SCRoomType;
type: SCThingType.Room;
}
/**

View File

@@ -13,12 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm';
import {SCThingMeta} from '../Thing';
/**
* Type of a semester
*/
export type SCSemesterType = 'semester';
import {SCThingMeta, SCThingType} from '../Thing';
/**
* A semester without references
@@ -34,13 +29,17 @@ export interface SCSemesterWithoutReferences extends SCAcademicTermWithoutRefere
/**
* Type of the semester
*/
type: SCSemesterType;
type: SCThingType.Semester;
}
/**
* A semester
*/
export interface SCSemester extends SCSemesterWithoutReferences {
/**
* Type of the semester
*/
type: SCThingType.Semester;
}
/**

View File

@@ -16,10 +16,9 @@ import {
SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties,
SCThingWithCategoriesWithoutReferences,
} from '../base/ThingWithCategories';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import { SCTranslations } from '../types/i18n';
export type SCSettingType = 'setting';
export type SCSettingCategories = string;
/**
@@ -43,7 +42,7 @@ export interface SCSettingWithoutReferences
/**
* The type of this model
*/
type: SCSettingType;
type: SCThingType.Setting;
}
/**
@@ -59,6 +58,10 @@ export type SCSettingInputType = SCSettingSingleChoice
* A setting with references
*/
export interface SCSetting extends SCSettingWithoutReferences {
/**
* The type of this model
*/
type: SCThingType.Setting;
}
/**

View File

@@ -13,12 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCEvent, SCEventWithoutReferences} from '../base/Event';
import {SCThingMeta} from '../Thing';
/**
* Type of a sport course
*/
export type SCSportCourseType = 'sport course';
import {SCThingMeta, SCThingType} from '../Thing';
/**
* A sport course without references
@@ -27,7 +22,7 @@ export interface SCSportCourseWithoutReferences extends SCEventWithoutReferences
/**
* Type of a sport course
*/
type: SCSportCourseType;
type: SCThingType.SportCourse;
}
/**
@@ -37,7 +32,7 @@ export interface SCSportCourse extends SCEvent, SCSportCourseWithoutReferences {
/**
* Type of a sport course
*/
type: SCSportCourseType;
type: SCThingType.SportCourse;
}
/**

View File

@@ -13,14 +13,9 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCThingInPlace} from '../base/ThingInPlace';
import {SCThing, SCThingMeta} from '../Thing';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
import {SCISO8601Duration} from '../types/Time';
/**
* Type of a ticket
*/
export type SCTicketType = 'ticket';
/**
* A ticket without references
*/
@@ -43,7 +38,7 @@ export interface SCTicketWithoutReferences extends SCThing {
/**
* Type of a ticket
*/
type: SCTicketType;
type: SCThingType.Ticket;
}
/**
@@ -53,7 +48,7 @@ export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace {
/**
* Type of a ticket
*/
type: SCTicketType;
type: SCThingType.Ticket;
}
/**

View File

@@ -12,12 +12,7 @@
* 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 {SCThing, SCThingMeta} from '../Thing';
/**
* Type of a tour
*/
export type SCTourType = 'tour';
import {SCThing, SCThingMeta, SCThingType} from '../Thing';
/**
* A tour without references
@@ -36,13 +31,17 @@ export interface SCTourWithoutReferences extends SCThing {
/**
* Type of a tour
*/
type: SCTourType;
type: SCThingType.Tour;
}
/**
* A tour
*/
export interface SCTour extends SCTourWithoutReferences {
/**
* Type of a tour
*/
type: SCThingType.Tour;
}
/**

View File

@@ -13,16 +13,11 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCCreativeWork, SCCreativeWorkWithoutReferences} from '../base/CreativeWork';
import {SCThingMeta} from '../Thing';
import {SCThingMeta, SCThingType} from '../Thing';
import {SCLanguage} from '../types/i18n';
import {SCISO8601Duration} from '../types/Time';
import {SCPersonWithoutReferences} from './Person';
/**
* Type of a video
*/
export type SCVideoType = 'video';
/**
* A video without references
*/
@@ -55,7 +50,7 @@ export interface SCVideoWithoutReferences extends SCCreativeWorkWithoutReference
/**
* Type of an Video
*/
type: SCVideoType;
type: SCThingType.Video;
}
export interface SCVideoSource {
@@ -114,7 +109,7 @@ export interface SCVideo extends SCCreativeWork, SCVideoWithoutReferences {
/**
* Type of a video
*/
type: SCVideoType;
type: SCThingType.Video;
}
export class SCVideoMeta extends SCThingMeta {

View File

@@ -12,7 +12,6 @@
* 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 {SCThingTypes} from '../../Thing';
import {SCSearchSortType} from '../sorts/Abstract';
import {SCUuid} from '../UUID';
import {SCMonitoringConfiguration} from './Monitoring';
@@ -25,8 +24,10 @@ export interface SCBackendConfiguration {
* A list of hidden SC types
*
* If a type is hidden it won't show in any result unless the type is filtered for
*
* Strings must be elements of the SCThingType enumeration.
*/
hiddenTypes: SCThingTypes[];
hiddenTypes: string[];
/**
* Name of university
@@ -63,7 +64,7 @@ export interface SCBackendConfigurationSortableField {
*
* If no type is given it is assumed it exists on every type
*/
onlyOnTypes?: SCThingTypes[];
onlyOnTypes?: string[];
/**
* A list of supported sorts on this field
@@ -110,7 +111,7 @@ export interface SCBackendConfigurationSearchBoosting {
/**
* Type of things the factor should be applied to
*/
type: SCThingTypes;
type: string;
}
/**
@@ -127,7 +128,7 @@ export interface SCBackendAggregationConfiguration {
*
* If the type is not given is is assumed the field exists on every type
*/
onlyOnTypes?: SCThingTypes[];
onlyOnTypes?: string[];
}
/**