Scopes¶
A scope describes which instances belong together for a purpose, starting from an instance of a type: a dataset with its authors and their affiliations, for example.
flowchart LR
D["Dataset<br/>(root)"] -- author --> P1["Person"]
D -- author --> P2["Person"]
P1 -- affiliation --> O["Organization"]
style D stroke-width:3px
Scopes are used for:
- Inviting reviewers to an instance and what surrounds it
- Checking the release status of a whole subgraph
- Retrieving a tree of related instances
Define a scope¶
Scopes are defined per type and have a name. A type can have any number.
| Action | Request |
|---|---|
| List | GET /v4/types/scopes?type=... |
| Read | GET /v4/types/scopes/{name}?type=... |
| Create or replace | PUT /v4/types/scopes/{name}?type=... |
| Delete | DELETE /v4/types/scopes/{name}?type=... |
All of these need DEFINE_SCOPES, granted by the ADMIN role.
A scope is a tree of steps with a fixed depth:
{
"structure": [
{
"path": "https://example.org/properties/author",
"structure": [
{ "path": "https://example.org/properties/affiliation" }
]
},
{
"path": {
"@id": "https://example.org/properties/dataset",
"reverse": true,
"typeFilter": { "@id": "https://example.org/types/Review" }
}
},
{
"path": [
"https://example.org/properties/license",
"https://example.org/properties/publisher"
]
}
]
}
A path is a plain property IRI, a hop object or a list of hops:
| Hop key | Description |
|---|---|
@id |
The property to follow |
reverse |
true follows links pointing to the instance |
typeFilter |
Restricts the reached instances, and further traversal, to the given types |
Every instance reached by a hop is part of the scope, including the intermediate ones on multi-hop paths.
Evaluate a scope¶
Without name, the combination of all scopes of the type is evaluated.
{
"@id": "...",
"@type": "https://example.org/types/Dataset",
"_space": "neuroscience",
"_label": "Mouse cortex recordings",
"_children": [
{
"@id": "...",
"@type": "https://example.org/types/Person",
"_space": "common",
"_label": "Ada Lovelace",
"_children": []
}
]
}
| Option | Adds to every instance in the tree |
|---|---|
returnPermissions=true |
_permissions: what you may do with it |
returnReleaseStatus=true |
_releaseStatus of that instance |
The result is reduced to what you may read. An unreadable instance is removed along with everything reached through it, and you must be able to read the root. Scopes are evaluated in PostgreSQL, so they don't need a graph database.