mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Remove @rdfjs/data-model dependency
We already have N3.js for term generation. No need to have two solutions there.
This commit is contained in:
23
package-lock.json
generated
23
package-lock.json
generated
@@ -10,7 +10,6 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@comunica/actor-init-sparql": "^1.21.3",
|
||||
"@rdfjs/data-model": "^1.2.0",
|
||||
"@solid/access-token-verifier": "^1.1.2",
|
||||
"@types/arrayify-stream": "^1.0.0",
|
||||
"@types/async-lock": "^1.1.2",
|
||||
@@ -4353,20 +4352,6 @@
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rdfjs/data-model": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@rdfjs/data-model/-/data-model-1.2.0.tgz",
|
||||
"integrity": "sha512-6ITWcu2sr9zJqXUPDm1XJ8DRpea7PotWBIkTzuO1MCSruLOWH2ICoQOAtlJy30cT+GqH9oAQKPR+CHXejsdizA==",
|
||||
"dependencies": {
|
||||
"@types/rdf-js": "*"
|
||||
},
|
||||
"bin": {
|
||||
"rdfjs-data-model-test": "bin/test.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@rdfjs/types": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@rdfjs/types/-/types-1.0.1.tgz",
|
||||
@@ -19067,14 +19052,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@panva/asn1.js/-/asn1.js-1.0.0.tgz",
|
||||
"integrity": "sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw=="
|
||||
},
|
||||
"@rdfjs/data-model": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@rdfjs/data-model/-/data-model-1.2.0.tgz",
|
||||
"integrity": "sha512-6ITWcu2sr9zJqXUPDm1XJ8DRpea7PotWBIkTzuO1MCSruLOWH2ICoQOAtlJy30cT+GqH9oAQKPR+CHXejsdizA==",
|
||||
"requires": {
|
||||
"@types/rdf-js": "*"
|
||||
}
|
||||
},
|
||||
"@rdfjs/types": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@rdfjs/types/-/types-1.0.1.tgz",
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@comunica/actor-init-sparql": "^1.21.3",
|
||||
"@rdfjs/data-model": "^1.2.0",
|
||||
"@solid/access-token-verifier": "^1.1.2",
|
||||
"@types/arrayify-stream": "^1.0.0",
|
||||
"@types/async-lock": "^1.1.2",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { namedNode } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import { SOLID_META } from '../../util/Vocabularies';
|
||||
import type { RepresentationMetadata } from '../representation/RepresentationMetadata';
|
||||
import type { AuxiliaryIdentifierStrategy } from './AuxiliaryIdentifierStrategy';
|
||||
@@ -24,7 +24,7 @@ export class LinkMetadataGenerator extends MetadataGenerator {
|
||||
const identifier = { path: metadata.identifier.value };
|
||||
if (!this.identifierStrategy.isAuxiliaryIdentifier(identifier)) {
|
||||
metadata.add(this.link,
|
||||
namedNode(this.identifierStrategy.getAuxiliaryIdentifier(identifier).path),
|
||||
DataFactory.namedNode(this.identifierStrategy.getAuxiliaryIdentifier(identifier).path),
|
||||
SOLID_META.terms.ResponseMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ import type { Readable } from 'stream';
|
||||
import type { ActorInitSparql } from '@comunica/actor-init-sparql';
|
||||
import { newEngine } from '@comunica/actor-init-sparql';
|
||||
import type { IQueryResultUpdate } from '@comunica/actor-init-sparql/lib/ActorInitSparql-browser';
|
||||
import { defaultGraph } from '@rdfjs/data-model';
|
||||
import { Store } from 'n3';
|
||||
import { DataFactory, Store } from 'n3';
|
||||
import type { BaseQuad } from 'rdf-js';
|
||||
import { Algebra } from 'sparqlalgebrajs';
|
||||
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
|
||||
@@ -86,7 +85,7 @@ export class SparqlUpdatePatcher extends RepresentationPatcher {
|
||||
* This means: no GRAPH statements, no DELETE WHERE containing terms of type Variable.
|
||||
*/
|
||||
private validateDeleteInsert(op: Algebra.DeleteInsert): void {
|
||||
const def = defaultGraph();
|
||||
const def = DataFactory.defaultGraph();
|
||||
const deletes = op.delete ?? [];
|
||||
const inserts = op.insert ?? [];
|
||||
if (!deletes.every((pattern): boolean => pattern.graph.equals(def))) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable function-paren-newline */
|
||||
import { namedNode } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { NamedNode } from 'rdf-js';
|
||||
|
||||
type RecordOf<TKey extends any[], TValue> = Record<TKey[number], TValue>;
|
||||
@@ -41,7 +41,7 @@ Namespace<typeof localNames, string> {
|
||||
*/
|
||||
export function createTermNamespace<T extends string>(baseUri: string, ...localNames: T[]):
|
||||
Namespace<typeof localNames, NamedNode> {
|
||||
return createNamespace(baseUri, namedNode, ...localNames);
|
||||
return createNamespace(baseUri, DataFactory.namedNode, ...localNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import { CredentialGroup } from '../../../src/authentication/Credentials';
|
||||
import type { CredentialSet } from '../../../src/authentication/Credentials';
|
||||
import type { AccessChecker } from '../../../src/authorization/access/AccessChecker';
|
||||
@@ -15,7 +15,7 @@ import { NotFoundHttpError } from '../../../src/util/errors/NotFoundHttpError';
|
||||
import { SingleRootIdentifierStrategy } from '../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import { guardedStreamFrom } from '../../../src/util/StreamUtil';
|
||||
|
||||
const nn = namedNode;
|
||||
const { namedNode: nn, quad } = DataFactory;
|
||||
|
||||
const acl = 'http://www.w3.org/ns/auth/acl#';
|
||||
const rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'jest-rdf';
|
||||
import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory } from 'n3';
|
||||
import { Algebra } from 'sparqlalgebrajs';
|
||||
import * as algebra from 'sparqlalgebrajs';
|
||||
import type { BodyParserArgs } from '../../../../../src/http/input/body/BodyParser';
|
||||
@@ -10,6 +10,7 @@ import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../../../../src/util/errors/UnsupportedMediaTypeHttpError';
|
||||
import { guardedStreamFrom } from '../../../../../src/util/StreamUtil';
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
describe('A SparqlUpdateBodyParser', (): void => {
|
||||
const bodyParser = new SparqlUpdateBodyParser();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import 'jest-rdf';
|
||||
import { Readable } from 'stream';
|
||||
import { namedNode } from '@rdfjs/data-model';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory } from 'n3';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
const { namedNode } = DataFactory;
|
||||
|
||||
describe('BasicRepresentation', (): void => {
|
||||
it('creates a representation with (data, metadata, binary).', (): void => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'jest-rdf';
|
||||
import { defaultGraph, literal, namedNode, quad } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { NamedNode, Quad } from 'rdf-js';
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
const { defaultGraph, literal, namedNode, quad } = DataFactory;
|
||||
|
||||
// Helper functions to filter quads
|
||||
function getQuads(quads: Quad[], subject?: string, predicate?: string, object?: string, graph?: string): Quad[] {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'jest-rdf';
|
||||
import type { Readable } from 'stream';
|
||||
import { namedNode } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { Representation } from '../../../../src/http/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import { FileDataAccessor } from '../../../../src/storage/accessors/FileDataAccessor';
|
||||
@@ -277,7 +277,7 @@ describe('A FileDataAccessor', (): void => {
|
||||
|
||||
it('updates the filename if the content-type gets updated.', async(): Promise<void> => {
|
||||
cache.data = { 'resource$.ttl': '<this> <is> <data>.', 'resource.meta': '<this> <is> <metadata>.' };
|
||||
metadata.identifier = namedNode(`${base}resource`);
|
||||
metadata.identifier = DataFactory.namedNode(`${base}resource`);
|
||||
metadata.contentType = 'text/plain';
|
||||
metadata.add('new', 'metadata');
|
||||
await expect(accessor.writeDocument({ path: `${base}resource` }, data, metadata))
|
||||
@@ -289,7 +289,7 @@ describe('A FileDataAccessor', (): void => {
|
||||
});
|
||||
|
||||
it('does not try to update the content-type if there is no original file.', async(): Promise<void> => {
|
||||
metadata.identifier = namedNode(`${base}resource.txt`);
|
||||
metadata.identifier = DataFactory.namedNode(`${base}resource.txt`);
|
||||
metadata.contentType = 'text/turtle';
|
||||
metadata.add('new', 'metadata');
|
||||
await expect(accessor.writeDocument({ path: `${base}resource.txt` }, data, metadata))
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { namedNode as nn, quad } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import { ContainerToTemplateConverter } from '../../../../src/storage/conversion/ContainerToTemplateConverter';
|
||||
import { SingleRootIdentifierStrategy } from '../../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import type { TemplateEngine } from '../../../../src/util/templates/TemplateEngine';
|
||||
import { LDP, RDF } from '../../../../src/util/Vocabularies';
|
||||
const { namedNode: nn, quad } = DataFactory;
|
||||
|
||||
describe('A ContainerToTemplateConverter', (): void => {
|
||||
const preferences = {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { namedNode, triple } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import rdfSerializer from 'rdf-serialize';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import type { Representation } from '../../../../src/http/representation/Representation';
|
||||
@@ -9,6 +9,7 @@ import { QuadToRdfConverter } from '../../../../src/storage/conversion/QuadToRdf
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { DC, PREFERRED_PREFIX_TERM } from '../../../../src/util/Vocabularies';
|
||||
const { namedNode, triple } = DataFactory;
|
||||
|
||||
describe('A QuadToRdfConverter', (): void => {
|
||||
const converter = new QuadToRdfConverter();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'jest-rdf';
|
||||
import { Readable } from 'stream';
|
||||
import { namedNode, triple } from '@rdfjs/data-model';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory } from 'n3';
|
||||
import rdfParser from 'rdf-parse';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import type { Representation } from '../../../../src/http/representation/Representation';
|
||||
@@ -11,6 +11,7 @@ import type { ResourceIdentifier } from '../../../../src/http/representation/Res
|
||||
import { RdfToQuadConverter } from '../../../../src/storage/conversion/RdfToQuadConverter';
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
const { namedNode, triple } = DataFactory;
|
||||
|
||||
describe('A RdfToQuadConverter', (): void => {
|
||||
const converter = new RdfToQuadConverter();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'jest-rdf';
|
||||
import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { Quad } from 'rdf-js';
|
||||
import type { Algebra } from 'sparqlalgebrajs';
|
||||
import { translate } from 'sparqlalgebrajs';
|
||||
@@ -12,6 +12,7 @@ import type { RepresentationPatcherInput } from '../../../../src/storage/patch/R
|
||||
import { SparqlUpdatePatcher } from '../../../../src/storage/patch/SparqlUpdatePatcher';
|
||||
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
function getPatch(query: string): SparqlUpdatePatch {
|
||||
const prefixedQuery = `prefix : <http://test.com/>\n${query}`;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import 'jest-rdf';
|
||||
import { literal, namedNode, quad } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import { parseQuads, serializeQuads } from '../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom, readableToString } from '../../../src/util/StreamUtil';
|
||||
const { literal, namedNode, quad } = DataFactory;
|
||||
|
||||
describe('QuadUtil', (): void => {
|
||||
describe('#serializeQuads', (): void => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'jest-rdf';
|
||||
import { literal, namedNode } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import {
|
||||
toCachedNamedNode,
|
||||
toNamedTerm,
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
isTerm,
|
||||
} from '../../../src/util/TermUtil';
|
||||
import { CONTENT_TYPE_TERM, XSD } from '../../../src/util/Vocabularies';
|
||||
const { literal, namedNode } = DataFactory;
|
||||
|
||||
describe('TermUtil', (): void => {
|
||||
describe('isTerm function', (): void => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { namedNode } from '@rdfjs/data-model';
|
||||
import { DataFactory } from 'n3';
|
||||
import { LDP } from '../../../src/util/Vocabularies';
|
||||
|
||||
describe('Vocabularies', (): void => {
|
||||
@@ -8,7 +8,7 @@ describe('Vocabularies', (): void => {
|
||||
});
|
||||
|
||||
it('contains its own URI as a term.', (): void => {
|
||||
expect(LDP.terms.namespace).toEqual(namedNode('http://www.w3.org/ns/ldp#'));
|
||||
expect(LDP.terms.namespace).toEqual(DataFactory.namedNode('http://www.w3.org/ns/ldp#'));
|
||||
});
|
||||
|
||||
it('exposes ldp:contains.', (): void => {
|
||||
@@ -16,7 +16,7 @@ describe('Vocabularies', (): void => {
|
||||
});
|
||||
|
||||
it('exposes ldp:contains as a term.', (): void => {
|
||||
expect(LDP.terms.contains).toEqual(namedNode('http://www.w3.org/ns/ldp#contains'));
|
||||
expect(LDP.terms.contains).toEqual(DataFactory.namedNode('http://www.w3.org/ns/ldp#contains'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user