UNPKG

rdf-dataset-fragmenter

Version:
39 lines (38 loc) 2.58 kB
import type * as RDF from '@rdfjs/types'; import { ResourceIdentifier } from './identifier/ResourceIdentifier'; import type { IQuadTransformer } from './IQuadTransformer'; import type { IValueModifier } from './value/IValueModifier'; /** * A quad transformer that matches all resources of the given type, * and rewrites its (subject) IRI (across all triples) so that it becomes part of the targeted resource. * * For example, a transformer matching on type `Post` for identifier predicate `hasId` and target predicate `hasCreator` * will modify all post IRIs to become a hash-based IRI inside the object IRI of `hasCreator`. * Concretely, `<ex:post1> a <Post>. <ex:post1> <hasId> '1'. <ex:post1> <hasCreator> <urn:person1>` * will become * `<urn:person1#Post1> a <Post>. <urn:person1#Post1> <hasId> '1'. <urn:person1#post1> <hasCreator> <urn:person1>`. * * WARNING: This transformer assumes that all the applicable resources * have `rdf:type` occurring as first triple with the resource IRI as subject. */ export declare class QuadTransformerRemapResourceIdentifier implements IQuadTransformer { private readonly newIdentifierSeparator; private readonly identifierPredicate; private readonly identifierValueModifier; private readonly keepSubjectFragment; readonly resourceIdentifier: ResourceIdentifier<RDF.NamedNode>; /** * @param newIdentifierSeparator Separator string to use inbetween the target IRI and the identifier value * when minting a new resource IRI. This may also be a relative IRI. * @param typeRegex The RDF type that should be used to capture resources. * @param identifierPredicateRegex Predicate regex that contains a resource identifier. * @param targetPredicateRegex Predicate regex that contains an IRI onto which the resource identifier should be * remapped. * @param identifierValueModifier An optional value modifier that will be applied on matched identifier values. * @param keepSubjectFragment If the fragment of the original subject should be inherited onto the new identifier IRI. */ constructor(newIdentifierSeparator: string, typeRegex: string, identifierPredicateRegex: string, targetPredicateRegex: string, identifierValueModifier: IValueModifier | undefined, keepSubjectFragment: boolean | undefined); transform(quad: RDF.Quad, allowedComponent?: 'subject' | 'object'): RDF.Quad[]; protected mapQuad(quad: RDF.Quad, allowedComponent?: 'subject' | 'object'): [boolean, RDF.Quad]; end(): void; }