import { Quad } from 'rdf-js'; import { Reference, LiteralTypes } from './index'; import { BareTripleDocument } from './document'; /** * Represents a single Subject in a [[TripleDocument]]. * * Used to read and modify properties of a single Subject in a [[TripleDocument]], using the `get*`, * `set*`, `add*` and `remove*` methods for the relevant data types. Note that those changes will * not be persisted until you call [[TripleDocument.save]]. */ export interface TripleSubject { /** * @returns The [[TripleDocument]] that contains this Subject. */ getDocument: () => BareTripleDocument; /** * @deprecated * @ignore This is mostly a convenience function to make it easy to work with n3 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 n3 * directly. * @returns The Triples pertaining to this Subject that are stored on the user's Pod. Note that * this does not return Triples that have not been saved yet - see * [[getPendingTriples]] for those. */ getTriples: () => Quad[]; /** * Find a literal string value for `predicate` on this Subject. * * This retrieves _one_ string literal, or `null` if none is found. If you want to find _all_ * string literals for a predicate, see [[getAllStrings]]. * * @param getString.predicate Which property of this Subject you want the value of. * @returns The first literal string value satisfying `predicate`, if any, and `null` otherwise. */ getString: (predicate: Reference) => string | null; /** * Find a literal string value in a given locale for `predicate` on this Subject. * * This retrieves _one_ string literal, or `null` if none (in the given locale) is found. If you * want to find _all_ string literals in a locale for a predicate, see [[getAllLocaleStrings]]. * * @param getLocaleString.predicate Which property of this Subject you want the value of. * @param getLocaleString.locale Which locale the string should be in, e.g. 'nl-NL'. * @returns The first literal string value satisfying `predicate` in the given locale, if any, and `null` otherwise. */ getLocaleString: (predicate: Reference, locale: string) => string | null; /** * Find a literal integer value for `predicate` on this Subject. * * This retrieves _one_ integer literal, or `null` if none is found. If you want to find _all_ * integer literals for a predicate, see [[getAllIntegers]]. * * @param getInteger.predicate Which property of this Subject you want the value of. * @returns The first literal integer value satisfying `predicate`, if any, and `null` otherwise. */ getInteger: (predicate: Reference) => number | null; /** * Find a literal decimal value for `predicate` on this Subject. * * This retrieves _one_ decimal literal, or `null` if none is found. If you want to find _all_ * decimal literals for a predicate, see [[getAllDecimals]]. * * @param getDecimal.predicate Which property of this Subject you want the value of. * @returns The first literal decimal value satisfying `predicate`, if any, and `null` otherwise. */ getDecimal: (predicate: Reference) => number | null; /** * Find a literal date+time value for `predicate` on this Subject. * * This retrieves _one_ date+time literal, or `null` if none is found. If you want to find _all_ * date+time literals for a predicate, see [[getAllDateTimes]]. * * @param getDateTime.predicate Which property of this Subject you want the value of. * @returns The first literal Date value satisfying `predicate`, if any, and `null` otherwise. */ getDateTime: (predicate: Reference) => Date | null; /** * @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. * @deprecated This method has been superseded by the type-specific methods [[getString]], * [[getInteger]], [[getDecimal]] and [[getDateTime]]. */ getLiteral: (predicate: Reference) => LiteralTypes | null; /** * @param getAllStrings.predicate Which property of this Subject you want the values of. * @returns All literal string values satisfying `predicate`. */ getAllStrings: (predicate: Reference) => string[]; /** * @param getAllLocaleStrings.predicate Which property of this Subject you want the values of. * @param getAllLocaleStrings.locale Which locale the values should be in, e.g. 'nl-NL', or `undefined` to get all locale strings. * @returns All literal string values satisfying `predicate` in the given locale, or all locale strings if no locale was specified. */ getAllLocaleStrings: (predicate: Reference, locale?: string) => GetAllLocaleStringsReturnType; /** * @param getAllIntegers.predicate Which property of this Subject you want the values of. * @returns All literal integer values satisfying `predicate`. */ getAllIntegers: (predicate: Reference) => number[]; /** * @param getAllDecimals.predicate Which property of this Subject you want the values of. * @returns All literal decimal values satisfying `predicate`. */ getAllDecimals: (predicate: Reference) => number[]; /** * @param getAllDateTimes.predicate Which property of this Subject you want the values of. * @returns All literal DateTime values satisfying `predicate`. */ getAllDateTimes: (predicate: Reference) => Date[]; /** * @param getAllLiterals.predicate Which property of this Subject you want the values of. * @returns All literal values satisfying `predicate`. * @deprecated This method has been superseded by the type-specific methods [[getAllStrings]], * [[getAllIntegers]], [[getAllDecimals]] and [[getAllDates]]. */ getAllLiterals: (predicate: Reference) => LiteralTypes[]; /** * Find a local Subject (i.e. without its own URL) referenced by this Subject with `predicate`. * * This retrieves _one_ [[TripleSubject]], or `null` if none is found. If you want to find _all_ * local Subjects for a predicate, see [[getAllLocalSubjects]]. * * @param getRef.predicate Which property of this Subject you want the value of. * @returns The first referenced local Subject satisfying `predicate`, if any, and `null` otherwise. * @ignore Experimental API; could change in minor or patch releases. */ getLocalSubject: (predicate: Reference) => TripleSubject | null; /** * Find local Subject (i.e. without their own URLs) referenced by this Subject with `predicate`. * * @param getRef.predicate Which property of this Subject you want the values of. * @returns All referenced local Subjects satisfying `predicate`. * @ignore Experimental API; could change in minor or patch releases. */ getAllLocalSubjects: (predicate: Reference) => Array; /** * Find a reference attached to this Subject with `predicate`. * * This retrieves _one_ reference, or `null` if none is found. If you want to find _all_ * references for a predicate, see [[getAllRefs]]. * * @param getRef.predicate Which property of this Subject you want the value of. * @returns The first referenced IRI satisfying `predicate`, if any, and `null` otherwise. */ getRef: (predicate: Reference) => Reference | null; /** * @ignore Deprecated method. * @deprecated Replaced by [[getRef]]. */ getNodeRef: (predicate: Reference) => Reference | null; /** * @returns The type of this Subject, if known. */ getType: () => Reference | null; /** * @param getAllRefs.predicate Which property of this Subject you want the values of. * @returns All references satisfying `predicate`. */ getAllRefs: (predicate: Reference) => Array; /** * @ignore Deprecated method. * @deprecated Replaced by [[getAllRefs]]. */ getAllNodeRefs: (predicate: Reference) => Array; /** * Set a property of this Subject to a Literal string value. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addString.predicate The property you want to add another value of. * @param addString.object The Literal string value you want to add. */ addString: (predicate: Reference, object: string) => void; /** * Set a property of this Subject to a Literal localised string value. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addLocaleString.predicate The property you want to add another value of. * @param addLocaleString.object The Literal string value you want to add. * @param addLocaleString.locale The locale the given string is in. */ addLocaleString: (predicate: Reference, object: string, locale: string) => void; /** * Set a property of this Subject to a Literal integer value. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addInteger.predicate The property you want to add another value of. * @param addInteger.object The Literal integer value you want to add. */ addInteger: (predicate: Reference, object: number) => void; /** * Set a property of this Subject to a Literal decimal value. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addDecimal.predicate The property you want to add another value of. * @param addDecimal.object The Literal decimal value you want to add. */ addDecimal: (predicate: Reference, object: number) => void; /** * Set a property of this Subject to a Literal DateTime value. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addDateTime.predicate The property you want to add another value of. * @param addDateTime.object The Literal DateTime value you want to add. */ addDateTime: (predicate: Reference, object: Date) => void; /** * 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]]. * @deprecated This method has been superseded by the type-specific methods [[addString]], * [[addInteger]], [[addDecimal]] and [[addDateTime]]. */ addLiteral: (predicate: Reference, object: LiteralTypes) => void; /** * Set a property of this Subject to a [[Reference]]. * * Note that this value is not saved to the user's Pod until you save the containing Document. * * @param addRef.predicate The property you want to add another value of. * @param addRef.object The IRI you want to add a reference to. */ addRef: (predicate: Reference, object: Reference) => void; /** * @ignore Deprecated method. * @deprecated Replaced by [[addRef]]. */ addNodeRef: (predicate: Reference, object: Reference) => void; /** * Remove a Literal string 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 removeString.predicate The property you want to remove a value of. * @param removeString.object The Literal string value you want to remove. */ removeString: (predicate: Reference, object: string) => void; /** * Remove a Literal localised string 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 removeLocaleString.predicate The property you want to remove a value of. * @param removeLocaleString.object The Literal string value you want to remove. * @param removeLocaleString.locale The locale of the string to remove. */ removeLocaleString: (predicate: Reference, object: string, locale: string) => void; /** * Remove a Literal integer 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 removeInteger.predicate The property you want to remove a value of. * @param removeInteger.object The Literal integer value you want to remove. */ removeInteger: (predicate: Reference, object: number) => void; /** * Remove a Literal decimal 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 removeDecimal.predicate The property you want to remove a value of. * @param removeDecimal.object The Literal decimal value you want to remove. */ removeDecimal: (predicate: Reference, object: number) => void; /** * Remove a Literal DateTime 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 removeDateTime.predicate The property you want to remove a value of. * @param removeDateTime.object The Literal DateTime value you want to remove. */ removeDateTime: (predicate: Reference, object: Date) => 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]]. * @deprecated This method has been superseded by the type-specific methods [[removeString]], * [[removeInteger]], [[removeDecimal]] and [[removeDateTime]]. */ removeLiteral: (predicate: Reference, object: LiteralTypes) => void; /** * Remove a [[Reference]] value for a property of this Subject. * * Note that this pointer is not removed from the user's Pod until you save the containing Document. * * @param removeRef.predicate The property you want to remove a reference for. * @param removeRef.object The reference you want to remove. */ removeRef: (predicate: Reference, object: Reference) => void; /** * @ignore Deprecated. * @deprecated Replaced by [[removeRef]]. */ removeNodeRef: (predicate: Reference, object: Reference) => 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: Reference) => void; /** * Set a property of this Subject to a string 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 setString.predicate The property you want to set the value of. * @param setString.object The string Literal value you want to set. */ setString: (predicate: Reference, object: string) => void; /** * Set a property of this Subject to a localised string 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 setLocaleString.predicate The property you want to set the value of. * @param setLocaleString.object The string Literal value you want to set. * @param setLocaleString.locale The locale of the given string. */ setLocaleString: (predicate: Reference, object: string, locale: string) => void; /** * Set a property of this Subject to an integer 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 setInteger.predicate The property you want to set the value of. * @param setInteger.object The integer Literal value you want to set. */ setInteger: (predicate: Reference, object: number) => void; /** * Set a property of this Subject to a decimal 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 setDecimal.predicate The property you want to set the value of. * @param setDecimal.object The decimal Literal value you want to set. */ setDecimal: (predicate: Reference, object: number) => void; /** * Set a property of this Subject to a DateTime 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 setDateTime.predicate The property you want to set the value of. * @param setDateTime.object The DateTime Literal value you want to set. */ setDateTime: (predicate: Reference, object: Date) => 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]]. * @deprecated This method has been superseded by the type-specific methods [[setString]], * [[setInteger]], [[setDecimal]] and [[setDateTime]]. */ setLiteral: (predicate: Reference, object: LiteralTypes) => void; /** * Set a property of this Subject to a [[Reference]], clearing all existing values. * * Note that this change is not saved to the user's Pod until you save the containing Document. * * @param setRef.predicate The property you want to set the value of. * @param setRef.object The reference you want to add. */ setRef: (predicate: Reference, object: Reference) => void; /** * @ignore Deprecated. * @deprecated Replaced by [[setRef]]. */ setNodeRef: (predicate: Reference, object: Reference) => void; /** * Get the IRI of the [[Reference]] representing this specific Subject. * * @returns The IRI of this specific Subject. */ asRef: () => Reference; /** * @ignore Deprecated. * @deprecated Replaced by [[asRef]]. */ asNodeRef: () => Reference; } declare type StringWithLocale = { locale: string; value: string; }; declare type GetAllLocaleStringsReturnType = X extends string ? string[] : Array; export {};