Compare commits

..

28 Commits

Author SHA1 Message Date
Rainer Killinger
4036bfd193 0.48.0 2021-07-14 12:41:26 +02:00
Rainer Killinger
f4f372b9ad docs: adjust @validatable documentation 2021-07-14 11:16:56 +02:00
Rainer Killinger
872c1f5fc3 fix: correct parameter name of thing update route 2021-07-14 11:16:55 +02:00
Rainer Killinger
4f2ca30dab refactor: make resonse error types validatable 2021-07-14 11:16:55 +02:00
Wieland Schöbl
882483ee24 feat: support geo shape queries 2021-07-09 13:32:28 +00:00
openstappsbot
c998166938 refactor: update all 2021-06-23 13:11:10 +00:00
Rainer Killinger
d61e33de39 docs: update changelog 2021-06-15 10:48:03 +02:00
Rainer Killinger
07d6c4770a 0.47.0 2021-06-15 10:48:01 +02:00
openstappsbot
aab3e9fa6c refactor: update all 2021-06-15 10:46:58 +02:00
Rainer Killinger
4a4cd4e6d4 fix: set date-series frequency non translatable 2021-06-15 09:41:27 +02:00
Wieland Schöbl
942cd11469 feat: make SCDateSeries.frequency compliant with schema.org 2021-06-07 12:23:48 +02:00
Wieland Schöbl
fe090c7387 test: increase schema timeout 2021-05-12 18:03:09 +02:00
Wieland Schöbl
f0782d8820 test: add mapping test 2021-05-12 17:52:22 +02:00
Jovan Krunić
a2461d5904 docs: update changelog 2021-05-04 16:51:52 +02:00
Jovan Krunić
d2e0069dc2 0.46.0 2021-05-04 16:51:50 +02:00
Wieland Schöbl
9c6972af78 feat: change range offer to use date range
add date range type
change availability filter
2021-05-04 16:48:10 +02:00
Rainer Killinger
56b03aa0b9 docs: update changelog 2021-04-26 10:29:36 +02:00
Rainer Killinger
b517837671 0.45.0 2021-04-26 10:29:34 +02:00
Rainer Killinger
6f03ede8bf refactor: make SCCatalog level filterable 2021-04-13 16:11:44 +02:00
wulkanat@gmail.com
952207ace1 docs: update changelog 2021-04-12 15:06:12 +02:00
wulkanat@gmail.com
3d9d28c60c 0.44.0 2021-04-12 15:06:04 +02:00
Wieland Schöbl
913c5691da feat: add support for multiple values in the value filter 2021-04-08 08:06:38 +00:00
Rainer Killinger
03cdbc6f9b docs: update changelog 2021-04-07 13:34:33 +02:00
Rainer Killinger
9f886a8968 0.43.0 2021-04-07 13:34:29 +02:00
openstappsbot
e80afe2c93 refactor: update all 2021-04-06 16:12:49 +00:00
Rainer Killinger
6b10cc86d8 refactor: update @types/node for node version 14 2021-04-06 14:08:42 +02:00
openstappsbot
1aedd6332f refactor: update all 2021-03-29 04:15:38 +00:00
Rainer Killinger
790c8bbc3f docs: update changelog 2021-02-16 14:04:46 +01:00
34 changed files with 858 additions and 711 deletions

View File

@@ -47,6 +47,16 @@ test:
- report
- coverage
mapping:
dependencies:
- build
stage: test
services:
- name: registry.gitlab.com/openstapps/database:master
alias: elasticsearch
script:
- node ./node_modules/@openstapps/core-tools/lib/cli.js put-es-templates ./src http://elasticsearch:9200/ "pattern,see,minlength,tjs-format"
package:
dependencies:
- build

View File

@@ -1,3 +1,47 @@
# [0.47.0](https://gitlab.com/openstapps/core/compare/v0.46.0...v0.47.0) (2021-06-15)
### Bug Fixes
* set date-series frequency non translatable ([4a4cd4e](https://gitlab.com/openstapps/core/commit/4a4cd4e6d4b01ac34b5338dfcf4aeb959f54461d))
### Features
* make SCDateSeries.frequency compliant with schema.org ([942cd11](https://gitlab.com/openstapps/core/commit/942cd1146966aa9e60321160489a6605877925e9))
# [0.46.0](https://gitlab.com/openstapps/core/compare/v0.45.0...v0.46.0) (2021-05-04)
### Features
* change range offer to use date range ([9c6972a](https://gitlab.com/openstapps/core/commit/9c6972af787678567409877b6bc9f9417e1374e2))
# [0.45.0](https://gitlab.com/openstapps/core/compare/v0.44.0...v0.45.0) (2021-04-26)
# [0.44.0](https://gitlab.com/openstapps/core/compare/v0.43.0...v0.44.0) (2021-04-12)
### Features
* add support for multiple values in the value filter ([913c569](https://gitlab.com/openstapps/core/commit/913c5691da46ad2591fe14bcf7286f12b29ab5ee))
# [0.43.0](https://gitlab.com/openstapps/core/compare/v0.42.0...v0.43.0) (2021-04-07)
# [0.42.0](https://gitlab.com/openstapps/core/compare/v0.41.0...v0.42.0) (2021-02-16)
# [0.41.0](https://gitlab.com/openstapps/core/compare/v0.40.0...v0.41.0) (2021-02-08)

View File

@@ -45,7 +45,7 @@ External dependencies can not be covered by the annotations. Documentation about
| `@sortable` | field is sortable if the core schema is used to put data into a database/key-value store. Fields are always sortable through generic sort, even without annotation. | sort method to be used: `ducet`, `price`, `distance` |
| `@text` | string field is interpreted as text | |
| `@date` | string field is interpreted as a date field | |
| `@validatable` | marks the type as validatable if the core schema is used to put data into a database/key-value store | |
| `@validatable` | Marks the type for json schema generation, which can be checked at runtime. Any top-level type that is put into a database should always be marked as validatable. | |
| `@filterable` | non-object/nested field is filterable if the core schema is used to put data into a database/key-value store | |
| `@inheritTags` | inherit all tags from another field | `[SCThingType]::[field]` |

1256
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/core",
"version": "0.42.0",
"version": "0.48.0",
"description": "StAppsCore - Generalized model of data",
"keywords": [
"Model",
@@ -43,28 +43,28 @@
"Wieland Schöbl"
],
"dependencies": {
"@openstapps/core-tools": "0.17.0",
"@openstapps/core-tools": "0.21.0",
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/json-schema": "7.0.7",
"@types/node": "10.17.44",
"@types/node": "14.17.4",
"fast-clone": "1.5.13",
"fast-deep-equal": "3.1.3",
"http-status-codes": "2.1.4",
"json-patch": "0.7.0",
"json-schema": "0.2.5",
"json-schema": "0.3.0",
"ts-optchain": "0.1.8"
},
"devDependencies": {
"@openstapps/configuration": "0.25.0",
"@openstapps/logger": "0.5.0",
"@openstapps/configuration": "0.27.0",
"@openstapps/logger": "0.7.0",
"@testdeck/mocha": "0.1.2",
"@types/chai": "4.2.15",
"@types/chai": "4.2.19",
"@types/rimraf": "3.0.0",
"chai": "4.3.0",
"chai": "4.3.4",
"conditional-type-checks": "1.0.5",
"conventional-changelog-cli": "2.1.1",
"mocha": "8.3.0",
"mocha": "8.4.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"source-map-support": "0.5.19",

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned, when an internal server error occurred
*
* @validatable
*/
export class SCInternalServerErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned, when the used HTTP method is not allowed on the requested route
*
* @validatable
*/
export class SCMethodNotAllowedErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned when the requested route or resource was not found
*
* @validatable
*/
export class SCNotFoundErrorResponse extends SCError {
/**

View File

@@ -18,6 +18,8 @@ import {SCError} from '../error';
/**
* An error that is returned when the request is in the right format, but contains parameters that are invalid or not
* acceptable.
*
* @validatable
*/
export class SCParametersNotAcceptable extends SCError {
/**

View File

@@ -20,6 +20,8 @@ import {SCPluginMetaData} from '../routes/plugin-register';
* An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin
* running at the same time.
* This usually indicates that there is more than one instance a plugin running.
*
* @validatable
*/
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned whenever there is an unexpected error while creating a plugin
*
* @validatable
*/
export class SCPluginRegisteringFailedErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned, when the request body is too large.
*
* @validatable
*/
export class SCRequestBodyTooLargeErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned whenever there is a syntax error
*
* @validatable
*/
export class SCSyntaxErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned, when to many request are submitted at once
*
* @validatable
*/
export class SCTooManyRequestsErrorResponse extends SCError {
/**

View File

@@ -17,6 +17,8 @@ import {SCError} from '../error';
/**
* An error that is returned when the content type of the request is not supported
*
* @validatable
*/
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**

View File

@@ -18,6 +18,8 @@ import {SCError} from '../error';
/**
* An error that is returned when the validation of a request fails
*
* @validatable
*/
export class SCValidationErrorResponse extends SCError {
/**

View File

@@ -55,7 +55,7 @@ export class SCThingUpdateRoute extends SCAbstractRoute {
];
this.method = SCRouteHttpVerbs.PUT;
this.obligatoryParameters = {
TYPE: 'SCThingTypes',
TYPE: 'SCThingType',
UID: 'SCUuid',
};
this.requestBodyName = 'SCThingUpdateRequest';

View File

@@ -19,6 +19,7 @@ import {SCMap} from '../../general/map';
import {SCSearchAvailabilityFilter} from './filters/availability';
import {SCSearchBooleanFilter} from './filters/boolean';
import {SCSearchDistanceFilter} from './filters/distance';
import {SCGeoFilter} from './filters/geo';
import {SCSearchDateRangeFilter, SCSearchNumericRangeFilter} from './filters/range';
import {SCSearchValueFilter} from './filters/value';
@@ -31,7 +32,8 @@ export type SCSearchFilterType =
| 'distance'
| 'value'
| 'date range'
| 'numeric range';
| 'numeric range'
| 'geo';
/**
* Structure of a filter instruction
@@ -62,4 +64,5 @@ export type SCSearchFilter =
| SCSearchDistanceFilter
| SCSearchValueFilter
| SCSearchNumericRangeFilter
| SCSearchDateRangeFilter;
| SCSearchDateRangeFilter
| SCGeoFilter;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -33,17 +33,17 @@ export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAva
*/
export interface SCAvailabilityFilterArguments extends SCSearchAbstractFilterArguments {
/**
* Field which marks the start of the availability
* Field which marks availability range
*/
fromField: SCThingsField;
field: SCThingsField;
/**
* Time to check. Defaults to 'now'
* If set, the provided time will apply to the full hour, day, week, etc.
*/
time?: SCISO8601Date | 'now';
scope?: 's' | 'm' | 'H' | 'd' | 'w' | 'M' | 'y';
/**
* Field which marks the end of the availability
* Time to check. Defaults current time if not set
*/
toField: SCThingsField;
time?: SCISO8601Date;
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2021 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 {Polygon} from 'geojson';
import {SCThingsField} from '../../../meta';
import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter';
/**
* A geo filter
*
* Filter for documents that are in relation to some geo data
*/
export interface SCGeoFilter extends SCSearchAbstractFilter<SCGeoFilterArguments> {
/**
* @see SCSearchAbstractFilter.type
*/
type: 'geo';
}
/**
* Arguments for filter instruction by geo data
*/
export interface SCGeoFilterArguments extends SCSearchAbstractFilterArguments {
/**
* Field on which to filter
*/
field: SCThingsField;
/**
* Geo data to check up on
*/
shape: Polygon;
/**
* Spatial relation between the provided shape and the shape of the field.
*
* intersects - both shapes intersect (default)
* disjoint - both shapes don't intersect
* within - the search shape contains the field shape
* contains - the search shape is contained in the field shape
*/
spatialRelation?: 'intersects' | 'disjoint' | 'within' | 'contains';
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 StApps
* Copyright (C) 2020-2021 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.
@@ -85,6 +85,15 @@ export interface SCRangeFilterArguments<T> extends SCSearchAbstractFilterArgumen
* Field where the filter will be applied
*/
field: SCThingsField;
/**
* Relation when searching on other range fields
*
* Intersects (Default): Both search and field range intersect
* Within: Search range is within the field range
* Contains: Search range contains the field range
*/
relation?: 'intersects' | 'within' | 'contains';
}
export interface Bounds<T> {

View File

@@ -32,7 +32,7 @@ export interface SCValueFilterArguments extends SCSearchAbstractFilterArguments
field: SCThingsField;
/**
* Value to filter. Value has to match the field exactly.
* Value to filter. One or more values has to match the field exactly.
*/
value: string;
value: string | string[];
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2021 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 {SCISO8601Date} from '../../general/time';
/**
* Date Range
*
* CAUTION: Changing the name requires changes in the core-tools premaps
*/
export type SCISO8601DateRange = SCRange<SCISO8601Date>;
/**
* Generic range type
*/
export type SCRange<T> = {
/**
* Greater than value
*/
gt?: never;
/**
* Greater or equal to value
*/
gte?: T;
/**
* Greater than value
*/
lt?: never;
/**
* Greater or equal to value
*/
lte?: T;
} | {
// tslint:disable:completed-docs
gt?: T;
gte?: never;
lt?: T;
lte?: never;
} | {
gt?: T;
gte?: never;
lt?: never;
lte?: T;
} | {
gt?: never;
gte?: T;
lt?: T;
lte?: never;
// tslint:enable:completed-docs
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -13,10 +13,10 @@
* 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 {SCISO8601DateRange} from './range';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/**
@@ -100,14 +100,9 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup>
availability: SCThingThatCanBeOfferedAvailability;
/**
* The time when the thing becomes unavailable as an SCISO8601Date formatted string.
* The time when the thing is available.
*/
availabilityEnds?: SCISO8601Date;
/**
* The time when the thing becomes available as an SCISO8601Date formatted string.
*/
availabilityStarts?: SCISO8601Date;
availabilityRange?: SCISO8601DateRange;
/**
* List of prices that are distinct for specific groups

View File

@@ -33,6 +33,7 @@ export interface SCCatalogWithoutReferences
*
* Needed for keeping order in catalog inheritance array.
*
* @filterable
* @integer
*/
level: number;

View File

@@ -65,9 +65,9 @@ export interface SCDateSeriesWithoutReferences
/**
* Frequency of the date series
*
* @keyword
* @filterable
*/
frequency: string;
repeatFrequency?: SCISO8601Duration;
/**
* Translated properties
@@ -131,7 +131,7 @@ export class SCDateSeriesMeta
duration: 'Dauer',
event: 'Event',
exceptions: 'Ausnahmen',
frequency: 'Frequenz',
repeatFrequency: 'Frequenz',
performers: 'Vortragende',
},
en: {
@@ -143,7 +143,7 @@ export class SCDateSeriesMeta
duration: 'duration',
event: 'event',
exceptions: 'exceptions',
frequency: 'frequency',
repeatFrequency: 'frequency',
performers: 'performers',
},
};
@@ -174,8 +174,4 @@ export class SCDateSeriesMeta
*/
export interface SCDateSeriesTranslatableProperties
extends SCThingThatCanBeOfferedTranslatableProperties {
/**
* @see SCDateSeriesWithoutReferences.frequency
*/
frequency?: string;
}

View File

@@ -22,7 +22,7 @@
}
}
},
"frequency": "once",
"repeatFrequency": "P1W",
"dates": [
"2016-04-15T17:00:00+00:00"
],

View File

@@ -23,7 +23,6 @@
"name": "EMH 225",
"floorName": "2"
},
"frequency": "once",
"dates": [
"2016-04-12T11:00:00+00:00"
],

View File

@@ -23,7 +23,6 @@
"name": "EMH 225",
"floorName": "2"
},
"frequency": "once",
"dates": [
"2016-04-12T11:00:00+00:00"
],
@@ -43,8 +42,10 @@
"offers": [
{
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"prices": {
"default": 6.5,
"student": 5,

View File

@@ -19,8 +19,10 @@
"offers": [
{
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"prices": {
"default": 4.85,
"student": 2.85,

View File

@@ -20,8 +20,10 @@
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"inPlace": {
"geo": {
"point": {

View File

@@ -11,9 +11,11 @@
],
"offers": [
{
"availabilityEnds": "2017-03-27T23:59:59.000Z",
"availabilityStarts": "2017-03-27T00:00:00.000Z",
"availability": "in stock",
"availabilityRange": {
"gte": "2017-03-27T00:00:00.000Z",
"lte": "2017-03-27T23:59:59.000Z"
},
"inPlace": {
"type": "room",
"name": "Cafeteria LEVEL",

View File

@@ -22,8 +22,8 @@
},
{
"arguments": {
"fromField": "availabilityStarts",
"toField": "availabilityEnds",
"scope": "d",
"field": "availabilityRange",
"time": "2018-01-15T04:13:00+00:00"
},
"type": "availability"

View File

@@ -102,7 +102,7 @@ function getExtendedTypes(thingReflection: DeclarationReflection,
return extendedTypes;
}
@suite(timeout(10000), slow(5000))
@suite(timeout(15000), slow(10000))
export class SchemaSpec {
static objects: { [name: string]: DeclarationReflection } = {};
static reflection: ProjectReflection;