@rdfc/js-runner 3.0.2 → 3.0.4-remote
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +12 -0
- package/README.md +41 -1
- package/__tests__/echoProcessor.test.ts +11 -12
- package/bin/runner.js +7 -1
- package/bin/server.js +13 -0
- package/bun.lock +820 -0
- package/examples/echo/.idea/echo.iml +9 -0
- package/examples/echo/.idea/misc.xml +6 -0
- package/{.idea → examples/echo/.idea}/modules.xml +1 -1
- package/examples/echo/.idea/vcs.xml +7 -0
- package/examples/echo/.swls/config.json +1 -0
- package/examples/echo/package-lock.json +27 -29
- package/examples/echo/pipeline.ttl +0 -1
- package/examples/echo/processors.ttl +1 -1
- package/examples/echo/remote_pipeline.ttl +18 -0
- package/examples/echo/server.ttl +5 -0
- package/examples/echo/untitled:/types/MyType.ttl +0 -0
- package/file:/home/silvius/Projects/mumo-pipeline/ldes/http_3A_2F_2Fdata.mumo.be_2Fstreams_2Fnodes_2Fdefault/root/index.trig +3 -0
- package/ldes/http_3A_2F_2Fdata.mumo.be_2Fstreams_2Fnodes_2Fdefault/root/index.trig +3 -0
- package/lib/client.d.ts +2 -1
- package/lib/client.js +70 -22
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/jsonld.d.ts +17 -0
- package/lib/jsonld.js +135 -0
- package/lib/logger.d.ts +1 -0
- package/lib/logger.js +19 -9
- package/lib/reader.d.ts +4 -1
- package/lib/reader.js +11 -3
- package/lib/runner.d.ts +6 -1
- package/lib/runner.js +43 -15
- package/lib/server.d.ts +9 -0
- package/lib/server.js +459 -0
- package/lib/state.d.ts +32 -0
- package/lib/state.js +71 -0
- package/lib/testUtils/duplex.js +1 -1
- package/lib/testUtils/index.d.ts +9 -9
- package/lib/testUtils/index.js +9 -9
- package/lib/testUtils.d.ts +24 -0
- package/lib/testUtils.js +150 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/writer.d.ts +5 -1
- package/lib/writer.js +26 -10
- package/minimal.ttl +99 -0
- package/package.json +21 -19
- package/src/client.ts +99 -24
- package/src/index.ts +2 -0
- package/src/logger.ts +15 -7
- package/src/reader.ts +19 -9
- package/src/runner.ts +61 -12
- package/src/server.ts +545 -0
- package/src/state.ts +105 -0
- package/src/testUtils/duplex.ts +1 -4
- package/src/testUtils/index.ts +25 -21
- package/src/writer.ts +36 -12
- package/.idea/LNKD.tech Editor.xml +0 -194
- package/.idea/codeStyles/Project.xml +0 -52
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/js-runner.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/dist/args.d.ts +0 -4
- package/dist/args.js +0 -58
- package/dist/connectors/file.d.ts +0 -15
- package/dist/connectors/file.js +0 -89
- package/dist/connectors/http.d.ts +0 -14
- package/dist/connectors/http.js +0 -82
- package/dist/connectors/kafka.d.ts +0 -48
- package/dist/connectors/kafka.js +0 -68
- package/dist/connectors/ws.d.ts +0 -10
- package/dist/connectors/ws.js +0 -72
- package/dist/connectors.d.ts +0 -73
- package/dist/connectors.js +0 -168
- package/dist/index.cjs +0 -732
- package/dist/index.d.ts +0 -42
- package/dist/index.js +0 -83
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/util.d.ts +0 -71
- package/dist/util.js +0 -92
- package/jest.config.js +0 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# JavaScript runner for RDF-Connect
|
|
2
2
|
|
|
3
|
+
[](https://github.com/rdf-connect/js-runner/actions/workflows/build-test.yml) [](https://npmjs.com/package/@rdfc/js-runner)
|
|
4
|
+
|
|
5
|
+
This package provides a JavaScript runner implementation for RDF-Connect, which allows you to run JavaScript/TypeScript processors in your [RDF-Connect](https://github.com/rdf-connect/rdf-connect) pipeline.
|
|
6
|
+
|
|
3
7
|
## Usage
|
|
4
8
|
|
|
5
9
|
To use the JavaScript (Node or Bun) runner for RDF-Connect, you need to have a pipeline configuration that includes JavaScript/TypeScript processors.
|
|
@@ -28,6 +32,42 @@ You can install the js-runner package using the following command:
|
|
|
28
32
|
npm install @rdfc/js-runner
|
|
29
33
|
```
|
|
30
34
|
|
|
35
|
+
### Remote runner usage
|
|
36
|
+
|
|
37
|
+
The js-runner can also be used as a remote runner. To do this, start the runner server using `npx js-runner-server ./server.ttl`.
|
|
38
|
+
This starts the remote server as configured in `server.ttl`
|
|
39
|
+
|
|
40
|
+
```turtle
|
|
41
|
+
@prefix rdfc: <https://w3id.org/rdf-connect#>.
|
|
42
|
+
|
|
43
|
+
<> a rdfc:JsRunnerServer;
|
|
44
|
+
rdfc:port 3000;
|
|
45
|
+
# one or more processor definition files to host
|
|
46
|
+
rdfc:processorConfig <./processors.ttl>.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This enables the user to configure the pipeline just like a normal pipeline. The runner definition is automatically available at `localhost:{PORT}`.
|
|
50
|
+
|
|
51
|
+
```turtle
|
|
52
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
|
|
53
|
+
@prefix rdfc: <https://w3id.org/rdf-connect#>.
|
|
54
|
+
|
|
55
|
+
# the endpoint serving the example configuration
|
|
56
|
+
@prefix runner: <http://localhost:3000/>.
|
|
57
|
+
|
|
58
|
+
# import the runner and the processor definitions
|
|
59
|
+
<> owl:imports runner:, runner:processors.ttl.
|
|
60
|
+
|
|
61
|
+
# setup the pipeline
|
|
62
|
+
<> a rdfc:Pipeline;
|
|
63
|
+
rdfc:consistsOf [
|
|
64
|
+
rdfc:processor <logProc>, <sendProc>;
|
|
65
|
+
rdfc:instantiates runner:runner;
|
|
66
|
+
].
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
There is an example in `./examples/echo`, start the server with `npx js-runner-server ./server.ttl` and run the pipeline `npx rdfc ./remote_pipeline.ttl`.
|
|
70
|
+
|
|
31
71
|
## Logging
|
|
32
72
|
|
|
33
73
|
The JavaScript runner and processors use the `winston` logging library for logging.
|
|
@@ -86,7 +126,7 @@ JavaScript/TypeScript processors must include the JavaScript specific configurat
|
|
|
86
126
|
|
|
87
127
|
The JavaScript runner is implemented in TypeScript.
|
|
88
128
|
The source code is contained in the `src` folder.
|
|
89
|
-
The main cli entry
|
|
129
|
+
The main cli entry points are the `bin/runner.js` and `bin/server.js` files, which you can also run after installation of the package using `npx js-runner` and `npx js-runner-server` respectively.
|
|
90
130
|
|
|
91
131
|
If you want to get started with the development of the js-runner, you can clone the repository and install the dependencies using the following commands.
|
|
92
132
|
|
|
@@ -70,12 +70,11 @@ describe('EchoProcessor', () => {
|
|
|
70
70
|
|
|
71
71
|
const msgs: string[] = []
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
;(async () => {
|
|
74
|
+
for await (const m of outputReader.strings()) {
|
|
75
|
+
msgs.push(m)
|
|
76
|
+
}
|
|
77
|
+
})()
|
|
79
78
|
|
|
80
79
|
await inputWriter.string('Hello')
|
|
81
80
|
expect(msgs).toEqual(['Hello'])
|
|
@@ -107,13 +106,13 @@ describe('EchoProcessor', () => {
|
|
|
107
106
|
|
|
108
107
|
const msgs: string[] = []
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
;(async () => {
|
|
110
|
+
for await (const m of outputReader.strings()) {
|
|
111
|
+
msgs.push(m)
|
|
112
|
+
}
|
|
113
|
+
})()
|
|
115
114
|
|
|
116
|
-
const gen = async function*() {
|
|
115
|
+
const gen = async function* () {
|
|
117
116
|
yield encoder.encode('Hello')
|
|
118
117
|
yield encoder.encode('World')
|
|
119
118
|
}
|
package/bin/runner.js
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { start } from '../lib/client.js'
|
|
4
4
|
|
|
5
|
+
// One-shot CLI mode: connect to an existing orchestrator, run processors, then exit.
|
|
6
|
+
// process.exit is needed because grpc-js keeps the event loop alive after client.close().
|
|
5
7
|
const host = process.argv[2]
|
|
6
8
|
const uri = process.argv[3]
|
|
7
|
-
|
|
8
9
|
start(host, uri)
|
|
10
|
+
.then(() => process.exit(0))
|
|
11
|
+
.catch((err) => {
|
|
12
|
+
console.error(err)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
})
|
package/bin/server.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { serve } from '../lib/server.js'
|
|
4
|
+
|
|
5
|
+
const configPath = process.argv[2]
|
|
6
|
+
if (!configPath) {
|
|
7
|
+
console.error('Usage: js-runner-server <config>')
|
|
8
|
+
process.exit(1)
|
|
9
|
+
}
|
|
10
|
+
serve(configPath).catch((err) => {
|
|
11
|
+
console.error(err)
|
|
12
|
+
process.exit(1)
|
|
13
|
+
})
|