Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rdf connect paper #54

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

examples/file.txt

bin/bundle.mjs
# Outputs
lib
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Typescript/Javascript executor for an [RDF-Connect](https://rdf-connect.github.i

## Process definition

Each js process must have `js:file`, `js:function` and `js:mapping` objects.
Each js process must have `rdfc-js:file`, `rdfc-js:function` and `rdfc-js:mapping` objects.

- `js:file` points to the location of the main javascript file, containing the function.
- `js:location` points to the starting location for `js:file` relative from the current file.
- `js:function` points to the function name in the file.
- `js:mapping` is a `fno:Mapping` object that links properties to function arguments.
- `rdfc-js:file` points to the location of the main javascript file, containing the function.
- `rdfc-js:location` points to the starting location for `js:file` relative from the current file.
- `rdfc-js:function` points to the function name in the file.
- `rdfc-js:mapping` is a `fno:Mapping` object that links properties to function arguments.

When you declare a new js process, it is required to add a SHACL shape.
Each `sh:property` is accounted for, noting the type `sh:class` or `sh:datatype`.
Expand All @@ -22,9 +22,9 @@ Example definitions are available in `processor/configs/*.ttl`.

In a js pipeline you can use all declared js processes, as defined in their SHACL shapes.

An example can be found in `input.ttl`, here a `js:Send` process and a `js:Resc` process are defined.
`js:Send` takes in a message to send, and a channel to send it to.
`js:Resc` only takes a channel to read from.
An example can be found in `input.ttl`, here a `rdfc-js:Send` process and a `rdfc-js:Resc` process are defined.
`rdfc-js:Send` takes in a message to send, and a channel to send it to.
`rdfc-js:Resc` only takes a channel to read from.

(implementation can be found in `procossor/test.js`)

Expand All @@ -37,4 +37,4 @@ tsc
bun bin/js-runner.js input.ttl
```

This example input configuration file uses `owl:imports` to specify additional configuration files.
This example input configuration file uses `owl:imports` to specify additional configuration files.
Binary file modified bun.lockb
Binary file not shown.
37 changes: 0 additions & 37 deletions channels/file.ttl

This file was deleted.

59 changes: 0 additions & 59 deletions channels/http.ttl

This file was deleted.

98 changes: 0 additions & 98 deletions channels/kafka.ttl

This file was deleted.

33 changes: 0 additions & 33 deletions channels/ws.ttl

This file was deleted.

85 changes: 85 additions & 0 deletions examples/multiple-channels.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfc: <https://w3id.org/rdf-connect#> .
@prefix rdfc-js: <https://w3id.org/rdf-connect/js#> .

#################################
## Entity definitions
#################################

<> owl:imports
<../processor/echo.ttl>,
<../processor/send.ttl>,
<../processor/resc.ttl>,
<../ontology.ttl> .

#################################
## Channels
#################################

# JS in-memory channel
[ ] a rdfc-js:JSChannel ;
rdfc:reader <jr> ;
rdfc:writer <jw> .
<jr> a rdfc-js:JSReaderChannel .
<jw> a rdfc-js:JSWriterChannel .

# HTTP channel
[ ] a rdfc:HttpChannel ;
rdfc:reader <hr> ;
rdfc:writer <hw> .
<hr> a rdfc:HttpReaderChannel ;
rdfc:httpPort 8081 .
<hw> a rdfc:HttpWriterChannel ;
rdfc:httpEndpoint "http://localhost:8081" ;
rdfc:httpMethod "POST" .

# WebSocket channel
[ ] a rdfc:WebSocketChannel ;
rdfc:reader <wsr> ;
rdfc:writer <wsw> .
<wsr> a rdfc:WebSocketReaderChannel ;
rdfc:wsPort 8083 ;
rdfc:wsHost "localhost" .
<wsw> a rdfc:WebSocketWriterChannel ;
rdfc:wsUrl "ws://localhost:8083" .

# File channel
[ ] a rdfc:FileChannel ;
rdfc:reader <fr> ;
rdfc:writer <fw> .
<fr> a rdfc:FileReaderChannel ;
rdfc:filePath "../examples/file.txt" ;
rdfc:fileOnReplace true .
<fw> a rdfc:FileWriterChannel ;
rdfc:filePath "../examples/file.txt" ;
rdfc:fileOnReplace true .

#################################
## Processors
#################################

# Send message
[ ] a rdfc-js:Send ;
rdfc-js:msg "RDF-Connect says: " ;
rdfc-js:sendWriter <jw> .

# Echo 1
[ ] a rdfc-js:Echo ;
rdfc-js:input <jr> ;
rdfc-js:output <hw> .

# Echo 2
[ ] a rdfc-js:Echo ;
rdfc-js:input <hr> ;
rdfc-js:output <wsw> .

# Echo 3
[ ] a rdfc-js:Echo ;
rdfc-js:input <wsr> ;
rdfc-js:output <fw> .

# Write to console
[ ] a rdfc-js:Resc ;
rdfc-js:rescReader <fr> .
26 changes: 26 additions & 0 deletions examples/simple.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@prefix rdfc-js: <https://w3id.org/rdf-connect/js#> .
@prefix rdfc: <https://w3id.org/rdf-connect#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

<> owl:imports
<../processor/send.ttl>,
<../processor/resc.ttl>,
<../ontology.ttl> .

[ ] a rdfc-js:JSChannel ;
rdfc:reader <jr> ;
rdfc:writer <jw> .

<jr> a rdfc-js:JSReaderChannel .
<jw> a rdfc-js:JSWriterChannel .

[ ] a rdfc-js:Send ;
rdfc-js:msg "Hello" ;
rdfc-js:sendWriter <jw> .

[ ] a rdfc-js:Resc ;
rdfc-js:rescReader <jr> .

Loading
Loading