SEMICeu / LinkedDataEventStreams

The Linked Data Event Streams specification
https://tree.linkeddatafragments.org/linked-data-event-streams/
23 stars 9 forks source link

Default JSON-LD context #48

Open pietercolpaert opened 7 months ago

pietercolpaert commented 7 months ago

JSON-LD can lower the barrier for adoption of Linked Data when given clear rules on how to implement the JSON frame. @phochste proposed to have, in this repository, also a standard JSON-LD context that can be use for a default frame

pietercolpaert commented 7 months ago

I created a first proposal of a JSON-LD context and what a JSON document would look like then:

The context

{
  "@context": {
      "tree": "https://w3id.org/tree#",
      "ldes": "https://w3id.org/ldes#",
      "shape": { "@type":"@id", "@id":"tree:shape"},
      "xsd": "http://www.w3.org/2001/XMLSchema#",
      "EventStream": "ldes:EventStream",
      "node": {"@type": "@id", "@id": "tree:node"},
      "members": {"@type": "@id", "@id": "tree:member"},
      "relations": {"@id": "tree:relation"},
      "view": {"@id": "tree:view"},
      "path": {"@container": "@list", "@id": "tree:path", "@type": "@id"},
      "value": {"@id":"tree:value"},
      "timestampPath": {"@id":"ldes:timestampPath", "@type":"@id", "@container":"@list"},
      "versionOfPath": {"@id":"ldes:versionOfPath", "@type":"@id", "@container":"@list"},
      "retention": {"@id":"ldes:retentionPolicy"},
      "amount": {"@id":"ldes:amount","@type":"xsd:integer"}
    }
}

An implementation

{
  "@context": [
    {
      "@base": "https://example.org/",
      "ex": "https://example.org/",
      "as": "https://www.w3.org/ns/activitystreams#"
    },
    "https://w3id.org/ldes/context.jsonld"
  ],
  "@id": "ex:MyEventStream",
  "@type": "EventStream",
  "shape": "ex:shaclShape",
  "timestampPath": "as:published",
  "members": [
    {
      "@id": "ex:Activity1",
      "@type": "as:Create",
      "as:published": "2023-11-30",
      "as:object": "ex:S",
      "@graph": {
        "@id": "ex:S",
        "ex:P": "O"
      }
    },
    {
      "@id": "ex:Activity2",
      "@type": "as:Update",
      "as:published": "2023-11-30",
      "as:object": "ex:S",
      "@graph": {
        "@id": "ex:S",
        "ex:P": "O2"
      }
    }
  ],
  "view": {
    "@id": "",
    "@comment": "↑ this must be a URI to the current page (which is satisfied here through it being relative)",
    "retention": {
      "@type":"ldes:LatestVersionSubset",
      "amount": "2",
      "versionOfPath": "as:object"
    },
    "relations": [
        {
          "@type" : "tree:GreaterThanRelation",
          "value": {
            "@value": "2023-11-30",
            "@type": "xsd:date"
          },
          "path": "as:published",
          "node": "/Node2"
        },
        {
          "@type" : "tree:LessThanRelation",
          "value": {
            "@value": "2023-12-30",
            "@type": "xsd:date"
          },
          "path": "as:published",
          "node": "/Node2"
        }
    ]
  }
}