From d3533ca309253bd494bd8209ec2244f32e89dd89 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Mon, 20 Nov 2023 12:24:00 +0100 Subject: [PATCH] start with documentation in the readme --- README.md | 22 ++++++++++++++++++++++ test/unit/typeIndexHelpers.test.ts | 3 +-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ace456a..ae55a57 100644 --- a/README.md +++ b/README.md @@ -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"); ``` \ No newline at end of file diff --git a/test/unit/typeIndexHelpers.test.ts b/test/unit/typeIndexHelpers.test.ts index c8fa8e5..3bcf85a 100644 --- a/test/unit/typeIndexHelpers.test.ts +++ b/test/unit/typeIndexHelpers.test.ts @@ -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"); }); }); \ No newline at end of file