feat: Add getChildren function to DataAccessor interface

DataAccessors are now no longer responsible for generating ldp:contains triples.
This commit is contained in:
Joachim Van Herwegen
2021-05-11 14:40:42 +02:00
parent 52a3b84ee0
commit cae9d54fac
12 changed files with 187 additions and 137 deletions

View File

@@ -1,5 +1,4 @@
import arrayifyStream from 'arrayify-stream';
import { DataFactory } from 'n3';
import type { NamedNode, Quad } from 'rdf-js';
import { BasicRepresentation } from '../ldp/representation/BasicRepresentation';
import type { Representation } from '../ldp/representation/Representation';
@@ -27,18 +26,6 @@ export function generateResourceQuads(subject: NamedNode, isContainer: boolean):
return quads;
}
/**
* Helper function to generate the quads describing that the resource URIs are children of the container URI.
* @param containerURI - The URI of the container.
* @param childURIs - The URI of the child resources.
*
* @returns The generated quads.
*/
export function generateContainmentQuads(containerURI: NamedNode, childURIs: string[]): Quad[] {
return new RepresentationMetadata(containerURI,
{ [LDP.contains]: childURIs.map(DataFactory.namedNode) }).quads();
}
/**
* Helper function to clone a representation, the original representation can still be used.
* This function loads the entire stream in memory.