Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start with documentation in the readme #20

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
});
});