refactor: tidy structure of source files

Fixes #79
This commit is contained in:
Karl-Philipp Wulfert
2019-06-19 15:04:59 +02:00
parent 5de9bf3794
commit ceab7cc7ef
99 changed files with 1395 additions and 1511 deletions

View File

@@ -0,0 +1,110 @@
/*
* 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 {SCMetaTranslations} from '../../general/i18n';
import {SCThing, SCThingMeta, SCThingWithoutReferences} from './thing';
/**
* An academic degree without references
*/
export interface SCAcademicDegreeWithoutReferences
extends SCThingWithoutReferences {
/**
* The achievable academic degree
*/
academicDegree: SCGermanAcademicDegree;
/**
* The achievable academic degree with academic field specification
* (eg. Master of Science)
*
* @keyword
*/
academicDegreewithField: string;
/**
* The achievable academic degree with academic field specification
* shorted (eg. M.Sc.).
*
* @keyword
*/
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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
academicDegree: 'Hochschulgrad',
academicDegreewithField: 'Abschlussbezeichnungen',
academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
academicDegree: 'academic degree',
academicDegreewithField: 'acedemic degree and discipline',
academicDegreewithFieldShort: 'acedemic degree and discipline (short)',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
academicDegree: {
'bachelor': 'Bachelor',
'diploma': 'Diplom',
'doctor': 'Doktor',
'licentiate': 'Lizenziat',
'magister': 'Magister',
'master': 'Master',
'masterstudent': 'Meisterschüler',
'state examination': 'Staatsexamen',
},
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}
/**
* Types of (german) academic degrees
*/
export type SCGermanAcademicDegree =
'bachelor'
| 'diploma'
| 'doctor'
| 'licentiate'
| 'magister'
| 'master'
| 'master pupil'
| 'state examination' ;

View File

@@ -0,0 +1,99 @@
/*
* 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 {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
* @keyword
*/
acronym: string;
/**
* End date of the academic term
*/
endDate: SCISO8601Date;
/**
* End date of lectures in the academic term
*/
eventsEndDate?: SCISO8601Date;
/**
* Start date of lectures in the academic term
*/
eventsStartDate?: SCISO8601Date;
/**
* Start date of the academic term
*/
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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
acronym: 'Akronym',
endDate: 'Enddatum',
eventsEndDate: 'Enddatum der Veranstaltungen',
eventsStartDate: 'Startdatum der Veranstaltungen',
startDate: 'Startdatum',
},
en: {
...SCThingMeta.getInstance<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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,133 @@
/*
* 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 {SCLanguage, SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from './thing-that-can-be-offered';
/**
* A creative work without references
*/
export interface SCCreativeWorkWithoutReferences
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* Date the creative work was published
*/
datePublished?: SCISO8601Date;
/**
* List of languages this creative work is written/recorded/... in
*/
inLanguages?: SCLanguage[];
/**
* Keywords of the creative work
*
* @aggregatable
* @keyword
*/
keywords?: string[];
/**
* Translated fields of the creative work
*/
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
}
/**
* A creative work
*/
export interface SCCreativeWork
extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* Authors of the creative work
*/
authors?: SCPersonWithoutReferences[];
/**
* List of publishers of the creative work
*/
publishers?: Array<SCPersonWithoutReferences | SCOrganizationWithoutReferences>;
/**
* Translated fields of the creative work
*/
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
}
/**
* Translatable properties of creative works
*/
export interface SCCreativeWorkTranslatableProperties
extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/**
* 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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
authors: 'Authoren',
datePublished: 'Veröffentlichungsdatum',
inLanguages: 'verfügbare Übersetzungen',
keywords: 'Schlagwörter',
publishers: 'Verleger',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
authors: 'authors',
datePublished: 'release date',
inLanguages: 'available Languages',
keywords: 'keywords',
publishers: 'publishers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,121 @@
/*
* 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 {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: {
...SCThingMeta.getInstance<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: {
...SCThingMeta.getInstance<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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,176 @@
/*
* 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/>.
*/
// tslint:disable-next-line:no-implicit-dependencies
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
*/
addressCountry: string;
/**
* City of the address
*/
addressLocality: string;
/**
* State of the address
*/
addressRegion?: string;
/**
* Zip code of the address
*/
postalCode: string;
/**
* Optional post box number
*/
postOfficeBoxNumber?: string;
/**
* Street of the address - with house number!
*/
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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
address: 'Adresse',
geo: 'Geoinformation',
openingHours: 'Öffnungszeiten',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
address: 'address',
geo: 'geographic information',
openingHours: 'opening hours',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<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;
}

View 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 {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThingWithoutReferences
extends SCThingWithoutReferences {
// noop
}
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThing<T extends SCThingWithoutReferences>
extends SCSaveableThingWithoutReferences, SCThing {
/**
* The contained data
*/
data: T;
/**
* Type of the origin
*/
origin: SCThingUserOrigin;
}

View File

@@ -0,0 +1,57 @@
/*
* 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 {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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
inPlace: 'Ort',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
inPlace: 'location',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,80 @@
/*
* 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 {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
*/
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: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
paymentsAccepted: 'Bezahlmethoden',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
paymentsAccepted: 'accepted payment methods',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
paymentsAccepted: {
'cafeteria card': 'Mensakarte',
'cash': 'Bar',
'credit': 'Kreditkarte',
},
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
}

View File

@@ -0,0 +1,204 @@
/*
* 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 {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCInPlace} from './place';
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 becomes unavailable as an SCISO8601Date formatted string.
*/
availabilityEnds?: SCISO8601Date;
/**
* The time when the thing becomes available as an SCISO8601Date formatted string.
*/
availabilityStarts?: SCISO8601Date;
/**
* 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>> {
/**
* Instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance().fieldTranslations.de,
offers: 'Angebote',
},
en: {
...SCThingMeta.getInstance().fieldTranslations.en,
offers: 'offers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T extends SCPriceGroup>(): SCThingThatCanBeOfferedMeta<T> {
if (!SCThingThatCanBeOfferedMeta._instance.has(this.name)) {
SCThingThatCanBeOfferedMeta._instance.set(this.name, new SCThingThatCanBeOfferedMeta<T>());
}
return SCThingThatCanBeOfferedMeta._instance
.get(this.name) as SCThingThatCanBeOfferedMeta<T>;
}
protected constructor() {
}
}

View File

@@ -0,0 +1,168 @@
/*
* 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 {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
*/
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
*/
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
*
* @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>
implements SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
/**
* Instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
categories: 'Kategorien',
categorySpecificValues: 'besondere Kategorien',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
categories: 'categories',
categorySpecificValues: 'category with specific values',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance (including generics)
*/
public static getInstance<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> {
if (!SCThingWithCategoriesWithoutReferencesMeta._instance.has(this.name)) {
SCThingWithCategoriesWithoutReferencesMeta._instance
.set(this.name, new SCThingWithCategoriesWithoutReferencesMeta<T, U>());
}
return SCThingWithCategoriesWithoutReferencesMeta._instance
.get(this.name) as SCThingWithCategoriesWithoutReferencesMeta<T, U>;
}
protected constructor() {
}
}

View File

@@ -0,0 +1,306 @@
/*
* 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 {SCMetaTranslations, SCTranslations} from '../../general/i18n';
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 {
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',
Organization = 'organization',
Person = 'person',
PointOfInterest = 'point of interest',
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
*
* @keyword
*/
alternateNames?: string[];
/**
* Description of the thing
*
* @minLength 1
* @text
*/
description?: string;
/**
* URL of an image of the thing
*
* @keyword
*/
image?: string;
/**
* Name of the thing
*
* @minLength 1
* @sortable ducet
* @text
*/
name: 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
* @aggregatable
*/
type: SCThingType;
/**
* Universally unique identifier of the thing
*/
uid: SCUuid;
/**
* URL of the thing
*/
url?: string;
}
/**
* 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
*
* @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> {
/**
* Set type definiton for singleton instance
*/
protected static _instance = new Map<string, unknown>();
/**
* Translations of fields
*/
fieldTranslations = {
de: {
alternateNames: 'alternative Namen',
description: 'Beschreibung',
image: 'Bild',
name: 'Name',
origin: 'Ursprung',
translations: 'Übersetzungen',
type: 'Typ',
uid: 'Identifikation',
url: 'URL',
},
en: {
alternateNames: 'alternate names',
description: 'description',
image: 'image',
name: 'name',
origin: 'origin',
translations: 'translations',
type: 'type',
uid: 'identification',
url: 'URL',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
type: 'Ding',
},
en: {
type: 'Thing',
},
};
// tslint:disable:static-this
/**
* Function to retrieve typed singleton instance
*/
public static getInstance<T extends SCThingMeta>(): T {
if (!SCThingMeta._instance.has(this.name)) {
SCThingMeta._instance.set(this.name, new this());
}
return SCThingMeta._instance.get(this.name) as T;
}
protected constructor() {
}
}