Skip to content

Commit

Permalink
feat: created talos for bootstrapping APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Apr 12, 2021
1 parent 80ef858 commit 5779ddd
Show file tree
Hide file tree
Showing 48 changed files with 654 additions and 211 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-stingrays-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/talos": minor
---

First version
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.d.ts
mocha-setup.js
packages/*/bin/
15 changes: 0 additions & 15 deletions apps/conduit/bootstrap/1. acl.http

This file was deleted.

15 changes: 0 additions & 15 deletions apps/conduit/bootstrap/2. events.http

This file was deleted.

39 changes: 0 additions & 39 deletions apps/conduit/bootstrap/3. users.http

This file was deleted.

5 changes: 0 additions & 5 deletions apps/conduit/bootstrap/http-client.env.json

This file was deleted.

4 changes: 3 additions & 1 deletion apps/conduit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"private": true,
"version": "0.0.0",
"scripts": {
"init": "node -r ts-node/register ../../packages/knossos init --api https://conduit.knossos.lndo.site --endpoint http://minos:[email protected]/repositories/labyrinth --overwrite"
"resources": "knossos-dev init",
"bootstrap": "talos-dev put --vocabs --acl --resources --api https://conduit.knossos.lndo.site --endpoint http://minos:[email protected]/repositories/labyrinth"
},
"dependencies": {
"@hydrofoil/knossos": "0.0.0",
"@hydrofoil/talos": "0.0.0",
"@rdfjs/term-set": "^1.0.1",
"@tpluscode/rdf-ns-builders": "^0.4",
"@tpluscode/sparql-builder": "^0.3.11",
Expand Down
2 changes: 2 additions & 0 deletions apps/conduit/resources/api/RegisteredUser.ttl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix dash: <http://datashapes.org/dash#> .
Expand All @@ -8,6 +9,7 @@

</api/RegisteredUser>
a </api/hydra/Class>, sh:NodeShape, rdfs:Class ;
hydra:apiDocumentation </api> ;
rdfs:subClassOf rdfs:Resource, </api/hydra/Resource> ;
sh:property
[
Expand Down
1 change: 1 addition & 0 deletions apps/conduit/resources/api/User.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</api/User>
a </api/hydra/Class>, sh:NodeShape, rdfs:Class ;
rdfs:subClassOf rdfs:Resource, </api/hydra/Resource> ;
hydra:apiDocumentation </api> ;
hydra:supportedOperation
[
a schema:ReplaceAction ;
Expand Down
1 change: 1 addition & 0 deletions apps/conduit/resources/api/UsersCollection.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</api/UsersCollection>
a </api/hydra/Class>, rdfs:Class, sh:NodeShape ;
rdfs:subClassOf </api/hydra/Collection> ;
hydra:apiDocumentation </api> ;
knossos:createWithPUT true ;
hydra:supportedOperation
[
Expand Down
79 changes: 79 additions & 0 deletions apps/conduit/resources/api/acl/Authorization.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix code: <https://code.described.at/> .
@prefix auth: <https://hypermedia.app/auth#> .
@prefix knossos: <https://hypermedia.app/knossos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .

<> rdfs:subClassOf acl:Authorization ;
a hydra:Class, sh:NodeShape, rdfs:Class ;
knossos:createWithPUT true ;
hydra:apiDocumentation </api> ;
hydra:supportedOperation
[
hydra:method "PUT" ;
auth:access acl:Write ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/resource#PUT> ;
]
] ;
sh:property
[
sh:path acl:mode ;
sh:minCount 1 ;
sh:in (
acl:Read acl:Write acl:Control acl:Delete acl:Create
) ;
] ;
sh:or
(
[
sh:property
[
sh:path acl:agent ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
]
]
[
sh:property
[
sh:path acl:agentClass ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
]
]
[
sh:property
[
sh:path acl:agentGroup ;
sh:minCount 1 ;
sh:class vcard:Group ;
]
]
) ;
sh:or
(
[
sh:property
[
sh:path acl:accessTo ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
]
]
[
sh:property
[
sh:path acl:accessToClass ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
]
]
)
.
11 changes: 11 additions & 0 deletions apps/conduit/resources/api/classes.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .

<>
a <hydra/Collection> ;
hydra:manages
[
hydra:property rdf:type ;
hydra:object hydra:Class ;
]
.
23 changes: 23 additions & 0 deletions apps/conduit/resources/api/events/EventHandler.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix events: <https://hypermedia.app/events#> .
@prefix code: <https://code.described.at/> .
@prefix auth: <https://hypermedia.app/auth#> .
@prefix knossos: <https://hypermedia.app/knossos#> .

<> rdfs:subClassOf events:EventHandler ;
a sh:NodeShape, rdfs:Class, hydra:Class ;
hydra:apiDocumentation </api> ;
hydra:supportedOperation
[
hydra:method "PUT" ;
auth:access acl:Write ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/resource#PUT> ;
]
] ;
.
4 changes: 4 additions & 0 deletions apps/conduit/resources/api/events/index.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix events: <https://hypermedia.app/events#> .

events:EventHandler rdfs:subClassOf rdfs:Resource .
29 changes: 29 additions & 0 deletions apps/conduit/resources/api/events/invalidate-api.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix code: <https://code.described.at/> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix as: <https://www.w3.org/ns/activitystreams#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix events: <https://hypermedia.app/events#> .

<> a events:EventHandler ;
rdfs:comment "Void ApiDocumentation cache when a hydra:Class is created of updated" ;
events:eventSpec
[
rdf:predicate rdf:type ;
rdf:object as:Update ;
] ,
[
rdf:predicate rdf:type ;
rdf:object as:Create ;
] ;
events:objectSpec
[
rdf:predicate rdf:type ;
rdf:object hydra:Class ;
] ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/lib/api#invalidate> ;
]
.
23 changes: 23 additions & 0 deletions apps/conduit/resources/api/hydra/ApiDocumentation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@prefix code: <https://code.described.at/> .
@prefix auth: <https://hypermedia.app/auth#> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix knossos: <https://hypermedia.app/knossos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .

</api/hydra/ApiDocumentation>
rdfs:subClassOf hydra:ApiDocumentation, rdfs:Resource ;
a sh:NodeShape, rdfs:Class, hydra:Class ;
hydra:apiDocumentation </api> ;
hydra:supportedOperation
[
hydra:method "DELETE" ;
auth:access acl:Delete ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/lib/api#DELETE> ;
]
] ;
.
32 changes: 32 additions & 0 deletions apps/conduit/resources/api/hydra/Class.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@prefix code: <https://code.described.at/> .
@prefix auth: <https://hypermedia.app/auth#> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix knossos: <https://hypermedia.app/knossos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .

<> rdfs:subClassOf hydra:Class, </api/hydra/Resource> ;
a sh:NodeShape, rdfs:Class, hydra:Class ;
knossos:createWithPUT true ;
hydra:supportedOperation
[
hydra:method "PUT" ;
auth:access acl:Write ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/resource#PUT> ;
]
] ;
hydra:supportedOperation
[
hydra:method "DELETE" ;
auth:access acl:Delete ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/knossos/resource#DELETE> ;
]
] ;
.
25 changes: 25 additions & 0 deletions apps/conduit/resources/api/hydra/Collection.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix code: <https://code.described.at/> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix auth: <https://hypermedia.app/auth#> .

<> rdfs:subClassOf hydra:Collection ;
a hydra:Class, rdfs:Class, sh:NodeShape ;
hydra:supportedOperation
[
hydra:method "GET" ;
auth:access acl:Read ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/labyrinth/collection#get> ;
]
] ;
sh:property
[
sh:path hydra:manages ;
sh:minCount 1 ;
]
.
19 changes: 19 additions & 0 deletions apps/conduit/resources/api/hydra/Resource.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix code: <https://code.described.at/> .
@prefix acl: <http://www.w3.org/ns/auth/acl#> .
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .
@prefix auth: <https://hypermedia.app/auth#> .

<> rdfs:subClassOf hydra:Resource ;
a hydra:Class ;
hydra:supportedOperation
[
hydra:method "GET" ;
auth:access acl:Read ;
code:implementedBy
[
a code:EcmaScript ;
code:link <node:@hydrofoil/labyrinth/resource#get> ;
]
]
.
6 changes: 6 additions & 0 deletions apps/conduit/resources/api/index.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@prefix hydra: <http://www.w3.org/ns/hydra/core#> .

<>
a </api/hydra/ApiDocumentation> ;
hydra:entrypoint <../> ;
.
Loading

0 comments on commit 5779ddd

Please sign in to comment.