import { BlankNode, Literal, NamedNode, Node } from '../models.js'; import { Shape } from './Shape.js'; import { List } from './List.js'; import { ShapeSet } from '../collections/ShapeSet.js'; import { NodeSet } from '../collections/NodeSet.js'; import { CoreMap } from '../collections/CoreMap.js'; import { ShapeValuesSet } from '../collections/ShapeValuesSet.js'; export declare const LINCD_DATA_ROOT: string; export declare class SHACL_Shape extends Shape { static targetClass: NamedNode; static validating: Set; get type(): NamedNode; set type(val: NamedNode); protected _validateNode(node: NamedNode, validated?: CoreMap): boolean; } export declare class NodeShape extends SHACL_Shape { static targetClass: NamedNode; private static _instances; /** * Because (currently) all NodeShapes are initialized immediately upon initialisation * We can cache the instances of NodeShapes to speed up frequent methods used in Storage */ static get instances(): ShapeSet; get targetNode(): NamedNode; set targetNode(value: NamedNode); get targetClass(): NamedNode; set targetClass(value: NamedNode); get properties(): ShapeSet; get extends(): NodeShape; set extends(value: NodeShape); /** * A human-readable description for this shape */ get description(): string; set description(val: string); static getShapesOf(node: Node): ShapeSet; addPropertyShape(property: PropertyShape): void; getPropertyShapes(includeSuperClasses?: boolean): ShapeSet; getPropertyShape(label: string, checkSubShapes?: boolean): PropertyShape; /** * Returns all the classes and properties that are references by this shape */ getOntologyEntities(): NodeSet; validateNode(node: Node): boolean; validateNodeByType(node: Node): boolean; protected _validateNode(node: Node, validated?: CoreMap): boolean; } export declare class PropertyShape extends SHACL_Shape { static targetClass: NamedNode; get class(): NamedNode; set class(value: NamedNode); /** * Returns the NodeShape that all value nodes need to conform to * On a graph level this accessor returns the value of shacl:node for this PropertyShape (if any) * Note: it's named valueShape because node & nodeShape are already used internally in LINCD * @see https://www.w3.org/TR/shacl/#NodeConstraintComponent * */ get valueShape(): NodeShape; set valueShape(value: NodeShape | NamedNode); get nodeKind(): NamedNode; set nodeKind(value: NamedNode); get datatype(): NamedNode; set datatype(value: NamedNode); get maxCount(): number; set maxCount(value: number); get minCount(): number; set minCount(value: number); get name(): string; set name(value: string); get description(): string; set description(value: string); get path(): NamedNode | NamedNode[]; set path(value: NamedNode | NamedNode[]); get in(): NamedNode; set in(value: NamedNode); get inList(): List; set inList(value: List); get parentNodeShape(): NodeShape; /** * Returns all the classes and properties that are references by this shape */ getOntologyEntities(): NodeSet; validateNode(node: NamedNode): boolean; resolveFor(node: NamedNode): NamedNode | import("../collections/NodeValuesSet.js").NodeValuesSet | NodeSet; protected _validateNode(node: NamedNode, validated?: CoreMap): boolean; } export interface NodeShapeConfig { /** * Set to true to close the shape. This means any target node of this shape that has properties outside the defined properties of this shape is invalid. */ closed?: boolean; /** * Optional list of properties that are also permitted in addition to those explicitly listed by this shape. */ ignoredProperties: NodeSet; } export interface LiteralPropertyShapeConfig extends PropertyShapeConfig { nodeKind?: typeof Literal; /** * Values of the configured property must be less than the values of this 'lessThan' property * Provide a NamedNode with rdf:type rdf:Property */ lessThan?: NamedNode; /** * Values of the configured property must be less than or equal the values of this 'lessThan' property * Provide a NamedNode with rdf:type rdf:Property */ lessThanOrEquals?: NamedNode; /** * All values of this property must be higher than this number */ minExclusive?: number | string | Literal; /** * All values of this property must be higher than or equal this number */ minInclusive?: number; /** * All values of this property must be lower than this number */ maxExclusive?: number; /** * All values of this property must be lower than or equal this number */ maxInclusive?: number; /** * All literal values of this property must at least be this long */ minLength?: number; /** * All literal values of this property must at most be this long */ maxLength?: number; /** * All literal values of this property must match this regular expression */ pattern?: RegExp; /** * All literal values of this property must have one of these languages as their language tag */ languageIn?: string[]; /** * No pair of values may use the same language tag. */ uniqueLang?: boolean; /** * Each literal value of this property must use this datatype */ datatype?: NamedNode; /** * Each value of the property must occur in this set */ in?: NodeSet | Node[]; } export interface ObjectPropertyShapeConfig extends PropertyShapeConfig { nodeKind?: typeof NamedNode | typeof BlankNode; /** * Each value of this property must have this class as its rdf:type */ class?: NamedNode; /** * The shape that values of this property path need to confirm to. * You need to provide a class that extends Shape. * This is LINCDs equivalent of shacl:node */ shape?: typeof Shape | [string, string]; } export interface PropertyShapeConfig { /** * The property path of this property shape. * * Currently, only 1 property is supported. * * Provide a NamedNode that has is a `rdf:Property` */ path: NamedNode | NamedNode[]; /** * Indicates that this property must exist. * Shorthand for minCount=1 */ required?: boolean; /** Each value must be of this node type. Choose from NamedNode or BlankNode or Literal and provide the actual class as value @example ```tsx import {BlankNode,NamedNode,Literal} from "lincd/models"; @linkedProperty({nodeKind:NamedNode}) ``` */ nodeKind?: typeof Node | (typeof Node)[]; /** * Minimum number of values required */ minCount?: number; /** * Maximum number of values allowed */ maxCount?: number; /** * Values of the configured property must equal the values of this 'equals' property. * Provide a NamedNode with rdf:type rdf:Property */ equals?: NamedNode; /** * Values of the configured property must differ from the values of this 'disjoint' property * Provide a NamedNode with rdf:type rdf:Property */ disjoint?: NamedNode; /** * At least one value of this property must equal the given Node */ hasValue?: Node; name?: string; description?: string; order?: number; group?: string; /** * should correlate to the given datatype or class * i.e. if class = foaf.Person you should provide a NamedNode with rdf.type foaf.Person or a Shape instance that has targetClass foaf.Person */ defaultValue?: string | number | Node | Shape; /** * Each value of the property must occur in this set */ in?: NodeSet | Node[]; /** * Values of the configured property path are sorted by the values of this property path. */ sortBy?: NamedNode | NamedNode[]; } export interface ParameterConfig { optional?: number; } export declare function registerPropertyShape(shape: NodeShape, propertyShape: PropertyShape): void; export declare function createPropertyShape(config: Config, propertyKey: string, defaultNodeKind?: NamedNode, shapeClass?: typeof Shape | [string, string]): PropertyShape; export declare function onShapeSetup(shapeClass: typeof Shape | [string, string], callback: (shape: NodeShape) => void, propertyName?: string, waitForSuperShapes?: boolean): void; export declare const literalProperty: (config: LiteralPropertyShapeConfig) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; export declare const objectProperty: (config: ObjectPropertyShapeConfig) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; /** * The most general decorator to indicate a get/set method requires & provides a certain linked data property. * Using this generator generates a [SHACL Property Shape](https://www.w3.org/TR/shacl/#property-shapes) * @param config - configures the property shape with a plain javascript object that follows the [PropertyShapeConfig](/docs/lincd.js/interfaces/utils_ShapeDecorators.PropertyShapeConfig) interface. * * @example * ``` * \@linkedProperty({ * path:foaf.name, * required:true, * nodeKind:Literal, * maxLength:1, * defaultValue:"John" * }) * get name(){ * return this.getValue(foaf.name) || "John" * } * ``` */ export declare const linkedProperty: (config: ObjectPropertyShapeConfig | LiteralPropertyShapeConfig) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; export declare function disallowProperty(target: any, propertyKey: string, descriptor: PropertyDescriptor): void; export declare class ValidationResult extends Shape { static targetClass: NamedNode; get focusNode(): Node; set focusNode(value: Node); get sourceShape(): SHACL_Shape; set sourceShape(value: SHACL_Shape); get resultSeverity(): NamedNode; set resultSeverity(value: NamedNode); get resultPath(): NamedNode | NamedNode[]; set resultPath(value: NamedNode | NamedNode[]); get validatedValue(): Node; set validatedValue(value: Node); get message(): string; set message(value: string); get sourceConstraintComponent(): NamedNode; set sourceConstraintComponent(value: NamedNode); static createForNodeAgainstPropertyShape(focusNode: NamedNode, propertyShape: PropertyShape): ValidationResult; toString(): string; } export declare class ValidationReport extends Shape { static targetClass: NamedNode; static validating: CoreMap; get conforms(): boolean; set conforms(val: boolean); get validationResults(): ShapeValuesSet; /** * From the SHACL spec: https://www.w3.org/TR/shacl/#validation-definition * Validation of a focus node against a shape: Given a focus node in the data graph and a shape in the shapes graph, the validation results are the union of the results of the validation of the focus node against all constraints declared by the shape, unless the shape has been deactivated, in which case the validation results are empty. * @param focusNode * @param shape */ static forNodeAgainstShape(focusNode: Node, shape: NodeShape): ValidationReport; static printForShapeInstances(shape: typeof Shape): void; toString(): string; } export declare function getNodeShapeUri(packageName: string, shapeName: string): string; export declare function getAndClearCallbacks(nodeShape: NamedNode): ((shape: NodeShape) => void)[]; export declare const addNodeShapeCallback: (nodeShape: NamedNode, callback: (shape: NodeShape) => void) => void;