Skip to content

Commit

Permalink
start with documentation in the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Nov 20, 2023
1 parent 3d13438 commit d3533ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@ Some utils for use in combination with [Soukai-Solid](https://github.com/NoelDeM
npm install
npm test
npm run build
```

## Functions provided
### getTypeIndexFromProfile
Finds the URL of one of the type indexes, given the URL of the profile document.
Returns a string or throws an error, namely:
FIXME: Complete this list and create a unit test for each of them, ref https://github.com/pondersource/soukai-solid-utils/issues/17
If the webId URL is malformed then ...
If the profile document cannot be retrieved, then ...
If fetching the profile document times out based on the timeout of the Fetch function (?), then ...
If the profile document is not valid JSON-LD then ...
If the profile document does not contain a link to a type index of the requested type then ...

Example usage:
```
const args = {
webId: "https://michielbdejong.solidcommunity.net/profile/card#me",
// fetch: {}, FIXME: https://github.com/pondersource/soukai-solid-utils/issues/17
typePredicate: "solid:publicTypeIndex",
};
const result = await getTypeIndexFromProfile(args as any);
expect(result).toBe("https://michielbdejong.solidcommunity.net/settings/publicTypeIndex.ttl");
```
3 changes: 1 addition & 2 deletions test/unit/typeIndexHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe("getTypeIndexFromProfile", () => {
// fetch: {}, FIXME: https://github.com/pondersource/soukai-solid-utils/issues/17
typePredicate: "solid:publicTypeIndex",
};
const result = await
getTypeIndexFromProfile(args as any);
const result = await getTypeIndexFromProfile(args as any);
expect(result).toBe("https://michielbdejong.solidcommunity.net/settings/publicTypeIndex.ttl");
});
});

0 comments on commit d3533ca

Please sign in to comment.