@rdfc/js-runner 1.0.0 → 2.0.0-alpha.10
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/.idea/LNKD.tech Editor.xml +194 -0
- package/.idea/codeStyles/Project.xml +52 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/js-runner.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierrc +4 -0
- package/README.md +3 -38
- package/__tests__/channels.test.ts +96 -0
- package/bin/runner.js +8 -0
- package/dist/args.d.ts +3 -3
- package/dist/args.js +50 -51
- package/dist/connectors/file.d.ts +11 -11
- package/dist/connectors/file.js +79 -79
- package/dist/connectors/http.d.ts +10 -10
- package/dist/connectors/http.js +76 -76
- package/dist/connectors/kafka.d.ts +36 -36
- package/dist/connectors/kafka.js +66 -62
- package/dist/connectors/ws.d.ts +6 -6
- package/dist/connectors/ws.js +66 -63
- package/dist/connectors.d.ts +61 -42
- package/dist/connectors.js +155 -132
- package/dist/index.cjs +650 -595
- package/dist/index.d.ts +40 -31
- package/dist/index.js +72 -63
- package/dist/util.d.ts +63 -35
- package/dist/util.js +80 -63
- 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 +48 -0
- package/examples/echo/processors.ttl +82 -0
- package/examples/echo/src/processors.ts +74 -0
- package/examples/echo/tsconfig.json +114 -0
- package/index.ttl +71 -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 +7 -0
- package/lib/index.js +8 -0
- package/lib/jsonld.d.ts +17 -0
- package/lib/jsonld.js +135 -0
- package/lib/logger.d.ts +17 -0
- package/lib/logger.js +49 -0
- package/lib/processor.d.ts +19 -0
- package/lib/processor.js +13 -0
- package/lib/reader.d.ts +30 -0
- package/lib/reader.js +101 -0
- package/lib/reexports.d.ts +3 -0
- package/lib/reexports.js +4 -0
- package/lib/runner.d.ts +26 -0
- package/lib/runner.js +121 -0
- package/lib/testUtils.d.ts +24 -0
- package/lib/testUtils.js +150 -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 +26 -0
- package/lib/writer.js +57 -0
- package/package.json +49 -51
- package/src/client.ts +52 -0
- package/src/convertor.ts +59 -0
- package/src/index.ts +8 -0
- package/src/jsonld.ts +220 -0
- package/src/logger.ts +64 -0
- package/src/processor.ts +39 -0
- package/src/reader.ts +142 -0
- package/src/reexports.ts +6 -0
- package/src/runner.ts +197 -0
- package/src/testUtils.ts +196 -0
- package/src/util_processors.ts +20 -0
- package/src/writer.ts +90 -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/ontology.ttl +0 -169
- 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/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/ontology.ttl
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
@prefix js: <https://w3id.org/conn/js#>.
|
|
2
|
-
@prefix fno: <https://w3id.org/function/ontology#>.
|
|
3
|
-
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>.
|
|
4
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
5
|
-
@prefix : <https://w3id.org/conn#>.
|
|
6
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
7
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
8
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
|
9
|
-
@prefix dc: <http://purl.org/dc/terms/>.
|
|
10
|
-
@prefix rdfl: <https://w3id.org/rdf-lens/ontology#>.
|
|
11
|
-
|
|
12
|
-
[ ] a sh:NodeShape;
|
|
13
|
-
sh:targetClass :Channel;
|
|
14
|
-
sh:property [
|
|
15
|
-
sh:path ( );
|
|
16
|
-
sh:name "id";
|
|
17
|
-
sh:maxCount 1;
|
|
18
|
-
sh:minCount 1;
|
|
19
|
-
sh:datatype xsd:iri;
|
|
20
|
-
], [
|
|
21
|
-
sh:path :reader;
|
|
22
|
-
sh:name "reader";
|
|
23
|
-
sh:maxCount 1;
|
|
24
|
-
sh:datatype xsd:iri;
|
|
25
|
-
], [
|
|
26
|
-
sh:path :writer;
|
|
27
|
-
sh:name "writer";
|
|
28
|
-
sh:maxCount 1;
|
|
29
|
-
sh:datatype xsd:iri;
|
|
30
|
-
].
|
|
31
|
-
|
|
32
|
-
[ ] a sh:NodeShape;
|
|
33
|
-
sh:targetClass :ReaderChannel;
|
|
34
|
-
sh:property [
|
|
35
|
-
sh:path ( );
|
|
36
|
-
sh:name "id";
|
|
37
|
-
sh:maxCount 1;
|
|
38
|
-
sh:minCount 1;
|
|
39
|
-
sh:datatype xsd:iri;
|
|
40
|
-
], [
|
|
41
|
-
sh:path rdf:type;
|
|
42
|
-
sh:name "ty";
|
|
43
|
-
sh:maxCount 1;
|
|
44
|
-
sh:datatype xsd:iri;
|
|
45
|
-
], [
|
|
46
|
-
sh:path ( );
|
|
47
|
-
sh:name "config";
|
|
48
|
-
sh:maxCount 1;
|
|
49
|
-
sh:minCount 1;
|
|
50
|
-
sh:class rdfl:TypedExtract;
|
|
51
|
-
].
|
|
52
|
-
|
|
53
|
-
[ ] a sh:NodeShape;
|
|
54
|
-
sh:targetClass :WriterChannel;
|
|
55
|
-
sh:property [
|
|
56
|
-
sh:path ( );
|
|
57
|
-
sh:name "id";
|
|
58
|
-
sh:maxCount 1;
|
|
59
|
-
sh:minCount 1;
|
|
60
|
-
sh:datatype xsd:iri;
|
|
61
|
-
], [
|
|
62
|
-
sh:path rdf:type;
|
|
63
|
-
sh:name "ty";
|
|
64
|
-
sh:maxCount 1;
|
|
65
|
-
sh:minCount 1;
|
|
66
|
-
sh:datatype xsd:iri;
|
|
67
|
-
], [
|
|
68
|
-
sh:path ( );
|
|
69
|
-
sh:name "config";
|
|
70
|
-
sh:maxCount 1;
|
|
71
|
-
sh:minCount 1;
|
|
72
|
-
sh:class rdfl:TypedExtract;
|
|
73
|
-
].
|
|
74
|
-
|
|
75
|
-
js:JsChannel rdfs:subClassOf :Channel.
|
|
76
|
-
js:JsReaderChannel rdfs:subClassOf :ReaderChannel.
|
|
77
|
-
[ ] a sh:NodeShape;
|
|
78
|
-
sh:targetClass js:JsReaderChannel;
|
|
79
|
-
sh:property [
|
|
80
|
-
sh:path [ sh:inversePath :reader ];
|
|
81
|
-
sh:name "channel";
|
|
82
|
-
sh:maxCount 1;
|
|
83
|
-
sh:minCount 1;
|
|
84
|
-
sh:class :Channel;
|
|
85
|
-
].
|
|
86
|
-
|
|
87
|
-
js:JsWriterChannel rdfs:subClassOf :WriterChannel.
|
|
88
|
-
[ ] a sh:NodeShape;
|
|
89
|
-
sh:targetClass js:JsWriterChannel;
|
|
90
|
-
sh:property [
|
|
91
|
-
sh:path [ sh:inversePath :writer ];
|
|
92
|
-
sh:name "channel";
|
|
93
|
-
sh:maxCount 1;
|
|
94
|
-
sh:minCount 1;
|
|
95
|
-
sh:class :Channel;
|
|
96
|
-
].
|
|
97
|
-
|
|
98
|
-
#
|
|
99
|
-
js:JsChannel a :Channel;
|
|
100
|
-
dc:title "Javascript in memory channel";
|
|
101
|
-
dc:description "Channel only used by the JsRunner, enabling fast in memory communication.";
|
|
102
|
-
:reader :JsReaderChannel;
|
|
103
|
-
:writer :JsWriterChannel.
|
|
104
|
-
|
|
105
|
-
js:JsProcess a :ProcessClass;
|
|
106
|
-
dc:title "Javascript Runner";
|
|
107
|
-
dc:description "The JSRunner is one of the most feature rich runners of the connector architecture. It enables lifting javascript functions to connector architecture components. It allows for fast in memory communication between these processors with the js:JsChannel. More information can be found at https://the-connector-architecture.github.io/site/.";
|
|
108
|
-
:supportsChannel :WsChannel,
|
|
109
|
-
:JsChannel,
|
|
110
|
-
:FileChannel,
|
|
111
|
-
:KafkaChannel,
|
|
112
|
-
:HttpChannel.
|
|
113
|
-
|
|
114
|
-
[ ] a sh:NodeShape;
|
|
115
|
-
sh:targetClass fno:Mapping;
|
|
116
|
-
sh:property [
|
|
117
|
-
sh:class fnom:PositionParameterMapping;
|
|
118
|
-
sh:path fno:parameterMapping;
|
|
119
|
-
sh:name "parameters";
|
|
120
|
-
].
|
|
121
|
-
|
|
122
|
-
[ ] a sh:NodeShape;
|
|
123
|
-
sh:targetClass fnom:PositionParameterMapping;
|
|
124
|
-
sh:property [
|
|
125
|
-
sh:datatype xsd:string;
|
|
126
|
-
sh:path fnom:functionParameter;
|
|
127
|
-
sh:name "parameter";
|
|
128
|
-
sh:maxCount 1;
|
|
129
|
-
], [
|
|
130
|
-
sh:datatype xsd:integer;
|
|
131
|
-
sh:path fnom:implementationParameterPosition;
|
|
132
|
-
sh:name "position";
|
|
133
|
-
sh:maxCount 1;
|
|
134
|
-
].
|
|
135
|
-
|
|
136
|
-
js:JsProcessorShape a sh:NodeShape;
|
|
137
|
-
sh:targetClass js:JsProcess;
|
|
138
|
-
sh:property [
|
|
139
|
-
sh:datatype xsd:iri;
|
|
140
|
-
sh:path ( );
|
|
141
|
-
sh:name "ty";
|
|
142
|
-
sh:maxCount 1;
|
|
143
|
-
sh:minCount 1;
|
|
144
|
-
], [
|
|
145
|
-
sh:datatype xsd:string;
|
|
146
|
-
sh:path js:file;
|
|
147
|
-
sh:name "file";
|
|
148
|
-
sh:maxCount 1;
|
|
149
|
-
sh:minCount 1;
|
|
150
|
-
], [
|
|
151
|
-
sh:datatype xsd:string;
|
|
152
|
-
sh:path js:location;
|
|
153
|
-
sh:name "location";
|
|
154
|
-
sh:maxCount 1;
|
|
155
|
-
sh:minCount 1;
|
|
156
|
-
], [
|
|
157
|
-
sh:datatype xsd:string;
|
|
158
|
-
sh:path js:function;
|
|
159
|
-
sh:name "func";
|
|
160
|
-
sh:maxCount 1;
|
|
161
|
-
sh:minCount 1;
|
|
162
|
-
], [
|
|
163
|
-
sh:class fno:Mapping;
|
|
164
|
-
sh:path js:mapping;
|
|
165
|
-
sh:name "mapping";
|
|
166
|
-
sh:maxCount 1;
|
|
167
|
-
sh:minCount 1;
|
|
168
|
-
].
|
|
169
|
-
|
package/processor/echo.ttl
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@prefix js: <https://w3id.org/conn/js#>.
|
|
2
|
-
@prefix fno: <https://w3id.org/function/ontology#>.
|
|
3
|
-
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>.
|
|
4
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
5
|
-
@prefix : <https://w3id.org/conn#>.
|
|
6
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
7
|
-
|
|
8
|
-
js:Echo a js:JsProcess;
|
|
9
|
-
js:file <./test.js>;
|
|
10
|
-
js:function "echo";
|
|
11
|
-
js:location <./>;
|
|
12
|
-
js:mapping [
|
|
13
|
-
a fno:Mapping;
|
|
14
|
-
fno:parameterMapping [
|
|
15
|
-
a fnom:PositionParameterMapping;
|
|
16
|
-
fnom:functionParameter "Input Channel";
|
|
17
|
-
fnom:implementationParameterPosition "0"^^xsd:int;
|
|
18
|
-
], [
|
|
19
|
-
a fnom:PositionParameterMapping;
|
|
20
|
-
fnom:functionParameter "Output Channel";
|
|
21
|
-
fnom:implementationParameterPosition "1"^^xsd:int;
|
|
22
|
-
];
|
|
23
|
-
].
|
|
24
|
-
|
|
25
|
-
[ ] a sh:NodeShape;
|
|
26
|
-
sh:targetClass js:Echo;
|
|
27
|
-
sh:property [
|
|
28
|
-
sh:class :ReaderChannel;
|
|
29
|
-
sh:path js:input;
|
|
30
|
-
sh:name "Input Channel";
|
|
31
|
-
sh:maxCount 1;
|
|
32
|
-
], [
|
|
33
|
-
sh:class :WriterChannel;
|
|
34
|
-
sh:path js:output;
|
|
35
|
-
sh:name "Output Channel";
|
|
36
|
-
sh:maxCount 1;
|
|
37
|
-
].
|
|
38
|
-
|
package/processor/resc.ttl
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
@prefix js: <https://w3id.org/conn/js#>.
|
|
2
|
-
@prefix fno: <https://w3id.org/function/ontology#>.
|
|
3
|
-
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>.
|
|
4
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
5
|
-
@prefix : <https://w3id.org/conn#>.
|
|
6
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
7
|
-
|
|
8
|
-
<> :install [
|
|
9
|
-
a :LocalInstall;
|
|
10
|
-
:path <./>;
|
|
11
|
-
].
|
|
12
|
-
|
|
13
|
-
js:Resc a js:JsProcess;
|
|
14
|
-
js:file <./test.js>;
|
|
15
|
-
js:function "resc";
|
|
16
|
-
js:location <./>;
|
|
17
|
-
js:mapping [
|
|
18
|
-
a fno:Mapping;
|
|
19
|
-
fno:parameterMapping [
|
|
20
|
-
a fnom:PositionParameterMapping;
|
|
21
|
-
fnom:functionParameter "input";
|
|
22
|
-
fnom:implementationParameterPosition "0"^^xsd:int;
|
|
23
|
-
];
|
|
24
|
-
].
|
|
25
|
-
|
|
26
|
-
[ ] a sh:NodeShape;
|
|
27
|
-
sh:targetClass js:Resc;
|
|
28
|
-
sh:property [
|
|
29
|
-
sh:class :ReaderChannel;
|
|
30
|
-
sh:path js:rescReader;
|
|
31
|
-
sh:name "input";
|
|
32
|
-
sh:maxCount 1;
|
|
33
|
-
].
|
|
34
|
-
|
package/processor/send.ttl
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
@prefix js: <https://w3id.org/conn/js#>.
|
|
2
|
-
@prefix fno: <https://w3id.org/function/ontology#>.
|
|
3
|
-
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>.
|
|
4
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
5
|
-
@prefix : <https://w3id.org/conn#>.
|
|
6
|
-
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
7
|
-
|
|
8
|
-
js:Send a js:JsProcess;
|
|
9
|
-
js:file <./test.js>;
|
|
10
|
-
js:function "send";
|
|
11
|
-
js:location <./>;
|
|
12
|
-
js:mapping [
|
|
13
|
-
a fno:Mapping;
|
|
14
|
-
fno:parameterMapping [
|
|
15
|
-
a fnom:PositionParameterMapping;
|
|
16
|
-
fnom:functionParameter "msg";
|
|
17
|
-
fnom:implementationParameterPosition "0"^^xsd:int;
|
|
18
|
-
], [
|
|
19
|
-
a fnom:PositionParameterMapping;
|
|
20
|
-
fnom:functionParameter "output";
|
|
21
|
-
fnom:implementationParameterPosition "1"^^xsd:int;
|
|
22
|
-
];
|
|
23
|
-
].
|
|
24
|
-
|
|
25
|
-
[ ] a sh:NodeShape;
|
|
26
|
-
sh:targetClass js:Send;
|
|
27
|
-
sh:property [
|
|
28
|
-
sh:datatype xsd:string;
|
|
29
|
-
sh:path js:msg;
|
|
30
|
-
sh:name "msg";
|
|
31
|
-
sh:maxCount 1;
|
|
32
|
-
sh:minCount 1;
|
|
33
|
-
], [
|
|
34
|
-
sh:class :WriterChannel;
|
|
35
|
-
sh:path js:sendWriter;
|
|
36
|
-
sh:name "output";
|
|
37
|
-
sh:maxCount 1;
|
|
38
|
-
sh:minCount 1;
|
|
39
|
-
].
|
|
40
|
-
|
package/processor/test.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import http from "http";
|
|
2
|
-
|
|
3
|
-
function streamToString(ev) {
|
|
4
|
-
const datas = [];
|
|
5
|
-
return new Promise((res) => {
|
|
6
|
-
ev.on("data", (d) => datas.push(d));
|
|
7
|
-
ev.on("end", () => res(Buffer.concat(datas)));
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function send(msg, writer) {
|
|
12
|
-
const host = "0.0.0.0";
|
|
13
|
-
const port = 8000;
|
|
14
|
-
const requestListener = async function (req, res) {
|
|
15
|
-
const data = await streamToString(req);
|
|
16
|
-
const ret = `${msg} ${data}`;
|
|
17
|
-
await writer.push(ret);
|
|
18
|
-
res.writeHead(200);
|
|
19
|
-
res.end(ret);
|
|
20
|
-
};
|
|
21
|
-
const server = http.createServer(requestListener);
|
|
22
|
-
|
|
23
|
-
await new Promise((res) => {
|
|
24
|
-
server.listen(port, host, () => {
|
|
25
|
-
console.log(`Server is running on http://${host}:${port} prefix ${msg}`);
|
|
26
|
-
res();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return () => writer.push("Hallo!");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function resc(reader) {
|
|
34
|
-
reader.data((x) => console.log("data", x));
|
|
35
|
-
}
|