@jeswr/shacl2shex
Version:
Convert SHACL to ShEx
66 lines (65 loc) • 2.15 kB
TypeScript
/**
* @fileoverview ShapeMap generation functionality for preserving SHACL target class information
* @generated This file was generated by GitHub Copilot AI to resolve issue #283
*/
import { Store } from 'n3';
/**
* A ShapeMap entry that associates RDF nodes with shapes for validation
* Based on the ShapeMap specification: https://shexspec.github.io/shape-map/
*/
export interface ShapeMapEntry {
/** The node pattern (e.g., "FOCUS rdf:type ex:Person") */
node: string;
/** The shape to validate against */
shape: string;
}
/**
* A complete ShapeMap that can be used with ShEx validation
*/
export interface ShapeMap {
/** Array of node-shape associations */
entries: ShapeMapEntry[];
}
/**
* Extracts ShapeMap information from a SHACL dataset
*
* This function processes SHACL NodeShapes and generates corresponding ShapeMap entries
* that preserve the target class information from sh:targetClass properties.
*
* @param shapeStore - The RDF store containing SHACL shapes
* @returns A ShapeMap object containing the extracted mappings
*
* @example
* ```typescript
* import { shapeMapFromDataset } from './shapeMapFromDataset';
*
* const store = // ... load SHACL data
* const shapeMap = shapeMapFromDataset(store);
* console.log(shapeMap);
* // Output: {
* // entries: [
* // {
* // node: "FOCUS rdf:type ex:ClassOfProduct",
* // shape: "ex:ClassOfProductShape"
* // }
* // ]
* // }
* ```
*/
export declare function shapeMapFromDataset(shapeStore: Store): ShapeMap;
/**
* Converts a ShapeMap object to a human-readable string format
*
* @param shapeMap - The ShapeMap to serialize
* @param prefixes - Optional prefix mappings for shorter URIs
* @returns A string representation of the ShapeMap
*
* @example
* ```typescript
* const shapeMap = { entries: [{ node: "FOCUS rdf:type ex:Person", shape: "ex:PersonShape" }] };
* const output = writeShapeMap(shapeMap);
* console.log(output);
* // Output: "FOCUS rdf:type ex:Person@ex:PersonShape"
* ```
*/
export declare function writeShapeMap(shapeMap: ShapeMap, prefixes?: Record<string, string>): string;