From d29f94747dc3085a500752e44fd3bd2110880b21 Mon Sep 17 00:00:00 2001 From: Reza Soltani Date: Tue, 9 Jan 2024 13:21:03 +0330 Subject: [PATCH] create container before inserting to typeIndex --- package-lock.json | 4 ++-- package.json | 2 +- src/TypeIndexHelper.ts | 15 ++++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1fe4e84..3ffa23d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rezasoltani/solid-typeindex-support", - "version": "0.0.1", + "version": "0.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rezasoltani/solid-typeindex-support", - "version": "0.0.1", + "version": "0.0.4", "license": "MIT", "dependencies": { "@inrupt/solid-client": "^1.30.2", diff --git a/package.json b/package.json index 7365596..77a3ca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rezasoltani/solid-typeindex-support", - "version": "0.0.4", + "version": "0.0.5", "description": "", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/TypeIndexHelper.ts b/src/TypeIndexHelper.ts index c6fb61d..4a13921 100644 --- a/src/TypeIndexHelper.ts +++ b/src/TypeIndexHelper.ts @@ -3,6 +3,7 @@ import { ThingPersisted, addNamedNode, buildThing, + createSolidDataset, createThing, getNamedNode, getSolidDataset, @@ -196,13 +197,9 @@ export class TypeIndexHelper { ): Promise { const typeIndex = await this.getTypeIndex(webId, fetch, isPrivate); - const typeIndexDS = await getSolidDataset(typeIndex?.value, { - fetch, - }); + const typeIndexDS = await getSolidDataset(typeIndex?.value, { fetch }); - const registeryThing = buildThing( - createThing({ name: typeRegistrationTitle }) - ) + const registeryThing = buildThing(createThing({ name: typeRegistrationTitle })) .addNamedNode(__forClass, namedNode(rdfClass)) .addNamedNode(isContainer ? __solid_instance_container : __solid_instance, namedNode(registeryUrl)) .addUrl(RDF.type, __solidTypeRegistration) @@ -210,9 +207,9 @@ export class TypeIndexHelper { const updatedTypeIndexDS = setThing(typeIndexDS, registeryThing); - return await saveSolidDatasetAt(typeIndex?.value, updatedTypeIndexDS, { - fetch, - }); + await saveSolidDatasetAt(registeryUrl, createSolidDataset(), { fetch }); + + return await saveSolidDatasetAt(typeIndex?.value, updatedTypeIndexDS, { fetch }); }