Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DsUtilitiesV5

DsUtilitiesV5 is a Class that offers an API for DS-Specification 5.0

Instances of this class can be created with following static functions of this library:

Below you can find the API functions provided by this class (categorized by functionality).

example
// following DsUtilitiesV5 instance is used in the code examples below
const myDsUtilitiesV5 = DsUtil.getDsUtilitiesForDsSpecVersion("5.0");

Hierarchy

  • DsUtilitiesBase
    • DsUtilitiesV5

Index

General

extractSdoVersionNumber: (schemaVersionValue: string) => string = extractSdoVersionNumber

Type declaration

    • (schemaVersionValue: string): string
    • Extracts the schema.org version number (as string) from the given schema.org version URL.

      This function accepts URLs with following formats (any protocol variant is allowed - http/https):

      • "https://schema.org/docs/releases.html#v10.0" -> "10.0"
      • "https://schema.org/version/3.4/" -> "3.4"
      example
      myDsUtilities.extractSdoVersionNumber("https://schema.org/version/12.0/");
      // "12.0"

      Parameters

      • schemaVersionValue: string

        a URL specifying a schema.org version

      Returns string

      The version number as a string

getDsSpecificationVersion: (ds: DsGeneric) => string = getDsSpecificationVersion

Type declaration

    • (ds: DsGeneric): string
    • Identifies the used DS-Specification version used by the given Domain Specification.

      example
      const usedVersion = myDsUtilities.getDsSpecificationVersion(exampleDs);
      // "7.0" (assuming the given DS 'exampleDs' uses DsV7)

      Parameters

      • ds: DsGeneric

        The input Domain Specification

      Returns string

      The detected DS-Specification version

getDsUtilitiesVersion: () => "5.0" = getDsUtilitiesVersion

Type declaration

    • (): "5.0"
    • Returns the used DS-Specification version of this DS-Utilities instance, which is "5.0".

      DS-Utilities instances are always bound to a specific DS-Specification version.

      example
      const dsSpecificationVersion = myDsUtilitiesV5.getDsUtilitiesVersion();
      // "5.0"

      Returns "5.0"

UI-Interaction

getDsAuthorName: (ds: DsV5) => string | undefined = getDsAuthorName

Type declaration

    • (ds: DsV5): string | undefined
    • Returns the author name (schema:author -> schema:name) of the given DS.

      schema:author is optional in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string | undefined

      The author name of the given DS

getDsDescription: (ds: DsV5) => string | undefined = getDsDescription

Type declaration

    • (ds: DsV5): string | undefined
    • Returns the description (schema:description) of the given DS.

      schema:description is optional in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string | undefined

      the description of the given DS

getDsExternalVocabularies: (ds: DsV5) => string[] = getDsExternalVocabularies

Type declaration

    • (ds: DsV5): string[]
    • Returns the used external vocabularies (ds:usedVocabularies) of the given DS (clone - no reference).

      ds:usedVocabularies is optional in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string[]

      array with the used external vocabularies (empty if none)

getDsName: (ds: DsV5) => string | undefined = getDsName

Type declaration

    • (ds: DsV5): string | undefined
    • Returns the name (schema:name) of the given DS.

      schema:name is optional in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string | undefined

      The name of the given DS

getDsSchemaVersion: (ds: DsV5) => string = getDsSchemaVersion

Type declaration

    • (ds: DsV5): string
    • Returns the used schema.org version (schema:schemaVersion) of the given DS.

      schema:schemaVersion is mandatory in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string

      the schema.org version identifier as simple string, e.g. "11.0"

getDsTargetClasses: (ds: DsV5) => string[] = getDsTargetClasses

Type declaration

    • (ds: DsV5): string[]
    • Returns the target classes (sh:targetClass) of the given DS (clone - no reference).

      sh:targetClass is mandatory in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string[]

      array with the target classes (empty if none)

getDsVersion: (ds: DsV5) => number | undefined = getDsVersion

Type declaration

    • (ds: DsV5): number | undefined
    • Returns the used ds version (schema:version) of the given DS.

      schema:version is optional in DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns number | undefined

      the ds version as number, e.g. 1.04

prettyPrintCompactedIRIs: (compactedIRIs: string | string[]) => string = prettyPrintCompactedIRIs

Type declaration

    • (compactedIRIs: string | string[]): string
    • Returns the "pretty" version of a compacted IRI (single IRI or array of IRIs). If an IRI belongs to schema.org, then the IRI is returned without the schema: vocabulary indicator.

      example
      const targetClasses = [ "schema:Hotel", "ex:SkiLift" ];
      const prettifiedTargetClasses = myDsUtilities.prettyPrintCompactedIRIs(targetClasses);
      // "Hotel + ex:SkiLift"

      const property = "schema:description";
      const prettifiedProperty = myDsUtilities.prettyPrintCompactedIRIs(property);
      // "description"

      Parameters

      • compactedIRIs: string | string[]

        the input IRI or array of IRIs

      Returns string

      The pretty-string for the given input

DS-Structure

getDsDataTypeForSchemaDataType: (schemaDataType: DataTypeSchemaV5) => DataTypeDsV5 = getDsDataTypeForSchemaDataType

Type declaration

    • (schemaDataType: DataTypeSchemaV5): DataTypeDsV5
    • Returns the corresponding DS-V5 datatype (XSD/RDF) for a given schema.org datatype.

      Parameters

      • schemaDataType: DataTypeSchemaV5

        a compacted IRI representing a DataType of schema.org (e.g. schema:Text)

      Returns DataTypeDsV5

      the corresponding DS-V5 Datatype (from XSD or RDF)

getDsId: (ds: DsV5) => string = getDsId

Type declaration

    • (ds: DsV5): string
    • Returns the @id of the given DS (for DS-V5 this @id is found in outermost node). A DS @id is mandatory for DS-V5.

      Parameters

      • ds: DsV5

        the input DS

      Returns string

      The @id of the given DS

getDsRootNode: (ds: DsV5) => RootNodeV5 = getDsRootNode

Type declaration

    • (ds: DsV5): RootNodeV5
    • Returns a reference to the root node of the given Domain Specification

      Parameters

      • ds: DsV5

        The input Domain Specification

      Returns RootNodeV5

      The root node if the given DS

getDsStandardContext: () => ContextV5 = getDsStandardContext

Type declaration

    • (): ContextV5
    • Returns the standard @context for DS-V5 (clone - no reference).

      Returns ContextV5

      The standard @context for DS-V5

getSchemaDataTypeForDsDataType: (dsDataType: DataTypeDsV5) => DataTypeSchemaV5 = getSchemaDataTypeForDsDataType

Type declaration

    • (dsDataType: DataTypeDsV5): DataTypeSchemaV5
    • Returns the corresponding schema.org datatype for a given DS-V5 datatype (XSD/RDF)

      Parameters

      • dsDataType: DataTypeDsV5

        a compacted IRI representing a DataType of DS-V5 (from XSD or RDF, e.g. "xsd:string")

      Returns DataTypeSchemaV5

      the corresponding schema.org Datatype