mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 08:02:55 +00:00
feat: add core
This commit is contained in:
46
src/core/base/AcademicTerm.ts
Normal file
46
src/core/base/AcademicTerm.ts
Normal 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;
|
||||
}
|
||||
80
src/core/base/CreativeWork.ts
Normal file
80
src/core/base/CreativeWork.ts
Normal 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
70
src/core/base/Event.ts
Normal 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
44
src/core/base/Place.ts
Normal 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;
|
||||
}
|
||||
31
src/core/base/ThingInPlace.ts
Normal file
31
src/core/base/ThingInPlace.ts
Normal 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;
|
||||
}
|
||||
33
src/core/base/ThingThatAcceptsPayments.ts
Normal file
33
src/core/base/ThingThatAcceptsPayments.ts
Normal 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[];
|
||||
}
|
||||
128
src/core/base/ThingThatCanBeOffered.ts
Normal file
128
src/core/base/ThingThatCanBeOffered.ts
Normal 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';
|
||||
90
src/core/base/ThingWithCategories.ts
Normal file
90
src/core/base/ThingWithCategories.ts
Normal 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;
|
||||
}
|
||||
23
src/core/base/ThingWithTranslations.ts
Normal file
23
src/core/base/ThingWithTranslations.ts
Normal 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>;
|
||||
}
|
||||
Reference in New Issue
Block a user