import * as RDF from "@rdfjs/types"; import { IBindings, ISettings } from "sparqljson-parse"; /** * Converts SPARQL JSON results to a tree-based structure by splitting variables on a certain delimiter. */ export declare class Converter { private readonly delimiter; private readonly parser; private readonly materializeRdfJsTerms; constructor(settings?: IConverterSettings); /** * Adds a value to a tree. * @param tree A tree datastructure. * @param {string[]} path The path of keys in the tree. * @param {Term} value A value to add. * @param {string} lastKeyPath The accumulated key path (separated by the given delimiter) * through recursive calls, can be empty. * @param {ISchema} schema A schema. * @param {string} delimiter The string to join key paths by. */ static addValueToTree(tree: any, path: string[], value: RDF.Term, lastKeyPath: string, schema: ISchema, delimiter: string): void; /** * Recursively merge the two given trees. * @param tree1 A first tree (has key priority on literals). * @param tree2 A second tree. All arrays will/should only have a single element. * @return {any} The merged tree. */ static mergeTrees(tree1: any, tree2: any): IMergeResult; /** * Materialize all RDF terms in the given tree to raw values. * This does not mutate the original tree. * @param tree A tree. * @return {any} A materialized tree. */ static materializeTree(tree: any): any; /** * Convert a complete SPARQL JSON response to a GraphQL results tree. * @param sparqlResponse A SPARQL JSON response. * @param {ISchema} schema A schema. * @return {any} A GraphQL results tree. */ sparqlJsonResultsToTree(sparqlResponse: any, schema?: ISchema): any; /** * Convert an array of bindings to a GraphQL results tree. * @param {IBindings[]} bindingsArray An array of bindings. * @param {ISchema} schema A schema. * @return {any} A GraphQL results tree. */ bindingsToTree(bindingsArray: IBindings[], schema: ISchema): any; } /** * Constructor settings object interface for {@link Converter}. */ export interface IConverterSettings extends ISettings { /** * The string to split variable names by. * Defaults to '_'. */ delimiter?: string; /** * If RDFJS terms should be converted to their raw value. * Defaults to false. */ materializeRdfJsTerms?: boolean; } export interface ISchema { /** * Defines for each variable if the tree structure should have an array or a singular value for its values. * If true, a single value is represented, without array. * Defaults to false (arrays), due to the open-world-assumption in RDF. */ singularizeVariables: { [id: string]: boolean; }; } export interface IMergeResult { /** * If the merging was successful. * If not, information was withheld from the result. */ valid: boolean; /** * The result of the merge. */ result: any; }