@rdfc/js-runner 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
Files changed (56) hide show
  1. package/.idea/LNKD.tech Editor.xml +194 -0
  2. package/.idea/codeStyles/Project.xml +52 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/js-runner.iml +12 -0
  6. package/{examples/echo/.idea → .idea}/modules.xml +1 -1
  7. package/.idea/vcs.xml +6 -0
  8. package/dist/args.d.ts +4 -0
  9. package/dist/args.js +58 -0
  10. package/dist/connectors/file.d.ts +15 -0
  11. package/dist/connectors/file.js +89 -0
  12. package/dist/connectors/http.d.ts +14 -0
  13. package/dist/connectors/http.js +82 -0
  14. package/dist/connectors/kafka.d.ts +48 -0
  15. package/dist/connectors/kafka.js +68 -0
  16. package/dist/connectors/ws.d.ts +10 -0
  17. package/dist/connectors/ws.js +72 -0
  18. package/dist/connectors.d.ts +73 -0
  19. package/dist/connectors.js +168 -0
  20. package/dist/index.cjs +732 -0
  21. package/dist/index.d.ts +42 -0
  22. package/dist/index.js +83 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -0
  24. package/dist/util.d.ts +71 -0
  25. package/dist/util.js +92 -0
  26. package/lib/client.js +1 -1
  27. package/lib/index.d.ts +1 -0
  28. package/lib/index.js +2 -1
  29. package/lib/logger.d.ts +3 -1
  30. package/lib/logger.js +23 -1
  31. package/lib/reader.js +1 -1
  32. package/lib/runner.js +3 -3
  33. package/lib/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +1 -1
  35. package/src/client.ts +14 -16
  36. package/src/index.ts +1 -0
  37. package/src/logger.ts +27 -1
  38. package/src/reader.ts +8 -10
  39. package/src/runner.ts +4 -6
  40. package/.editorconfig +0 -9
  41. package/__tests__/channels.test.js +0 -117
  42. package/examples/echo/.idea/echo.iml +0 -9
  43. package/examples/echo/.idea/misc.xml +0 -6
  44. package/examples/echo/.idea/vcs.xml +0 -7
  45. package/examples/echo/.swls/config.json +0 -1
  46. package/examples/echo/index.ttl +0 -3
  47. package/examples/echo/minimal.ttl +0 -90
  48. package/examples/echo/shacl.ttl +0 -9
  49. package/examples/echo/shape.ttl +0 -1339
  50. package/examples/echo/src/processors.js +0 -123
  51. package/examples/echo/test.ttl +0 -11
  52. package/examples/echo/untitled:/types/MyType.ttl +0 -0
  53. package/file:/home/silvius/Projects/mumo-pipeline/ldes/http_3A_2F_2Fdata.mumo.be_2Fstreams_2Fnodes_2Fdefault/root/index.trig +0 -3
  54. package/ldes/http_3A_2F_2Fdata.mumo.be_2Fstreams_2Fnodes_2Fdefault/root/index.trig +0 -3
  55. package/minimal.ttl +0 -99
  56. package/vite.config.js +0 -11
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __asyncValues = (this && this.__asyncValues) || function (o) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var m = o[Symbol.asyncIterator], i;
14
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.SendProcessor = exports.LogProcessor = exports.EchoProcessor = exports.TestProcessor = void 0;
20
- const js_runner_1 = require("@rdfc/js-runner");
21
- class TestProcessor extends js_runner_1.Processor {
22
- init() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- this.logger.info(JSON.stringify(this.args, undefined, 2));
25
- });
26
- }
27
- transform() {
28
- return __awaiter(this, void 0, void 0, function* () { });
29
- }
30
- produce() {
31
- return __awaiter(this, void 0, void 0, function* () { });
32
- }
33
- }
34
- exports.TestProcessor = TestProcessor;
35
- class EchoProcessor extends js_runner_1.Processor {
36
- init() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- this.logger.info('Init echo processor');
39
- });
40
- }
41
- transform() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- var _a, e_1, _b, _c;
44
- try {
45
- for (var _d = true, _e = __asyncValues(this.reader.streams()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
46
- _c = _f.value;
47
- _d = false;
48
- const msg = _c;
49
- this.logger.info('Echoing message');
50
- yield this.writer.stream(msg);
51
- }
52
- }
53
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
54
- finally {
55
- try {
56
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
57
- }
58
- finally { if (e_1) throw e_1.error; }
59
- }
60
- yield this.writer.close();
61
- this.logger.info('closed');
62
- });
63
- }
64
- produce() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- // nothing
67
- });
68
- }
69
- }
70
- exports.EchoProcessor = EchoProcessor;
71
- class LogProcessor extends js_runner_1.Processor {
72
- produce() {
73
- return __awaiter(this, void 0, void 0, function* () { });
74
- }
75
- init() {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- this.logger.info('Init log processor');
78
- });
79
- }
80
- transform() {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- var _a, e_2, _b, _c;
83
- try {
84
- for (var _d = true, _e = __asyncValues(this.args.reader.strings()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
85
- _c = _f.value;
86
- _d = false;
87
- const msg = _c;
88
- this.logger.info('Got msg' + msg);
89
- }
90
- }
91
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
92
- finally {
93
- try {
94
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
95
- }
96
- finally { if (e_2) throw e_2.error; }
97
- }
98
- });
99
- }
100
- }
101
- exports.LogProcessor = LogProcessor;
102
- class SendProcessor extends js_runner_1.Processor {
103
- init() {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- this.logger.info('Init send processor');
106
- });
107
- }
108
- transform() {
109
- return __awaiter(this, void 0, void 0, function* () { });
110
- }
111
- produce() {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- for (const msg of this.get('msgs')) {
114
- yield this.get('writer').string(msg);
115
- this.logger.info('Sending ' + msg);
116
- yield new Promise((res) => setTimeout(res, 1000));
117
- }
118
- yield this.get('writer').close();
119
- this.logger.info('Closed');
120
- });
121
- }
122
- }
123
- exports.SendProcessor = SendProcessor;
@@ -1,11 +0,0 @@
1
- @prefix rdfc: <https://w3id.org/rdf-connect#>.
2
- @prefix foaf: <http://xmlns.com/foaf/0.1/>.
3
-
4
- [ ] foaf:knows [
5
- foaf:name "Arthur";
6
- foaf:img <img>;
7
- foaf:knows <me>;
8
- ];
9
- foaf:name "Arthur".
10
-
11
- <b> <c> <D>
File without changes
@@ -1,3 +0,0 @@
1
- <../../index.trig> a <https://w3id.org/ldes#EventStream>.
2
- <index.trig> a <https://w3id.org/tree#Node>;
3
- <http://purl.org/dc/terms/isPartOf> <../../index.trig>.
@@ -1,3 +0,0 @@
1
- <../../index.trig> a <https://w3id.org/ldes#EventStream>.
2
- <index.trig> a <https://w3id.org/tree#Node>;
3
- <http://purl.org/dc/terms/isPartOf> <../../index.trig>.
package/minimal.ttl DELETED
@@ -1,99 +0,0 @@
1
- @prefix prov: <http://www.w3.org/ns/prov#>.
2
- @prefix sds: <https://w3id.org/sds#>.
3
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
4
- @prefix owl: <http://www.w3.org/2002/07/owl#>.
5
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
6
- @prefix sh: <http://www.w3.org/ns/shacl#>.
7
- @prefix rdfc: <https://w3id.org/rdf-connect#>.
8
-
9
- ############################################################
10
- # General statements #
11
- ############################################################
12
- # sds:Activity is a prov:Activity
13
- sds:Activity rdfs:subClassOf prov:Activity.
14
-
15
- # rdfc:Processor too
16
- rdfc:Processor rdfs:subClassOf sds:Activity.
17
-
18
- # sds:implementationOf is subClassOf
19
- sds:implementationOf rdfs:subPropertyOf rdfs:subClassOf.
20
-
21
- ############################################################
22
- # Javascript statements #
23
- ############################################################
24
- # specialized for js too
25
- rdfc:jsImplementationOf rdfs:subPropertyOf sds:implementationOf.
26
-
27
- # A node runner, runs things that are rdfc:jsImplementationOf rdfc:Processor (aka, rdfs:subClassOf prov:Activity)
28
- rdfc:NodeRunner a rdfc:Runner;
29
- rdfc:handlesSubjectsOf rdfc:jsImplementationOf;
30
- rdfc:command "npx js-runner".
31
-
32
- # This shouldn't be necessary, should work with sh:targetSubjectsOf
33
- # rdfc:processor_definition <JsProcessorShape>.
34
- #
35
- # Shape that a Js Processor should fulfil;
36
- [ ] a sh:NodeShape;
37
- # This shouldn't be necessary,should work with sh:targetSubjectsOf and this isn't a real Class
38
- sh:targetClass <JsProcessorShape>;
39
- # We target it with jsImplementationOf
40
- sh:targetSubjectsOf rdfc:jsImplementationOf;
41
- sh:property [
42
- sh:path rdfc:entrypoint;
43
- sh:name "location";
44
- sh:minCount 1;
45
- sh:maxCount 1;
46
- sh:datatype xsd:iri;
47
- ], [
48
- sh:path rdfc:file;
49
- sh:name "file";
50
- sh:minCount 1;
51
- sh:maxCount 1;
52
- sh:datatype xsd:iri;
53
- ], [
54
- sh:path rdfc:class;
55
- sh:name "clazz";
56
- sh:maxCount 1;
57
- sh:datatype xsd:string;
58
- ].
59
-
60
- ############################################################
61
- # Processor statements #
62
- ############################################################
63
- rdfc:FooBarProcessor a owl:Class;
64
- rdfs:label "My Epic FooBar Processor";
65
- rdfs:description "FooBars everything!";
66
- rdfc:jsImplementationOf rdfc:Processor;
67
- rdfc:entrypoint <./>;
68
- rdfc:file <./lib/processors.js>;
69
- rdfc:class "FooBarProcessor".
70
-
71
- [ ] a sh:NodeShape;
72
- sh:targetClass rdfc:FooBarProcessor;
73
- sh:property [
74
- sh:path rdfc:reader;
75
- sh:name "reader";
76
- sh:minCount 1;
77
- sh:maxCount 1;
78
- sh:class rdfc:Reader;
79
- ], [
80
- sh:path rdfc:writer;
81
- sh:name "writer";
82
- sh:maxCount 1;
83
- sh:class rdfc:Writer;
84
- ].
85
-
86
- ############################################################
87
- # Pipeline statements #
88
- ############################################################
89
- <> a rdfc:Pipeline;
90
- rdfc:consistsOf [
91
- rdfc:instantiates rdfc:NodeRunner;
92
- rdfc:processor <foobar>;
93
- ].
94
-
95
- <incomingMessages> a rdfc:Reader, rdfc:Writer.
96
- <foobar> a rdfc:FooBarProcessor;
97
- rdfc:reader <incomingMessages>;
98
- rdfc:writer <incomingMessages>.
99
-
package/vite.config.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_1 = require("vitest/config");
4
- exports.default = (0, config_1.defineConfig)({
5
- test: {
6
- coverage: {
7
- enabled: true,
8
- include: ['src/'],
9
- },
10
- },
11
- });