agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
92 lines • 5.47 kB
TypeScript
/** The SKOS core namespace. */
export declare const SKOS_NS = "http://www.w3.org/2004/02/skos/core#";
/** The OWL namespace — read for `owl:versionInfo` only; OWL itself is out of scope. */
export declare const OWL_NS = "http://www.w3.org/2002/07/owl#";
/** Our own namespace for what SKOS cannot say: units, sources, tools, coverage, other relations. */
export declare const FOOTPRINT_NS = "https://footprintjs.dev/ns/ontology#";
/** The prefixes the reader knows without a context — the fixed table. */
export declare const KNOWN_PREFIXES: Readonly<Record<string, string>>;
/** The IRIs the reader looks at, by name. */
export declare const SKOS: Readonly<{
readonly Concept: "http://www.w3.org/2004/02/skos/core#Concept";
readonly ConceptScheme: "http://www.w3.org/2004/02/skos/core#ConceptScheme";
readonly prefLabel: "http://www.w3.org/2004/02/skos/core#prefLabel";
readonly altLabel: "http://www.w3.org/2004/02/skos/core#altLabel";
readonly hiddenLabel: "http://www.w3.org/2004/02/skos/core#hiddenLabel";
readonly definition: "http://www.w3.org/2004/02/skos/core#definition";
readonly scopeNote: "http://www.w3.org/2004/02/skos/core#scopeNote";
readonly broader: "http://www.w3.org/2004/02/skos/core#broader";
readonly narrower: "http://www.w3.org/2004/02/skos/core#narrower";
readonly related: "http://www.w3.org/2004/02/skos/core#related";
readonly inScheme: "http://www.w3.org/2004/02/skos/core#inScheme";
readonly topConceptOf: "http://www.w3.org/2004/02/skos/core#topConceptOf";
readonly hasTopConcept: "http://www.w3.org/2004/02/skos/core#hasTopConcept";
}>;
/** Where a scheme's version may be written, in the order the reader looks. */
export declare const VERSION_IRIS: readonly string[];
/** The `footprint:` properties `toSkos` writes and `readSkos` reads back. */
export declare const FOOTPRINT: Readonly<{
readonly unit: "https://footprintjs.dev/ns/ontology#unit";
readonly edge: "https://footprintjs.dev/ns/ontology#edge";
readonly to: "https://footprintjs.dev/ns/ontology#to";
readonly relation: "https://footprintjs.dev/ns/ontology#relation";
readonly meaning: "https://footprintjs.dev/ns/ontology#meaning";
}>;
export type JsonLdNode = Readonly<Record<string, unknown>>;
/** A resolved `@context`: term → IRI, prefix → IRI, an optional `@vocab` and default `@language`. */
export interface SkosContext {
readonly terms: ReadonlyMap<string, string>;
readonly prefixes: ReadonlyMap<string, string>;
readonly vocab?: string;
readonly language?: string;
}
export declare function isRecord(value: unknown): value is JsonLdNode;
/**
* Read a `@context` (an object, an array of objects, or a URL — the last
* is not fetched). A term whose value is a string or `{ "@id": … }` maps
* to that IRI; a term whose value ends in `#` or `/` is also a prefix.
*/
export declare function readContext(context: unknown): SkosContext;
/**
* Resolve a key or a `@type` / `@id` value to an IRI: a keyword stays a
* keyword; a term the context maps; `prefix:local`; a full IRI; a bare
* name under `@vocab`. Anything else stays as written (a bare literal),
* which no SKOS IRI ever equals — so it is ignored, not misread.
*/
export declare function expandIri(value: string, context: SkosContext): string;
/** A node's properties keyed by expanded IRI (keywords keep their `@` names). */
export declare function expandNode(node: JsonLdNode, context: SkosContext): ReadonlyMap<string, unknown>;
/** Every value under a property as a flat list (`@list`, arrays and singles alike). */
export declare function valuesOf(node: ReadonlyMap<string, unknown>, iri: string): readonly unknown[];
/** The `@type` IRIs of a node. */
export declare function typesOf(node: ReadonlyMap<string, unknown>, context: SkosContext): readonly string[];
/** A language-tagged or plain literal. */
export interface Literal {
readonly value: string;
readonly language?: string;
}
/** The literals under a property: plain strings, numbers and `{ "@value", "@language"? }` objects. */
export declare function literalsOf(node: ReadonlyMap<string, unknown>, iri: string, context: SkosContext): readonly Literal[];
/** The IRIs a property points at: strings (resolved) and `{ "@id": … }` objects. */
export declare function irisOf(node: ReadonlyMap<string, unknown>, iri: string, context: SkosContext): readonly string[];
/**
* The literal in the asked language: a label TAGGED with it wins; a label
* with no tag at all serves any language (it is not tagged as another);
* a label tagged with a different language is never taken. Tags compare
* case-insensitively and exactly (`en` is not `en-US`).
*/
export declare function inLanguage(literals: readonly Literal[], language: string): readonly string[];
/**
* `iri.replace(/[?].*$/, '')` in one pass: the IRI up to its query. That
* regex can only finish at the end of the text and its `.` stops at a line
* break, so it cuts at the first `?` after the last line break — but it
* re-tried from every earlier `?`, which is quadratic on a run of them before a
* line break in a document's IRI.
*/
export declare function withoutQuery(iri: string): string;
/**
* A concept id from its IRI: the last `/` or `#` segment, percent-decoded,
* lower-cased, `-` and spaces to `_`. Empty when the IRI ends in a delimiter.
*/
export declare function idFromIri(iri: string): string;
//# sourceMappingURL=skosJsonLd.d.ts.map