Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanireza65 committed Dec 28, 2023
1 parent df6335a commit 206685e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/solid-typeindex-support.typeindexhelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export declare class TypeIndexHelper
| Method | Modifiers | Description |
| --- | --- | --- |
| [getFromTypeIndex(webId, rdfClass, fetch, isPrivate)](./solid-typeindex-support.typeindexhelper.getfromtypeindex.md) | <code>static</code> | Retrieves all instances of the given RDF class from the user's typeIndexe. |
| [registerInTypeIndex(webId, typeRegistrationTitle, rdfClass, fetch, solidInstanceUrl, isPrivate)](./solid-typeindex-support.typeindexhelper.registerintypeindex.md) | <code>static</code> | Registers a typeRegistration in the user's typeIndexe. |
| [registerInTypeIndex(webId, typeRegistrationTitle, rdfClass, fetch, registeryUrl, isContainer, isPrivate)](./solid-typeindex-support.typeindexhelper.registerintypeindex.md) | <code>static</code> | Registers a typeRegistration in the user's typeIndexe. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Registers a typeRegistration in the user's typeIndexe.
**Signature:**

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

## Parameters
Expand All @@ -20,7 +20,8 @@ static registerInTypeIndex(webId: string, typeRegistrationTitle: string, rdfClas
| typeRegistrationTitle | string | The title to use for the typeRegistration inside the typeIndex, |
| rdfClass | string | The RDF class that this registration is for, as a Valid URL |
| fetch | any | The authenticated fetch function |
| solidInstanceUrl | string | The URL of the solid:instance being registered |
| registeryUrl | string | The URL of the solid:instance or solid:instanceContainer being registered |
| isContainer | boolean | Whether to register a solid:instanceContainer or a solid:instance |
| isPrivate | boolean | Whether to register in the private or public typeIndexe |

**Returns:**
Expand Down
2 changes: 1 addition & 1 deletion etc/solid-typeindex-support.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class TypeIndexHelper {
instanceContainers: string[];
instances: string[];
}>;
static registerInTypeIndex(webId: string, typeRegistrationTitle: string, rdfClass: string, fetch: any, solidInstanceUrl: string, isPrivate: boolean): Promise<SolidDataset>;
static registerInTypeIndex(webId: string, typeRegistrationTitle: string, rdfClass: string, fetch: any, registeryUrl: string, isContainer: boolean, isPrivate: boolean): Promise<SolidDataset>;
}

// (No @packageDocumentation comment for this package)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rezasoltani/solid-typeindex-support",
"version": "0.0.3",
"version": "0.0.4",
"description": "",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
12 changes: 7 additions & 5 deletions src/TypeIndexHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class TypeIndexHelper {

const all = getThingAll(instanceContainerDS); // all files under the instanceContainer

const urls = all.map(x => x.url) // all file urls
const urls = all.filter(x => x.url !== "").map(x => x.url) // all file urls

return urls.filter(url => url !== instanceContainer) // remove the instanceContainer itself, only file urls needed;
})
Expand All @@ -180,7 +180,8 @@ export class TypeIndexHelper {
* @param typeRegistrationTitle - The title to use for the typeRegistration inside the typeIndex,
* @param rdfClass - The RDF class that this registration is for, as a Valid URL
* @param fetch - The authenticated fetch function
* @param solidInstanceUrl - The URL of the solid:instance being registered
* @param registeryUrl - The URL of the solid:instance or solid:instanceContainer being registered
* @param isContainer - Whether to register a solid:instanceContainer or a solid:instance
* @param isPrivate - Whether to register in the private or public typeIndexe
* @returns A Promise resolving to the updated typeIndexe dataset
*/
Expand All @@ -189,8 +190,9 @@ export class TypeIndexHelper {
typeRegistrationTitle: string,
rdfClass: string,
fetch: any,
solidInstanceUrl: string,
isPrivate: boolean
registeryUrl: string,
isContainer: boolean,
isPrivate: boolean,
): Promise<SolidDataset> {
const typeIndex = await this.getTypeIndex(webId, fetch, isPrivate);

Expand All @@ -202,7 +204,7 @@ export class TypeIndexHelper {
createThing({ name: typeRegistrationTitle })
)
.addNamedNode(__forClass, namedNode(rdfClass))
.addNamedNode(__solid_instance, namedNode(solidInstanceUrl))
.addNamedNode(isContainer ? __solid_instance_container : __solid_instance, namedNode(registeryUrl))
.addUrl(RDF.type, __solidTypeRegistration)
.build();

Expand Down
13 changes: 8 additions & 5 deletions test/unit/TypeIndexHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ describe('getFromTypeIndex', () => {

const result = await TypeIndexHelper.getFromTypeIndex(session.info.webId, BOOKMARK.Bookmark, session.fetch, isPrivate);

expect(result).toEqual([]);
expect(result.instances).toEqual([]);
expect(result.instanceContainers).toEqual([]);
});
it('should return an array of instances', async () => {
const isPrivate = true;
Expand All @@ -128,7 +129,8 @@ describe('getFromTypeIndex', () => {

const result = await TypeIndexHelper.getFromTypeIndex(session.info.webId, BOOKMARK.Bookmark, session.fetch, isPrivate);

expect(result.length).toBeGreaterThan(0);
expect(result.instances.length).toBeGreaterThan(0);
expect(result.instanceContainers.length).toBeGreaterThan(0);
});

});
Expand All @@ -139,13 +141,14 @@ describe("registerInTypeIndex", () => {
// });
test('Register in typeIndex - Private typeIndex', async () => {
const isPrivate = true;
const isContainer = false;

jest.spyOn(TypeIndexHelper, 'getTypeIndex').mockResolvedValueOnce(namedNode(privateTypeIndexPath));
jest.spyOn(inruptSOLIDClient, "getSolidDataset").mockResolvedValue(loadFixture("privateTypeIndexDS.json"));
jest.spyOn(inruptSOLIDClient, 'setThing').mockReturnValueOnce(loadFixture("privateTypeIndexDS.json"));
jest.spyOn(inruptSOLIDClient, 'saveSolidDatasetAt').mockResolvedValueOnce(loadFixture("privateTypeIndexDS.json"));

const res = await TypeIndexHelper.registerInTypeIndex(session.info.webId, "bookmarks", BOOKMARK.bookmarks, session.fetch, indexUrl, isPrivate);
const res = await TypeIndexHelper.registerInTypeIndex(session.info.webId, "bookmarks", BOOKMARK.bookmarks, session.fetch, indexUrl, isContainer, isPrivate);

expect(res).toEqual(loadFixture("privateTypeIndexDS.json"));
expect(TypeIndexHelper.getTypeIndex).toHaveBeenCalledWith(session.info.webId, session.fetch, isPrivate);
Expand All @@ -156,13 +159,14 @@ describe("registerInTypeIndex", () => {

test('Register in typeIndex - Public typeIndex', async () => {
const isPrivate = false;
const isContainer = false;

jest.spyOn(TypeIndexHelper, 'getTypeIndex').mockResolvedValueOnce(namedNode(privateTypeIndexPath));
jest.spyOn(inruptSOLIDClient, "getSolidDataset").mockResolvedValue(loadFixture("publicTypeIndexDS.json"));
jest.spyOn(inruptSOLIDClient, 'setThing').mockReturnValueOnce(loadFixture("publicTypeIndexDS.json"));
jest.spyOn(inruptSOLIDClient, 'saveSolidDatasetAt').mockResolvedValueOnce(loadFixture("publicTypeIndexDS.json"));

const res = await TypeIndexHelper.registerInTypeIndex(session.info.webId, "bookmarks", BOOKMARK.bookmarks, session.fetch, indexUrl, isPrivate);
const res = await TypeIndexHelper.registerInTypeIndex(session.info.webId, "bookmarks", BOOKMARK.bookmarks, session.fetch, indexUrl, isContainer, isPrivate);

expect(res).toEqual(loadFixture("publicTypeIndexDS.json"));
expect(TypeIndexHelper.getTypeIndex).toHaveBeenCalledWith(session.info.webId, session.fetch, isPrivate);
Expand Down Expand Up @@ -220,7 +224,6 @@ describe("getTypeIndexPredicate", () => {
it("returns __privateTypeIndex if isPrivate is true", () => {
const isPrivate = true;
const result = TypeIndexHelper.getTypeIndexPredicate(isPrivate);
console.log("🚀 ~ file: TypeIndexHelper.test.ts:223 ~ it ~ result:", result)
expect(result).toBe(__privateTypeIndex);
});

Expand Down
8 changes: 0 additions & 8 deletions test/unit/fixtures/privateTypeIndex.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@

<> a solid:TypeIndex, solid:UnlistedDocument.

:2bdc3da9-e0f0-48b5-b1aa-8123bb468a92
a solid:TypeRegistration;
solid:forClass schem:WatchAction;
solid:instanceContainer mov: .
:5677e892-fad5-4039-8108-4f4ed2640b98
a solid:TypeRegistration;
solid:forClass schem:Movie;
solid:instanceContainer mov: .
:bookmarks_registery
a solid:TypeRegistration;
solid:forClass bookm:Bookmark;
Expand Down

0 comments on commit 206685e

Please sign in to comment.