feat: add core

This commit is contained in:
Karl-Philipp Wulfert
2018-11-29 16:22:57 +01:00
commit 2d770dde44
131 changed files with 41268 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 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} from '../Thing';
import {SCISO8601Date} from '../types/Time';
/**
* An academic term without references
*/
export interface SCAcademicTermWithoutReferences extends SCThing {
/**
* Short name of the academic term, using the given pattern
*/
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;
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2018 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, SCThingTranslatableProperties} from '../Thing';
import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCLanguage, SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedTranslatableProperties,
} from './ThingThatCanBeOffered';
/**
* A creative work without references
*/
export interface SCCreativeWorkWithoutReferences extends SCThing {
/**
* 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
*/
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
*/
keywords?: string[];
}

70
src/core/base/Event.ts Normal file
View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2018 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} from '../Thing';
import {SCCatalogWithoutReferences} from '../things/Catalog';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCAcademicTermWithoutReferences} from './AcademicTerm';
import {SCCreativeWorkWithoutReferences} from './CreativeWork';
/**
* An event without references
*/
export interface SCEventWithoutReferences extends SCThing {
/**
* Maximum number of participants of the event
*
* A maximum number of people that can participate in the event.
*/
maximumParticipants?: number;
/**
* Remaining attendee capacity of the event
*
* This number represents the remaining open spots.
*/
remainingAttendeeCapacity?: number;
}
/**
* An event
*/
export interface SCEvent extends SCEventWithoutReferences {
/**
* Academic terms that an event belongs to, e.g. semester(s).
*/
academicTerms?: SCAcademicTermWithoutReferences[];
/**
* 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[];
}

44
src/core/base/Place.ts Normal file
View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2018 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Point, Polygon} from 'geojson';
import {SCThing} from '../Thing';
import {SCPostalAddress} from '../types/PostalAddress';
/**
* A place without references
*/
export interface SCPlaceWithoutReferences extends SCThing {
/**
* Address of the place
*/
address?: SCPostalAddress;
/**
* Position/shape of the place
*
* !!! BEWARE !!!
* Can not be a GeometryCollection because ElasticSearch does not allow distance filtering/sorting on other types
*/
geo: {
point: Point,
polygon?: Polygon,
};
/**
* Opening hours of the place
* @see http://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
*/
openingHours?: string;
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2018 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} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
/**
* A thing that is or happens in a place
*/
export interface SCThingInPlace extends SCThing {
/**
* Place the thing is or happens in
*/
inPlace?:
SCBuildingWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2018 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} from '../Thing';
/**
* Types of payment that are accepted at a place.
*/
export type SCThingThatAcceptsPaymentsAcceptedPayments =
'Cash'
| 'Credit'
| 'Cafeteria Card';
/**
* A place without references that accepts payments
*/
export interface SCThingThatAcceptsPaymentsWithoutReferences extends SCThing {
/**
* Accepted payments of the place
*/
paymentsAccepted?: SCThingThatAcceptsPaymentsAcceptedPayments[];
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2018 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, SCThingTranslatableProperties} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
import {SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time';
/**
* A map from group name to price
*/
export interface SCPriceGroup {
[s: string]: number | undefined;
}
/**
* Price distinctions for academic context
*/
export interface SCAcademicPriceGroup extends SCPriceGroup {
/**
* Price for employees
*/
employee?: number;
/**
* Price for guests
*/
guest?: number;
/**
* Price for students
*/
student?: number;
}
/**
* A thing without references that has a price tag
*/
export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing {
/**
* 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> {
/**
* Availability of an offer
*/
availability: SCThingThatCanBeOfferedAvailabilty;
/**
* 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;
/**
* Default price of the thing
*/
price: number;
/**
* 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
*/
'offers[].availability'?: string;
}
/**
* Possible things a provider can be
*/
export type SCThingThatCanBeOfferedProvider =
SCBuildingWithoutReferences
| SCOrganizationWithoutReferences
| SCPersonWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
/**
* Availability of an Offer
*/
export type SCThingThatCanBeOfferedAvailabilty =
'in stock'
| 'out of stock'
| 'online only'
| 'limited availabilty';

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2018 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, SCThingTranslatableProperties} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* A thing without references with categories
*
* !!! BEWARE !!!
* `T` should be a union type - e.g. `T = 'foo' | 'bar' | 'foobar';`
*/
export interface SCThingWithCategoriesWithoutReferences<T,
U extends SCThingWithCategoriesSpecificValues>
extends SCThing {
/**
* Categories of a thing with categories
*/
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.
*
* !!! BEWARE !!!
* TypeScript does not allow generics as index signatures. The properties of the map should exist in `T`.
*/
categorySpecificValues?: {
[s: string]: 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
*/
alternateNames?: string[];
/**
* Category specific description of a thing
*/
description?: string;
/**
* Category specific image of a thing
*/
image?: string;
/**
* Category specific name of a thing
*/
name?: string;
/**
* Category specific URL of a thing
*/
url?: string;
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2018 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, SCThingTranslatableProperties} from '../Thing';
import {SCTranslations} from '../types/i18n';
/**
* A thing that has translations
*/
export interface SCThingWithTranslations extends SCThing {
translations: SCTranslations<SCThingTranslatableProperties>;
}