Seems like that is what i need but when i try to use it, i get errors.
I create a dataset “podurl/comments”. I add comments using the inrupt functions “buildThing” and “saveSolidDatasetAt”. So i get a container “comments” with an index.ttl file that contains my comments.
I want all comments in the container to be readable publicly by default so i tried using universalAccess.setPublicAccess on the container URL (podURL/comments/) and when that did not work i tried using the specifiek comment his url (podURL/comments/index.ttl#someID).
I also tried using this function: Manage Access to Data (ACP) — Inrupt JavaScript Client Libraries.
All cases i get a similar error saying it cant find an acl. So i guess i need to create one? But i cant really figure out how…
I have also tried something similar to this post: [SOLVED] Solid-Client create ACL for container makes agent lose control but cant really figure out the creation of the acl.
I tried following code to create an acl but i get an error the commentDataset is of a wrong type.
Argument of type ‘Readonly<{ type: “Dataset”; graphs: Readonly<Record<string, Readonly<Record<string, Readonly<{ type: “Subject”; url: string; predicates: Readonly<Record<string, Readonly<Partial<{ literals: Readonly<Record<string, readonly string>>; langStrings: Readonly<…>; namedNodes: readonly string; blankNodes: readonly (
...' is not assignable to parameter of type 'WithResourceInfo & { internal_resourceInfo: { aclUrl?: string; linkedResources: LinkedResourceUrlAll; permissions?: internal_WacAllow; }; } & { ...; }'. Type 'Readonly<{ type: "Dataset"; graphs: Readonly<Record<string, Readonly<Record<string, Readonly<{ type: "Subject"; url: string; predicates: Readonly<Record<string, Readonly<Partial<{ literals: Readonly<Record<string, readonly string[]>>; langStrings: Readonly<...>; namedNodes: readonly string[]; blankNodes: readonly (
…’ is not assignable to type ‘{ internal_resourceInfo: { aclUrl: string; }; }’.
Types of property ‘internal_resourceInfo’ are incompatible.
Type ‘{ sourceIri: string; isRawData: boolean; contentType?: string; } & { aclUrl?: string; linkedResources: LinkedResourceUrlAll; permissions?: internal_WacAllow; }’ is not assignable to type ‘{ aclUrl: string; }’.
Property ‘aclUrl’ is optional in type ‘{ sourceIri: string; isRawData: boolean; contentType?: string; } & { aclUrl?: string; linkedResources: LinkedResourceUrlAll; permissions?: internal_WacAllow; }’ but required in type ‘{ aclUrl: string; }’
// code
const commentDataset = await getOrCreateCommentDataset(containerUri, session.fetch);
const acl = createAcl(commentDataset);
// code
async function getOrCreateCommentDataset(containerUri, fetch){
const indexUrl = `${containerUri}index.ttl`;
console.log("container uri: " + JSON.stringify(containerUri));
try {
const commentList = await getSolidDatasetWithAcl(indexUrl, { fetch });
return commentList;
} catch (error) {
if (error.statusCode === 404) {
const commentList = await saveSolidDatasetAt(
indexUrl,
createSolidDataset(),
{
fetch,
}
);
return await getSolidDatasetWithAcl(indexUrl);
}
}
}
Functions i use without the acl/set public acces:
async function getOrCreateCommentDataset(containerUri, fetch){
const indexUrl = `${containerUri}index.ttl`;
try {
const commentList = await getSolidDataset(indexUrl, { fetch });
return commentList;
} catch (error) {
if (error.statusCode === 404) {
const commentList = await saveSolidDatasetAt(
indexUrl,
createSolidDataset(),
{
fetch,
}
);
return commentList;
}
}
}
function createNewCommentThing() {
const newCommentThing = buildThing()
.addStringNoLocale(rdfText, comment)
.addDatetime(rdfDateCreated,new Date())
.addUrl(rdfCreator, profileThing)
.build();
return newCommentThing;
}
function updateDataset(newCommentThing) {
const updatedCommentDataset = setThing(commentDataset, newCommentThing);
setCommentDataset(updatedCommentDataset);
return updatedCommentDataset;
}
async function saveToPod(updatedCommentDataset) {
const indexUrl = getSourceUrl(commentDataset);
const savedCommentDataset = await saveSolidDatasetAt(
indexUrl,
updatedCommentDataset,
{ fetch: session.fetch }
);
}