@rdfc/js-runner 2.0.0-alpha.10 → 2.0.0-alpha.11
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/.editorconfig +9 -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/index.ttl +3 -0
- package/examples/echo/minimal.ttl +90 -0
- package/examples/echo/shacl.ttl +9 -0
- package/examples/echo/shape.ttl +1339 -0
- package/examples/echo/test.ttl +11 -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.js +2 -2
- package/lib/testUtils.d.ts +8 -8
- package/lib/testUtils.js +32 -32
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/minimal.ttl +99 -0
- package/package.json +1 -1
- package/src/client.ts +15 -15
- package/src/testUtils.ts +140 -140
- package/.idea/LNKD.tech Editor.xml +0 -194
- package/.idea/codeStyles/Project.xml +0 -52
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- 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/dist/connectors.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { createTermNamespace } from '@treecg/types'
|
|
2
|
-
import {
|
|
3
|
-
startFileStreamReader,
|
|
4
|
-
startFileStreamWriter,
|
|
5
|
-
} from './connectors/file.js'
|
|
6
|
-
export * from './connectors/file.js'
|
|
7
|
-
import { startWsStreamReader, startWsStreamWriter } from './connectors/ws.js'
|
|
8
|
-
export * from './connectors/ws.js'
|
|
9
|
-
import {
|
|
10
|
-
startKafkaStreamReader,
|
|
11
|
-
startKafkaStreamWriter,
|
|
12
|
-
} from './connectors/kafka.js'
|
|
13
|
-
export * from './connectors/kafka.js'
|
|
14
|
-
import {
|
|
15
|
-
startHttpStreamReader,
|
|
16
|
-
startHttpStreamWriter,
|
|
17
|
-
} from './connectors/http.js'
|
|
18
|
-
import { LOG } from './util.js'
|
|
19
|
-
export * from './connectors/http.js'
|
|
20
|
-
export const Conn = createTermNamespace(
|
|
21
|
-
'https://w3id.org/conn#',
|
|
22
|
-
'FileReaderChannel',
|
|
23
|
-
'FileWriterChannel',
|
|
24
|
-
'HttpReaderChannel',
|
|
25
|
-
'HttpWriterChannel',
|
|
26
|
-
'KafkaReaderChannel',
|
|
27
|
-
'KafkaWriterChannel',
|
|
28
|
-
'WsReaderChannel',
|
|
29
|
-
'WsWriterChannel',
|
|
30
|
-
'WriterChannel',
|
|
31
|
-
'ReaderChannel',
|
|
32
|
-
)
|
|
33
|
-
export const JsOntology = createTermNamespace(
|
|
34
|
-
'https://w3id.org/conn/js#',
|
|
35
|
-
'JsProcess',
|
|
36
|
-
'JsChannel',
|
|
37
|
-
'JsReaderChannel',
|
|
38
|
-
'JsWriterChannel',
|
|
39
|
-
)
|
|
40
|
-
export class ChannelFactory {
|
|
41
|
-
inits = []
|
|
42
|
-
jsChannelsNamedNodes = {}
|
|
43
|
-
jsChannelsBlankNodes = {}
|
|
44
|
-
createReader(config) {
|
|
45
|
-
LOG.channel('Creating reader %s: a %s', config.id.value, config.ty.value)
|
|
46
|
-
if (config.ty.equals(Conn.FileReaderChannel)) {
|
|
47
|
-
const { reader, init } = startFileStreamReader(config.config)
|
|
48
|
-
this.inits.push(init)
|
|
49
|
-
return reader
|
|
50
|
-
}
|
|
51
|
-
if (config.ty.equals(Conn.WsReaderChannel)) {
|
|
52
|
-
const { reader, init } = startWsStreamReader(config.config)
|
|
53
|
-
this.inits.push(init)
|
|
54
|
-
return reader
|
|
55
|
-
}
|
|
56
|
-
if (config.ty.equals(Conn.KafkaReaderChannel)) {
|
|
57
|
-
const { reader, init } = startKafkaStreamReader(config.config)
|
|
58
|
-
this.inits.push(init)
|
|
59
|
-
return reader
|
|
60
|
-
}
|
|
61
|
-
if (config.ty.equals(Conn.HttpReaderChannel)) {
|
|
62
|
-
const { reader, init } = startHttpStreamReader(config.config)
|
|
63
|
-
this.inits.push(init)
|
|
64
|
-
return reader
|
|
65
|
-
}
|
|
66
|
-
if (config.ty.equals(JsOntology.JsReaderChannel)) {
|
|
67
|
-
const c = config.config
|
|
68
|
-
if (c.channel) {
|
|
69
|
-
const id = c.channel.id.value
|
|
70
|
-
if (c.channel.id.termType === 'NamedNode') {
|
|
71
|
-
if (!this.jsChannelsNamedNodes[id]) {
|
|
72
|
-
this.jsChannelsNamedNodes[id] = new SimpleStream()
|
|
73
|
-
}
|
|
74
|
-
return this.jsChannelsNamedNodes[id]
|
|
75
|
-
}
|
|
76
|
-
if (c.channel.id.termType === 'BlankNode') {
|
|
77
|
-
if (!this.jsChannelsBlankNodes[id]) {
|
|
78
|
-
this.jsChannelsBlankNodes[id] = new SimpleStream()
|
|
79
|
-
}
|
|
80
|
-
return this.jsChannelsBlankNodes[id]
|
|
81
|
-
}
|
|
82
|
-
throw 'Should have found a thing'
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
throw 'Unknown reader channel ' + config.ty.value
|
|
86
|
-
}
|
|
87
|
-
createWriter(config) {
|
|
88
|
-
LOG.channel('Creating writer %s: a %s', config.id.value, config.ty.value)
|
|
89
|
-
if (config.ty.equals(Conn.FileWriterChannel)) {
|
|
90
|
-
const { writer, init } = startFileStreamWriter(config.config)
|
|
91
|
-
this.inits.push(init)
|
|
92
|
-
return writer
|
|
93
|
-
}
|
|
94
|
-
if (config.ty.equals(Conn.WsWriterChannel)) {
|
|
95
|
-
const { writer, init } = startWsStreamWriter(config.config)
|
|
96
|
-
this.inits.push(init)
|
|
97
|
-
return writer
|
|
98
|
-
}
|
|
99
|
-
if (config.ty.equals(Conn.KafkaWriterChannel)) {
|
|
100
|
-
const { writer, init } = startKafkaStreamWriter(config.config)
|
|
101
|
-
this.inits.push(init)
|
|
102
|
-
return writer
|
|
103
|
-
}
|
|
104
|
-
if (config.ty.equals(Conn.HttpWriterChannel)) {
|
|
105
|
-
const { writer, init } = startHttpStreamWriter(config.config)
|
|
106
|
-
this.inits.push(init)
|
|
107
|
-
return writer
|
|
108
|
-
}
|
|
109
|
-
if (config.ty.equals(JsOntology.JsWriterChannel)) {
|
|
110
|
-
const c = config.config
|
|
111
|
-
if (c.channel) {
|
|
112
|
-
const id = c.channel.id.value
|
|
113
|
-
if (c.channel.id.termType === 'NamedNode') {
|
|
114
|
-
if (!this.jsChannelsNamedNodes[id]) {
|
|
115
|
-
this.jsChannelsNamedNodes[id] = new SimpleStream()
|
|
116
|
-
}
|
|
117
|
-
return this.jsChannelsNamedNodes[id]
|
|
118
|
-
}
|
|
119
|
-
if (c.channel.id.termType === 'BlankNode') {
|
|
120
|
-
if (!this.jsChannelsBlankNodes[id]) {
|
|
121
|
-
this.jsChannelsBlankNodes[id] = new SimpleStream()
|
|
122
|
-
}
|
|
123
|
-
return this.jsChannelsBlankNodes[id]
|
|
124
|
-
}
|
|
125
|
-
throw 'Should have found a thing'
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
throw 'Unknown writer channel ' + config.ty.value
|
|
129
|
-
}
|
|
130
|
-
async init() {
|
|
131
|
-
await Promise.all(this.inits.map((x) => x()))
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export class SimpleStream {
|
|
135
|
-
dataHandlers = []
|
|
136
|
-
endHandlers = []
|
|
137
|
-
disconnect
|
|
138
|
-
lastElement
|
|
139
|
-
ended = false
|
|
140
|
-
constructor(onDisconnect) {
|
|
141
|
-
this.disconnect = onDisconnect || (async () => {})
|
|
142
|
-
}
|
|
143
|
-
data(listener) {
|
|
144
|
-
this.dataHandlers.push(listener)
|
|
145
|
-
return this
|
|
146
|
-
}
|
|
147
|
-
async push(data) {
|
|
148
|
-
if (this.ended) {
|
|
149
|
-
throw new Error('Trying to push to a stream that has ended!')
|
|
150
|
-
}
|
|
151
|
-
this.lastElement = data
|
|
152
|
-
await Promise.all(this.dataHandlers.map((handler) => handler(data)))
|
|
153
|
-
}
|
|
154
|
-
async end() {
|
|
155
|
-
await this.disconnect()
|
|
156
|
-
await Promise.all(this.endHandlers.map((handler) => handler()))
|
|
157
|
-
this.ended = true
|
|
158
|
-
}
|
|
159
|
-
on(event, listener) {
|
|
160
|
-
if (event === 'data') {
|
|
161
|
-
this.dataHandlers.push(listener)
|
|
162
|
-
}
|
|
163
|
-
if (event === 'end') {
|
|
164
|
-
this.endHandlers.push(listener)
|
|
165
|
-
}
|
|
166
|
-
return this
|
|
167
|
-
}
|
|
168
|
-
}
|