extract-cbd-shape
Version:
Extract an entity based on CBD and a SHACL shape
97 lines (96 loc) • 3.81 kB
TypeScript
import { RdfStore } from "rdf-stores";
import { Term } from "@rdfjs/types";
import { Path } from "./Path";
import { RDFMap, ShapeTemplate } from "./Shape";
export declare class ShapesGraph {
shapes: RDFMap<ShapeTemplate>;
private counter;
constructor(shapeStore: RdfStore);
/**
* This function returns a Mermaid representation of a shape identified by a given term.
* @param term {Term} - The term of the Shape that is the start of the representation.
*/
toMermaid(term: Term): string;
/**
* This function returns a Mermaid representation of a given shape.
* @param shape - The shape for which to generate a representation.
* @param id - The ID to identify the shape in the representation.
* @param name - The name used for the shape in the representation.
* @private
*/
private toMermaidSingleShape;
/**
* This function removes < and > from a label.
* It also adds the invisible character after 'http(s):' and after 'www' to avoid
* the path being interpreted as a link. See https://github.com/orgs/community/discussions/106690.
* @param path - The path from which to remove the < and >.
* @private
*/
private clean;
/**
* This function returns true if the given path is required.
* @param path - The path that needs to be checked.
* @param requiredPaths - An array of all required paths.
* @private
*/
private isPathRequired;
/**
* This function returns a Mermaid presentation for an array of simple paths.
* This function is intended to be used with shape.requiredPaths and shape.optionalPaths.
* @param paths - An array of paths.
* @param alreadyProcessedPaths - An array of stringified paths that already have been processed.
* @param shapedId - The id of the shape to which these paths belong.
* @param link - The Mermaid link that needs to be used.
* @private
*/
private simplePathToMermaid;
/**
* This function returns true if a given path is real inverse path.
* This means that the path is not a double, quadruple, ... inverse path.
* @param path - The path that needs to be checked.
* @private
*/
private isRealInversePath;
/**
* This function removes all the ^ from the path.
* @param path - The path from which to remove the ^.
* @private
*/
private getRealPath;
protected constructPathPattern(shapeStore: RdfStore, listItem: Term, literalType?: Term): Path;
/**
* @param shapeStore
* @param propertyShapeId
* @param shape
* @param required
* @returns false if it wasn't a property shape
*/
protected preprocessPropertyShape(shapeStore: RdfStore, propertyShapeId: Term, shape: ShapeTemplate, required?: boolean): boolean;
/**
* Processes a NodeShape or PropertyShape and adds NodeLinks and required properties to the arrays.
* @param shapeStore
* @param shapeId
* @param shape
* @returns
*/
preprocessShape(shapeStore: RdfStore, shapeId: Term, shape: ShapeTemplate): true | void;
/**
* Processes a NodeShape
* @param shapeStore
* @param nodeShapeId
* @param shape
*/
protected preprocessNodeShape(shapeStore: RdfStore, nodeShapeId: Term, shape: ShapeTemplate): void;
/**
* @param shapeStore
*/
initializeFromStore(shapeStore: RdfStore): RDFMap<ShapeTemplate>;
/**
* Processes all element from an RDF List, or detects it wasn't a list after all and it's just one element.
* @param shapeStore
* @param item
* @returns
*/
protected rdfListToGenerator(shapeStore: RdfStore, item: Term): Generator<Term>;
protected rdfListToArray(shapeStore: RdfStore, item: Term): Array<Term>;
}