feat: add certification thing

This commit is contained in:
Thea Schöbl
2023-05-15 13:38:11 +00:00
parent b21dc75964
commit fd63fb764f
68 changed files with 6776 additions and 24439 deletions

View File

@@ -29,8 +29,10 @@ import {SCFavorite, SCFavoriteWithoutReferences} from '../src/things/favorite';
import {SCFloor, SCFloorWithoutReferences} from '../src/things/floor';
import {SCMessage, SCMessageWithoutReferences} from '../src/things/message';
import {SCOrganization, SCOrganizationWithoutReferences} from '../src/things/organization';
import {SCPeriodical, SCPeriodicalWithoutReferences} from '../src/things/periodical';
import {SCPerson, SCPersonWithoutReferences} from '../src/things/person';
import {SCPointOfInterest, SCPointOfInterestWithoutReferences} from '../src/things/point-of-interest';
import {SCPublicationEvent, SCPublicationEventWithoutReferences} from '../src/things/publication-event';
import {SCRoom, SCRoomWithoutReferences} from '../src/things/room';
import {SCSemester, SCSemesterWithoutReferences} from '../src/things/semester';
import {SCSetting, SCSettingWithoutReferences} from '../src/things/setting';
@@ -40,8 +42,6 @@ import {SCTicket, SCTicketWithoutReferences} from '../src/things/ticket';
import {SCToDo, SCToDoWithoutReferences} from '../src/things/todo';
import {SCTour, SCTourWithoutReferences} from '../src/things/tour';
import {SCVideo, SCVideoWithoutReferences} from '../src/things/video';
import {SCPeriodical, SCPeriodicalWithoutReferences} from '../src/things/periodical';
import {SCPublicationEvent, SCPublicationEventWithoutReferences} from '../src/things/publication-event';
/**
* Check if E extends T
@@ -51,10 +51,13 @@ type Extends<E, T> = E extends T ? true : false;
/**
* Get type of array elements up to nesting level 3
*/
type ElementType<T> = T extends any[] ?
(T[0] extends any[] ?
(T[0][0] extends any[] ?
T[0][0][0] : T[0][0]) : T[0]) : T;
type ElementType<T> = T extends any[]
? T[0] extends any[]
? T[0][0] extends any[]
? T[0][0][0]
: T[0][0]
: T[0]
: T;
/**
* Get types of properties
@@ -62,15 +65,17 @@ type ElementType<T> = T extends any[] ?
* - Extracts only the properties which extend object and are not any.
* - If type is an array it returns the type of the elements.
*/
type PropertyTypes<T> = Extract<ElementType<T extends object ?
(IsAny<T[keyof T]> extends true ?
never : T[keyof T]) : never>
, object>;
type PropertyTypes<T> = Extract<
ElementType<T extends object ? (IsAny<T[keyof T]> extends true ? never : T[keyof T]) : never>,
object
>;
/**
* Get nested property types
*/
type PropertyTypesNested<T> = PropertyTypes<T> extends object ? PropertyTypes<PropertyTypes<T>> : PropertyTypes<T>;
type PropertyTypesNested<T> = PropertyTypes<T> extends object
? PropertyTypes<PropertyTypes<T>>
: PropertyTypes<T>;
/**
* Types of properties of SCDiff
@@ -108,13 +113,13 @@ assert<Extends<SCArticle, SCThing>>(true);
/**
* Types of properties of SCAssessment
*/
type SCAssessmentPropertyTypes = PropertyTypesNested<SCAssessment>;
assert<NotHas<SCAssessmentPropertyTypes, SCThingWithoutReferences>>(false);
assert<Has<SCAssessmentPropertyTypes, SCThingWithoutReferences>>(true);
assert<NotHas<SCAssessmentPropertyTypes, SCThing>>(true);
assert<Has<SCAssessmentPropertyTypes, SCThing>>(false);
assert<Extends<SCAssessmentWithoutReferences, SCThing>>(false);
assert<Extends<SCAssessment, SCThing>>(true);
type SCAssessmentPropertyTypes = PropertyTypesNested<SCAssessment>;
assert<NotHas<SCAssessmentPropertyTypes, SCThingWithoutReferences>>(false);
assert<Has<SCAssessmentPropertyTypes, SCThingWithoutReferences>>(true);
assert<NotHas<SCAssessmentPropertyTypes, SCThing>>(true);
assert<Has<SCAssessmentPropertyTypes, SCThing>>(false);
assert<Extends<SCAssessmentWithoutReferences, SCThing>>(false);
assert<Extends<SCAssessment, SCThing>>(true);
/**
* Types of properties of SCBook