tripledoc
Version:
Library to read, create and update documents on a Solid Pod
132 lines (131 loc) • 6.32 kB
TypeScript
import { Statement } from 'rdflib';
import { NodeRef, LiteralTypes } from './index';
import { TripleDocument } from './document';
export interface TripleSubject {
/**
* @returns The [[TripleDocument]] that contains this Subject.
*/
getDocument: () => TripleDocument;
/**
* @deprecated
* @ignore This is mostly a convenience function to make it easy to work with rdflib and tripledoc
* simultaneously. If you rely on this, it's probably best to either file an issue
* describing what you want to do that Tripledoc can't do directly, or to just use rdflib
* directly.
* @returns The Statements pertaining to this Subject that are stored on the user's Pod. Note that
* this does not return Statements that have not been saved yet - see
* [[getPendingStatements]] for those.
*/
getStatements: () => Statement[];
/**
* @param getLiteral.predicate Which property of this Subject you want the value of.
* @returns The first literal value satisfying `predicate`, if any, and `null` otherwise.
*/
getLiteral: (predicate: NodeRef) => LiteralTypes | null;
/**
* @param getAllLiterals.predicate Which property of this Subject you want the values of.
* @returns All literal values satisfying `predicate`.
*/
getAllLiterals: (predicate: NodeRef) => LiteralTypes[];
/**
* @param getNodeRef.predicate Which property of this Subject you want the value of.
* @returns The IRI of the first Node satisfying `predicate`, if any, and `null` otherwise.
*/
getNodeRef: (predicate: NodeRef) => NodeRef | null;
/**
* @returns The type of this Subject, if known.
*/
getType: () => NodeRef | null;
/**
* @param getAllNodeRefs.predicate Which property of this Subject you want the values of.
* @returns IRIs of all Nodes satisfying `predicate`.
*/
getAllNodeRefs: (predicate: NodeRef) => Array<NodeRef>;
/**
* Set a property of this Subject to a Literal value (i.e. not a URL).
*
* Note that this value is not saved to the user's Pod until you save the containing Document.
*
* @param addLiteral.predicate The property you want to add another value of.
* @param addLiteral.object The Literal value you want to add, the type of which is one of [[LiteralTypes]].
*/
addLiteral: (predicate: NodeRef, object: LiteralTypes) => void;
/**
* Set a property of this Subject to a Node.
*
* Note that this value is not saved to the user's Pod until you save the containing Document.
*
* @param addNodeRef.predicate The property you want to add another value of.
* @param addNodeRef.object The IRI of the Node you want to add.
*/
addNodeRef: (predicate: NodeRef, object: NodeRef) => void;
/**
* Remove a Literal value for a property of this Subject.
*
* Note that this value is not removed from the user's Pod until you save the containing Document.
*
* @param removeLiteral.predicate The property you want to remove a value of.
* @param removeLiteral.object The Literal value you want to remove, the type of which is one of [[LiteralTypes]].
*/
removeLiteral: (predicate: NodeRef, object: LiteralTypes) => void;
/**
* No longer point a property of this Subject to a given Node.
*
* Note that this pointer is not removed from the user's Pod until you save the containing Document.
*
* @param removeNodeRef.predicate The property you no longer want to point to the given Node.
* @param removeNodeRef.object The IRI of the Node you want to remove.
*/
removeNodeRef: (predicate: NodeRef, object: NodeRef) => void;
/**
* Remove all values for a property of this Subject.
*
* Note that these values are not removed from the user's Pod until you save the containing
* Document.
*
* @param removeAll.predicate The property you want to remove the values of.
*/
removeAll: (predicate: NodeRef) => void;
/**
* Set a property of this Subject to a Literal value, clearing all existing values.
*
* Note that this change is not saved to the user's Pod until you save the containing Document.
*
* @param setLiteral.predicate The property you want to set the value of.
* @param setLiteral.object The Literal value you want to set, the type of which is one of [[LiteralTypes]].
*/
setLiteral: (predicate: NodeRef, object: LiteralTypes) => void;
/**
* Set a property of this Subject to a Node, clearing all existing values.
*
* Note that this change is not saved to the user's Pod until you save the containing Document.
*
* @param setNodeRef.predicate The property you want to set the value of.
* @param setNodeRef.object The IRI of the Node you want to add.
*/
setNodeRef: (predicate: NodeRef, object: NodeRef) => void;
/**
* @ignore Pending Statements are only provided so the Document can access them in order to save
* them - this is not part of the public API and can thus break in a minor release.
* @returns A tuple with the first element being a list of Statements that should be deleted from
* the store, and the second element a list of Statements that should be added to it.
*/
getPendingStatements: () => [Statement[], Statement[]];
/**
* @ignore `onSave` should only be called by the Document that is responsible for saving this
* Subject, so it's not part of the public API and can break in a minor release.
*/
onSave: () => void;
/**
* Get the IRI of the Node representing this specific Subject.
*
* @returns The IRI of this specific Subject.
*/
asNodeRef: () => NodeRef;
}
/**
* @ignore Only to be called by the Document containing this subject; not a public API.
* @param document The Document this Subject is defined in.
* @param subjectRef The URL that identifies this subject.
*/
export declare function initialiseSubject(document: TripleDocument, subjectRef: NodeRef): TripleSubject;