CenterForDigitalHumanities / TinyNode

TinyThings in NodeJS
0 stars 1 forks source link

Improve `@id` handling #59

Closed cubap closed 4 months ago

cubap commented 5 months ago

In a lot of these cases moving forward, we'll have something like a Web Annotation, which uses the context https://www.w3.org/ns/anno.jsonld that includes id: {"@type":"@id", "@id":"@id"} so that the id property replaces @id legitimately. A helper processor for @id would be great. In fact, there may be space here for a Record or Document kind of class that includes all this stuff, but that's a future problem. We know at a minimum that if @context is present, then @type and @id may exist without the "@" annotation.

cubap commented 5 months ago

okay... jsonld library is helpful

jsonld expand "https://store.rerum.io/v1/id/618d9b9a50c86821e60b2cce"
Debugger listening on ws://127.0.0.1:64542/b09d3eba-e193-46bc-80f0-9ff96cba12a6
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
[
  {
    "@id": "https://store.rerum.io/v1/id/618d9b9a50c86821e60b2cce",
    "@type": [
      "http://schema.org/Text"
    ],
    "http://schema.org/__rerum": [
      {
        "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#APIversion": [
          {
            "@type": "http://www.w3.org/2001/XMLSchema#string",
            "@value": "1.0.0"
          }
        ],
        "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#alpha": [
          {
            "@type": "http://www.w3.org/2001/XMLSchema#boolean",
            "@value": true
          }
        ],
        "http://purl.org/dc/terms/created": [
          {
            "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
            "@value": "2021-11-11T16:39:22.544"
          }
        ],
        "http://www.w3.org/ns/activitystreams#generator": [
          {
            "@id": "http://store.rerum.io/v1/id/618acffb50c86821e60b274c"
          }
        ],
        "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#history": [
          {
            "http://purl.org/dc/terms/isVersionOf": [],
            "https://www.w3.org/TR/prov/#wasRevisionOf": [
              {
                "@id": ""
              }
            ],
            "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#prime": [
              {
                "@id": "root"
              }
            ]
          }
        ],
        "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#isOverwritten": [
          {
            "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
            "@value": ""
          }
        ],
        "http://purl.org/dc/terms/issued": [
          {
            "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
            "@value": ""
          }
        ],
        "https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/blob/main/public/API.html#releases": [
          {
            "http://purl.org/dc/terms/isVersionOf": [],
            "https://www.w3.org/TR/prov/#wasRevisionOf": [
              {
                "@id": ""
              }
            ],
            "http://purl.org/dc/terms/replaces": [
              {
                "@id": ""
              }
            ]
          }
        ]
      }
    ],
    "http://schema.org/creator": [
      {
        "@value": "http://store.rerum.io/v1/id/618d4cfa50c86821e60b2cba"
      }
    ],
    "http://schema.org/label": [
      {
        "@value": "Dayton. Autograph letter signed"
      }
    ]
  }
]
cubap commented 4 months ago

hmmm...

If there is a thing with missing bits, this library can only work with @id and @context and @type all in place. It can be a different key, but it all has to be there for the utilities to run successfully.