@rdfc/js-runner 1.0.0-alpha.7 → 2.0.0-alpha.1
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/.husky/pre-commit +6 -0
- package/.prettierrc +4 -0
- package/README.md +3 -38
- package/__tests__/channels.test.ts +133 -0
- package/bin/runner.js +8 -0
- package/eslint.config.mjs +21 -0
- package/examples/echo/package-lock.json +80 -0
- package/examples/echo/package.json +18 -0
- package/examples/echo/pipeline.ttl +30 -0
- package/examples/echo/processors.ttl +84 -0
- package/examples/echo/src/processors.ts +75 -0
- package/examples/echo/test.ttl +14 -0
- package/examples/echo/tsconfig.json +114 -0
- package/examples/echo/untitled:/types/MyType.ttl +0 -0
- package/index.ttl +63 -0
- package/jest.config.js +2 -0
- package/lib/client.d.ts +1 -0
- package/lib/client.js +43 -0
- package/lib/convertor.d.ts +9 -0
- package/lib/convertor.js +51 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/jsonld.d.ts +17 -0
- package/lib/jsonld.js +134 -0
- package/lib/logger.d.ts +15 -0
- package/lib/logger.js +27 -0
- package/lib/processor.d.ts +19 -0
- package/lib/processor.js +13 -0
- package/lib/reader.d.ts +29 -0
- package/lib/reader.js +110 -0
- package/lib/runner.d.ts +25 -0
- package/lib/runner.js +111 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/util_processors.d.ts +11 -0
- package/lib/util_processors.js +13 -0
- package/lib/writer.d.ts +25 -0
- package/lib/writer.js +57 -0
- package/package.json +53 -59
- package/src/client.ts +52 -0
- package/src/convertor.ts +59 -0
- package/src/index.ts +4 -0
- package/src/jsonld.ts +217 -0
- package/src/logger.ts +38 -0
- package/src/processor.ts +39 -0
- package/src/reader.ts +148 -0
- package/src/runner.ts +186 -0
- package/src/util_processors.ts +20 -0
- package/src/writer.ts +89 -0
- package/tsconfig.json +33 -0
- package/vite.config.ts +10 -0
- package/LICENSE +0 -21
- package/bin/js-runner.js +0 -4
- package/channels/file.ttl +0 -37
- package/channels/http.ttl +0 -59
- package/channels/kafka.ttl +0 -98
- package/channels/ws.ttl +0 -33
- package/dist/args.d.ts +0 -4
- package/dist/args.js +0 -59
- 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 -64
- package/dist/connectors/ws.d.ts +0 -10
- package/dist/connectors/ws.js +0 -69
- package/dist/connectors.d.ts +0 -57
- package/dist/connectors.js +0 -174
- package/dist/index.d.ts +0 -39
- package/dist/index.js +0 -88
- package/dist/profiling.d.ts +0 -6
- package/dist/profiling.js +0 -79
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/util.d.ts +0 -43
- package/dist/util.js +0 -75
- package/ontology.ttl +0 -196
- package/processor/echo.ttl +0 -38
- package/processor/resc.ttl +0 -34
- package/processor/send.ttl +0 -40
- package/processor/test.js +0 -35
package/src/runner.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OrchestratorMessage,
|
|
3
|
+
Processor,
|
|
4
|
+
RunnerClient,
|
|
5
|
+
RunnerMessage,
|
|
6
|
+
} from '@rdfc/proto'
|
|
7
|
+
import { Reader, ReaderInstance } from './reader'
|
|
8
|
+
import { Writer, WriterInstance } from './writer'
|
|
9
|
+
import { Processor as Proc } from './processor'
|
|
10
|
+
import { Logger } from 'winston'
|
|
11
|
+
|
|
12
|
+
import winston from 'winston'
|
|
13
|
+
import { RpcTransport } from './logger'
|
|
14
|
+
import { parse_jsonld } from './jsonld'
|
|
15
|
+
import { Cont, empty, extractShapes, Shapes } from 'rdf-lens'
|
|
16
|
+
import { NamedNode, Parser } from 'n3'
|
|
17
|
+
import { createNamespace, createUriAndTermNamespace, RDF } from '@treecg/types'
|
|
18
|
+
import { Quad, Term } from '@rdfjs/types'
|
|
19
|
+
|
|
20
|
+
const RDFL = createUriAndTermNamespace(
|
|
21
|
+
'https://w3id.org/rdf-lens/ontology#',
|
|
22
|
+
'CBD',
|
|
23
|
+
'Path',
|
|
24
|
+
'PathLens',
|
|
25
|
+
'Context',
|
|
26
|
+
'TypedExtract',
|
|
27
|
+
'EnvVariable',
|
|
28
|
+
'envKey',
|
|
29
|
+
'envDefault',
|
|
30
|
+
'datatype',
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
const RDFC = createNamespace(
|
|
34
|
+
'https://w3id.org/rdf-connect/ontology#',
|
|
35
|
+
(x) => x,
|
|
36
|
+
'Reader',
|
|
37
|
+
'Writer',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
type Writable = (msg: OrchestratorMessage) => Promise<unknown>
|
|
41
|
+
|
|
42
|
+
type ProcessorConfig = {
|
|
43
|
+
location: string
|
|
44
|
+
file: string
|
|
45
|
+
clazz?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class Runner {
|
|
49
|
+
private readonly readers: { [uri: string]: ReaderInstance[] } = {}
|
|
50
|
+
private readonly writers: { [uri: string]: WriterInstance[] } = {}
|
|
51
|
+
private readonly client: RunnerClient
|
|
52
|
+
private readonly write: Writable
|
|
53
|
+
private readonly logger: Logger
|
|
54
|
+
private shapes: Shapes
|
|
55
|
+
private quads: Quad[] = []
|
|
56
|
+
|
|
57
|
+
private readonly uri: string
|
|
58
|
+
|
|
59
|
+
private readonly processors: Proc<unknown>[] = []
|
|
60
|
+
private readonly processorTransforms: Promise<unknown>[] = []
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
client: RunnerClient,
|
|
64
|
+
write: Writable,
|
|
65
|
+
uri: string,
|
|
66
|
+
logger: Logger,
|
|
67
|
+
) {
|
|
68
|
+
this.client = client
|
|
69
|
+
this.write = write
|
|
70
|
+
this.uri = uri
|
|
71
|
+
this.logger = logger
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async addProcessor(proc: Processor) {
|
|
75
|
+
const procLogger = winston.createLogger({
|
|
76
|
+
transports: [
|
|
77
|
+
new RpcTransport({
|
|
78
|
+
entities: [proc.uri, this.uri],
|
|
79
|
+
stream: this.client.logStream(() => { }),
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const ty = JSON.stringify(this.quads.filter(x => x.subject.value === proc.uri && x.predicate.equals(RDF.terms.type)).map(x => x.object.value))
|
|
85
|
+
this.logger.info("parsing " + proc.uri + " type " + ty)
|
|
86
|
+
const args = this.shapes.lenses[RDFL.TypedExtract].execute({
|
|
87
|
+
id: new NamedNode(proc.uri),
|
|
88
|
+
quads: this.quads,
|
|
89
|
+
})
|
|
90
|
+
// this.logger.info('Parsed ' + JSON.stringify(args))
|
|
91
|
+
|
|
92
|
+
// const args = await parse_jsonld(proc.arguments, procLogger, {
|
|
93
|
+
// client: this.client,
|
|
94
|
+
// write: this.write,
|
|
95
|
+
// readers: this.readers,
|
|
96
|
+
// writers: this.writers,
|
|
97
|
+
// })
|
|
98
|
+
|
|
99
|
+
const config: ProcessorConfig = JSON.parse(proc.config)
|
|
100
|
+
const url = new URL(config.location)
|
|
101
|
+
process.chdir(url.pathname)
|
|
102
|
+
const jsProgram = await import(config.file)
|
|
103
|
+
const clazz = jsProgram[config.clazz || 'default']
|
|
104
|
+
const instance: Proc<unknown> = new clazz(args, procLogger)
|
|
105
|
+
await instance.init()
|
|
106
|
+
|
|
107
|
+
this.logger.info("inited " + proc.uri + " type " + ty)
|
|
108
|
+
await this.write({ init: { uri: proc.uri } })
|
|
109
|
+
|
|
110
|
+
this.processors.push(instance)
|
|
111
|
+
this.processorTransforms.push(instance.transform())
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async start() {
|
|
115
|
+
await Promise.all(this.processors.map((x) => x.produce()))
|
|
116
|
+
await Promise.all(this.processorTransforms)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
createWriter(uri: Term): Writer {
|
|
120
|
+
const ids = uri.value;
|
|
121
|
+
|
|
122
|
+
if (this.writers[ids] === undefined) {
|
|
123
|
+
this.writers[ids] = []
|
|
124
|
+
}
|
|
125
|
+
const writer = new WriterInstance(
|
|
126
|
+
ids,
|
|
127
|
+
this.client,
|
|
128
|
+
this.write,
|
|
129
|
+
this.logger,
|
|
130
|
+
)
|
|
131
|
+
this.writers[ids].push(writer)
|
|
132
|
+
return writer
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
createReader(uri: Term): Reader {
|
|
136
|
+
const ids = uri.value;
|
|
137
|
+
|
|
138
|
+
if (this.readers[ids] === undefined) {
|
|
139
|
+
this.readers[ids] = []
|
|
140
|
+
}
|
|
141
|
+
const reader = new ReaderInstance(ids, this.client, this.logger)
|
|
142
|
+
this.readers[ids].push(reader)
|
|
143
|
+
return reader
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async handleOrchMessage(msg: RunnerMessage) {
|
|
147
|
+
if (msg.msg) {
|
|
148
|
+
this.logger.debug('Handling data msg for ' + msg.msg.channel)
|
|
149
|
+
for (const reader of this.readers[msg.msg.channel] || []) {
|
|
150
|
+
reader.handleMsg(msg.msg)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (msg.streamMsg) {
|
|
155
|
+
for (const reader of this.readers[msg.streamMsg.channel] || []) {
|
|
156
|
+
reader.handleStreamingMessage(msg.streamMsg)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (msg.close) {
|
|
161
|
+
const uri = msg.close.channel
|
|
162
|
+
|
|
163
|
+
for (const reader of this.readers[uri] || []) {
|
|
164
|
+
reader.close()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
for (const writer of this.writers[uri] || []) {
|
|
168
|
+
await writer.close(true)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (msg.pipeline) {
|
|
173
|
+
// here
|
|
174
|
+
const quads = new Parser().parse(msg.pipeline);
|
|
175
|
+
this.shapes = extractShapes(quads, {
|
|
176
|
+
[RDFC.Reader]: (x: Cont) => this.createReader(x.id),
|
|
177
|
+
[RDFC.Writer]: (x: Cont) => this.createWriter(x.id)
|
|
178
|
+
}, {
|
|
179
|
+
[RDFC.Reader]: empty<Cont>(),
|
|
180
|
+
[RDFC.Writer]: empty<Cont>()
|
|
181
|
+
});
|
|
182
|
+
this.quads = quads;
|
|
183
|
+
this.logger.info("extracted shapes " + JSON.stringify(Object.keys(this.shapes.lenses)));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Processor } from './processor'
|
|
2
|
+
import { Reader } from './reader'
|
|
3
|
+
|
|
4
|
+
type LogArgs = {
|
|
5
|
+
reader: Reader
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class LogProcessor extends Processor<LogArgs> {
|
|
9
|
+
async init(): Promise<void> {
|
|
10
|
+
this.logger.info('Init log processor')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async transform(this: LogArgs & this): Promise<void> {
|
|
14
|
+
for await (const msg of this.args.reader.strings()) {
|
|
15
|
+
this.logger.info('Got msg' + msg)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async produce() {}
|
|
20
|
+
}
|
package/src/writer.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Id, OrchestratorMessage, RunnerClient } from '@rdfc/proto'
|
|
2
|
+
import { promisify } from 'util'
|
|
3
|
+
import { Logger } from 'winston'
|
|
4
|
+
import { Any } from './reader'
|
|
5
|
+
|
|
6
|
+
type Writable = (msg: OrchestratorMessage) => Promise<unknown>
|
|
7
|
+
export interface Writer {
|
|
8
|
+
buffer(buffer: Uint8Array): Promise<void>
|
|
9
|
+
|
|
10
|
+
stream(buffer: AsyncIterable<Uint8Array>): Promise<void>
|
|
11
|
+
stream<T>(
|
|
12
|
+
buffer: AsyncIterable<T>,
|
|
13
|
+
tranform: (x: T) => Uint8Array,
|
|
14
|
+
): Promise<void>
|
|
15
|
+
|
|
16
|
+
string(buffer: string): Promise<void>
|
|
17
|
+
any(any: Any): Promise<void>
|
|
18
|
+
close(): Promise<void>
|
|
19
|
+
}
|
|
20
|
+
const encoder = new TextEncoder()
|
|
21
|
+
export class WriterInstance implements Writer {
|
|
22
|
+
private readonly uri: string
|
|
23
|
+
private readonly client: RunnerClient
|
|
24
|
+
private readonly write: Writable
|
|
25
|
+
private readonly logger: Logger
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
uri: string,
|
|
29
|
+
client: RunnerClient,
|
|
30
|
+
write: Writable,
|
|
31
|
+
logger: Logger,
|
|
32
|
+
) {
|
|
33
|
+
this.client = client
|
|
34
|
+
this.write = write
|
|
35
|
+
this.uri = uri
|
|
36
|
+
this.logger = logger
|
|
37
|
+
}
|
|
38
|
+
async any(any: Any): Promise<void> {
|
|
39
|
+
if ('stream' in any) {
|
|
40
|
+
await this.stream(any.stream)
|
|
41
|
+
}
|
|
42
|
+
if ('buffer' in any) {
|
|
43
|
+
await this.buffer(any.buffer)
|
|
44
|
+
}
|
|
45
|
+
if ('string' in any) {
|
|
46
|
+
await this.string(any.string)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async buffer(buffer: Uint8Array): Promise<void> {
|
|
51
|
+
this.logger.debug(`${this.uri} sends buffer ${buffer.length} bytes`)
|
|
52
|
+
await this.write({ msg: { data: buffer, channel: this.uri } })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async stream<T = Uint8Array>(
|
|
56
|
+
buffer: AsyncIterable<T>,
|
|
57
|
+
transform?: (x: T) => Uint8Array,
|
|
58
|
+
) {
|
|
59
|
+
const t = transform || ((x: unknown) => <Uint8Array>x)
|
|
60
|
+
const stream = this.client.sendStreamMessage()
|
|
61
|
+
const id: Id = await new Promise((res) => stream.once('data', res))
|
|
62
|
+
this.logger.debug(`${this.uri} streams message with id ${id.id}`)
|
|
63
|
+
await this.write({ streamMsg: { id, channel: this.uri } })
|
|
64
|
+
|
|
65
|
+
const write = promisify(stream.write.bind(stream))
|
|
66
|
+
for await (const msg of buffer) {
|
|
67
|
+
await write({ data: t(msg) })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.logger.debug(`${this.uri} is done streaming message with id ${id.id}`)
|
|
71
|
+
stream.end()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async string(msg: string): Promise<void> {
|
|
75
|
+
this.logger.debug(`${this.uri} sends string ${msg.length} characters`)
|
|
76
|
+
await this.write({
|
|
77
|
+
msg: { data: encoder.encode(msg), channel: this.uri },
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async close(issued = false): Promise<void> {
|
|
82
|
+
this.logger.debug(`${this.uri} closes stream`)
|
|
83
|
+
if (!issued) {
|
|
84
|
+
await this.write({
|
|
85
|
+
close: { channel: this.uri },
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"outDir": "lib/",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"module": "ES2022",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"inlineSourceMap": true, // 🔴 Keeps source maps in JS files
|
|
10
|
+
"inlineSources": true, // 🔴 Includes the original TS source in maps
|
|
11
|
+
"preserveConstEnums": true,
|
|
12
|
+
"downlevelIteration": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"strictFunctionTypes": false,
|
|
16
|
+
"strictPropertyInitialization": false,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"allowSyntheticDefaultImports": true,
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"removeComments": true
|
|
22
|
+
},
|
|
23
|
+
"ts-node": {
|
|
24
|
+
"esm": true,
|
|
25
|
+
"experimentalSpecifierResolution": "node"
|
|
26
|
+
},
|
|
27
|
+
"tsc-alias": {
|
|
28
|
+
"resolveFullPaths": true,
|
|
29
|
+
"verbose": false
|
|
30
|
+
},
|
|
31
|
+
"include": ["src/**/*"],
|
|
32
|
+
"exclude": ["node_modules/**/*", "**/__tests__/**/*"]
|
|
33
|
+
}
|
package/vite.config.ts
ADDED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Jens Pots
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/bin/js-runner.js
DELETED
package/channels/file.ttl
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
@prefix : <https://w3id.org/conn#>.
|
|
2
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
3
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
4
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
5
|
-
|
|
6
|
-
:FileWriterChannel rdfs:subClassOf :WriterChannel.
|
|
7
|
-
:FileReaderChannel rdfs:subClassOf :ReaderChannel.
|
|
8
|
-
[ ] a sh:NodeShape;
|
|
9
|
-
sh:targetClass :FileReaderChannel, :FileWriterChannel;
|
|
10
|
-
sh:property [
|
|
11
|
-
sh:path :filePath;
|
|
12
|
-
sh:name "path";
|
|
13
|
-
sh:maxCount 1;
|
|
14
|
-
sh:minCount 1;
|
|
15
|
-
sh:datatype xsd:string;
|
|
16
|
-
sh:description "Path of the used file";
|
|
17
|
-
], [
|
|
18
|
-
sh:path :fileOnReplace;
|
|
19
|
-
sh:name "onReplace";
|
|
20
|
-
sh:maxCount 1;
|
|
21
|
-
sh:minCount 1;
|
|
22
|
-
sh:datatype xsd:boolean;
|
|
23
|
-
sh:description "Boolean indicating if the files is always replaced, or appended to";
|
|
24
|
-
], [
|
|
25
|
-
sh:path :fileReadFirstContent;
|
|
26
|
-
sh:name "readFirstContent";
|
|
27
|
-
sh:maxCount 1;
|
|
28
|
-
sh:datatype xsd:boolean;
|
|
29
|
-
sh:description "Boolean indicating whether or not the initial content is also a message";
|
|
30
|
-
], [
|
|
31
|
-
sh:path :fileEncoding;
|
|
32
|
-
sh:name "encoding";
|
|
33
|
-
sh:maxCount 1;
|
|
34
|
-
sh:datatype xsd:string;
|
|
35
|
-
sh:description "The encoding used for the file";
|
|
36
|
-
].
|
|
37
|
-
|
package/channels/http.ttl
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
@prefix : <https://w3id.org/conn#>.
|
|
2
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
3
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
4
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
5
|
-
|
|
6
|
-
:HttpReaderChannel rdfs:subClassOf :ReaderChannel.
|
|
7
|
-
:HttpWriterChannel rdfs:subClassOf :WriterChannel.
|
|
8
|
-
[ ] a sh:NodeShape;
|
|
9
|
-
sh:targetClass :HttpReaderChannel;
|
|
10
|
-
sh:property [
|
|
11
|
-
sh:path :httpEndpoint;
|
|
12
|
-
sh:name "endpoint";
|
|
13
|
-
sh:maxCount 1;
|
|
14
|
-
sh:datatype xsd:string;
|
|
15
|
-
sh:description "Used endpoint";
|
|
16
|
-
], [
|
|
17
|
-
sh:path :httpPort;
|
|
18
|
-
sh:name "port";
|
|
19
|
-
sh:maxCount 1;
|
|
20
|
-
sh:datatype xsd:integer;
|
|
21
|
-
sh:description "Used port";
|
|
22
|
-
], [
|
|
23
|
-
sh:path :binary;
|
|
24
|
-
sh:name "binary";
|
|
25
|
-
sh:maxCount 1;
|
|
26
|
-
sh:datatype xsd:boolean;
|
|
27
|
-
sh:description "Stream raw bytes if true";
|
|
28
|
-
], [
|
|
29
|
-
sh:path :waitHandled;
|
|
30
|
-
sh:name "waitHandled";
|
|
31
|
-
sh:maxCount 1;
|
|
32
|
-
sh:datatype xsd:boolean;
|
|
33
|
-
sh:description "Wait for handlers to be have handled the incoming message";
|
|
34
|
-
], [
|
|
35
|
-
sh:path :responseCode;
|
|
36
|
-
sh:name "responseCode";
|
|
37
|
-
sh:maxCount 1;
|
|
38
|
-
sh:datatype xsd:integer;
|
|
39
|
-
sh:description "Specify the expected response code (default 200)";
|
|
40
|
-
].
|
|
41
|
-
|
|
42
|
-
[ ] a sh:NodeShape;
|
|
43
|
-
sh:targetClass :HttpWriterChannel;
|
|
44
|
-
sh:property [
|
|
45
|
-
sh:path :httpEndpoint;
|
|
46
|
-
sh:name "endpoint";
|
|
47
|
-
sh:maxCount 1;
|
|
48
|
-
sh:minCount 1;
|
|
49
|
-
sh:datatype xsd:string;
|
|
50
|
-
sh:description "Used endpoint";
|
|
51
|
-
], [
|
|
52
|
-
sh:path :httpMethod;
|
|
53
|
-
sh:name "method";
|
|
54
|
-
sh:minCount 1;
|
|
55
|
-
sh:maxCount 1;
|
|
56
|
-
sh:datatype xsd:string;
|
|
57
|
-
sh:description "Used method";
|
|
58
|
-
].
|
|
59
|
-
|
package/channels/kafka.ttl
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
@prefix : <https://w3id.org/conn#>.
|
|
2
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
3
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
4
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
5
|
-
|
|
6
|
-
:KafkaReaderChannel rdfs:subClassOf :ReaderChannel.
|
|
7
|
-
:KafkaReaderChannelShape a sh:NodeShape;
|
|
8
|
-
sh:targetClass :KafkaReaderChannel;
|
|
9
|
-
sh:property [
|
|
10
|
-
sh:path :kafkaTopic;
|
|
11
|
-
sh:name "topic";
|
|
12
|
-
sh:minCount 1;
|
|
13
|
-
sh:maxCount 1;
|
|
14
|
-
sh:class :KafkaTopic;
|
|
15
|
-
sh:description "Information about the used topic";
|
|
16
|
-
], [
|
|
17
|
-
sh:path :kafkaConsumer;
|
|
18
|
-
sh:name "consumer";
|
|
19
|
-
sh:minCount 1;
|
|
20
|
-
sh:maxCount 1;
|
|
21
|
-
sh:class :KafkaConsumer;
|
|
22
|
-
sh:description "Information about the kafka consumer";
|
|
23
|
-
], [
|
|
24
|
-
sh:path :kafkaBroker;
|
|
25
|
-
sh:name "broker";
|
|
26
|
-
sh:minCount 1;
|
|
27
|
-
sh:maxCount 1;
|
|
28
|
-
sh:class :KafkaBroker;
|
|
29
|
-
sh:description "Information about the kafka broker";
|
|
30
|
-
].
|
|
31
|
-
|
|
32
|
-
[ ] a sh:NodeShape;
|
|
33
|
-
sh:targetClass :KafkaTopic;
|
|
34
|
-
sh:property [
|
|
35
|
-
sh:path :topicName;
|
|
36
|
-
sh:name "name";
|
|
37
|
-
sh:minCount 1;
|
|
38
|
-
sh:maxCount 1;
|
|
39
|
-
sh:datatype xsd:string;
|
|
40
|
-
sh:description "Name of the topic";
|
|
41
|
-
], [
|
|
42
|
-
sh:path :topicFromBeginning;
|
|
43
|
-
sh:name "fromBeginning";
|
|
44
|
-
sh:maxCount 1;
|
|
45
|
-
sh:datatype xsd:boolean;
|
|
46
|
-
sh:description "Restart the topic from the beginning";
|
|
47
|
-
].
|
|
48
|
-
|
|
49
|
-
[ ] a sh:NodeShape;
|
|
50
|
-
sh:targetClass :KafkaConsumer;
|
|
51
|
-
sh:property [
|
|
52
|
-
sh:path :groupId;
|
|
53
|
-
sh:name "groupId";
|
|
54
|
-
sh:minCount 1;
|
|
55
|
-
sh:maxCount 1;
|
|
56
|
-
sh:datatype xsd:string;
|
|
57
|
-
sh:description "Group identifier";
|
|
58
|
-
].
|
|
59
|
-
|
|
60
|
-
[ ] a sh:NodeShape;
|
|
61
|
-
sh:targetClass :KafkaBroker;
|
|
62
|
-
sh:property [
|
|
63
|
-
sh:path :brokerHost;
|
|
64
|
-
sh:name "hosts";
|
|
65
|
-
sh:minCount 1;
|
|
66
|
-
sh:datatype xsd:string;
|
|
67
|
-
sh:description "Broker host to connect to";
|
|
68
|
-
].
|
|
69
|
-
|
|
70
|
-
:KafkaWriterChannel rdfs:subClassOf :WriterChannel.
|
|
71
|
-
[ ] a sh:NodeShape;
|
|
72
|
-
sh:targetClass :KafkaWriterChannel;
|
|
73
|
-
sh:property [
|
|
74
|
-
sh:path :kafkaTopic;
|
|
75
|
-
sh:name "topic";
|
|
76
|
-
sh:minCount 1;
|
|
77
|
-
sh:maxCount 1;
|
|
78
|
-
sh:class :KafkaTopic;
|
|
79
|
-
sh:description "Information about the used topic";
|
|
80
|
-
], [
|
|
81
|
-
sh:path :kafkaBroker;
|
|
82
|
-
sh:name "broker";
|
|
83
|
-
sh:minCount 1;
|
|
84
|
-
sh:maxCount 1;
|
|
85
|
-
sh:class :KafkaBroker;
|
|
86
|
-
sh:description "Information about the kafka broker";
|
|
87
|
-
], [
|
|
88
|
-
sh:path :kafkaProducer;
|
|
89
|
-
sh:name "producer";
|
|
90
|
-
sh:minCount 1;
|
|
91
|
-
sh:maxCount 1;
|
|
92
|
-
sh:class :KafkaProducer;
|
|
93
|
-
sh:description "Information about the kafka producer";
|
|
94
|
-
].
|
|
95
|
-
|
|
96
|
-
[ ] a sh:NodeShape;
|
|
97
|
-
sh:targetClass :KafkaProducer.
|
|
98
|
-
|
package/channels/ws.ttl
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
@prefix : <https://w3id.org/conn#>.
|
|
2
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
3
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
4
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
5
|
-
|
|
6
|
-
:WsReaderChannel rdfs:subClassOf :ReaderChannel.
|
|
7
|
-
:WsWriterChannel rdfs:subClassOf :WriterChannel.
|
|
8
|
-
[ ] a sh:NodeShape;
|
|
9
|
-
sh:targetClass :WsReaderChannel;
|
|
10
|
-
sh:property [
|
|
11
|
-
sh:name "url";
|
|
12
|
-
sh:path :wsUrl;
|
|
13
|
-
sh:datatype xsd:string;
|
|
14
|
-
sh:maxCount 1;
|
|
15
|
-
sh:minCount 1;
|
|
16
|
-
].
|
|
17
|
-
|
|
18
|
-
[ ] a sh:NodeShape;
|
|
19
|
-
sh:targetClass :WsWriterChannel;
|
|
20
|
-
sh:property [
|
|
21
|
-
sh:name "port";
|
|
22
|
-
sh:path :wsPort;
|
|
23
|
-
sh:datatype xsd:integer;
|
|
24
|
-
sh:maxCount 1;
|
|
25
|
-
sh:minCount 1;
|
|
26
|
-
], [
|
|
27
|
-
sh:name "host";
|
|
28
|
-
sh:path :wsHost;
|
|
29
|
-
sh:datatype xsd:string;
|
|
30
|
-
sh:maxCount 1;
|
|
31
|
-
sh:minCount 1;
|
|
32
|
-
].
|
|
33
|
-
|
package/dist/args.d.ts
DELETED
package/dist/args.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import commandLineArgs from "command-line-args";
|
|
2
|
-
import commandLineUsage from "command-line-usage";
|
|
3
|
-
const optionDefinitions = [
|
|
4
|
-
{
|
|
5
|
-
name: "input",
|
|
6
|
-
type: String,
|
|
7
|
-
defaultOption: true,
|
|
8
|
-
summary: "Specify what input file to start up",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
name: "help",
|
|
12
|
-
alias: "h",
|
|
13
|
-
type: Boolean,
|
|
14
|
-
description: "Display this help message",
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
const sections = [
|
|
18
|
-
{
|
|
19
|
-
header: "Js-runner",
|
|
20
|
-
content: "JS-runner is part of the {italic connector architecture}. Starting from an input file start up all JsProcessors that are defined. Please do not use blank nodes, skolemize your data somewhere else!",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
header: "Synopsis",
|
|
24
|
-
content: "$ js-runner <input>",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
header: "Command List",
|
|
28
|
-
content: [
|
|
29
|
-
{ name: "input", summary: "Specify what input file to start up" },
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
optionList: [optionDefinitions[1]],
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
function validArgs(args) {
|
|
37
|
-
if (!args.input)
|
|
38
|
-
return false;
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
function printUsage() {
|
|
42
|
-
const usage = commandLineUsage(sections);
|
|
43
|
-
console.log(usage);
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
46
|
-
export function getArgs() {
|
|
47
|
-
let args;
|
|
48
|
-
try {
|
|
49
|
-
args = commandLineArgs(optionDefinitions);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
console.error(e);
|
|
53
|
-
printUsage();
|
|
54
|
-
}
|
|
55
|
-
if (args.help || !validArgs(args)) {
|
|
56
|
-
printUsage();
|
|
57
|
-
}
|
|
58
|
-
return args;
|
|
59
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReaderConstructor, WriterConstructor } from "../connectors.js";
|
|
2
|
-
export interface FileReaderConfig {
|
|
3
|
-
path: string;
|
|
4
|
-
onReplace: boolean;
|
|
5
|
-
readFirstContent?: boolean;
|
|
6
|
-
encoding?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface FileWriterConfig {
|
|
9
|
-
path: string;
|
|
10
|
-
onReplace: boolean;
|
|
11
|
-
readFirstContent?: boolean;
|
|
12
|
-
encoding?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const startFileStreamReader: ReaderConstructor<FileReaderConfig>;
|
|
15
|
-
export declare const startFileStreamWriter: WriterConstructor<FileWriterConfig>;
|