@rdfc/js-runner 2.0.0-alpha.9 → 3.0.0
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/.github/renovate.json +3 -0
- package/README.md +127 -3
- package/__tests__/channels.test.ts +131 -74
- package/__tests__/echoProcessor.test.ts +131 -0
- package/__tests__/testProcessor.test.ts +69 -0
- package/eslint.config.mjs +1 -1
- 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/index.ttl +3 -31
- package/ldes/http_3A_2F_2Fdata.mumo.be_2Fstreams_2Fnodes_2Fdefault/root/index.trig +3 -0
- package/lib/client.js +7 -10
- package/lib/logger.d.ts +2 -2
- package/lib/logger.js +3 -3
- package/lib/reader.d.ts +8 -6
- package/lib/reader.js +135 -26
- package/lib/runner.d.ts +10 -5
- package/lib/runner.js +86 -46
- package/lib/testUtils/duplex.d.ts +25 -0
- package/lib/testUtils/duplex.js +70 -0
- package/lib/testUtils/index.d.ts +51 -0
- package/lib/testUtils/index.js +243 -0
- package/lib/testUtils.d.ts +6 -0
- package/lib/testUtils.js +92 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/writer.d.ts +12 -5
- package/lib/writer.js +66 -13
- package/minimal.ttl +99 -0
- package/package.json +5 -5
- package/src/client.ts +9 -12
- package/src/logger.ts +3 -3
- package/src/reader.ts +207 -30
- package/src/runner.ts +128 -65
- package/src/testUtils/duplex.ts +112 -0
- package/src/testUtils/index.ts +430 -0
- package/src/writer.ts +106 -16
- 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/src/jsonld.ts +0 -220
- package/src/testUtils.ts +0 -77
package/src/testUtils.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { DataChunk, RunnerClient } from '@rdfc/proto'
|
|
2
|
-
import { ClientReadableStream } from '@grpc/grpc-js'
|
|
3
|
-
import * as grpc from '@grpc/grpc-js'
|
|
4
|
-
import { ClientReadableStreamImpl } from './reexports'
|
|
5
|
-
import { extractShapes } from 'rdf-lens'
|
|
6
|
-
import { Parser } 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
|
-
|
|
12
|
-
export async function getProcessorShape(
|
|
13
|
-
baseIRI = process.cwd() + '/node_modules/@rdfc/js-runner/index.ttl',
|
|
14
|
-
) {
|
|
15
|
-
const configFile = await readFile(baseIRI, { encoding: 'utf8' })
|
|
16
|
-
const configQuads = new Parser().parse(configFile)
|
|
17
|
-
const shapes = extractShapes(configQuads)
|
|
18
|
-
|
|
19
|
-
return shapes
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class TestClient extends RunnerClient {
|
|
23
|
-
next: (stream: ClientReadableStream<DataChunk>) => unknown
|
|
24
|
-
|
|
25
|
-
constructor() {
|
|
26
|
-
super('localhost:5400', grpc.credentials.createInsecure())
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
nextStream(): Promise<ClientReadableStream<DataChunk>> {
|
|
30
|
-
return new Promise((res) => (this.next = res))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
receiveStreamMessage(): ClientReadableStream<DataChunk> {
|
|
34
|
-
const stream = new ClientReadableStreamImpl<DataChunk>((data: Buffer) => {
|
|
35
|
-
return { data }
|
|
36
|
-
})
|
|
37
|
-
this.next(stream)
|
|
38
|
-
return stream
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function one<T>(iter: AsyncIterable<T>): Promise<T | undefined> {
|
|
43
|
-
for await (const item of iter) {
|
|
44
|
-
return item
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const client = new TestClient()
|
|
49
|
-
export const uri = 'someUri'
|
|
50
|
-
export const logger = createLogger({
|
|
51
|
-
transports: new winston.transports.Console({
|
|
52
|
-
level: process.env['DEBUG'] || 'info',
|
|
53
|
-
}),
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
export function createWriter(iri = uri): [WriterInstance, ReaderInstance] {
|
|
57
|
-
const reader = createReader(iri)
|
|
58
|
-
const writeStream = new WriterInstance(
|
|
59
|
-
iri,
|
|
60
|
-
client,
|
|
61
|
-
async (msg) => {
|
|
62
|
-
if (msg.msg) {
|
|
63
|
-
reader.handleMsg(msg.msg)
|
|
64
|
-
}
|
|
65
|
-
if (msg.close) {
|
|
66
|
-
reader.close()
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
logger,
|
|
70
|
-
)
|
|
71
|
-
return [writeStream, reader]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function createReader(iri = uri): ReaderInstance {
|
|
75
|
-
const reader = new ReaderInstance(iri, client, logger)
|
|
76
|
-
return reader
|
|
77
|
-
}
|