CenterForDigitalHumanities / TPEN-services

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

Save Project to local database #93

Open thehabes opened 4 months ago

thehabes commented 4 months ago

Projects will be saved into the local mongo database Projects collection (identified in .env file). A minimal project will look something like this:

 {
    "_id": {
        "$oid": "65f48b254da4e4b8c656d0d1"
    },
    "slug": "exampleProject",
    "creator": "https://store.rerum.io/v1/id/exampleAgent",
    "created": 1,
    "group": {
        "$oid": "65f48c9a4da4e4b8c656d0d2"
    },
    "layers": [ "https://store.rerum.io/v1/id/exampleAnnotationCollection" ],
    "lastModified": "exampleAnnotationPageId",
    "viewer": "https://static.t-pen.org/#65f48b254da4e4b8c656d0d1",
    "license": "CC-BY",
    "manifest": "https://external.example.com/manifest.json",
    "tools": [],
    "options": {},
    "tags": ["gog"],
    "title": "First Project"
}

undefined values do not need to be set and should not be assumed to be present on any Project. This chart explains the expected values and how they are used:

key type description required notes
_id ObjectID(hex) MongoDB generated complex key This will be generated if not provided, but should be assigned before saving so the Interface can be notified of the location before it clears the queue in the DB driver.
slug String slugified from user input as alternate lookup value This must be unique, but is not required.
creator URI Rerum Agent Id of Project owner/creator Based on auth'ed User, does not change after creation
created Date Literal timestamp of the time this Project was created for sorting and filtering
group ObjectID(hex) MongoDB generated complex key If provided (maybe as a hexstring), can point to an existing Group but must be generated and saved into Groups collection if not
layers Array of URI Annotation Collection(s) in RERUM 🥝 Interfaces won't really work without it, but it doesn't need to be added until the first Annotations are added
lastModified RERUM URI The most recent Annotation or Canvas manipulated Not defined on creation
viewer URL Interface location for readonly HTML Static page location once Project is publicly visible
license String statement of license If not defined, default to "CC-BY" which might be added to a config
manifest URI IIIF Manifest of source must preexist or be embedded in the body of a post and created in RERUM
tools Array project tools no default, no rules set for inclusion yet, just Interfaces aid
options Object config object for overriding Interfaces defaults
tags Array of String open tags defined by Users or by Interfaces
title String unicode title of Project generate if not provided
cubap commented 4 months ago

Tests should confirm validation checks for new Projects, mock the driver actions, and respond correctly to expected errors or invalid inputs.