@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
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="http://lnkd.tech/editor#BuiltinGlobalGraphs">
|
|
4
|
+
<option name="disabled">
|
|
5
|
+
<set>
|
|
6
|
+
<option value="DC_AM" />
|
|
7
|
+
<option value="DC_E" />
|
|
8
|
+
<option value="DC_T" />
|
|
9
|
+
<option value="DC_TYPE" />
|
|
10
|
+
<option value="FOAF" />
|
|
11
|
+
<option value="FOAF_ORG" />
|
|
12
|
+
<option value="ML_XS" />
|
|
13
|
+
<option value="OWL2" />
|
|
14
|
+
<option value="RDF" />
|
|
15
|
+
<option value="RDFS" />
|
|
16
|
+
<option value="SHACL" />
|
|
17
|
+
<option value="SHACL_SHACL" />
|
|
18
|
+
<option value="SKOS" />
|
|
19
|
+
<option value="SKOS_ORG" />
|
|
20
|
+
<option value="SPIN_MODELING" />
|
|
21
|
+
<option value="SPIN_MODELING_ORG" />
|
|
22
|
+
<option value="SPIN_SPARQL" />
|
|
23
|
+
<option value="SPIN_SPARQL_ORG" />
|
|
24
|
+
<option value="SPIN_STD" />
|
|
25
|
+
<option value="SPIN_STD_ORG" />
|
|
26
|
+
<option value="VANN" />
|
|
27
|
+
<option value="VOAF" />
|
|
28
|
+
<option value="schemaorg_all_http" />
|
|
29
|
+
<option value="schemaorg_all_https" />
|
|
30
|
+
</set>
|
|
31
|
+
</option>
|
|
32
|
+
</component>
|
|
33
|
+
<component name="http://lnkd.tech/editor#GlobalGraphsAssignments">
|
|
34
|
+
<option name="assignments">
|
|
35
|
+
<map>
|
|
36
|
+
<entry key="urn:tag:lnslr.eu,2018:java:eu.lunisolar.lava.rdfvocab.get.lava.LavaCatalog">
|
|
37
|
+
<value>
|
|
38
|
+
<map>
|
|
39
|
+
<entry key="http://purl.org/dc/dcam">
|
|
40
|
+
<value>
|
|
41
|
+
<set>
|
|
42
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/58ABCE836B2D0022BF4C4C921A8C34C6E2F4B4AB015C4649FCAFD9572ED4DB47" />
|
|
43
|
+
</set>
|
|
44
|
+
</value>
|
|
45
|
+
</entry>
|
|
46
|
+
<entry key="http://purl.org/dc/dcmitype">
|
|
47
|
+
<value>
|
|
48
|
+
<set>
|
|
49
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/F987B11D556E556FEF95D7E9410C1C561FC1B7AC05CCD457128DC8962641B01E" />
|
|
50
|
+
</set>
|
|
51
|
+
</value>
|
|
52
|
+
</entry>
|
|
53
|
+
<entry key="http://purl.org/dc/elements/1.1">
|
|
54
|
+
<value>
|
|
55
|
+
<set>
|
|
56
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/FFB46B7A21E40344B93BC4AD2E6808B24DD53E261995EC3A926DF6BCD87BBFA5" />
|
|
57
|
+
</set>
|
|
58
|
+
</value>
|
|
59
|
+
</entry>
|
|
60
|
+
<entry key="http://purl.org/dc/terms">
|
|
61
|
+
<value>
|
|
62
|
+
<set>
|
|
63
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/13DF401072DD7015BF9D75162F3E41C8138075304B7B9CC1AA1E9C16DB976797" />
|
|
64
|
+
</set>
|
|
65
|
+
</value>
|
|
66
|
+
</entry>
|
|
67
|
+
<entry key="http://purl.org/vocab/vann">
|
|
68
|
+
<value>
|
|
69
|
+
<set>
|
|
70
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/96DE3675A0EAE0C2979D58A21FB808417E0C75DA18EFB9FEB050135BBAC790CA" />
|
|
71
|
+
</set>
|
|
72
|
+
</value>
|
|
73
|
+
</entry>
|
|
74
|
+
<entry key="http://purl.org/vocommons/voaf">
|
|
75
|
+
<value>
|
|
76
|
+
<set>
|
|
77
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/8FF39E5D8A3A8DBE88C790E499F2DAA0FC520CD825EBBE59E79A388361839150" />
|
|
78
|
+
</set>
|
|
79
|
+
</value>
|
|
80
|
+
</entry>
|
|
81
|
+
<entry key="http://schema.org">
|
|
82
|
+
<value>
|
|
83
|
+
<set>
|
|
84
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/62854C817CF24454C9FC1D9DDB605C7B6A4FDE0FF574960D40B0E150166997B6" />
|
|
85
|
+
</set>
|
|
86
|
+
</value>
|
|
87
|
+
</entry>
|
|
88
|
+
<entry key="http://spinrdf.org/sp">
|
|
89
|
+
<value>
|
|
90
|
+
<set>
|
|
91
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/FD2A599D1CE5D78A65896D5CE0A34553533715EE61388AD5F6E2AC75CF36FE94" />
|
|
92
|
+
</set>
|
|
93
|
+
</value>
|
|
94
|
+
</entry>
|
|
95
|
+
<entry key="http://spinrdf.org/spin">
|
|
96
|
+
<value>
|
|
97
|
+
<set>
|
|
98
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/CC3E56C1F2BC6D4213BAF662C0A1FEB97ED968FA21D6C0ED7E44887747C74BC3" />
|
|
99
|
+
</set>
|
|
100
|
+
</value>
|
|
101
|
+
</entry>
|
|
102
|
+
<entry key="http://spinrdf.org/spl">
|
|
103
|
+
<value>
|
|
104
|
+
<set>
|
|
105
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/EAD726323D0CC38A6FD1D332E1781E2601C32537102E82A0995E7FBA87BEF306" />
|
|
106
|
+
</set>
|
|
107
|
+
</value>
|
|
108
|
+
</entry>
|
|
109
|
+
<entry key="http://www.w3.org/1999/02/22-rdf-syntax-ns">
|
|
110
|
+
<value>
|
|
111
|
+
<set>
|
|
112
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/93D52B1A5824C7DD6504CA79C16205C0B740A0BA68B7A14952780F52561186A2" />
|
|
113
|
+
</set>
|
|
114
|
+
</value>
|
|
115
|
+
</entry>
|
|
116
|
+
<entry key="http://www.w3.org/2000/01/rdf-schema">
|
|
117
|
+
<value>
|
|
118
|
+
<set>
|
|
119
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/164A70B28D9AC4B828EEC7D9E4B548A9465A5E2C154D53A142CC5E18566E04EC" />
|
|
120
|
+
</set>
|
|
121
|
+
</value>
|
|
122
|
+
</entry>
|
|
123
|
+
<entry key="http://www.w3.org/2002/07/owl">
|
|
124
|
+
<value>
|
|
125
|
+
<set>
|
|
126
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/718FA1DB7840D3315BFCE94398543F91437EF6FE933054FD93F5471D19262FC5" />
|
|
127
|
+
</set>
|
|
128
|
+
</value>
|
|
129
|
+
</entry>
|
|
130
|
+
<entry key="http://www.w3.org/2004/02/skos/core">
|
|
131
|
+
<value>
|
|
132
|
+
<set>
|
|
133
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/2D0AC9174D7C53393C546802A19669534B44590EA00D807F4C149C6FFB4CF6BB" />
|
|
134
|
+
</set>
|
|
135
|
+
</value>
|
|
136
|
+
</entry>
|
|
137
|
+
<entry key="http://www.w3.org/ns/shacl">
|
|
138
|
+
<value>
|
|
139
|
+
<set>
|
|
140
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/0E5D8AEA0EAB98A072D4A02FAAEE1EE914EC99EAB2CA473429726FAED4A13F69" />
|
|
141
|
+
</set>
|
|
142
|
+
</value>
|
|
143
|
+
</entry>
|
|
144
|
+
<entry key="http://www.w3.org/ns/shacl-shacl">
|
|
145
|
+
<value>
|
|
146
|
+
<set>
|
|
147
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/250D6274CADC8FA5359D5DBC28BC943F1DE01ADB7FFC3369681216B583122E4A" />
|
|
148
|
+
</set>
|
|
149
|
+
</value>
|
|
150
|
+
</entry>
|
|
151
|
+
<entry key="http://xmlns.com/foaf/0.1">
|
|
152
|
+
<value>
|
|
153
|
+
<set>
|
|
154
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/630DAF410F3C34ED9FE7302E4A8A5439488B68375789E7CF5DD137892DAC6789" />
|
|
155
|
+
</set>
|
|
156
|
+
</value>
|
|
157
|
+
</entry>
|
|
158
|
+
<entry key="https://schema.org">
|
|
159
|
+
<value>
|
|
160
|
+
<set>
|
|
161
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/24D9BBA4119AA8C8708767B12B3BCACBC8BB8750CDB111F573996899AA29F089" />
|
|
162
|
+
</set>
|
|
163
|
+
</value>
|
|
164
|
+
</entry>
|
|
165
|
+
<entry key="urn:tag:lnkd.tech,2020:MissingLink:XMLDataTypes">
|
|
166
|
+
<value>
|
|
167
|
+
<set>
|
|
168
|
+
<option value="urn:tag:lnkd.tech,2023:digest:sha-256/E7430AD6C9345DEC6A8C7E0665607B34D1F6B6FDC47A30FAC3FB146179213174" />
|
|
169
|
+
</set>
|
|
170
|
+
</value>
|
|
171
|
+
</entry>
|
|
172
|
+
</map>
|
|
173
|
+
</value>
|
|
174
|
+
</entry>
|
|
175
|
+
</map>
|
|
176
|
+
</option>
|
|
177
|
+
</component>
|
|
178
|
+
<component name="http://lnkd.tech/editor#GraphVisibilityConfig">
|
|
179
|
+
<option name="visibility">
|
|
180
|
+
<map>
|
|
181
|
+
<entry key="DOCUMENTATION">
|
|
182
|
+
<value>
|
|
183
|
+
<Visibility />
|
|
184
|
+
</value>
|
|
185
|
+
</entry>
|
|
186
|
+
<entry key="GENERAL">
|
|
187
|
+
<value>
|
|
188
|
+
<Visibility />
|
|
189
|
+
</value>
|
|
190
|
+
</entry>
|
|
191
|
+
</map>
|
|
192
|
+
</option>
|
|
193
|
+
</component>
|
|
194
|
+
</project>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
+
<code_scheme name="Project" version="173">
|
|
3
|
+
<HTMLCodeStyleSettings>
|
|
4
|
+
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
+
</HTMLCodeStyleSettings>
|
|
6
|
+
<JSCodeStyleSettings version="0">
|
|
7
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
8
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
9
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
10
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
11
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
12
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
13
|
+
</JSCodeStyleSettings>
|
|
14
|
+
<TypeScriptCodeStyleSettings version="0">
|
|
15
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
16
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
17
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
18
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
19
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
20
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
21
|
+
</TypeScriptCodeStyleSettings>
|
|
22
|
+
<VueCodeStyleSettings>
|
|
23
|
+
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
24
|
+
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
25
|
+
</VueCodeStyleSettings>
|
|
26
|
+
<codeStyleSettings language="HTML">
|
|
27
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
28
|
+
<indentOptions>
|
|
29
|
+
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
30
|
+
</indentOptions>
|
|
31
|
+
</codeStyleSettings>
|
|
32
|
+
<codeStyleSettings language="JavaScript">
|
|
33
|
+
<option name="INDENT_CASE_FROM_SWITCH" value="false" />
|
|
34
|
+
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
|
35
|
+
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
|
36
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
37
|
+
</codeStyleSettings>
|
|
38
|
+
<codeStyleSettings language="TypeScript">
|
|
39
|
+
<option name="INDENT_CASE_FROM_SWITCH" value="false" />
|
|
40
|
+
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
|
41
|
+
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
|
42
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
43
|
+
</codeStyleSettings>
|
|
44
|
+
<codeStyleSettings language="Vue">
|
|
45
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
46
|
+
<indentOptions>
|
|
47
|
+
<option name="INDENT_SIZE" value="4" />
|
|
48
|
+
<option name="TAB_SIZE" value="4" />
|
|
49
|
+
</indentOptions>
|
|
50
|
+
</codeStyleSettings>
|
|
51
|
+
</code_scheme>
|
|
52
|
+
</component>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/js-runner.iml" filepath="$PROJECT_DIR$/.idea/js-runner.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RDFC-2 Javascript runner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Communitcates with the rdfc orchestrator though grpc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Process definition
|
|
8
|
-
|
|
9
|
-
Each js process must have `js:file`, `js:function` and `js:mapping` objects.
|
|
10
|
-
|
|
11
|
-
- `js:file` points to the location of the main javascript file, containing the function.
|
|
12
|
-
- `js:location` points to the starting location for `js:file` relative from the current file.
|
|
13
|
-
- `js:function` points to the function name in the file.
|
|
14
|
-
- `js:mapping` is a `fno:Mapping` object that links properties to function arguments.
|
|
15
|
-
|
|
16
|
-
When you declare a new js process, it is required to add a SHACL shape.
|
|
17
|
-
Each `sh:property` is accounted for, noting the type `sh:class` or `sh:datatype`.
|
|
18
|
-
|
|
19
|
-
Example definitions are available in `processor/configs/*.ttl`.
|
|
20
|
-
|
|
21
|
-
## Pipeline configuration
|
|
22
|
-
|
|
23
|
-
In a js pipeline you can use all declared js processes, as defined in their SHACL shapes.
|
|
24
|
-
|
|
25
|
-
An example can be found in `input.ttl`, here a `js:Send` process and a `js:Resc` process are defined.
|
|
26
|
-
`js:Send` takes in a message to send, and a channel to send it to.
|
|
27
|
-
`js:Resc` only takes a channel to read from.
|
|
28
|
-
|
|
29
|
-
(implementation can be found in `procossor/test.js`)
|
|
30
|
-
|
|
31
|
-
Note: currently Websockets are configured, but changing the configuration to use the JsReaderChannel and JsWriterChannel will work too, even without a serialization step.
|
|
32
|
-
|
|
33
|
-
You can execute this pipeline with
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
tsc
|
|
37
|
-
npx bin/js-runner.js input.ttl
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
This example input configuration file uses `owl:imports` to specify additional configuration files.
|
|
5
|
+
Take a look at the example pipeline at `./examples/echo/` for example processors and an example pipeline.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import { ReaderInstance } from '../src/reader'
|
|
3
|
+
import { one, uri, client, logger } from '../src/testUtils'
|
|
4
|
+
|
|
5
|
+
const encoder = new TextEncoder()
|
|
6
|
+
|
|
7
|
+
describe('Reader', async () => {
|
|
8
|
+
test('handles string', async () => {
|
|
9
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
10
|
+
|
|
11
|
+
const promise = one(reader.strings())
|
|
12
|
+
reader.handleMsg({ data: encoder.encode('Hello world'), channel: uri })
|
|
13
|
+
const out = await promise
|
|
14
|
+
|
|
15
|
+
expect(out).toEqual('Hello world')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('handles closed string', async () => {
|
|
19
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
20
|
+
|
|
21
|
+
const promise = one(reader.strings())
|
|
22
|
+
reader.close()
|
|
23
|
+
const out = await promise
|
|
24
|
+
|
|
25
|
+
expect(out).toEqual(undefined)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('handles strings', async () => {
|
|
29
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
30
|
+
|
|
31
|
+
const msgsPromise = (async () => {
|
|
32
|
+
const msgs: string[] = []
|
|
33
|
+
for await (const msg of reader.strings()) {
|
|
34
|
+
msgs.push(msg)
|
|
35
|
+
}
|
|
36
|
+
return msgs
|
|
37
|
+
})()
|
|
38
|
+
reader.handleMsg({ data: encoder.encode('Hello'), channel: uri })
|
|
39
|
+
reader.handleMsg({ data: encoder.encode('World'), channel: uri })
|
|
40
|
+
reader.close()
|
|
41
|
+
|
|
42
|
+
const msgs = await msgsPromise
|
|
43
|
+
|
|
44
|
+
expect(msgs).toEqual(['Hello', 'World'])
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('handles buffer', async () => {
|
|
48
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
49
|
+
|
|
50
|
+
const data = encoder.encode('Hello world')
|
|
51
|
+
const promise = one(reader.buffers())
|
|
52
|
+
reader.handleMsg({ data, channel: uri })
|
|
53
|
+
const out = await promise
|
|
54
|
+
|
|
55
|
+
expect(out).toEqual(data)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('handles buffers', async () => {
|
|
59
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
60
|
+
|
|
61
|
+
const data = encoder.encode('Hello world')
|
|
62
|
+
const promise = one(reader.buffers())
|
|
63
|
+
reader.handleMsg({ data, channel: uri })
|
|
64
|
+
const out = await promise
|
|
65
|
+
|
|
66
|
+
expect(out).toEqual(data)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
test('handles stream', async () => {
|
|
70
|
+
const reader = new ReaderInstance(uri, client, logger)
|
|
71
|
+
|
|
72
|
+
const nextStream = client.nextStream()
|
|
73
|
+
const promise = one(reader.streams())
|
|
74
|
+
reader.handleStreamingMessage({ id: { id: 5 }, channel: uri })
|
|
75
|
+
const stream = await nextStream
|
|
76
|
+
|
|
77
|
+
stream.push('Hello')
|
|
78
|
+
stream.push('World')
|
|
79
|
+
console.log(stream.eventNames())
|
|
80
|
+
|
|
81
|
+
const out = await promise
|
|
82
|
+
const msgsPromise = (async () => {
|
|
83
|
+
const msgs: Uint8Array[] = []
|
|
84
|
+
for await (const msg of out!) {
|
|
85
|
+
msgs.push(msg)
|
|
86
|
+
}
|
|
87
|
+
return msgs
|
|
88
|
+
})()
|
|
89
|
+
|
|
90
|
+
stream.emit('end')
|
|
91
|
+
stream.emit('close')
|
|
92
|
+
|
|
93
|
+
const msgs = await msgsPromise
|
|
94
|
+
console.log(msgs)
|
|
95
|
+
})
|
|
96
|
+
})
|
package/bin/runner.js
ADDED
package/dist/args.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type Args = {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
export declare function getArgs(): Args
|
|
2
|
+
input: string
|
|
3
|
+
}
|
|
4
|
+
export declare function getArgs(): Args
|
package/dist/args.js
CHANGED
|
@@ -1,59 +1,58 @@
|
|
|
1
|
-
import commandLineArgs from
|
|
2
|
-
import commandLineUsage from
|
|
1
|
+
import commandLineArgs from 'command-line-args'
|
|
2
|
+
import commandLineUsage from 'command-line-usage'
|
|
3
3
|
const optionDefinitions = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
]
|
|
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
17
|
const sections = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
{
|
|
19
|
+
header: 'Js-runner',
|
|
20
|
+
content:
|
|
21
|
+
'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!',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
header: 'Synopsis',
|
|
25
|
+
content: '$ js-runner <input>',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
header: 'Command List',
|
|
29
|
+
content: [
|
|
30
|
+
{ name: 'input', summary: 'Specify what input file to start up' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
optionList: [optionDefinitions[1]],
|
|
35
|
+
},
|
|
36
|
+
]
|
|
36
37
|
function validArgs(args) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return true;
|
|
38
|
+
if (!args.input) return false
|
|
39
|
+
return true
|
|
40
40
|
}
|
|
41
41
|
function printUsage() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const usage = commandLineUsage(sections)
|
|
43
|
+
console.log(usage)
|
|
44
|
+
process.exit(0)
|
|
45
45
|
}
|
|
46
46
|
export function getArgs() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return args;
|
|
47
|
+
let args
|
|
48
|
+
try {
|
|
49
|
+
args = commandLineArgs(optionDefinitions)
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error(e)
|
|
52
|
+
printUsage()
|
|
53
|
+
}
|
|
54
|
+
if (args.help || !validArgs(args)) {
|
|
55
|
+
printUsage()
|
|
56
|
+
}
|
|
57
|
+
return args
|
|
59
58
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ReaderConstructor, WriterConstructor } from
|
|
1
|
+
import { ReaderConstructor, WriterConstructor } from '../connectors.js'
|
|
2
2
|
export interface FileReaderConfig {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
path: string
|
|
4
|
+
onReplace: boolean
|
|
5
|
+
readFirstContent?: boolean
|
|
6
|
+
encoding?: string
|
|
7
7
|
}
|
|
8
8
|
export interface FileWriterConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
path: string
|
|
10
|
+
onReplace: boolean
|
|
11
|
+
readFirstContent?: boolean
|
|
12
|
+
encoding?: string
|
|
13
13
|
}
|
|
14
|
-
export declare const startFileStreamReader: ReaderConstructor<FileReaderConfig
|
|
15
|
-
export declare const startFileStreamWriter: WriterConstructor<FileWriterConfig
|
|
14
|
+
export declare const startFileStreamReader: ReaderConstructor<FileReaderConfig>
|
|
15
|
+
export declare const startFileStreamWriter: WriterConstructor<FileWriterConfig>
|