All files / languages/sparql/services sparql-result-serializer.interface.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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 45 46 47 48 49 50 51 52 53 54 55                                                                                                             
import * as vscode from 'vscode';
import { AsyncIterator } from 'asynciterator';
import { Bindings, Quad } from '@rdfjs/types';
import { BindingsResult, SparqlQueryExecutionState } from '@src/languages/sparql/services/sparql-query-state';
 
/**
 * Interface for the SparqlResultSerializer.
 */
export interface ISparqlResultSerializer {
	/**
	 * Serializes SPARQL query results into a format suitable for the webview.
	 * @param context The query execution context.
	 * @param bindingStream The SPARQL query results as a BindingsStream.
	 * @param token The cancellation token.
	 * @returns An object containing the serialized results.
	 */
	serializeBindings(
		context: SparqlQueryExecutionState,
		bindingStream: AsyncIterator<Bindings>,
		token: vscode.CancellationToken
	): Promise<BindingsResult>;
 
	/**
	 * Serializes a stream of quads into Turtle format.
	 * @param context The query execution context.
	 * @param quadStream The SPARQL query results as a QuadStream.
	 * @param token The cancellation token.
	 * @returns A string containing the serialized Turtle document.
	 */
	serializeQuads(
		context: SparqlQueryExecutionState,
		quadStream: AsyncIterator<Quad>,
		token: vscode.CancellationToken
	): Promise<string>;
 
	/**
	 * Serializes an array of quads into Turtle format without requiring a context.
	 * @param quads The array of quads to serialize.
	 * @param namespaces Optional namespace map for prefix resolution.
	 * @returns A string containing the serialized Turtle document.
	 */
	serializeQuadsToString(quads: Quad[], namespaces?: Record<string, string>): Promise<string>;
 
	/**
	 * Builds a bindings result from a list of IRIs for a single column, without
	 * executing a query. Used to render already-cached data (e.g. auto-loaded
	 * named graphs) in the standard results table.
	 * @param query The SPARQL query the IRIs correspond to; used to derive the column name.
	 * @param iris The IRIs to render, one per row.
	 * @param documentIri The IRI of the document used for prefix resolution.
	 * @returns A BindingsResult mirroring the shape produced by `serializeBindings`.
	 */
	serializeIriList(query: string, iris: string[], documentIri?: string): BindingsResult;
}