CenterForDigitalHumanities / TPEN-services

Services required by TPEN interfaces in order to interact with data
1 stars 0 forks source link

Extend Page web API #56

Closed cubap closed 5 months ago

cubap commented 6 months ago

Improve the GET /page/{id} endpoint to return the type of thing expected. Actual connections to the database can be mocked for now.

See #19 for expectations as well as #49 for docs about possible parameters in the request to handle.

Write the failing tests first, then build to suit.

For now, a Page will look like this:

{ 
  "id"          : "#PageId",
  "@context"    : "http://t-pen.org/3/context.json",
  "@type"       : "CreativeWork",
  "metadata"    : [],
  "name"        : { "none" : "page name" },
  "creator"     : "https://store.rerum.io/v1/id/hash",
  "project"     :  { "id" : "#ProjectId",
      "viewer"      : "https://static.t-pen.org/#ProjectId",
      "tools"       : [],
      "options"     : {},
      "license"     : "CC-BY"
  },
  "canvas"      : "https://example.com/canvas.json",
  "annotations" : [ "#AnnotationPageId" ],
  "viewer"      : "https://static.t-pen.org/#ProjectId/#PageId"
}

This will be stored in a database that is not set up yet, but you can assume a database controller abstraction with db.getByID() and db.find({property: match}) at a minimum, the return of which will be a JSON that contains the minimum unique Project information.

This endpoint should also provide alternate returns for certain parameters:

These parameters are all mutually exclusive except embed and passing multiple or a nonsense combo ("?view=html&embed=true") is an error.

thehabes commented 6 months ago

Note that Linked Data principles state that the @context property should always be the first property in JSON-LD objects.