@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.
Files changed (89) hide show
  1. package/.husky/pre-commit +6 -0
  2. package/.idea/LNKD.tech Editor.xml +194 -0
  3. package/.idea/codeStyles/Project.xml +52 -0
  4. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  5. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  6. package/.idea/js-runner.iml +12 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/.prettierrc +4 -0
  10. package/README.md +3 -38
  11. package/__tests__/channels.test.ts +96 -0
  12. package/bin/runner.js +8 -0
  13. package/dist/args.d.ts +3 -3
  14. package/dist/args.js +50 -51
  15. package/dist/connectors/file.d.ts +11 -11
  16. package/dist/connectors/file.js +79 -79
  17. package/dist/connectors/http.d.ts +10 -10
  18. package/dist/connectors/http.js +76 -76
  19. package/dist/connectors/kafka.d.ts +36 -36
  20. package/dist/connectors/kafka.js +66 -62
  21. package/dist/connectors/ws.d.ts +6 -6
  22. package/dist/connectors/ws.js +66 -63
  23. package/dist/connectors.d.ts +61 -42
  24. package/dist/connectors.js +155 -132
  25. package/dist/index.cjs +650 -595
  26. package/dist/index.d.ts +40 -31
  27. package/dist/index.js +72 -63
  28. package/dist/util.d.ts +63 -35
  29. package/dist/util.js +80 -63
  30. package/eslint.config.mjs +21 -0
  31. package/examples/echo/package-lock.json +80 -0
  32. package/examples/echo/package.json +18 -0
  33. package/examples/echo/pipeline.ttl +48 -0
  34. package/examples/echo/processors.ttl +82 -0
  35. package/examples/echo/src/processors.ts +74 -0
  36. package/examples/echo/tsconfig.json +114 -0
  37. package/index.ttl +71 -0
  38. package/jest.config.js +2 -0
  39. package/lib/client.d.ts +1 -0
  40. package/lib/client.js +43 -0
  41. package/lib/convertor.d.ts +9 -0
  42. package/lib/convertor.js +51 -0
  43. package/lib/index.d.ts +7 -0
  44. package/lib/index.js +8 -0
  45. package/lib/jsonld.d.ts +17 -0
  46. package/lib/jsonld.js +135 -0
  47. package/lib/logger.d.ts +17 -0
  48. package/lib/logger.js +49 -0
  49. package/lib/processor.d.ts +19 -0
  50. package/lib/processor.js +13 -0
  51. package/lib/reader.d.ts +30 -0
  52. package/lib/reader.js +101 -0
  53. package/lib/reexports.d.ts +3 -0
  54. package/lib/reexports.js +4 -0
  55. package/lib/runner.d.ts +26 -0
  56. package/lib/runner.js +121 -0
  57. package/lib/testUtils.d.ts +24 -0
  58. package/lib/testUtils.js +150 -0
  59. package/lib/tsconfig.tsbuildinfo +1 -0
  60. package/lib/util_processors.d.ts +11 -0
  61. package/lib/util_processors.js +13 -0
  62. package/lib/writer.d.ts +26 -0
  63. package/lib/writer.js +57 -0
  64. package/package.json +49 -51
  65. package/src/client.ts +52 -0
  66. package/src/convertor.ts +59 -0
  67. package/src/index.ts +8 -0
  68. package/src/jsonld.ts +220 -0
  69. package/src/logger.ts +64 -0
  70. package/src/processor.ts +39 -0
  71. package/src/reader.ts +142 -0
  72. package/src/reexports.ts +6 -0
  73. package/src/runner.ts +197 -0
  74. package/src/testUtils.ts +196 -0
  75. package/src/util_processors.ts +20 -0
  76. package/src/writer.ts +90 -0
  77. package/tsconfig.json +33 -0
  78. package/vite.config.ts +10 -0
  79. package/LICENSE +0 -21
  80. package/bin/js-runner.js +0 -4
  81. package/channels/file.ttl +0 -37
  82. package/channels/http.ttl +0 -59
  83. package/channels/kafka.ttl +0 -98
  84. package/channels/ws.ttl +0 -33
  85. package/ontology.ttl +0 -169
  86. package/processor/echo.ttl +0 -38
  87. package/processor/resc.ttl +0 -34
  88. package/processor/send.ttl +0 -40
  89. package/processor/test.js +0 -35
@@ -0,0 +1,6 @@
1
+ export * from '@rdfc/proto'
2
+ export {
3
+ ClientReadableStreamImpl,
4
+ ClientReadableStream,
5
+ } from '@grpc/grpc-js/build/src/call.js'
6
+ export * as grpc from '@grpc/grpc-js'
package/src/runner.ts ADDED
@@ -0,0 +1,197 @@
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 { Cont, empty, extractShapes, Shapes } from 'rdf-lens'
15
+ import { NamedNode, Parser } from 'n3'
16
+ import { createNamespace, createUriAndTermNamespace, RDF } from '@treecg/types'
17
+ import { Quad, Term } from '@rdfjs/types'
18
+
19
+ const RDFL = createUriAndTermNamespace(
20
+ 'https://w3id.org/rdf-lens/ontology#',
21
+ 'CBD',
22
+ 'Path',
23
+ 'PathLens',
24
+ 'Context',
25
+ 'TypedExtract',
26
+ 'EnvVariable',
27
+ 'envKey',
28
+ 'envDefault',
29
+ 'datatype',
30
+ )
31
+
32
+ const RDFC = createNamespace(
33
+ 'https://w3id.org/rdf-connect#',
34
+ (x) => x,
35
+ 'Reader',
36
+ 'Writer',
37
+ )
38
+
39
+ export type Writable = (msg: OrchestratorMessage) => Promise<unknown>
40
+
41
+ type ProcessorConfig = {
42
+ location: string
43
+ file: string
44
+ clazz?: string
45
+ }
46
+
47
+ export type FullProc<C extends Proc<unknown>> =
48
+ C extends Proc<infer T> ? T & C : unknown
49
+ export class Runner {
50
+ private readonly readers: { [uri: string]: ReaderInstance[] } = {}
51
+ private readonly writers: { [uri: string]: WriterInstance[] } = {}
52
+ private readonly client: RunnerClient
53
+ private readonly write: Writable
54
+ private readonly logger: Logger
55
+ private shapes: Shapes
56
+ private quads: Quad[] = []
57
+
58
+ private readonly uri: string
59
+
60
+ private readonly processors: Proc<unknown>[] = []
61
+ private readonly processorTransforms: Promise<unknown>[] = []
62
+
63
+ constructor(
64
+ client: RunnerClient,
65
+ write: Writable,
66
+ uri: string,
67
+ logger: Logger,
68
+ ) {
69
+ this.client = client
70
+ this.write = write
71
+ this.uri = uri
72
+ this.logger = logger
73
+ }
74
+
75
+ async addProcessor<P extends Proc<unknown>>(
76
+ proc: Processor,
77
+ ): Promise<FullProc<P>> {
78
+ const procLogger = winston.createLogger({
79
+ transports: [
80
+ new RpcTransport({
81
+ entities: [proc.uri, this.uri],
82
+ stream: this.client.logStream(() => {}),
83
+ }),
84
+ ],
85
+ })
86
+
87
+ const ty = JSON.stringify(
88
+ this.quads
89
+ .filter(
90
+ (x) =>
91
+ x.subject.value === proc.uri && x.predicate.equals(RDF.terms.type),
92
+ )
93
+ .map((x) => x.object.value),
94
+ )
95
+ this.logger.info('parsing ' + proc.uri + ' type ' + ty)
96
+ const args = this.shapes.lenses[RDFL.TypedExtract].execute({
97
+ id: new NamedNode(proc.uri),
98
+ quads: this.quads,
99
+ })
100
+
101
+ const config: ProcessorConfig = JSON.parse(proc.config)
102
+ // const url = new URL(config.location)
103
+ // process.chdir(url.pathname)
104
+ const jsProgram = await import(config.file)
105
+ const clazz = jsProgram[config.clazz || 'default']
106
+ const instance: Proc<unknown> = new clazz(args, procLogger)
107
+ await instance.init()
108
+
109
+ this.logger.info('inited ' + proc.uri + ' type ' + ty)
110
+
111
+ this.processors.push(instance)
112
+ this.processorTransforms.push(instance.transform())
113
+
114
+ await this.write({ init: { uri: proc.uri } })
115
+
116
+ return <FullProc<P>>instance
117
+ }
118
+
119
+ async start() {
120
+ try {
121
+ await Promise.all(this.processors.map((x) => x.produce()))
122
+ await Promise.all(this.processorTransforms)
123
+ } catch (ex: unknown) {
124
+ this.logger.error('Start failed: ' + JSON.stringify(ex))
125
+ }
126
+ }
127
+
128
+ createWriter(uri: Term): Writer {
129
+ const ids = uri.value
130
+
131
+ if (this.writers[ids] === undefined) {
132
+ this.writers[ids] = []
133
+ }
134
+ const writer = new WriterInstance(ids, this.client, this.write, this.logger)
135
+ this.writers[ids].push(writer)
136
+ return writer
137
+ }
138
+
139
+ createReader(uri: Term): Reader {
140
+ const ids = uri.value
141
+
142
+ if (this.readers[ids] === undefined) {
143
+ this.readers[ids] = []
144
+ }
145
+ const reader = new ReaderInstance(ids, this.client, this.logger)
146
+ this.readers[ids].push(reader)
147
+ return reader
148
+ }
149
+
150
+ async handleOrchMessage(msg: RunnerMessage) {
151
+ if (msg.msg) {
152
+ this.logger.debug('Handling data msg for ' + msg.msg.channel)
153
+ for (const reader of this.readers[msg.msg.channel] || []) {
154
+ reader.handleMsg(msg.msg)
155
+ }
156
+ }
157
+
158
+ if (msg.streamMsg) {
159
+ for (const reader of this.readers[msg.streamMsg.channel] || []) {
160
+ reader.handleStreamingMessage(msg.streamMsg)
161
+ }
162
+ }
163
+
164
+ if (msg.close) {
165
+ const uri = msg.close.channel
166
+
167
+ for (const reader of this.readers[uri] || []) {
168
+ reader.close()
169
+ }
170
+
171
+ for (const writer of this.writers[uri] || []) {
172
+ await writer.close(true)
173
+ }
174
+ }
175
+
176
+ if (msg.pipeline) {
177
+ try {
178
+ // here
179
+ const quads = new Parser().parse(msg.pipeline)
180
+ this.shapes = extractShapes(
181
+ quads,
182
+ {
183
+ [RDFC.Reader]: (x: Cont) => this.createReader(x.id),
184
+ [RDFC.Writer]: (x: Cont) => this.createWriter(x.id),
185
+ },
186
+ {
187
+ [RDFC.Reader]: empty<Cont>(),
188
+ [RDFC.Writer]: empty<Cont>(),
189
+ },
190
+ )
191
+ this.quads = quads
192
+ } catch (ex: unknown) {
193
+ this.logger.error('Pipeline failed: ' + JSON.stringify(ex))
194
+ }
195
+ }
196
+ }
197
+ }
@@ -0,0 +1,196 @@
1
+ import { DataChunk, RunnerClient } from "@rdfc/proto";
2
+ import * as grpc from "@grpc/grpc-js";
3
+ import { ClientReadableStream } from "@grpc/grpc-js";
4
+ import { ClientReadableStreamImpl, OrchestratorMessage } from "./reexports";
5
+ import { extractShapes } from "rdf-lens";
6
+ import { NamedNode, Parser, Writer } from "n3";
7
+ import { readFile } from "fs/promises";
8
+ import winston, { createLogger } from "winston";
9
+ import { WriterInstance } from "./writer";
10
+ import { ReaderInstance } from "./reader";
11
+ import { Processor } from "./processor";
12
+ import { FullProc, Runner } from "./runner";
13
+ import { Quad, Term } from "@rdfjs/types";
14
+ import { createTermNamespace } from "@treecg/types";
15
+ import { expect } from "vitest";
16
+
17
+ export async function getProcessorShape(
18
+ baseIRI = process.cwd() + "/node_modules/@rdfc/js-runner/index.ttl",
19
+ ) {
20
+ const configFile = await readFile(baseIRI, { encoding: "utf8" });
21
+ const configQuads = new Parser().parse(configFile);
22
+ const shapes = extractShapes(configQuads);
23
+
24
+ return shapes;
25
+ }
26
+
27
+ export class TestClient extends RunnerClient {
28
+ next: (stream: ClientReadableStream<DataChunk>) => unknown;
29
+
30
+ constructor() {
31
+ super("localhost:5400", grpc.credentials.createInsecure());
32
+ }
33
+
34
+ nextStream(): Promise<ClientReadableStream<DataChunk>> {
35
+ return new Promise((res) => (this.next = res));
36
+ }
37
+
38
+ receiveStreamMessage(): ClientReadableStream<DataChunk> {
39
+ const stream = new ClientReadableStreamImpl<DataChunk>((data: Buffer) => {
40
+ return { data };
41
+ });
42
+ this.next(stream);
43
+ return stream;
44
+ }
45
+ }
46
+
47
+ export async function one<T>(iter: AsyncIterable<T>): Promise<T | undefined> {
48
+ for await (const item of iter) {
49
+ return item;
50
+ }
51
+ }
52
+
53
+ export const client = new TestClient();
54
+ export const uri = "someUri";
55
+ export const logger = createLogger({
56
+ transports: new winston.transports.Console({
57
+ level: process.env["DEBUG"] || "info",
58
+ }),
59
+ });
60
+
61
+ export function createWriter(iri = uri): [WriterInstance, ReaderInstance] {
62
+ const reader = createReader(iri);
63
+ const writeStream = new WriterInstance(
64
+ iri,
65
+ client,
66
+ async (msg) => {
67
+ if (msg.msg) {
68
+ reader.handleMsg(msg.msg);
69
+ }
70
+ if (msg.close) {
71
+ reader.close();
72
+ }
73
+ },
74
+ logger,
75
+ );
76
+ return [writeStream, reader];
77
+ }
78
+
79
+ export function createReader(iri = uri): ReaderInstance {
80
+ const reader = new ReaderInstance(iri, client, logger);
81
+ return reader;
82
+ }
83
+
84
+ const shapeQuads = `
85
+ @prefix rdfc: <https://w3id.org/rdf-connect#>.
86
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
87
+ @prefix sh: <http://www.w3.org/ns/shacl#>.
88
+ [ ] a sh:NodeShape;
89
+ sh:targetClass <JsProcessorShape>;
90
+ sh:property [
91
+ sh:path rdfc:entrypoint;
92
+ sh:name "location";
93
+ sh:minCount 1;
94
+ sh:maxCount 1;
95
+ sh:datatype xsd:string;
96
+ ], [
97
+ sh:path rdfc:file;
98
+ sh:name "file";
99
+ sh:minCount 1;
100
+ sh:maxCount 1;
101
+ sh:datatype xsd:string;
102
+ ], [
103
+ sh:path rdfc:class;
104
+ sh:name "clazz";
105
+ sh:maxCount 1;
106
+ sh:datatype xsd:string;
107
+ ].
108
+ `;
109
+ const OWL = createTermNamespace("http://www.w3.org/2002/07/owl#", "imports");
110
+ const processorShapes = extractShapes(new Parser().parse(shapeQuads));
111
+ const base = "https://w3id.org/rdf-connect#";
112
+
113
+ export async function importFile(file: string): Promise<Quad[]> {
114
+ const done = new Set<string>();
115
+ const todo = [new URL("file://" + file)];
116
+ const quads: Quad[] = [];
117
+
118
+ let item = todo.pop();
119
+ while (item !== undefined) {
120
+ if (done.has(item.toString())) {
121
+ item = todo.pop();
122
+ continue;
123
+ }
124
+ done.add(item.toString());
125
+ if (item.protocol !== "file:") {
126
+ throw "No supported protocol " + item.protocol;
127
+ }
128
+
129
+ const txt = await readFile(item.pathname, { encoding: "utf8" });
130
+ const extras = new Parser({ baseIRI: item.toString() }).parse(txt);
131
+
132
+ for (const o of extras
133
+ .filter(
134
+ (x) =>
135
+ x.subject.value === item?.toString() &&
136
+ x.predicate.equals(OWL.imports),
137
+ )
138
+ .map((x) => x.object.value)) {
139
+ todo.push(new URL(o));
140
+ }
141
+ quads.push(...extras);
142
+
143
+ item = todo.pop();
144
+ }
145
+
146
+ return quads;
147
+ }
148
+
149
+ export async function getProc<T extends Processor<unknown>>(
150
+ config: string,
151
+ ty: string,
152
+ configLocation: string,
153
+ uri = "http://example.com/ns#processor",
154
+ ): Promise<FullProc<T>> {
155
+ const configQuads = await importFile(configLocation);
156
+ const procConfig = processorShapes.lenses["JsProcessorShape"].execute({
157
+ id: new NamedNode(base + ty),
158
+ quads: configQuads,
159
+ });
160
+
161
+ const msgs: OrchestratorMessage[] = [];
162
+ const write = async (x: OrchestratorMessage) => {
163
+ msgs.push(x);
164
+ };
165
+ const runner = new Runner(
166
+ new TestClient(),
167
+ write,
168
+ "http://example.com/ns#",
169
+ logger,
170
+ );
171
+ configQuads.push(...new Parser().parse(config));
172
+ await runner.handleOrchMessage({
173
+ pipeline: new Writer().quadsToString(configQuads),
174
+ });
175
+
176
+ const proc = await runner.addProcessor<T>({
177
+ config: JSON.stringify(procConfig),
178
+ arguments: "",
179
+ uri,
180
+ });
181
+
182
+ return proc;
183
+ }
184
+
185
+ export async function checkProcDefinition(file: string, n: string) {
186
+ const quads = await importFile(file);
187
+ const procConfig = <{ file: Term; location: string; clazz: string }>(
188
+ processorShapes.lenses["JsProcessorShape"].execute({
189
+ id: new NamedNode(base + n),
190
+ quads: quads,
191
+ })
192
+ );
193
+ expect(procConfig.file, n + " has file").toBeDefined();
194
+ expect(procConfig.location, n + " has location").toBeDefined();
195
+ expect(procConfig.clazz, n + " has clazz").toBeDefined();
196
+ }
@@ -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,90 @@
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
+ readonly uri: string
9
+ buffer(buffer: Uint8Array): Promise<void>
10
+
11
+ stream(buffer: AsyncIterable<Uint8Array>): Promise<void>
12
+ stream<T>(
13
+ buffer: AsyncIterable<T>,
14
+ tranform: (x: T) => Uint8Array,
15
+ ): Promise<void>
16
+
17
+ string(buffer: string): Promise<void>
18
+ any(any: Any): Promise<void>
19
+ close(): Promise<void>
20
+ }
21
+ const encoder = new TextEncoder()
22
+ export class WriterInstance implements Writer {
23
+ readonly uri: string
24
+ private readonly client: RunnerClient
25
+ private readonly write: Writable
26
+ private readonly logger: Logger
27
+
28
+ constructor(
29
+ uri: string,
30
+ client: RunnerClient,
31
+ write: Writable,
32
+ logger: Logger,
33
+ ) {
34
+ this.client = client
35
+ this.write = write
36
+ this.uri = uri
37
+ this.logger = logger
38
+ }
39
+ async any(any: Any): Promise<void> {
40
+ if ('stream' in any) {
41
+ await this.stream(any.stream)
42
+ }
43
+ if ('buffer' in any) {
44
+ await this.buffer(any.buffer)
45
+ }
46
+ if ('string' in any) {
47
+ await this.string(any.string)
48
+ }
49
+ }
50
+
51
+ async buffer(buffer: Uint8Array): Promise<void> {
52
+ this.logger.debug(`${this.uri} sends buffer ${buffer.length} bytes`)
53
+ await this.write({ msg: { data: buffer, channel: this.uri } })
54
+ }
55
+
56
+ async stream<T = Uint8Array>(
57
+ buffer: AsyncIterable<T>,
58
+ transform?: (x: T) => Uint8Array,
59
+ ) {
60
+ const t = transform || ((x: unknown) => <Uint8Array>x)
61
+ const stream = this.client.sendStreamMessage()
62
+ const id: Id = await new Promise((res) => stream.once('data', res))
63
+ this.logger.debug(`${this.uri} streams message with id ${id.id}`)
64
+ await this.write({ streamMsg: { id, channel: this.uri } })
65
+
66
+ const write = promisify(stream.write.bind(stream))
67
+ for await (const msg of buffer) {
68
+ await write({ data: t(msg) })
69
+ }
70
+
71
+ this.logger.debug(`${this.uri} is done streaming message with id ${id.id}`)
72
+ stream.end()
73
+ }
74
+
75
+ async string(msg: string): Promise<void> {
76
+ this.logger.debug(`${this.uri} sends string ${msg.length} characters`)
77
+ await this.write({
78
+ msg: { data: encoder.encode(msg), channel: this.uri },
79
+ })
80
+ }
81
+
82
+ async close(issued = false): Promise<void> {
83
+ this.logger.debug(`${this.uri} closes stream`)
84
+ if (!issued) {
85
+ await this.write({
86
+ close: { channel: this.uri },
87
+ })
88
+ }
89
+ }
90
+ }
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
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ coverage: {
6
+ enabled: true,
7
+ include: ['src/'],
8
+ },
9
+ },
10
+ })
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
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { jsRunner } from "../dist/index.js";
3
-
4
- jsRunner().catch((e) => { console.error("Error:", e); console.error(e.stack) });
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
-