diff --git a/src/org/datafoodconsortium/connector/codegen/typescript/static/package.json b/src/org/datafoodconsortium/connector/codegen/typescript/static/package.json index 3f3f6ed..f420e87 100644 --- a/src/org/datafoodconsortium/connector/codegen/typescript/static/package.json +++ b/src/org/datafoodconsortium/connector/codegen/typescript/static/package.json @@ -24,6 +24,7 @@ }, "devDependencies": { "@types/jsonld": "^1.5.7", + "@types/node": "^22.7.6", "@types/rdf-ext": "^2.5.0", "@types/rdfjs__serializer-jsonld-ext": "^2.0.5", "typescript": "^4.5" diff --git a/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorExporterJsonldStream.ts b/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorExporterJsonldStream.ts index f963080..0e61eb8 100644 --- a/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorExporterJsonldStream.ts +++ b/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorExporterJsonldStream.ts @@ -1,6 +1,7 @@ import { Semanticable } from "@virtual-assembly/semantizer"; import SerializerJsonld from '@rdfjs/serializer-jsonld-ext'; -import { ContextDefinition } from "jsonld"; +import Quad from "rdf-ext/lib/Quad"; +import { ContextDefinition, ExpandedTermDefinition } from "jsonld"; import { Readable } from 'readable-stream'; import IConnectorExporter from "./IConnectorExporter"; @@ -24,7 +25,7 @@ export default class ConnectorExporterJsonldStream implements IConnectorExporter const input = new Readable({ objectMode: true, read: () => { - semanticObjets.forEach((semanticObject) => semanticObject.toRdfDatasetExt().forEach((quad) => input.push(quad))); + semanticObjets.forEach((semanticObject) => semanticObject.toRdfDatasetExt().forEach((quad: Quad) => input.push(quad))); input.push(null) } }); @@ -32,8 +33,8 @@ export default class ConnectorExporterJsonldStream implements IConnectorExporter const output = serializer.import(input); return new Promise((resolve, reject) => { - output.on('error', (error) => reject(error)); - output.on('data', (json) => { + output.on('error', (error: Error) => reject(error)); + output.on('data', (json: ExpandedTermDefinition) => { if (outputContext) { json["@context"] = outputContext; } diff --git a/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorImporterJsonldStream.ts b/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorImporterJsonldStream.ts index 48e7201..5acdfa5 100644 --- a/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorImporterJsonldStream.ts +++ b/src/org/datafoodconsortium/connector/codegen/typescript/static/src/ConnectorImporterJsonldStream.ts @@ -45,7 +45,7 @@ export default class ConnectorImporterJsonldStream implements IConnectorImporter // On each quad imported we fill the appropriate datasets. // If the quad is a blank node we add it to the blankNodes array, // otherwise we add it to the datasets array. - output.on('data', (quad) => { + output.on('data', (quad: QuadExt) => { const subject: string = quad.subject.value; const isBlankNode: boolean = (quad.subject.termType === "BlankNode"); @@ -82,7 +82,7 @@ export default class ConnectorImporterJsonldStream implements IConnectorImporter return new Promise((resolve, reject) => { // If an error occured during the import process, we reject the promise. - output.on('error', (error) => reject(error)); + output.on('error', (error: Error) => reject(error)); // When the import is done without any error. output.on('finish', () => { @@ -93,7 +93,7 @@ export default class ConnectorImporterJsonldStream implements IConnectorImporter // We should find a blank node index associated to the blank node name. if (blankNodeIndex !== undefined) { - const blankNodeDataset: DatasetExt | undefined = blankNodes.at(blankNodeIndex); + const blankNodeDataset: DatasetExt | undefined = blankNodes.at(blankNodeIndex); // FIXME: requires tsconfig target >= es2022 // When we find the blank node we add its quads to the corresponding dataset. if (blankNodeDataset) dataset.addAll(blankNodeDataset);