import { Literal, Quad_Graph } from "@rdfjs/types"; import { NamedNode, Quad, Term } from "@rdfjs/types"; import { ResolverHolder, WithResolver } from "./naming.js"; import { SubjectId } from "./dataspecAPI.js"; import { Graph } from "./graph.js"; import { TripleStore } from "./triplestore-client.js"; /** * Configuration of the FDR environment, providing defaults across * all open graphs and objects. */ export interface FDRConfig { /** * The default language to use when returning literal values. This is initially * undefined which means that a random literal will be return in case of a multi-lingual * graph. The set it to a specific value do `fdr.config.lang="en"`. * * Note that this affects only retrieval of literal values, not storage. That is, if a * new property is being added to an entity, one has to explicitly set the language of the literal * if one wants it to be stored in the triplestore. */ lang: string | undefined; } /** * */ export interface FDR { subjectId(name: string): SubjectId; graph(graphSpecification: { store: TripleStore; id?: string; label?: string; }): Graph; config: FDRConfig; } export interface RDFJS { named(iri: string): NamedNode; /** * Construct literaral with the given value for a given language * @param value * @param lang if value is a string, this is the language which will be * associated with it. The parameter has no effect if the value is not * a string. If value is a string and lang is not set, the resulting literal * will have no language (duh.) * TODO we probably need a type parameter in order to support non string * types which are represented by JS strings * */ literal(value: string | number | boolean, lang?: string): Literal; quad(x: NamedNode, y: NamedNode, z: Term, g?: Quad_Graph): Quad; metaQuad(x: Quad, y: NamedNode, z: Quad | NamedNode | Literal, g?: Quad_Graph): Quad; } export declare type LiteralValue = number | string | boolean; export type { NameResolver, DefaultNameResolver } from "./naming.js"; export type { Subject } from "./dataspecAPI.js"; export * from "./triplestore-client.js"; export * from "./graph.js"; /** * An environment which hosts multiple related graphs and contains state * which should be shared between those graphs e.g. prefixes, default * language. * * The objects used to interact with the graphs must be created using * the factory methods of the environment which holds the graph. */ export declare type GraphEnvironment = FDR & WithResolver; /** * Facade which combines the APIs of * 1. RDFJS (for creating RDFJS objects) * 2. ResolverHolder (if the user needs the resolvers) * 3. and FDR */ export declare const fdr: FDR & RDFJS & ResolverHolder; /** * factory for creating rdfjs objects */ export declare class rdfjs { static maker: RDFJS & WithResolver; static named(iri: string): NamedNode; /** * * @param value * @param lang * @returns */ static literal(value: string | number | boolean, lang?: string): Literal; static quad(x: NamedNode, y: NamedNode, z: Term, g?: Quad_Graph): Quad; static metaQuad(x: Quad, y: NamedNode, z: Quad | NamedNode | Literal, g?: Quad_Graph): Quad; } /** * A factory for common FDR objects. */ export declare class fdrmake { static maker: FDR & RDFJS & ResolverHolder; static subjectId(name: string): SubjectId; static graph(graphSpecification: { store: TripleStore; id?: string; label?: string; }): Graph; }