Skip to content

Commit

Permalink
add docs to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanireza65 committed Dec 19, 2023
1 parent 7635535 commit 68f5337
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 8 deletions.
83 changes: 75 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,88 @@ npm run test


## Usage

```bash
mpm install @rezasoltani/solid-typeindex-support
```

```typescript
import { TypeIndexHelper } from "@rezasoltani/solid-typeindex-support";
import { TypeIndexHelper } from '@rezasoltani/solid-typeindex-support';

const webId = 'https://example.com/profile#me';
const indexUrl = '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, indexUrl, true);

```

## Classes

| Class | Description |
| --- | --- |
| TypeIndexHelper | TypeIndexHelper provides helper methods for working with typeIndexes in Solid. This includes methods for getting and updating a user's public and private typeIndexes. |


## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| getFromTypeIndex(webId, rdfClass, fetch, isPrivate) | <code>static</code> | Retrieves all instances of the given RDF class from the user's typeIndexe. |
| registerInTypeIndex(webId, typeRegistrationTitle, rdfClass, fetch, indexUrl, isPrivate) | <code>static</code> | Registers 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:**

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

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| webId | string | The user's WebID |
| rdfClass | string | The RDF class to retrieve instances for |
| fetch | any | Authenticated fetch function |
| isPrivate | true | Whether the typeIndexe is private or public |

**Returns:**

Promise&lt;string\[\]&gt;



## TypeIndexHelper.registerInTypeIndex() method

Registers a type registration in the user's typeIndexe.

**Signature:**

```typescript
const webId = "https://fake-pod.net/profile/card#me";
const indexUrl = "https://fake-pod.net/settings/privateTypeIndex.ttl";
const isPrivate = true;
static registerInTypeIndex(webId: string, typeRegistrationTitle: string, rdfClass: string, fetch: any, indexUrl: string, isPrivate: boolean): Promise<SolidDataset>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| webId | string | The WebID of the user |
| typeRegistrationTitle | string | The title to use for the type registration |
| rdfClass | string | The RDF class that this registration is for |
| fetch | any | The authenticated fetch function |
| indexUrl | string | The URL of the index being registered |
| isPrivate | boolean | Whether to register in the private or public typeIndexe |

**Returns:**

const registeries: string[] = await TypeIndexHelper.getFromTypeIndex(webId, session.fetch, isPrivate);
Promise&lt;SolidDataset&gt;

const result: SolidDataset = await TypeIndexHelper.registerInTypeIndex(webId, session.fetch, indexUrl, isPrivate);
```
A Promise resolving to the updated typeIndexe dataset
Empty file added Untitled
Empty file.

0 comments on commit 68f5337

Please sign in to comment.