From 39853b0bd082490bbd4bcb832ccade9389f9e882 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Thu, 25 Jun 2020 08:56:37 +0200 Subject: [PATCH] fix: update N3 typings --- package-lock.json | 20 ++++++++++++++------ package.json | 4 ++-- src/ldp/http/SimpleBodyParser.ts | 7 +------ src/storage/SimpleResourceStore.ts | 3 +-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 248c3e085..20ca4f34d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -920,9 +920,9 @@ "dev": true }, "@types/n3": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@types/n3/-/n3-1.1.6.tgz", - "integrity": "sha512-ZUZsoA13IkJOLZCXG9bgZGuzvGqhPQJ3CisPvZJ5Yfi+RxVtDCcezyTRw7olArfmxpD0UuEOtrIP/1PUCfkEBw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@types/n3/-/n3-1.4.0.tgz", + "integrity": "sha512-lVesnHn2/3wv6EqdR42JGel9pZ4PcRS31M0osht7cGEUVVzBVNBlyFq/8Z3e8EdAFGZrYVYyDnaBRX0bZsFUvA==", "requires": { "@types/node": "*", "@types/rdf-js": "*" @@ -4312,9 +4312,12 @@ "dev": true }, "n3": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/n3/-/n3-1.3.7.tgz", - "integrity": "sha512-IREbOmZyTlc34vxlp31ECT5jliRNZqHg3THhzrVd5bcSWGto5xsN8fF5xWKYXZr8TdZX+GXFkCxttTKM1N3JZg==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/n3/-/n3-1.4.0.tgz", + "integrity": "sha512-aEo8Jc+ZM9GoBtt7/OW+7aczMh4wLdt1IUcT8JCgv/b+ko5PCvkR0793rzWdu7+wJmA93sNb/3yM+01i9pz6fA==", + "requires": { + "queue-microtask": "^1.1.2" + } }, "nanomatch": { "version": "1.2.13", @@ -4835,6 +4838,11 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "queue-microtask": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.1.3.tgz", + "integrity": "sha512-zC1ZDLKFhZSa8vAdFbkOGouHcOUMgUAI/2/3on/KktpY+BaVqABkzDSsCSvJfmLbICOnrEuF9VIMezZf+T0mBA==" + }, "ramda": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.0.tgz", diff --git a/package.json b/package.json index 986a048ab..f92593f11 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,10 @@ ], "dependencies": { "@rdfjs/data-model": "^1.1.2", - "@types/n3": "^1.1.6", + "@types/n3": "^1.4.0", "@types/node": "^14.0.1", "@types/rdf-js": "^3.0.0", - "n3": "^1.3.7" + "n3": "^1.4.0" }, "devDependencies": { "@types/arrayify-stream": "^1.0.0", diff --git a/src/ldp/http/SimpleBodyParser.ts b/src/ldp/http/SimpleBodyParser.ts index 5b2b25d13..c8383c71b 100644 --- a/src/ldp/http/SimpleBodyParser.ts +++ b/src/ldp/http/SimpleBodyParser.ts @@ -1,10 +1,8 @@ import { BodyParser } from './BodyParser'; import { HttpRequest } from '../../server/HttpRequest'; -import { Quad } from 'rdf-js'; import { QuadRepresentation } from '../representation/QuadRepresentation'; import { RepresentationMetadata } from '../representation/RepresentationMetadata'; import { StreamParser } from 'n3'; -import { TypedReadable } from '../../util/TypedReadable'; import { UnsupportedMediaTypeHttpError } from '../../util/errors/UnsupportedMediaTypeHttpError'; export class SimpleBodyParser extends BodyParser { @@ -39,12 +37,9 @@ export class SimpleBodyParser extends BodyParser { contentType: mediaType, }; - // StreamParser is a Readable but typings are incorrect at time of writing - const quads: TypedReadable = input.pipe(new StreamParser()) as unknown as TypedReadable; - return { dataType: 'quad', - data: quads, + data: input.pipe(new StreamParser()), metadata, }; } diff --git a/src/storage/SimpleResourceStore.ts b/src/storage/SimpleResourceStore.ts index b1855ed36..d2f6e5b70 100644 --- a/src/storage/SimpleResourceStore.ts +++ b/src/storage/SimpleResourceStore.ts @@ -3,7 +3,6 @@ import { BinaryRepresentation } from '../ldp/representation/BinaryRepresentation import { NotFoundHttpError } from '../util/errors/NotFoundHttpError'; import { Quad } from 'rdf-js'; import { QuadRepresentation } from '../ldp/representation/QuadRepresentation'; -import { Readable } from 'stream'; import { Representation } from '../ldp/representation/Representation'; import { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences'; import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier'; @@ -74,7 +73,7 @@ export class SimpleResourceStore implements ResourceStore { private generateBinaryRepresentation(data: Quad[]): BinaryRepresentation { return { dataType: 'binary', - data: streamifyArray(data).pipe(new StreamWriter({ format: 'text/turtle' })) as unknown as Readable, + data: streamifyArray(data).pipe(new StreamWriter({ format: 'text/turtle' })), metadata: { raw: [], profiles: [], contentType: 'text/turtle' }, }; }