Skip to content
Snippets Groups Projects
Select Git revision
  • c7f4c072e5a3bcc3a595d8af0a167056c79a5d9c
  • main default
2 results

main_link.c

Blame
  • ContextDefinitions.ts 2.38 KiB
    import ComponentInformation from "../entity/ComponentInformation";
    
    const component = {
        "id": { "@id": "https://schema.org/url", "@type": "@id"},
        "dateCreated": "https://schema.org/dateCreated",
        "license": "http://www.w3.org/1999/xhtml/vocab#license"
    };
    
    const componentRelation = {
        "id": { "@id": "https://schema.org/url", "@type": "@id"},
        "from": "https://schema.org/DateTime",
        "to": "https://schema.org/DateTime",
        "license": "http://www.w3.org/1999/xhtml/vocab#license"
    };
    
    const information = function(metadataContext: unknown, previousVersion: ComponentInformation | undefined, nextVersion: ComponentInformation | undefined): Record<string, unknown> {
        const result: Record<string, unknown> = {
            "id": { "@id": "https://schema.org/url", "@type": "@id"},
            "component": { "@id": "https://schema.org/url", "@type": "@id"},
            "dateCreated": "https://schema.org/dateCreated",
            "name": "https://schema.org/name",
            "comment": "http://schema.org/comment",
            "informationLicense": "http://www.w3.org/1999/xhtml/vocab#license",
            "measurementLicense": "http://www.w3.org/1999/xhtml/vocab#license",
            "topic": "https://schema.org/text",
            "metadata": metadataContext
        };
    
        if(previousVersion) {
            result.previousVersion = { "@id": "https://schema.org/url", "@type": "@id"};
        }
    
        if(nextVersion) {
            result.nextVersion = { "@id": "https://schema.org/url", "@type": "@id"};
        }
    
        return result;
    };
    
    const measurement = function(valueContext: unknown, metadataContext: unknown | undefined): Record<string, unknown> {
        const result: Record<string, unknown> = {
            "id": { "@id": "https://schema.org/url", "@type": "@id"},
            "dateCreated": "https://schema.org/dateCreated",
            "license": "http://www.w3.org/1999/xhtml/vocab#license",
            "value": valueContext
        };
    
        if(metadataContext) {
            result.metadata = metadataContext;
        }
    
        return result;
    };
    
    const typeDefinition = {
        "name": { "@id": "https://schema.org/url", "@type": "@id"},
        "dateCreated": "https://schema.org/dateCreated",
        "comment": "http://schema.org/comment",
        "schema": "https://json-schema.org/draft/2020-12/json-schema-core.html",
        "license": "http://www.w3.org/1999/xhtml/vocab#license",
    };
    
    export default {
        component, 
        componentRelation, 
        information, 
        measurement,
        typeDefinition
    };