### Usage of Person class Source: https://rdf.js.org/wrapper/index.html Demonstrates getting and setting properties on a wrapped Person instance. ```javascript const person1 = new Person("https://example.org/person1", dataset_x, DataFactory) // Get property console.log(person1.name) // outputs "Alice" // Set property person1.name = [...person1].reverse().join("") console.log(person1.name) // outputs "ecilA" ``` -------------------------------- ### RDF data for People dataset Source: https://rdf.js.org/wrapper/index.html Example RDF data for testing the People dataset wrapper. ```turtle PREFIX ex: ex:person1 ex:name "Alice" . ex:person2 ex:name "Bob" . ``` -------------------------------- ### RDF data for Person class Source: https://rdf.js.org/wrapper/index.html Example RDF data to be loaded into a dataset for the Person class. ```turtle PREFIX ex: ex:person1 ex:name "Alice" . ``` -------------------------------- ### Projecting from a dataset to a mapping class Source: https://rdf.js.org/wrapper/types/ITermWrapperConstructor.html Example demonstrating how to use a mapping class constructor with instancesOf to iterate over dataset quads. ```typescript class Person extends TermWrapper { get name(): string { return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string) } } class People extends DatasetWrapper { [Symbol.iterator](): Iterator { return this.instancesOf("Person", Person) // 2nd param is an ITermWrapperConstructor } } ``` ```turtle [ a ; "Alice" ; ] . [ a ; "Bob" ; ] . ``` ```typescript for(const person of new People(dataset, factory)) { console.log(person.name) } ``` ```text Alice Bob ``` -------------------------------- ### RDF data for nested Person objects Source: https://rdf.js.org/wrapper/index.html Example RDF data containing nested relationships. ```turtle PREFIX ex: ex:person1 ex:name "Alice" . ex:person2 ex:name "Bob" ; ex:mum ex:person2 ; . ``` -------------------------------- ### Define RDF data for TermWrapper Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Example RDF data structure used for mapping to JavaScript objects. ```turtle BASE "some value" . ``` -------------------------------- ### Mapping as function Source: https://rdf.js.org/wrapper/interfaces/ITermFromValueMapping.html Examples of defining mapping logic as standalone functions in both TypeScript and JavaScript. ```typescript function term(value: string, factory: DataFactory): Term { return factory.literal(value) } ``` ```javascript function term(value, factory) { return factory.literal(value) } ``` -------------------------------- ### Projecting from one mapping class to another Source: https://rdf.js.org/wrapper/types/ITermWrapperConstructor.html Example showing how to use a mapping class constructor within a property getter to navigate between related terms. ```typescript class Book extends TermWrapper { get author(): Person { return RequiredFrom.subjectPredicate(this, "author", TermAs.instance(Person)) // Person is an ITermWrapperConstructor } } class Person extends TermWrapper { get name(): string { return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string) } } ``` ```turtle [ "Alice" ; ] . ``` ```typescript const dataset = const book = new Book("book", dataset, factory) console.log(book.author.name) ``` ```text Alice ``` -------------------------------- ### TermWrapper Data Manipulation Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Examples of how to use the TermWrapper to modify underlying dataset information using the DataFactory. ```APIDOC ## Data Manipulation with TermWrapper ### Description Demonstrates how to modify dataset information by creating quads via the factory and updating the dataset. ### Methods - **set author(value: string)**: Updates the author predicate in the dataset. - **add(something: string)**: Adds a new quad to the dataset. ### Request Example ```typescript // Updating a property this.dataset.delete(oldAuthors); this.dataset.add(newAuthor); // Adding a new entry this.dataset.add(quad); ``` ``` -------------------------------- ### Instantiate and use a TermWrapper class Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Initialize a custom TermWrapper instance and perform read/write operations on the underlying RDF data. ```typescript const dataset: DatasetCore // which has the RDF above loaded const instance = new SomeClass("http://example.com/someSubject", dataset, DataFactory) const value = instance.someProperty // contains "some value" instance.someProperty = "some other value" // underlying RDF is now "some other value" . ``` -------------------------------- ### Class: ListRootError Source: https://rdf.js.org/wrapper/classes/ListRootError.html Documentation for the ListRootError class constructor and properties. ```APIDOC ## Class: ListRootError ### Description An error with an associated term, extending TermError. ### Constructors #### constructor(term: Term, cause?: any) - **term** (Term) - Required - The term associated with this error. - **cause** (any) - Optional - The underlying cause of the error. ### Properties - **term** (Term) - Readonly - The term associated with this error. - **message** (string) - The error message. - **name** (string) - The name of the error. - **cause** (unknown) - Optional - The underlying cause. - **stack** (string) - Optional - The stack trace. ``` -------------------------------- ### Function instance Source: https://rdf.js.org/wrapper/functions/TermAs.instance.html The instance function creates a mapping for RDF terms to a specific wrapper constructor. ```APIDOC ## instance ### Description Creates an ITermAsValueMapping for a given constructor, allowing RDF terms to be wrapped into the specified type T. ### Parameters - **constructor** (ITermWrapperConstructor) - Required - The constructor function for the wrapper type. ### Returns - **ITermAsValueMapping** - A mapping object for the specified type. ``` -------------------------------- ### Usage of People dataset wrapper Source: https://rdf.js.org/wrapper/index.html Iterates through a dataset of people and logs their names. ```javascript const people = new People(dataset_y, DataFactory) for (const person of people) { console.log(person.name) } // outputs // Alice // Bob ``` -------------------------------- ### Instance Function Source: https://rdf.js.org/wrapper/functions/TermFrom.instance.html The 'instance' function is used to create an RDF term from a given value and a factory. It ensures that the created term conforms to the RDF.js specification. ```APIDOC ## Function instance ### Description Creates an RDF term from a given value and a factory. ### Parameters - **value** (IRdfJsTerm) - The value to be wrapped into an RDF term. - **factory** (DataFactory) - The RDF.js DataFactory instance to use for term creation. ### Returns - **Term** - The created RDF term. ``` -------------------------------- ### Function: string Source: https://rdf.js.org/wrapper/modules/BlankNodeFrom.html Maps a string primitive to an RDF/JS blank node. ```APIDOC ## Function: string ### Description Creates an RDF/JS blank node from a provided string primitive. ### Parameters #### Arguments - **value** (string) - Required - The string primitive to convert into a blank node. ``` -------------------------------- ### DatasetWrapper Class API Source: https://rdf.js.org/wrapper/classes/DatasetWrapper.html Methods and properties for interacting with the DatasetWrapper instance. ```APIDOC ## Constructor ### new DatasetWrapper(dataset: DatasetCore, factory: DataFactory) Creates a new instance of DatasetWrapper. ## Properties - **factory** (DataFactory) - Protected Readonly property. ## Accessors - **[toStringTag]** (string) - Returns the string representation. - **size** (number) - Returns the number of quads in the set. ## Methods ### add(quad: Quad) Adds a quad to the dataset. Returns this. ### delete(quad: Quad) Removes a quad from the dataset. Returns this. ### has(quad: Quad) Returns true if the dataset includes the quad. ### match(subject?: Term, predicate?: Term, object?: Term, graph?: Term) Returns a new DatasetCore containing quads that match the provided arguments. ``` -------------------------------- ### Using a built-in mapping Source: https://rdf.js.org/wrapper/interfaces/ITermFromValueMapping.html Demonstrates using a predefined mapping function like LiteralFrom.number within a class setter. ```typescript class Person extends TermWrapper { set age(value: number) { return RequiredAs.object(this. "age", LiteralFrom.number) // 2nd param is the mapping } } ``` -------------------------------- ### Class: TermError Source: https://rdf.js.org/wrapper/classes/TermError.html Documentation for the TermError constructor and its associated properties. ```APIDOC ## Class: TermError ### Description An error class that associates an error with a specific RDF term. It is part of the @rdfjs/wrapper hierarchy. ### Constructors #### constructor(term: Term, message?: string, cause?: any) Creates a new instance of TermError. - **term** (Term) - Required - The term associated with this error. - **message** (string) - Optional - A human-readable description of the error. - **cause** (any) - Optional - The specific original cause of the error. ### Properties - **term** (Term) - Readonly - The term associated with this error. - **message** (string) - The error message. - **name** (string) - The name of the error. - **cause** (unknown) - Optional - The original cause of the error. - **stack** (string) - Optional - The stack trace. ``` -------------------------------- ### TermFrom Namespace Functions Source: https://rdf.js.org/wrapper/modules/TermFrom.html Overview of the functions available within the TermFrom namespace for RDF/JS term creation. ```APIDOC ## TermFrom Namespace ### Description A collection of mappers that create RDF/JS terms from JavaScript primitives. ### Functions - **instance**: Creates an RDF/JS term instance from a JavaScript primitive. - **itself**: Returns the term itself if it is already an RDF/JS compliant term. ``` -------------------------------- ### Function langString Source: https://rdf.js.org/wrapper/functions/LiteralFrom.langString.html Creates a language-tagged string RDF term. ```APIDOC ## Function langString ### Description Creates a language-tagged string RDF term. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Term** (Term) - The created language-tagged string RDF term. #### Response Example N/A ### Function Signature `langString(value: ILangString, factory: DataFactory): Term` ### Parameters - **value** (ILangString) - The string value and language tag. - **factory** (DataFactory) - The RDFJS DataFactory instance to use for term creation. ``` -------------------------------- ### Function string Source: https://rdf.js.org/wrapper/functions/NamedNodeAs.string.html Converts a TermWrapper object into its string representation. ```APIDOC ## string(term: TermWrapper) ### Description Converts a TermWrapper object into a string. ### Parameters #### Parameters - **term** (TermWrapper) - Required - The term wrapper object to convert. ### Returns - **string** - The string representation of the term. ``` -------------------------------- ### Using an inline lambda Source: https://rdf.js.org/wrapper/interfaces/ITermFromValueMapping.html Shows how to define a custom mapping logic directly within the method call using an arrow function. ```typescript class Person extends TermWrapper { set age(value: number) { return RequiredAs.object(this. "age", (value, factory) => factory.literal(value.toString(), factory.namedNode(XSD.double))) // 2nd param is the mapping } } ``` -------------------------------- ### LiteralAs and string Function Source: https://rdf.js.org/wrapper/functions/LiteralAs.string.html Explains the LiteralAs type and the string function for converting RDF terms. ```APIDOC ## Function string ### Description Converts an RDF TermWrapper to its string representation. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ## Type LiteralAs ### Description Represents a literal value that can be treated as a string. ### Type Definition `string` ``` -------------------------------- ### Class: LiteralDatatypeError Source: https://rdf.js.org/wrapper/classes/LiteralDatatypeError.html Documentation for the LiteralDatatypeError class, including its constructor and properties. ```APIDOC ## Class: LiteralDatatypeError ### Description Error thrown when the datatype of a literal term is unexpected. This is typically used when code expects a specific datatype (e.g., xsd:int) but encounters a different one. ### Constructor - **new LiteralDatatypeError(literal, datatypes, cause?)** #### Parameters - **literal** (Literal) - Required - The literal associated with this error. - **datatypes** (Iterable) - Required - The expected datatypes. - **cause** (any) - Optional - The specific original cause of the error. ### Properties - **cause** (unknown) - Optional - The underlying cause of the error. - **datatypes** (Iterable) - Readonly - The expected datatypes. - **message** (string) - The error message. - **name** (string) - The name of the error. - **stack** (string) - Optional - The stack trace. - **term** (Term) - Readonly - The term associated with this error. ``` -------------------------------- ### Function string Source: https://rdf.js.org/wrapper/functions/LiteralFrom.string.html Converts a string value into an RDF Term using the provided DataFactory. ```APIDOC ## Function string ### Description Converts a string value into an RDF Term using a provided DataFactory. ### Parameters - **value** (string) - Required - The string value to convert. - **factory** (DataFactory) - Required - The DataFactory instance used to create the Term. ### Returns - **Term** - The resulting RDF Term. ``` -------------------------------- ### Function string Source: https://rdf.js.org/wrapper/functions/BlankNodeFrom.string.html Converts a string value into an RDF Term using the provided DataFactory. ```APIDOC ## Function string ### Description Converts a string value into an RDF Term using the provided DataFactory. ### Parameters - **value** (string | undefined) - Required - The string value to convert. - **factory** (DataFactory) - Required - The factory used to create the term. ### Returns - **Term** - The resulting RDF term. ``` -------------------------------- ### Convert Base64 RDF Literal to Uint8Array Source: https://rdf.js.org/wrapper/functions/LiteralAs.uInt8Array.html Demonstrates mapping an xsd:base64Binary literal to a Uint8Array using a TermWrapper class. ```text

"MDEyMzQ1Njc4OQ=="^^ . ``` ```typescript class Class extends TermWrapper { public get property(): Uint8Array { return RequiredFrom.subjectPredicate(this, "p", LiteralAs.uInt8Array) } } ``` -------------------------------- ### Add Item to Container using Dataset Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Use this method to add an item to a container within the dataset. This involves creating a new quad and adding it to the dataset. ```typescript class Container extends TermWrapper { add(something: string) { const subject = this as Quad_Subject const predicate = this.factory.namedNode("http://example.com/contains") const object = this.factory.literal(something) const quad = this.factory.quad(subject, predicate, object) this.dataset.add(quad) } } ``` -------------------------------- ### Function string Source: https://rdf.js.org/wrapper/functions/NamedNodeFrom.string.html Converts a string value into an RDF/JS Term using the provided factory. ```APIDOC ## string(value, factory) ### Description Converts a string value into an RDF/JS Term using the provided DataFactory. ### Parameters - **value** (string) - Required - The string value to convert. - **factory** (DataFactory) - Required - The RDF/JS DataFactory instance used to create the term. ### Returns - **Term** - The resulting RDF/JS Term object. ``` -------------------------------- ### Usage of nested Person class Source: https://rdf.js.org/wrapper/index.html Demonstrates accessing and setting nested properties on wrapped objects. ```javascript const person2 = new Person("https://example.org/person2", dataset_z, DataFactory) // Get property console.log(person2.name) // outputs "Bob" // Get property from child class console.log(person2.mum.name) // outputs "Alice" // Set class properties const person3 = new Person("https://example.org/person3", dataset_z, DataFactory) person3.name = "Joanne" person1.mum = person3 console.log(person1.mum.name) // outputs "Joanne" console.log(person2.mum.mum.name) // outputs "Joanne" ``` -------------------------------- ### DataFactory Usage Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Accessing the DataFactory to create new RDF terms such as literals and quads. ```APIDOC ## factory ### Description Returns the DataFactory instance used by the wrapper to create terms. ### Returns - **DataFactory**: A collection of methods for creating terms. ### Example ```typescript const date = new Date().toISOString(); const xsdDateTime = this.factory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"); return this.factory.literal(date, xsdDateTime); ``` ``` -------------------------------- ### Define a People dataset wrapper Source: https://rdf.js.org/wrapper/index.html Extends DatasetWrapper to iterate over subjects matching a specific predicate. ```javascript class People extends DatasetWrapper { [Symbol.iterator]() { return this.subjectsOf("https://example.org/name", Person) } } ``` -------------------------------- ### TermAs Namespace Functions Source: https://rdf.js.org/wrapper/modules/TermAs.html Overview of the available functions within the TermAs namespace for RDF/JS term conversion. ```APIDOC ## TermAs Namespace ### Description A collection of mappers that convert RDF/JS terms to JavaScript constructs. ### Functions - **instance**: Maps to an instance representation. - **is**: Checks for term type compatibility. - **list**: Converts RDF lists to JavaScript arrays. - **term**: General purpose mapper for RDF/JS terms. ``` -------------------------------- ### Define a custom TermWrapper class Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Extend TermWrapper to create models with accessors and mutators that interact with underlying RDF data. ```typescript class SomeClass extends TermWrapper { get someProperty(): string { return RequiredFrom.subjectPredicate(this, "http://example.com/someProperty", LiteralAs.string) } set someProperty(value: string) { RequiredAs.object(this, "http://example.com/someProperty", value, LiteralFrom.string) } } ``` -------------------------------- ### ILangString Interface Source: https://rdf.js.org/wrapper/interfaces/ILangString.html Defines the structure for a language-tagged string, including its string value, language tag, and text direction. ```APIDOC ## Interface ILangString ### Description Represents a language-tagged string. ### Properties - **direction** (string) - Optional - Specifies the text direction ('ltr' or 'rtl'). Can also be null. - **lang** (string) - Required - The language tag (e.g., 'en', 'fr'). - **string** (string) - Required - The actual string value. ``` -------------------------------- ### Create Literal from Current Date using Factory Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Use the factory to create a literal term representing the current date and time in ISO format with the xsd:dateTime datatype. ```typescript class Calendar extends TermWrapper { get currentDate(): Literal { const date = new Date().toISOString() const xsdDateTime = this.factory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime") return this.factory.literal(date, xsdDateTime) } } ``` -------------------------------- ### Use Inline Lambda Mapping Source: https://rdf.js.org/wrapper/interfaces/ITermAsValueMapping.html Use this for custom term-to-value conversions directly within your code. The lambda receives the term and should return the desired value. ```typescript class Person extends TermWrapper { get age(): number { return RequiredFrom.subjectPredicate(this. "age", term => Number(term.value)) // 2nd param is the mapping } } ``` -------------------------------- ### Function url Source: https://rdf.js.org/wrapper/functions/NamedNodeAs.url.html Maps a named node to a URL. Handles potential discrepancies between RDF IRI rules and JavaScript URL parsing. ```APIDOC ## Function url ### Description Maps a named node to a URL. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **term** (TermWrapper) - Required - The RDF term to convert. ### Returns - **URL** - A URL that represents the IRI of the named node. ### Remarks Lexical values of named nodes can be illegal URLs because the rules for handling IRIs in RDF frameworks that implement RDF/JS can differ from the rules for handling URLs in JavaScript engines. ### Example: Convert a named node to a URL The RDF ``` BASE

. ``` can be represented by the mapping ```typescript class Class extends TermWrapper { public get property(): URL { return RequiredFrom.subjectPredicate(this, "http://example.com/p", NamedNodeAs.url) } } ``` which returns the value `http://example.com/o`. ### Throws - **ReferenceError** - If the term is `undefined` or `null`. - **TypeError** - If the term is not a TermWrapper. - **TermTypeError** - If the term is not a NamedNode. - **TypeError** - If the value of the term cannot be parsed to a valid URL. ``` -------------------------------- ### LiteralFrom Namespace Functions Source: https://rdf.js.org/wrapper/modules/LiteralFrom.html This section details the functions available within the LiteralFrom namespace for creating RDF/JS literals from JavaScript primitives. ```APIDOC ## LiteralFrom Namespace A collection of mappers that create RDF/JS literals from JavaScript primitives. ### Functions - **anyUriString** - **anyUriUrl** - **base64** - **boolean** - **datatypeTuple** - **date** - **dateTime** - **double** - **hex** - **langString** - **langTuple** - **string** ``` -------------------------------- ### Function hex Source: https://rdf.js.org/wrapper/functions/LiteralFrom.hex.html Converts a Uint8Array to an RDF Term using the provided DataFactory. ```APIDOC ## Function hex ### Description Converts a Uint8Array to an RDF Term. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```json { "example": "No request body for this function" } ``` ### Response #### Success Response (200) - **Term** (Term) - The RDF Term representation of the input Uint8Array. #### Response Example ```json { "example": "RDF Term object" } ``` ``` -------------------------------- ### languageDictionary Function Source: https://rdf.js.org/wrapper/functions/Mapping.languageDictionary.html The languageDictionary function allows for the creation of a Map from RDF terms, using specified mappings for keys and values. ```APIDOC ## Function languageDictionary ### Description Creates a Map from RDF terms using provided key and value mapping functions. ### Method N/A (Function Signature) ### Endpoint N/A (Internal Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Type Parameters * **TKey**: The type of the keys in the resulting Map. * **TValue**: The type of the values in the resulting Map. ### Parameters * **anchor** (TermWrapper) - Required - The anchor term to start the mapping from. * **p** (string) - Required - A property string used in the mapping process. * **termAs**: ITermAsValueMapping<[TKey, TValue]> - Required - A mapping function to convert RDF terms into key-value pairs for the Map. * **termFrom**: ITermFromValueMapping<[TKey, TValue]> - Required - A mapping function to convert values back into RDF terms (used internally). ### Returns * **Map** - A Map where keys and values are derived from RDF terms based on the provided mappings. ``` -------------------------------- ### Instantiate TermTypeError Source: https://rdf.js.org/wrapper/classes/TermTypeError.html Demonstrates how to create a new instance of TermTypeError. This constructor is used when an RDF term's type does not match the expected type. ```typescript new TermTypeError(term, termType, cause?) ``` -------------------------------- ### Function datatypeTuple Source: https://rdf.js.org/wrapper/functions/LiteralFrom.datatypeTuple.html Creates a Term from a datatype tuple and a factory. ```APIDOC ## Function datatypeTuple ### Description Creates a Term from a datatype tuple and a factory. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Term** (Term) - The created Term object. #### Response Example N/A ``` -------------------------------- ### anyUriUrl Function Source: https://rdf.js.org/wrapper/functions/LiteralFrom.anyUriUrl.html The anyUriUrl function creates an RDF Term representing a URI. ```APIDOC ## Function anyUriUrl ### Description Creates an RDF Term representing a URI. ### Parameters #### Path Parameters - **value** (URL) - Required - The URL value for the URI. - **factory** (DataFactory) - Required - The DataFactory to use for creating the Term. ### Returns - **Term** - The created RDF Term representing the URI. ``` -------------------------------- ### Function langTuple Source: https://rdf.js.org/wrapper/functions/LiteralAs.langTuple.html Documentation for the langTuple function which extracts language information from a TermWrapper. ```APIDOC ## langTuple ### Description Extracts language information from a TermWrapper. ### Parameters - **term** (TermWrapper) - Required - The term to process. ### Returns - **[string, string]** - A tuple containing the string representation and the language tag. ``` -------------------------------- ### Function url Source: https://rdf.js.org/wrapper/functions/NamedNodeFrom.url.html The 'url' function creates an RDF Term from a URL value using a provided DataFactory. ```APIDOC ## Function url ### Description Creates an RDF Term from a URL value. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Term** (object) - The RDF Term created from the URL. #### Response Example ```json { "term": "" } ``` ### Function Signature `url(value: URL, factory: DataFactory): Term` ### Parameters - **value** (URL) - The URL to convert into an RDF Term. - **factory** (DataFactory) - The DataFactory instance to use for creating the Term. ### Returns - **Term** - An RDF Term representing the provided URL. ``` -------------------------------- ### base64 Function Source: https://rdf.js.org/wrapper/functions/LiteralFrom.base64.html Encodes a Uint8Array into a base64 encoded RDF Term using a provided DataFactory. ```APIDOC ## Function base64 ### Description Encodes a Uint8Array into a base64 encoded RDF Term. ### Method Function Call ### Parameters #### Path Parameters - **value** (Uint8Array) - Required - The byte array to encode. - **factory** (DataFactory) - Required - The DataFactory instance to use for creating the Term. ### Returns - **Term** - The base64 encoded RDF Term. ``` -------------------------------- ### anyUriString Function Source: https://rdf.js.org/wrapper/functions/LiteralFrom.anyUriString.html The anyUriString function creates an RDF Term representing a URI string. ```APIDOC ## Function anyUriString ### Description Creates an RDF Term representing a URI string. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Term** (object) - An RDF Term representing the URI string. #### Response Example N/A ### Function Signature `anyUriString(value: string, factory: DataFactory): Term` ### Parameters - **value** (string) - The string value of the URI. - **factory** (DataFactory) - The RDFJS DataFactory instance to use for creating the Term. ### Returns - **Term** (object) - The created RDF Term. ``` -------------------------------- ### LiteralAs Namespace Functions Source: https://rdf.js.org/wrapper/modules/LiteralAs.html This section details the various functions available within the LiteralAs namespace for converting RDF/JS literals to JavaScript primitives. ```APIDOC ## Namespace LiteralAs A collection of mappers that convert RDF/JS literals to JavaScript primitives. ### Functions - **bigint** - **boolean** - **datatypeTuple** - **date** - **langString** - **langTuple** - **number** - **string** - **symbol** - **uInt8Array** - **url** ``` -------------------------------- ### Namespace NamedNodeFrom Source: https://rdf.js.org/wrapper/modules/NamedNodeFrom.html The NamedNodeFrom namespace contains functions to create RDF/JS NamedNodes from JavaScript primitives like strings and URLs. ```APIDOC ## Namespace NamedNodeFrom ### Description A collection of mappers that create RDF/JS named nodes from JavaScript primitives. ### Functions - **string**: Creates a NamedNode from a string. - **url**: Creates a NamedNode from a URL. ### See Also - [NamedNode](link-to-namednode-docs) - [IRIs in RDF 1.1 Concepts and Abstract Syntax](link-to-rdf-concepts) ``` -------------------------------- ### Properties: TermTypeError Source: https://rdf.js.org/wrapper/classes/TermTypeError.html Details the properties available on the TermTypeError instance. ```APIDOC ## Properties - **cause** (unknown) - Optional - The underlying cause of the error. - **message** (string) - The error message. - **name** (string) - The name of the error. - **stack** (string) - Optional - The stack trace. - **term** (Term) - Readonly - The term associated with this error. - **termType** ("NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph" | "Quad") - Readonly - The expected term type that was not met. ``` -------------------------------- ### Constructor: new TermTypeError Source: https://rdf.js.org/wrapper/classes/TermTypeError.html Creates a new instance of TermTypeError when an RDF term type expectation is not met. ```APIDOC ## Constructor: new TermTypeError ### Description Creates a new instance of TermTypeError. This error is thrown when the type of a term is unexpected in the context of RDF processing. ### Parameters - **term** (Term) - Required - The term associated with this error. - **termType** ("NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph" | "Quad") - Required - The expected term type. - **cause** (any) - Optional - The specific original cause of the error. ### Returns - **TermTypeError** - A new instance of the error class. ``` -------------------------------- ### Match graph patterns with TermWrapper Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Use a TermWrapper instance to match statements within an RDF dataset. ```typescript let instance: TermWrapper let dataset: DatasetCore // Our instance used as subject when matching statements in a dataset dataset.match(instance as Term) ``` -------------------------------- ### Namespace NamedNodeAs Source: https://rdf.js.org/wrapper/modules/NamedNodeAs.html A collection of mappers that convert RDF/JS named nodes to JavaScript primitives. ```APIDOC ## Namespace NamedNodeAs ### Description A collection of mappers that convert RDF/JS named nodes to JavaScript primitives. ### See - NamedNode - IRIs in RDF 1.1 Concepts and Abstract Syntax ## Functions ### string Converts an RDF/JS named node to a JavaScript string. ### url Converts an RDF/JS named node to a JavaScript URL object. ``` -------------------------------- ### WrapperError Class Source: https://rdf.js.org/wrapper/classes/WrapperError.html Documentation for the base WrapperError class used in the rdf-js-wrapper library. ```APIDOC ## Class WrapperError Base class of all errors thrown by this library. ### Hierarchy * Error * WrapperError * TermError ### Constructors #### constructor * `new WrapperError(message?: string, cause?: any): WrapperError` Creates a new instance of WrapperError. ##### Parameters - `Optional` **message** (string) - A human-readable description of the error. - `Optional` **cause** (any) - The specific original cause of the error. ##### Returns - **WrapperError** - A new instance of WrapperError. ### Properties #### `Optional` cause - **cause** (unknown) - The original cause of the error. #### message - **message** (string) - A human-readable description of the error. #### name - **name** (string) - The name of the error. #### `Optional` stack - **stack** (string) - The stack trace of the error. ``` -------------------------------- ### RDF JS Wrapper - object Function Source: https://rdf.js.org/wrapper/functions/RequiredAs.object.html The object function is used to create RDF terms with specific properties. ```APIDOC ## Function object ### Description Creates an RDF term object. ### Method N/A (This is a function definition, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A (This function returns a value, not a response) #### Response Example N/A ## Type Parameters * T ## Parameters * **anchor**: TermWrapper - The anchor term. * **p**: string - The property. * **value**: T - The value of the term. * **termFrom**: ITermFromValueMapping - A mapping function to convert the value to an RDF term. ## Returns void (This function modifies or creates an object, it does not return a value directly in the context of a typical API response.) ``` -------------------------------- ### Use TermWrapper in quad creation Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Pass a TermWrapper instance as a subject when creating new quads via a DataFactory. ```typescript let instance: TermWrapper let factory: DataFactory const predicate = factory.namedNode("http://example.com/p") const object = factory.literal("o") // Our instance used as subject when creating a quad factory.quad(instance as Quad_Subject, predicate, object) ``` -------------------------------- ### Function langString Source: https://rdf.js.org/wrapper/functions/LiteralAs.langString.html The langString function creates a language-tagged string from a TermWrapper. ```APIDOC ## Function langString ### Description Creates a language-tagged string (ILangString) from a given TermWrapper. ### Method N/A (This is a function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Parameters - **term** (TermWrapper) - Required - The TermWrapper to convert into a language-tagged string. ### Returns - **ILangString** - The resulting language-tagged string. ``` -------------------------------- ### Convert Hexadecimal RDF Literal to Uint8Array Source: https://rdf.js.org/wrapper/functions/LiteralAs.uInt8Array.html Demonstrates mapping an xsd:hexBinary literal to a Uint8Array using a TermWrapper class. ```text

"30313233343536373839"^^ . ``` ```typescript class Class extends TermWrapper { public get property(): Uint8Array { return RequiredFrom.subjectPredicate(this, "p", LiteralAs.uInt8Array) } } ``` -------------------------------- ### Function term Source: https://rdf.js.org/wrapper/functions/TermAs.term.html Documentation for the term function used to unwrap TermWrapper objects. ```APIDOC ## Function term ### Description Converts a TermWrapper object back into its original RDF/JS Term representation. ### Parameters - **term** (TermWrapper) - Required - The wrapped term to be converted. ### Returns - **Term** - The unwrapped RDF/JS Term object. ``` -------------------------------- ### List Function Source: https://rdf.js.org/wrapper/functions/TermAs.list.html The 'list' function is used to retrieve a list of terms associated with a subject and predicate, with custom mapping for input and output terms. ```APIDOC ## list(subject: TermWrapper, predicate: string, termAs: ITermAsValueMapping, termFrom: ITermFromValueMapping): ITermAsValueMapping ### Description Retrieves a list of terms associated with a subject and predicate, applying custom mapping functions for term conversion. ### Method N/A (This is a function signature, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A (This is a function signature, not an HTTP endpoint) #### Response Example N/A ### Type Parameters * T - The type of the values to be mapped. ### Parameters * **subject**: TermWrapper - The subject term to query. * **predicate**: string - The predicate to query. * **termAs**: ITermAsValueMapping - A mapping function to convert RDF terms to type T. * **termFrom**: ITermFromValueMapping - A mapping function to convert type T back to RDF terms. ### Returns ITermAsValueMapping - A mapping object containing the list of terms converted to type T. ``` -------------------------------- ### URL Function Source: https://rdf.js.org/wrapper/functions/LiteralAs.url.html The 'url' function converts a TermWrapper to a URL. ```APIDOC ## Function url ### Description Converts a TermWrapper to a URL. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Function Signature `url(term: TermWrapper): URL` ### Parameters - **term** (TermWrapper) - The TermWrapper to convert. ### Returns - **URL** - The resulting URL. ``` -------------------------------- ### Function dateTime Source: https://rdf.js.org/wrapper/functions/LiteralFrom.dateTime.html Converts a JavaScript Date object into an RDF Term using the specified DataFactory. ```APIDOC ## dateTime ### Description Converts a JavaScript Date object into an RDF Term. ### Parameters - **value** (Date) - Required - The JavaScript Date object to convert. - **factory** (DataFactory) - Required - The DataFactory instance used to create the term. ### Returns - **Term** - The resulting RDF term representing the date. ``` -------------------------------- ### Function date Source: https://rdf.js.org/wrapper/functions/LiteralFrom.date.html Converts a JavaScript Date object into an RDF Term using the provided DataFactory. ```APIDOC ## Function date ### Description Converts a JavaScript Date object into an RDF Term. ### Parameters - **value** (Date) - Required - The JavaScript Date object to convert. - **factory** (DataFactory) - Required - The DataFactory instance used to create the term. ### Returns - **Term** - The resulting RDF term representing the date. ``` -------------------------------- ### Use Built-in Mapping - LiteralAs.number Source: https://rdf.js.org/wrapper/interfaces/ITermAsValueMapping.html Use this when you need to convert an RDF term to a number using a pre-defined mapping. Ensure the 'LiteralAs' namespace is accessible. ```typescript class Person extends TermWrapper { get age(): number { return RequiredFrom.subjectPredicate(this. "age", LiteralAs.number) // 2nd param is the mapping } } ``` -------------------------------- ### RDF.js Wrapper - Boolean Function Source: https://rdf.js.org/wrapper/functions/LiteralAs.boolean.html Provides information on how to use the `boolean` function from the @rdfjs/wrapper package to check if an RDF term is a boolean literal. ```APIDOC ## Function boolean ### Description Checks if the given RDF term is a boolean literal. ### Method N/A (This is a utility function, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **boolean** (boolean) - Returns `true` if the term is a boolean literal, `false` otherwise. #### Response Example N/A ``` -------------------------------- ### RDF/JS Term Properties Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Standard properties and methods for accessing RDF/JS term data. ```APIDOC ## Term Properties ### Properties - **datatype** (NamedNode): Returns the datatype of a literal. - **direction** ("" | "ltr" | "rtl" | null | undefined): Returns the base direction of a literal. - **graph** (Term): Returns the graph of a quad. - **language** (string): Returns the language tag of a literal. - **object** (Term): Returns the object of a quad. - **predicate** (Term): Returns the predicate of a quad. - **subject** (Term): Returns the subject of a quad. - **termType** (string): Returns the type of the term. - **value** (string): Returns the string value of the term. ### Methods - **equals(other: Term | null | undefined)**: Returns boolean indicating if the term equals the provided term. ``` -------------------------------- ### Function: langTuple Source: https://rdf.js.org/wrapper/functions/LiteralFrom.langTuple.html The langTuple function creates a language-tagged RDF term. It accepts an array of strings for the language tag and a DataFactory to create the term. ```APIDOC ## Function: langTuple ### Description Creates a language-tagged RDF term. ### Parameters #### Path Parameters * `__namedParameters` (Array) - Required - An array of strings representing the language tag (e.g., ['en', 'US']). * `factory` (DataFactory) - Required - The DataFactory instance to use for term creation. ### Returns * Term - The created language-tagged RDF term. ``` -------------------------------- ### bigint(term: TermWrapper) Source: https://rdf.js.org/wrapper/functions/LiteralAs.bigint.html Converts an RDF term wrapper into a JavaScript bigint. ```APIDOC ## bigint(term: TermWrapper) ### Description Converts an RDF term wrapper into a JavaScript bigint. ### Parameters #### Path Parameters - **term** (TermWrapper) - Required - The RDF term wrapper to convert. ### Returns - **bigint** - The resulting bigint value. ``` -------------------------------- ### Function date Source: https://rdf.js.org/wrapper/functions/LiteralAs.date.html The date function converts a TermWrapper into a native JavaScript Date object. ```APIDOC ## date(term: TermWrapper) ### Description Converts an RDF term wrapped in a TermWrapper into a JavaScript Date object. ### Parameters - **term** (TermWrapper) - Required - The term to be converted. ### Returns - **Date** - The resulting JavaScript Date object. ``` -------------------------------- ### ITermWrapperConstructor Type Alias Source: https://rdf.js.org/wrapper/types/ITermWrapperConstructor.html Defines the constructor signature for term mapping classes that extend TermWrapper. These classes are used to implement navigation properties on dataset and term wrappers. ```APIDOC ## Type Alias ITermWrapperConstructor ### Description Represents the constructor signature of term mapping classes that extend TermWrapper. Used by this library where constructors of mappers are accepted for implementing navigation properties that represent graph patterns on dataset and term wrappers. ### Type Parameters * T - The type of the mapping class whose instance is created. ### Type Declaration * `new (term: Term, dataset: DatasetCore, factory: DataFactory): T` #### Parameters * **term** (Term) - The underlying term being wrapped. * **dataset** (DatasetCore) - The dataset containing the wrapped term. * **factory** (DataFactory) - The data factory used for creating new terms. #### Returns T - An instance of the mapping class created when invoking the constructor. ### Remarks Mapping classes do not need to define a constructor that matches this signature, because the base class has a publicly accessible, matching constructor. ### Example: Projecting from a dataset to a mapping class ```javascript class Person extends TermWrapper { get name() { return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string) } } class People extends DatasetWrapper { [Symbol.iterator]() { return this.instancesOf("Person", Person) // 2nd param is an ITermWrapperConstructor } } ``` ```ttl [ a ; "Alice" ; ] . [ a ; "Bob" ; ] . ``` ```javascript for(const person of new People(dataset, factory)) { console.log(person.name) } ``` Output: ``` Alice Bob ``` ### Example: Projecting from one mapping class to another ```javascript class Book extends TermWrapper { get author() { return RequiredFrom.subjectPredicate(this, "author", TermAs.instance(Person)) // Person is an ITermWrapperConstructor } } class Person extends TermWrapper { get name() { return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string) } } ``` ```ttl [ "Alice" ; ] . ``` ```javascript const dataset = const book = new Book("book", dataset, factory) console.log(book.author.name) ``` Output: ``` Alice ``` ### See * DatasetWrapper.instancesOf * DatasetWrapper.matchObjectsOf * DatasetWrapper.matchSubjectsOf * DatasetWrapper.objectsOf * TermAs.instance ``` -------------------------------- ### Function is Source: https://rdf.js.org/wrapper/functions/TermAs.is.html Checks if a given term is an instance of a specific TermWrapper type. ```APIDOC ## Function is ### Description Checks if a given term is an instance of a specific TermWrapper type. ### Method N/A (This is a utility function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Type Parameters * T extends TermWrapper ### Parameters * **term**: T - The term to check. ### Returns T - The original term if it matches the type T. ``` -------------------------------- ### subjectPredicate Function Source: https://rdf.js.org/wrapper/modules/SetFrom.html Exposes RDF/JS graph patterns as a mutable JavaScript set based on subject and predicate. ```APIDOC ## subjectPredicate ### Description A mapper function that exposes RDF/JS graph patterns as a mutable JavaScript set, specifically targeting subject and predicate relationships. ### Namespace @rdfjs/wrapper/SetFrom ``` -------------------------------- ### Modify Book Author using Dataset Source: https://rdf.js.org/wrapper/classes/TermWrapper.html Use this method to update the author of a book directly within the dataset. This operates at a low level; consider using higher-level abstractions for simpler interactions. ```typescript class Book extends TermWrapper { set author(value: string) { const subject = this as Quad_Subject const predicate = this.factory.namedNode("http://example.com/author") const object = this.factory.literal(value) const oldAuthors = this.factory.quad(subject, predicate) const newAuthor = this.factory.quad(subject, predicate, object) this.dataset.delete(oldAuthors) this.dataset.add(newAuthor) } } ``` -------------------------------- ### Function symbol Source: https://rdf.js.org/wrapper/functions/LiteralAs.symbol.html Retrieves the symbol associated with a TermWrapper. ```APIDOC ## symbol ### Description Returns the symbol associated with the provided TermWrapper instance. ### Parameters - **term** (TermWrapper) - Required - The term wrapper instance to process. ### Returns - **symbol** - The symbol associated with the term. ```