0.0.7 • Published 4 months ago

@rezasoltani/solid-typeindex-support v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

solid-typeindex-support

See Docs

Development

git clone https://github.com/pondersource/solid-typeindex-support
npm install
npm run test

Dependencies:

  • @inrupt/solid-client: This module provides methods for interacting with the Solid Pod.
  • @inrupt/vocab-common-rdf: This module provides methods for working with RDF data.
  • @rdfjs/data-model: This module provides methods for working with RDF data.

Usage

mpm install @rezasoltani/solid-typeindex-support
import { TypeIndexHelper } from '@rezasoltani/solid-typeindex-support';

const webId = 'https://example.com/profile#me';
const solidInstanceUrl = 'https://example.com/type-index.ttl';
const rdfClass = "http://schema.org/Book";

const instances = await TypeIndexHelper.getFromTypeIndex(webId, rdfClass, fetch, true);

const updatedIndex = await TypeIndexHelper.registerInTypeIndex(webId, 'My Book List', rdfClass, fetch, solidInstanceUrl, true);

Classes

ClassDescription
TypeIndexHelperTypeIndexHelper provides helper methods for working with typeIndexes in Solid. This includes methods for getting and updating a user's public and private typeIndexes.

Methods

MethodModifiersDescription
getFromTypeIndex(webId, rdfClass, fetch, isPrivate)staticRetrieves all instances of the given RDF class from the user's typeIndexe.
registerInTypeIndex(webId, typeRegistrationTitle, rdfClass, fetch, solidInstanceUrl, isPrivate)staticRegisters a type registration in the user's typeIndexe.

TypeIndexHelper.getFromTypeIndex() method

Retrieves all instances of the given RDF class from the user's typeIndexe.

Signature:

static getFromTypeIndex(webId: string, rdfClass: string, fetch: any, isPrivate: true): Promise<string[]>;

Parameters

ParameterTypeDescription
webIdstringThe user's WebID
rdfClassstringThe RDF class to retrieve instances for
fetchanyAuthenticated fetch function
isPrivatetrueWhether the typeIndexe is private or public

Returns:

Promise<string[]>

TypeIndexHelper.registerInTypeIndex() method

Registers a type registration in the user's typeIndexe.

Signature:

static registerInTypeIndex(webId: string, typeRegistrationTitle: string, rdfClass: string, fetch: any, solidInstanceUrl: string, isPrivate: boolean): Promise<SolidDataset>;

Parameters

ParameterTypeDescription
webIdstringThe WebID of the user
typeRegistrationTitlestringThe title to use for the type registration
rdfClassstringThe RDF class that this registration is for
fetchanyThe authenticated fetch function
solidInstanceUrlstringThe URL of the index being registered
isPrivatebooleanWhether to register in the private or public typeIndexe

Returns:

Promise<SolidDataset>

A Promise resolving to the updated typeIndexe dataset