mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Use types to create vocabularies.
This commit is contained in:
parent
882c0fdba5
commit
8e138c36d1
@ -12,7 +12,7 @@ import { InternalServerError } from '../util/errors/InternalServerError';
|
||||
import { NotFoundHttpError } from '../util/errors/NotFoundHttpError';
|
||||
import { UnauthorizedHttpError } from '../util/errors/UnauthorizedHttpError';
|
||||
import type { IdentifierStrategy } from '../util/identifiers/IdentifierStrategy';
|
||||
import { ACL, FOAF } from '../util/UriConstants';
|
||||
import { ACL, FOAF } from '../util/Vocabularies';
|
||||
import type { AclManager } from './AclManager';
|
||||
import type { AuthorizerArgs } from './Authorizer';
|
||||
import { Authorizer } from './Authorizer';
|
||||
|
@ -199,6 +199,6 @@ export * from './util/QuadUtil';
|
||||
export * from './util/RecordObject';
|
||||
export * from './util/SequenceHandler';
|
||||
export * from './util/StreamUtil';
|
||||
export * from './util/WaterfallHandler';
|
||||
export * from './util/UriConstants';
|
||||
export * from './util/UriUtil';
|
||||
export * from './util/Vocabularies';
|
||||
export * from './util/WaterfallHandler';
|
||||
|
@ -7,7 +7,7 @@ import { TEXT_TURTLE } from '../util/ContentTypes';
|
||||
import { NotFoundHttpError } from '../util/errors/NotFoundHttpError';
|
||||
import { ensureTrailingSlash } from '../util/PathUtil';
|
||||
import { guardedStreamFrom } from '../util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../util/Vocabularies';
|
||||
import { Initializer } from './Initializer';
|
||||
|
||||
/**
|
||||
|
@ -8,8 +8,8 @@ import { NotFoundHttpError } from '../util/errors/NotFoundHttpError';
|
||||
import { ensureTrailingSlash } from '../util/PathUtil';
|
||||
import { generateResourceQuads } from '../util/ResourceUtil';
|
||||
import { guardedStreamFrom } from '../util/StreamUtil';
|
||||
import { PIM, RDF } from '../util/UriConstants';
|
||||
import { toCachedNamedNode } from '../util/UriUtil';
|
||||
import { PIM, RDF } from '../util/Vocabularies';
|
||||
import { Initializer } from './Initializer';
|
||||
import namedNode = DataFactory.namedNode;
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { DataFactory } from 'n3';
|
||||
import { getLoggerFor } from '../../../logging/LogUtil';
|
||||
import type { HttpRequest } from '../../../server/HttpRequest';
|
||||
import { parseParameters, splitAndClean, transformQuotedStrings } from '../../../util/HeaderUtil';
|
||||
import { RDF } from '../../../util/UriConstants';
|
||||
import { RDF } from '../../../util/Vocabularies';
|
||||
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';
|
||||
import type { MetadataParser } from './MetadataParser';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { getLoggerFor } from '../../../logging/LogUtil';
|
||||
import type { HttpRequest } from '../../../server/HttpRequest';
|
||||
import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError';
|
||||
import { HTTP } from '../../../util/UriConstants';
|
||||
import { HTTP } from '../../../util/Vocabularies';
|
||||
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';
|
||||
import type { MetadataParser } from './MetadataParser';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { DataFactory } from 'n3';
|
||||
import { HTTP } from '../../../util/UriConstants';
|
||||
import { HTTP } from '../../../util/Vocabularies';
|
||||
import { RepresentationMetadata } from '../../representation/RepresentationMetadata';
|
||||
import type { ResourceIdentifier } from '../../representation/ResourceIdentifier';
|
||||
import { ResponseDescription } from './ResponseDescription';
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
import { parseQuads } from '../util/QuadUtil';
|
||||
import { generateResourceQuads } from '../util/ResourceUtil';
|
||||
import { guardedStreamFrom } from '../util/StreamUtil';
|
||||
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF } from '../util/UriConstants';
|
||||
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF } from '../util/Vocabularies';
|
||||
import type { DataAccessor } from './accessors/DataAccessor';
|
||||
import type { ResourceStore } from './ResourceStore';
|
||||
|
||||
|
@ -16,8 +16,8 @@ import type { Guarded } from '../../util/GuardedStream';
|
||||
import { isContainerIdentifier } from '../../util/PathUtil';
|
||||
import { parseQuads, pushQuad, serializeQuads } from '../../util/QuadUtil';
|
||||
import { generateContainmentQuads, generateResourceQuads } from '../../util/ResourceUtil';
|
||||
import { CONTENT_TYPE, DCTERMS, LDP, POSIX, RDF, XSD } from '../../util/UriConstants';
|
||||
import { toCachedNamedNode, toLiteral } from '../../util/UriUtil';
|
||||
import { CONTENT_TYPE, DCTERMS, LDP, POSIX, RDF, XSD } from '../../util/Vocabularies';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../mapping/FileIdentifierMapper';
|
||||
import type { DataAccessor } from './DataAccessor';
|
||||
|
||||
|
@ -27,8 +27,8 @@ import { guardStream } from '../../util/GuardedStream';
|
||||
import type { Guarded } from '../../util/GuardedStream';
|
||||
import type { IdentifierStrategy } from '../../util/identifiers/IdentifierStrategy';
|
||||
import { isContainerIdentifier } from '../../util/PathUtil';
|
||||
import { CONTENT_TYPE, LDP } from '../../util/UriConstants';
|
||||
import { toCachedNamedNode } from '../../util/UriUtil';
|
||||
import { CONTENT_TYPE, LDP } from '../../util/Vocabularies';
|
||||
import type { DataAccessor } from './DataAccessor';
|
||||
|
||||
const { defaultGraph, namedNode, quad, variable } = DataFactory;
|
||||
|
@ -5,7 +5,7 @@ import { RepresentationMetadata } from '../../ldp/representation/RepresentationM
|
||||
import type { RepresentationPreferences } from '../../ldp/representation/RepresentationPreferences';
|
||||
import { INTERNAL_QUADS } from '../../util/ContentTypes';
|
||||
import { guardStream } from '../../util/GuardedStream';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../util/Vocabularies';
|
||||
import { matchingMediaTypes } from './ConversionUtil';
|
||||
import type { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
import { TypedRepresentationConverter } from './TypedRepresentationConverter';
|
||||
|
@ -5,7 +5,7 @@ import { RepresentationMetadata } from '../../ldp/representation/RepresentationM
|
||||
import { INTERNAL_QUADS } from '../../util/ContentTypes';
|
||||
import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError';
|
||||
import { pipeSafely } from '../../util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../util/Vocabularies';
|
||||
import type { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
import { TypedRepresentationConverter } from './TypedRepresentationConverter';
|
||||
|
||||
|
@ -14,7 +14,7 @@ import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError';
|
||||
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
|
||||
import { guardStream } from '../../util/GuardedStream';
|
||||
import type { ResourceLocker } from '../../util/locking/ResourceLocker';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../util/Vocabularies';
|
||||
import type { ResourceStore } from '../ResourceStore';
|
||||
import { PatchHandler } from './PatchHandler';
|
||||
|
||||
|
@ -2,8 +2,8 @@ import { DataFactory } from 'n3';
|
||||
import type { NamedNode, Quad } from 'rdf-js';
|
||||
import { RepresentationMetadata } from '../ldp/representation/RepresentationMetadata';
|
||||
import { pushQuad } from './QuadUtil';
|
||||
import { LDP, RDF } from './UriConstants';
|
||||
import { toCachedNamedNode } from './UriUtil';
|
||||
import { LDP, RDF } from './Vocabularies';
|
||||
|
||||
/**
|
||||
* Helper function to generate type quads for a Container or Resource.
|
||||
|
@ -1,72 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
const createNamespace = (prefix: string): ((suf: string) => string) => (suffix: string): string => `${prefix}${suffix}`;
|
||||
|
||||
const ACL_PREFIX = createNamespace('http://www.w3.org/ns/auth/acl#');
|
||||
export const ACL = {
|
||||
accessTo: ACL_PREFIX('accessTo'),
|
||||
agent: ACL_PREFIX('agent'),
|
||||
agentClass: ACL_PREFIX('agentClass'),
|
||||
default: ACL_PREFIX('default'),
|
||||
mode: ACL_PREFIX('mode'),
|
||||
|
||||
Write: ACL_PREFIX('Write'),
|
||||
Read: ACL_PREFIX('Read'),
|
||||
Append: ACL_PREFIX('Append'),
|
||||
Control: ACL_PREFIX('Control'),
|
||||
};
|
||||
|
||||
const DCTERMS_PREFIX = createNamespace('http://purl.org/dc/terms/');
|
||||
export const DCTERMS = {
|
||||
modified: DCTERMS_PREFIX('modified'),
|
||||
};
|
||||
|
||||
const FOAF_PREFIX = createNamespace('http://xmlns.com/foaf/0.1/');
|
||||
export const FOAF = {
|
||||
Agent: FOAF_PREFIX('Agent'),
|
||||
AuthenticatedAgent: FOAF_PREFIX('AuthenticatedAgent'),
|
||||
};
|
||||
|
||||
const HTTP_PREFIX = createNamespace('urn:solid:http:');
|
||||
export const HTTP = {
|
||||
location: HTTP_PREFIX('location'),
|
||||
slug: HTTP_PREFIX('slug'),
|
||||
};
|
||||
|
||||
const LDP_PREFIX = createNamespace('http://www.w3.org/ns/ldp#');
|
||||
export const LDP = {
|
||||
contains: LDP_PREFIX('contains'),
|
||||
|
||||
BasicContainer: LDP_PREFIX('BasicContainer'),
|
||||
Container: LDP_PREFIX('Container'),
|
||||
Resource: LDP_PREFIX('Resource'),
|
||||
};
|
||||
|
||||
const MA_PREFIX = createNamespace('http://www.w3.org/ns/ma-ont#');
|
||||
export const MA = {
|
||||
format: MA_PREFIX('format'),
|
||||
};
|
||||
|
||||
const PIM_PREFIX = createNamespace('http://www.w3.org/ns/pim/space#');
|
||||
export const PIM = {
|
||||
Storage: PIM_PREFIX('Storage'),
|
||||
};
|
||||
|
||||
const POSIX_PREFIX = createNamespace('http://www.w3.org/ns/posix/stat#');
|
||||
export const POSIX = {
|
||||
mtime: POSIX_PREFIX('mtime'),
|
||||
size: POSIX_PREFIX('size'),
|
||||
};
|
||||
|
||||
const RDF_PREFIX = createNamespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
||||
export const RDF = {
|
||||
type: RDF_PREFIX('type'),
|
||||
};
|
||||
|
||||
const XSD_PREFIX = createNamespace('http://www.w3.org/2001/XMLSchema#');
|
||||
export const XSD = {
|
||||
dateTime: XSD_PREFIX('dateTime'),
|
||||
integer: XSD_PREFIX('integer'),
|
||||
};
|
||||
|
||||
// Alias for most commonly used URI
|
||||
export const CONTENT_TYPE = MA.format;
|
@ -1,6 +1,6 @@
|
||||
import { DataFactory } from 'n3';
|
||||
import type { Literal, NamedNode, Term } from 'rdf-js';
|
||||
import { CONTENT_TYPE } from './UriConstants';
|
||||
import { CONTENT_TYPE } from './Vocabularies';
|
||||
|
||||
const { namedNode, literal } = DataFactory;
|
||||
|
||||
|
89
src/util/Vocabularies.ts
Normal file
89
src/util/Vocabularies.ts
Normal file
@ -0,0 +1,89 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention, function-paren-newline */
|
||||
|
||||
type PrefixResolver<T> = (localName: string) => T;
|
||||
type RecordOf<TKey extends any[], TValue> = Record<TKey[number], TValue>;
|
||||
|
||||
export type Namespace<TKey extends any[], TValue> =
|
||||
PrefixResolver<TValue> & RecordOf<TKey, TValue>;
|
||||
|
||||
/**
|
||||
* Creates a function that expands local names from the given base URI,
|
||||
* and exports the given local names as properties on the returned object.
|
||||
*/
|
||||
export const createNamespace = <T extends string>(baseUri: string, ...localNames: T[]):
|
||||
Namespace<typeof localNames, string> => {
|
||||
// Create a function that expands local names
|
||||
const expanded = {} as Record<string, string>;
|
||||
const namespace = ((localName: string): string => {
|
||||
if (!(localName in expanded)) {
|
||||
expanded[localName] = `${baseUri}${localName}`;
|
||||
}
|
||||
return expanded[localName];
|
||||
}) as Namespace<typeof localNames, string>;
|
||||
|
||||
// Expose the listed local names as properties
|
||||
for (const localName of localNames) {
|
||||
(namespace as RecordOf<typeof localNames, string>)[localName] = namespace(localName);
|
||||
}
|
||||
return namespace;
|
||||
};
|
||||
|
||||
export const ACL = createNamespace('http://www.w3.org/ns/auth/acl#',
|
||||
'accessTo',
|
||||
'agent',
|
||||
'agentClass',
|
||||
'default',
|
||||
'mode',
|
||||
|
||||
'Write',
|
||||
'Read',
|
||||
'Append',
|
||||
'Control',
|
||||
);
|
||||
|
||||
export const DCTERMS = createNamespace('http://purl.org/dc/terms/',
|
||||
'modified',
|
||||
);
|
||||
|
||||
export const FOAF = createNamespace('http://xmlns.com/foaf/0.1/',
|
||||
'Agent',
|
||||
'AuthenticatedAgent',
|
||||
);
|
||||
|
||||
export const HTTP = createNamespace('urn:solid:http:',
|
||||
'location',
|
||||
'slug',
|
||||
);
|
||||
|
||||
export const LDP = createNamespace('http://www.w3.org/ns/ldp#',
|
||||
'contains',
|
||||
|
||||
'BasicContainer',
|
||||
'Container',
|
||||
'Resource',
|
||||
);
|
||||
|
||||
export const MA = createNamespace('http://www.w3.org/ns/ma-ont#',
|
||||
'format',
|
||||
);
|
||||
|
||||
export const PIM = createNamespace('http://www.w3.org/ns/pim/space#',
|
||||
'Storage',
|
||||
);
|
||||
|
||||
export const POSIX = createNamespace('http://www.w3.org/ns/posix/stat#',
|
||||
'mtime',
|
||||
'size',
|
||||
);
|
||||
|
||||
export const RDF = createNamespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
||||
'type',
|
||||
);
|
||||
|
||||
export const XSD = createNamespace('http://www.w3.org/2001/XMLSchema#',
|
||||
'dateTime',
|
||||
'integer',
|
||||
);
|
||||
|
||||
// Alias for most commonly used URI
|
||||
export const CONTENT_TYPE = MA.format;
|
@ -3,7 +3,7 @@ import { join } from 'path';
|
||||
import type { HttpHandler, Initializer, ResourceStore } from '../../src/';
|
||||
import { RepresentationMetadata } from '../../src/ldp/representation/RepresentationMetadata';
|
||||
import { guardStream } from '../../src/util/GuardedStream';
|
||||
import { CONTENT_TYPE, LDP } from '../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE, LDP } from '../../src/util/Vocabularies';
|
||||
import { AclHelper, ResourceHelper } from '../util/TestHelpers';
|
||||
import { BASE, getTestFolder, createFolder, removeFolder, instantiateFromConfig } from './Config';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { HttpHandler, Initializer, ResourceStore } from '../../src/';
|
||||
import { LDP } from '../../src/util/UriConstants';
|
||||
import { LDP } from '../../src/util/Vocabularies';
|
||||
import { ResourceHelper } from '../util/TestHelpers';
|
||||
import { BASE, getTestFolder, createFolder, removeFolder, instantiateFromConfig } from './Config';
|
||||
|
||||
|
@ -13,7 +13,7 @@ import type { ResourceLocker } from '../../src/util/locking/ResourceLocker';
|
||||
import { SingleThreadedResourceLocker } from '../../src/util/locking/SingleThreadedResourceLocker';
|
||||
import { WrappedExpiringResourceLocker } from '../../src/util/locking/WrappedExpiringResourceLocker';
|
||||
import { guardedStreamFrom } from '../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../src/util/Vocabularies';
|
||||
import { BASE } from './Config';
|
||||
|
||||
describe('A LockingResourceStore', (): void => {
|
||||
|
@ -4,7 +4,7 @@ import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import { Parser } from 'n3';
|
||||
import type { MockResponse } from 'node-mocks-http';
|
||||
import type { HttpHandler } from '../../src/server/HttpHandler';
|
||||
import { LDP } from '../../src/util/UriConstants';
|
||||
import { LDP } from '../../src/util/Vocabularies';
|
||||
import { performRequest } from '../util/Util';
|
||||
import { BASE, instantiateFromConfig } from './Config';
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { ChainedConverter } from '../../src/storage/conversion/ChainedConverter'
|
||||
import { QuadToRdfConverter } from '../../src/storage/conversion/QuadToRdfConverter';
|
||||
import { RdfToQuadConverter } from '../../src/storage/conversion/RdfToQuadConverter';
|
||||
import { guardedStreamFrom, readableToString } from '../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../src/util/Vocabularies';
|
||||
|
||||
describe('A ChainedConverter', (): void => {
|
||||
const converters = [
|
||||
|
@ -9,7 +9,7 @@ import { RepresentationMetadata } from '../../../../src/ldp/representation/Repre
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
import { StaticAsyncHandler } from '../../../util/StaticAsyncHandler';
|
||||
|
||||
describe('A BasicResponseWriter', (): void => {
|
||||
|
@ -2,7 +2,7 @@ import { BasicMetadataExtractor } from '../../../../../src/ldp/http/metadata/Bas
|
||||
import type { MetadataParser } from '../../../../../src/ldp/http/metadata/MetadataParser';
|
||||
import type { RepresentationMetadata } from '../../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import { RDF } from '../../../../../src/util/UriConstants';
|
||||
import { RDF } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
class BasicParser implements MetadataParser {
|
||||
private readonly header: string;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { createResponse } from 'node-mocks-http';
|
||||
import { LinkRelMetadataWriter } from '../../../../../src/ldp/http/metadata/LinkRelMetadataWriter';
|
||||
import { RepresentationMetadata } from '../../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import { LDP, RDF } from '../../../../../src/util/UriConstants';
|
||||
import { toCachedNamedNode } from '../../../../../src/util/UriUtil';
|
||||
import { LDP, RDF } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A LinkRelMetadataWriter', (): void => {
|
||||
const writer = new LinkRelMetadataWriter({ [RDF.type]: 'type', dummy: 'dummy' });
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { LinkTypeParser } from '../../../../../src/ldp/http/metadata/LinkTypeParser';
|
||||
import { RepresentationMetadata } from '../../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import { RDF } from '../../../../../src/util/UriConstants';
|
||||
import { RDF } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A LinkTypeParser', (): void => {
|
||||
const parser = new LinkTypeParser();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { createResponse } from 'node-mocks-http';
|
||||
import { MappedMetadataWriter } from '../../../../../src/ldp/http/metadata/MappedMetadataWriter';
|
||||
import { RepresentationMetadata } from '../../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import { CONTENT_TYPE } from '../../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A MappedMetadataWriter', (): void => {
|
||||
const writer = new MappedMetadataWriter({ [CONTENT_TYPE]: 'content-type', dummy: 'dummy' });
|
||||
|
@ -2,7 +2,7 @@ import { SlugParser } from '../../../../../src/ldp/http/metadata/SlugParser';
|
||||
import { RepresentationMetadata } from '../../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
import { HTTP } from '../../../../../src/util/UriConstants';
|
||||
import { HTTP } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A SlugParser', (): void => {
|
||||
const parser = new SlugParser();
|
||||
|
@ -5,7 +5,7 @@ import type { ResourceIdentifier } from '../../../../src/ldp/representation/Reso
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
|
||||
import { HTTP } from '../../../../src/util/UriConstants';
|
||||
import { HTTP } from '../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A PostOperationHandler', (): void => {
|
||||
const store = {
|
||||
|
@ -2,7 +2,7 @@ import 'jest-rdf';
|
||||
import { literal, namedNode, quad } from '@rdfjs/data-model';
|
||||
import type { Literal, NamedNode, Quad } from 'rdf-js';
|
||||
import { RepresentationMetadata } from '../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A RepresentationMetadata', (): void => {
|
||||
let metadata: RepresentationMetadata;
|
||||
|
@ -18,8 +18,8 @@ import type { Guarded } from '../../../src/util/GuardedStream';
|
||||
import { SingleRootIdentifierStrategy } from '../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import * as quadUtil from '../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom } from '../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF } from '../../../src/util/UriConstants';
|
||||
import { toCachedNamedNode } from '../../../src/util/UriUtil';
|
||||
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF } from '../../../src/util/Vocabularies';
|
||||
import quad = DataFactory.quad;
|
||||
import namedNode = DataFactory.namedNode;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import type { RepresentationConverter } from '../../../src/storage/conversion/Re
|
||||
import { RepresentationConvertingStore } from '../../../src/storage/RepresentationConvertingStore';
|
||||
import type { ResourceStore } from '../../../src/storage/ResourceStore';
|
||||
import { InternalServerError } from '../../../src/util/errors/InternalServerError';
|
||||
import { CONTENT_TYPE } from '../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../src/util/Vocabularies';
|
||||
|
||||
describe('A RepresentationConvertingStore', (): void => {
|
||||
let store: RepresentationConvertingStore;
|
||||
|
@ -12,8 +12,8 @@ import type { SystemError } from '../../../../src/util/errors/SystemError';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../../../src/util/errors/UnsupportedMediaTypeHttpError';
|
||||
import type { Guarded } from '../../../../src/util/GuardedStream';
|
||||
import { guardedStreamFrom, readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, DCTERMS, LDP, POSIX, RDF, XSD } from '../../../../src/util/UriConstants';
|
||||
import { toCachedNamedNode, toLiteral } from '../../../../src/util/UriUtil';
|
||||
import { CONTENT_TYPE, DCTERMS, LDP, POSIX, RDF, XSD } from '../../../../src/util/Vocabularies';
|
||||
import { mockFs } from '../../../util/Util';
|
||||
|
||||
jest.mock('fs');
|
||||
|
@ -6,8 +6,8 @@ import { APPLICATION_OCTET_STREAM } from '../../../../src/util/ContentTypes';
|
||||
import { NotFoundHttpError } from '../../../../src/util/errors/NotFoundHttpError';
|
||||
import type { Guarded } from '../../../../src/util/GuardedStream';
|
||||
import { guardedStreamFrom, readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, LDP, RDF } from '../../../../src/util/UriConstants';
|
||||
import { toCachedNamedNode } from '../../../../src/util/UriUtil';
|
||||
import { CONTENT_TYPE, LDP, RDF } from '../../../../src/util/Vocabularies';
|
||||
|
||||
describe('An InMemoryDataAccessor', (): void => {
|
||||
const base = 'http://test.com/';
|
||||
|
@ -14,8 +14,8 @@ import { UnsupportedMediaTypeHttpError } from '../../../../src/util/errors/Unsup
|
||||
import type { Guarded } from '../../../../src/util/GuardedStream';
|
||||
import { SingleRootIdentifierStrategy } from '../../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, LDP, RDF } from '../../../../src/util/UriConstants';
|
||||
import { toCachedNamedNode } from '../../../../src/util/UriUtil';
|
||||
import { CONTENT_TYPE, LDP, RDF } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { literal, namedNode, quad } = DataFactory;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { ChainedConverter } from '../../../../src/storage/conversion/ChainedConv
|
||||
import { supportsConversion } from '../../../../src/storage/conversion/ConversionUtil';
|
||||
import type { RepresentationConverterArgs } from '../../../../src/storage/conversion/RepresentationConverter';
|
||||
import { TypedRepresentationConverter } from '../../../../src/storage/conversion/TypedRepresentationConverter';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
|
||||
class DummyConverter extends TypedRepresentationConverter {
|
||||
private readonly inTypes: Record<string, number>;
|
||||
|
@ -8,7 +8,7 @@ import type { RepresentationPreferences } from '../../../../src/ldp/representati
|
||||
import type { ResourceIdentifier } from '../../../../src/ldp/representation/ResourceIdentifier';
|
||||
import { QuadToRdfConverter } from '../../../../src/storage/conversion/QuadToRdfConverter';
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A QuadToRdfConverter', (): void => {
|
||||
const converter = new QuadToRdfConverter();
|
||||
|
@ -11,7 +11,7 @@ import type { ResourceIdentifier } from '../../../../src/ldp/representation/Reso
|
||||
import { RdfToQuadConverter } from '../../../../src/storage/conversion/RdfToQuadConverter';
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
|
||||
describe('A RdfToQuadConverter.test.ts', (): void => {
|
||||
const converter = new RdfToQuadConverter();
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'jest-rdf';
|
||||
import { literal, namedNode } from '@rdfjs/data-model';
|
||||
import { CONTENT_TYPE, XSD } from '../../../src/util/UriConstants';
|
||||
import {
|
||||
toCachedNamedNode,
|
||||
toSubjectTerm,
|
||||
@ -9,6 +8,7 @@ import {
|
||||
toLiteral,
|
||||
isTerm,
|
||||
} from '../../../src/util/UriUtil';
|
||||
import { CONTENT_TYPE, XSD } from '../../../src/util/Vocabularies';
|
||||
|
||||
describe('An UriUtil', (): void => {
|
||||
describe('isTerm function', (): void => {
|
||||
|
17
test/unit/util/Vocabularies.test.ts
Normal file
17
test/unit/util/Vocabularies.test.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { LDP } from '../../../src/util/Vocabularies';
|
||||
|
||||
describe('Vocabularies', (): void => {
|
||||
describe('LDP', (): void => {
|
||||
it('can create new properties.', (): void => {
|
||||
expect(LDP('new')).toBe('http://www.w3.org/ns/ldp#new');
|
||||
});
|
||||
|
||||
it('caches new properties.', (): void => {
|
||||
expect(LDP('new')).toBe(LDP('new'));
|
||||
});
|
||||
|
||||
it('exposes ldp:contains.', (): void => {
|
||||
expect(LDP.contains).toBe('http://www.w3.org/ns/ldp#contains');
|
||||
});
|
||||
});
|
||||
});
|
@ -8,7 +8,7 @@ import type { MockResponse } from 'node-mocks-http';
|
||||
import { createResponse } from 'node-mocks-http';
|
||||
import type { ResourceStore, PermissionSet, HttpHandler, HttpRequest } from '../../src/';
|
||||
import { guardedStreamFrom, RepresentationMetadata, ensureTrailingSlash } from '../../src/';
|
||||
import { CONTENT_TYPE } from '../../src/util/UriConstants';
|
||||
import { CONTENT_TYPE } from '../../src/util/Vocabularies';
|
||||
import { performRequest } from './Util';
|
||||
|
||||
/* eslint-disable jest/no-standalone-expect */
|
||||
|
Loading…
x
Reference in New Issue
Block a user