All files / languages/sparql/services/endpoints graphdb-endpoint-provider.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                            70x   70x           3x 3x   3x           3x                 1x      
import { SparqlConnection, SparqlStoreType } from '../sparql-connection';
import { ComunicaEndpoint, SparqlEndpoint } from '../sparql-endpoint';
import { ISparqlEndpointProvider, SparqlEndpointOptions } from '../sparql-endpoint-provider.interface';
 
/**
 * Query source provider for Ontotext GraphDB SPARQL endpoints.
 * 
 * GraphDB supports inference toggling via the `infer` URL parameter.
 * When `infer=true`, GraphDB includes inferred statements in results.
 * When `infer=false`, only explicit statements are returned.
 * 
 * @see https://graphdb.ontotext.com/documentation/10.0/sparql-api.html
 */
export class GraphDbEndpointProvider implements ISparqlEndpointProvider {
    readonly storeType: SparqlStoreType = 'graphdb';
 
    readonly supportsInference = true;
 
    async createEndpoint(
        connection: SparqlConnection,
        options: SparqlEndpointOptions
    ): Promise<ComunicaEndpoint> {
        const url = new URL(connection.endpointUrl);
        url.searchParams.set('infer', options.inferenceEnabled ? 'true' : 'false');
 
        const source: SparqlEndpoint = {
            type: 'sparql',
            value: url.toString(),
            connection: connection,
        };
 
        return source;
    }
 
    async getGraphs(
        _connection: SparqlConnection,
        _options: SparqlEndpointOptions
    ): Promise<string[]> {
        // TODO: Implement GraphDB-specific graph retrieval via SPARQL query
        // e.g., SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }
        return [];
    }
}