From 13a49650c4498f6edbe17c9de3598e0180b866da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovan=20Kruni=C4=87?= Date: Tue, 18 Dec 2018 22:34:29 +0100 Subject: [PATCH] feat: add different origin types: remote and user Related to #12 --- src/core/Thing.ts | 54 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/src/core/Thing.ts b/src/core/Thing.ts index 9680a16f..56353b8e 100644 --- a/src/core/Thing.ts +++ b/src/core/Thing.ts @@ -75,7 +75,7 @@ export interface SCThing { /** * Origin of the thing */ - origin: SCThingOrigin; + origin: SCThingRemoteOrigin | SCThingUserOrigin; /** * Translations of specific values of the object * @@ -96,15 +96,12 @@ export interface SCThing { url?: string; } +export type SCThingOriginType = 'remote' | 'user'; + /** * Origin of a thing */ export interface SCThingOrigin { - /** - * When the thing was indexed last from the origin - */ - indexed: SCISO8601Date; - /** * Maintainer of the origin * @@ -117,6 +114,21 @@ export interface SCThingOrigin { */ 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 */ @@ -134,12 +146,42 @@ export interface SCThingOrigin { */ responsibleEntity?: SCPerson | SCOrganization; + /** + * Type of the origin + */ + type: '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: 'user'; + + /** + * When the saved thing was last updated with the latest state (e.g. from the backend) + */ + updated?: SCISO8601Date; +} + /** * Meta information about things */