@metreeca/keep
    Preparing search index...

    Module @metreeca/keep-sparql - v0.12.2

    SPARQL 1.1 repository connector.

    Turns any SPARQL 1.1 Repository into a fully featured Store, so shape-driven retrieval and persistence run against a graph backend without hand-written queries. A ready-made connector from the @metreeca/wire collection (Oxigraph, generic HTTP endpoints, RDF4J, …) covers the common backends; a new backend is supported by implementing Repository directly.

    Wiring a Connector

    A ready-made connector is passed to createSPARQLStore to obtain a store:

    import { createSPARQLStore } from "@metreeca/keep-sparql";
    import { createOxiRepository } from "@metreeca/wire-sparql-oxigraph";

    const store = createSPARQLStore(createOxiRepository());

    await store.create({
    entry: "http://example.com/products/",
    shape: CatalogueShape,
    model: { products: {} },
    state: { name: "Widget", price: 9.99 }
    });

    Implementing a Connector

    A new SPARQL backend is supported by implementing a Repository. The repository exchanges SPARQL text and Tuple solution rows, whose values are @metreeca/trio Term values. Backend node values are lifted into terms with the named, tagged and typed constructors. The reference implementation in @metreeca/wire-sparql-oxigraph follows this pattern:

    import { named, tagged, type Term, typed } from "@metreeca/trio";
    import { type Repository } from "@metreeca/wire-sparql";

    function decode(node: BackendNode): Term {
    return node.kind === "iri" ? named(node.iri)
    : node.kind === "language" ? tagged(node.text, node.language)
    : typed(node.text, node.datatype);
    }

    export function createMyRepository(): Repository {
    // ... satisfy ask/select/construct/update/execute/close against the backend
    }

    Functions

    createSPARQLStore

    Creates a SPARQL store backed by a Repository.