• Public
  • Public/Protected
  • All

A Datatype is a handler for data in the domain that is 'indirected'. This means that its validation and storage is separate to the internal graph representation that is used for all other Subject properties.

A plain indirected data type is primarily used as an optimisation, to improve the cost of internal data indexing. However, a Shared data type adds the capability to present specialist mutable data with its own algorithms for reconciling concurrent mutations.

Type parameters

  • Data

    data type




Readonly @id

@id: string

The identity of the datatype itself. Used in the internal representation, which is visible to query filters; but a canonical json-rql Value is substituted in retrieval and updates.


Optional fromJSON

  • fromJSON(json: any): Data
  • Deserialises data. If this method is not provided, the data must be directly deserialisable from JSON.




    • json: any

    Returns Data


  • getDataId(data: Data): string
  • Obtains a (preferably short) identity for the given data, which is consistent with equality between data objects. The identity value is only visible to query filters; the data is {@link #toValue indirected} in retrieval and updates.


    • data: Data

    Returns string

Optional toJSON

  • toJSON(data: Data): any
  • Convert data to a representation that can be stringified to JSON. If this method is not provided, the data itself must be JSON serialisable. The implementation should include a version if the format is likely to change.




    • data: Data

    Returns any

Optional toValue

  • toValue(data: Data): Value
  • Provides a value to appear when the data is retrieved. The datatype should always accept the returned value forms in its validate method. If the value's type should be anything other than this datatype's @id, a ValueObject should be returned including the desired @type, even if it's a built-in type like xs:string. The value object will be compacted as normal in the application API.

    If the returned value is an expanded ValueObject, its datatype MUST be a fully expanded IRI.

    If this method is not provided, the data itself MUST be a valid API value.


    • data: Data

    Returns Value


  • validate(value: Value): Data | undefined
  • Parses a value provided by the app. This may give the application some leeway in type strictness; but note that the value provided back to the app will always be that returned by {@link Datatype#toValue}, if provided, or the Data itself if not.

    If the provided value is an expanded ValueObject, its datatype will be a fully pre-expanded IRI.


    TypeError if a validation message is indicated


    Returns Data | undefined

    the valid data, or undefined if the data is not valid


  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method
  • Protected method

Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.10.0 Source code licensed MIT. Privacy policy