From 3fd73725ea948735a99b51f1f458500f5bcbc1ca Mon Sep 17 00:00:00 2001 From: Jackson Morgan Date: Mon, 3 Mar 2025 09:51:17 -0500 Subject: [PATCH] Remove demo-react and fix tests on solid-type-index --- packages/demo-react/.eslintrc | 3 - packages/demo-react/.gitignore | 23 - packages/demo-react/LICENSE.txt | 21 - packages/demo-react/README.md | 12 - packages/demo-react/craco.config.js | 28 - packages/demo-react/package.json | 50 -- packages/demo-react/public/index.html | 41 - packages/demo-react/public/manifest.json | 25 - packages/demo-react/public/robots.txt | 3 - packages/demo-react/src/.ldo/post.context.ts | 31 - packages/demo-react/src/.ldo/post.schema.ts | 155 ---- .../demo-react/src/.ldo/post.shapeTypes.ts | 19 - packages/demo-react/src/.ldo/post.typings.ts | 45 -- .../src/.ldo/solidProfile.context.ts | 154 ---- .../src/.ldo/solidProfile.schema.ts | 749 ------------------ .../src/.ldo/solidProfile.shapeTypes.ts | 71 -- .../src/.ldo/solidProfile.typings.ts | 293 ------- packages/demo-react/src/.shapes/post.shex | 23 - .../demo-react/src/.shapes/solidProfile.shex | 121 --- packages/demo-react/src/App-old.tsx | 13 - packages/demo-react/src/App.tsx | 65 -- packages/demo-react/src/Header.tsx | 54 -- packages/demo-react/src/Layout.tsx | 50 -- .../demo-react/src/MainContainerProvider.tsx | 73 -- packages/demo-react/src/blog/Blog.tsx | 30 - packages/demo-react/src/blog/MakePost.tsx | 92 --- packages/demo-react/src/index.tsx | 8 - packages/demo-react/src/post/Post.tsx | 42 - packages/demo-react/src/post/PostPage.tsx | 16 - packages/demo-react/src/post/PostedBy.tsx | 16 - packages/demo-react/src/profile/Profile.tsx | 34 - packages/demo-react/tsconfig.json | 20 - .../src/.ldo/profile.context.ts | 2 +- .../src/.ldo/profile.typings.ts | 12 +- .../src/.ldo/typeIndex.context.ts | 18 +- .../src/.ldo/typeIndex.typings.ts | 18 +- packages/solid-type-index/src/getTypeIndex.ts | 3 +- .../src/react/useInstanceUris.ts | 2 +- packages/solid-type-index/src/setTypeIndex.ts | 60 +- .../solid-type-index/test/General.test.tsx | 16 +- 40 files changed, 81 insertions(+), 2430 deletions(-) delete mode 100644 packages/demo-react/.eslintrc delete mode 100644 packages/demo-react/.gitignore delete mode 100644 packages/demo-react/LICENSE.txt delete mode 100644 packages/demo-react/README.md delete mode 100644 packages/demo-react/craco.config.js delete mode 100644 packages/demo-react/package.json delete mode 100644 packages/demo-react/public/index.html delete mode 100644 packages/demo-react/public/manifest.json delete mode 100644 packages/demo-react/public/robots.txt delete mode 100644 packages/demo-react/src/.ldo/post.context.ts delete mode 100644 packages/demo-react/src/.ldo/post.schema.ts delete mode 100644 packages/demo-react/src/.ldo/post.shapeTypes.ts delete mode 100644 packages/demo-react/src/.ldo/post.typings.ts delete mode 100644 packages/demo-react/src/.ldo/solidProfile.context.ts delete mode 100644 packages/demo-react/src/.ldo/solidProfile.schema.ts delete mode 100644 packages/demo-react/src/.ldo/solidProfile.shapeTypes.ts delete mode 100644 packages/demo-react/src/.ldo/solidProfile.typings.ts delete mode 100644 packages/demo-react/src/.shapes/post.shex delete mode 100644 packages/demo-react/src/.shapes/solidProfile.shex delete mode 100644 packages/demo-react/src/App-old.tsx delete mode 100644 packages/demo-react/src/App.tsx delete mode 100644 packages/demo-react/src/Header.tsx delete mode 100644 packages/demo-react/src/Layout.tsx delete mode 100644 packages/demo-react/src/MainContainerProvider.tsx delete mode 100644 packages/demo-react/src/blog/Blog.tsx delete mode 100644 packages/demo-react/src/blog/MakePost.tsx delete mode 100644 packages/demo-react/src/index.tsx delete mode 100644 packages/demo-react/src/post/Post.tsx delete mode 100644 packages/demo-react/src/post/PostPage.tsx delete mode 100644 packages/demo-react/src/post/PostedBy.tsx delete mode 100644 packages/demo-react/src/profile/Profile.tsx delete mode 100644 packages/demo-react/tsconfig.json diff --git a/packages/demo-react/.eslintrc b/packages/demo-react/.eslintrc deleted file mode 100644 index 83c51a9..0000000 --- a/packages/demo-react/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["../../.eslintrc"] -} \ No newline at end of file diff --git a/packages/demo-react/.gitignore b/packages/demo-react/.gitignore deleted file mode 100644 index 4d29575..0000000 --- a/packages/demo-react/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/packages/demo-react/LICENSE.txt b/packages/demo-react/LICENSE.txt deleted file mode 100644 index b87e67e..0000000 --- a/packages/demo-react/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Jackson Morgan - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/demo-react/README.md b/packages/demo-react/README.md deleted file mode 100644 index 583b01b..0000000 --- a/packages/demo-react/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# LDO Demo-React - -A demo app to show off the use of LDO. - -## Sponsorship -This project was made possible by a grant from NGI Zero Entrust via nlnet. Learn more on the [NLnet project page](https://nlnet.nl/project/SolidUsableApps/). - -[nlnet foundation logo](https://nlnet.nl/) -[NGI Zero Entrust Logo](https://nlnet.nl/) - -## Liscense -MIT \ No newline at end of file diff --git a/packages/demo-react/craco.config.js b/packages/demo-react/craco.config.js deleted file mode 100644 index 6ab610a..0000000 --- a/packages/demo-react/craco.config.js +++ /dev/null @@ -1,28 +0,0 @@ -// this file overrides the default CRA configurations (webpack, eslint, babel, etc) -// Ingnore because config scripts can't use the import variable -// eslint-disable-next-line @typescript-eslint/no-var-requires -const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); - -module.exports = { - webpack: { - configure: (config) => { - // Remove ModuleScopePlugin which throws when we try to import something - // outside of src/. - config.resolve.plugins.pop(); - - // Resolve the path aliases. - config.resolve.plugins.push(new TsconfigPathsPlugin()); - - // Let Babel compile outside of src/. - const oneOfRule = config.module.rules.find((rule) => rule.oneOf); - const tsRule = oneOfRule.oneOf.find((rule) => - rule.test.toString().includes("ts|tsx"), - ); - - tsRule.include = undefined; - tsRule.exclude = /node_modules/; - - return config; - }, - }, -}; diff --git a/packages/demo-react/package.json b/packages/demo-react/package.json deleted file mode 100644 index 5116777..0000000 --- a/packages/demo-react/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "@ldo/demo-react", - "version": "0.0.1-alpha.32", - "dependencies": { - "@inrupt/solid-client-authn-browser": "^2.0.0", - "@ldo/solid-react": "^0.0.1-alpha.32", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-router-dom": "^6.15.0", - "react-scripts": "5.0.1", - "uuid": "^9.0.1" - }, - "scripts": { - "start": "craco start", - "build": "craco build", - "eject": "react-scripts eject", - "lint": "eslint src/** --fix --no-error-on-unmatched-pattern", - "build:ldo": "ldo build --input src/.shapes --output src/.ldo" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 firefox version", - "last 1 chrome version", - "last 1 safari version" - ] - }, - "devDependencies": { - "@craco/craco": "^7.1.0", - "@ldo/cli": "^0.0.1-alpha.32", - "@types/jsonld": "^1.5.9", - "@types/react": "^18.2.21", - "@types/shexj": "^2.1.4", - "tsconfig-paths-webpack-plugin": "^4.1.0" - }, - "gitHead": "0287cd6371f06630763568dec5e41653f7b8583e", - "publishConfig": { - "access": "public" - } -} diff --git a/packages/demo-react/public/index.html b/packages/demo-react/public/index.html deleted file mode 100644 index 127f789..0000000 --- a/packages/demo-react/public/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - React App - - - -
- - - diff --git a/packages/demo-react/public/manifest.json b/packages/demo-react/public/manifest.json deleted file mode 100644 index 080d6c7..0000000 --- a/packages/demo-react/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/packages/demo-react/public/robots.txt b/packages/demo-react/public/robots.txt deleted file mode 100644 index e9e57dc..0000000 --- a/packages/demo-react/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/packages/demo-react/src/.ldo/post.context.ts b/packages/demo-react/src/.ldo/post.context.ts deleted file mode 100644 index dafbe33..0000000 --- a/packages/demo-react/src/.ldo/post.context.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ContextDefinition } from "jsonld"; - -/** - * ============================================================================= - * postContext: JSONLD Context for post - * ============================================================================= - */ -export const postContext: ContextDefinition = { - type: { - "@id": "@type", - }, - SocialMediaPosting: "http://schema.org/SocialMediaPosting", - CreativeWork: "http://schema.org/CreativeWork", - Thing: "http://schema.org/Thing", - articleBody: { - "@id": "http://schema.org/articleBody", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - uploadDate: { - "@id": "http://schema.org/uploadDate", - "@type": "http://www.w3.org/2001/XMLSchema#date", - }, - image: { - "@id": "http://schema.org/image", - "@type": "@id", - }, - publisher: { - "@id": "http://schema.org/publisher", - "@type": "@id", - }, -}; diff --git a/packages/demo-react/src/.ldo/post.schema.ts b/packages/demo-react/src/.ldo/post.schema.ts deleted file mode 100644 index 39e8b63..0000000 --- a/packages/demo-react/src/.ldo/post.schema.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { Schema } from "shexj"; - -/** - * ============================================================================= - * postSchema: ShexJ Schema for post - * ============================================================================= - */ -export const postSchema: Schema = { - type: "Schema", - shapes: [ - { - id: "https://example.com/PostSh", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - valueExpr: { - type: "NodeConstraint", - values: [ - "http://schema.org/SocialMediaPosting", - "http://schema.org/CreativeWork", - "http://schema.org/Thing", - ], - }, - }, - { - type: "TripleConstraint", - predicate: "http://schema.org/articleBody", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#label", - object: { - value: "articleBody", - }, - }, - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The actual body of the article. ", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://schema.org/uploadDate", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#date", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#label", - object: { - value: "uploadDate", - }, - }, - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "Date when this media object was uploaded to this site.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://schema.org/image", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#label", - object: { - value: "image", - }, - }, - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A media object that encodes this CreativeWork. This property is a synonym for encoding.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://schema.org/publisher", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#label", - object: { - value: "publisher", - }, - }, - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The publisher of the creative work.", - }, - }, - ], - }, - ], - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#label", - object: { - value: "SocialMediaPost", - }, - }, - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A post to a social media platform, including blog posts, tweets, Facebook posts, etc.", - }, - }, - ], - }, - }, - ], -}; diff --git a/packages/demo-react/src/.ldo/post.shapeTypes.ts b/packages/demo-react/src/.ldo/post.shapeTypes.ts deleted file mode 100644 index 4c50683..0000000 --- a/packages/demo-react/src/.ldo/post.shapeTypes.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ShapeType } from "@ldo/ldo"; -import { postSchema } from "./post.schema"; -import { postContext } from "./post.context"; -import { PostSh } from "./post.typings"; - -/** - * ============================================================================= - * LDO ShapeTypes post - * ============================================================================= - */ - -/** - * PostSh ShapeType - */ -export const PostShShapeType: ShapeType = { - schema: postSchema, - shape: "https://example.com/PostSh", - context: postContext, -}; diff --git a/packages/demo-react/src/.ldo/post.typings.ts b/packages/demo-react/src/.ldo/post.typings.ts deleted file mode 100644 index 9ebaf71..0000000 --- a/packages/demo-react/src/.ldo/post.typings.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { ContextDefinition } from "jsonld"; - -/** - * ============================================================================= - * Typescript Typings for post - * ============================================================================= - */ - -/** - * PostSh Type - */ -export interface PostSh { - "@id"?: string; - "@context"?: ContextDefinition; - type: - | { - "@id": "SocialMediaPosting"; - } - | { - "@id": "CreativeWork"; - } - | { - "@id": "Thing"; - }; - /** - * The actual body of the article. - */ - articleBody?: string; - /** - * Date when this media object was uploaded to this site. - */ - uploadDate: string; - /** - * A media object that encodes this CreativeWork. This property is a synonym for encoding. - */ - image?: { - "@id": string; - }; - /** - * The publisher of the creative work. - */ - publisher: { - "@id": string; - }; -} diff --git a/packages/demo-react/src/.ldo/solidProfile.context.ts b/packages/demo-react/src/.ldo/solidProfile.context.ts deleted file mode 100644 index 82a8edf..0000000 --- a/packages/demo-react/src/.ldo/solidProfile.context.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { ContextDefinition } from "jsonld"; - -/** - * ============================================================================= - * solidProfileContext: JSONLD Context for solidProfile - * ============================================================================= - */ -export const solidProfileContext: ContextDefinition = { - type: { - "@id": "@type", - }, - Person: "http://schema.org/Person", - Person2: "http://xmlns.com/foaf/0.1/Person", - fn: { - "@id": "http://www.w3.org/2006/vcard/ns#fn", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - name: { - "@id": "http://xmlns.com/foaf/0.1/name", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - hasAddress: { - "@id": "http://www.w3.org/2006/vcard/ns#hasAddress", - "@type": "@id", - "@container": "@set", - }, - countryName: { - "@id": "http://www.w3.org/2006/vcard/ns#country-name", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - locality: { - "@id": "http://www.w3.org/2006/vcard/ns#locality", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - postalCode: { - "@id": "http://www.w3.org/2006/vcard/ns#postal-code", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - region: { - "@id": "http://www.w3.org/2006/vcard/ns#region", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - streetAddress: { - "@id": "http://www.w3.org/2006/vcard/ns#street-address", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - hasEmail: { - "@id": "http://www.w3.org/2006/vcard/ns#hasEmail", - "@type": "@id", - "@container": "@set", - }, - Dom: "http://www.w3.org/2006/vcard/ns#Dom", - Home: "http://www.w3.org/2006/vcard/ns#Home", - ISDN: "http://www.w3.org/2006/vcard/ns#ISDN", - Internet: "http://www.w3.org/2006/vcard/ns#Internet", - Intl: "http://www.w3.org/2006/vcard/ns#Intl", - Label: "http://www.w3.org/2006/vcard/ns#Label", - Parcel: "http://www.w3.org/2006/vcard/ns#Parcel", - Postal: "http://www.w3.org/2006/vcard/ns#Postal", - Pref: "http://www.w3.org/2006/vcard/ns#Pref", - Work: "http://www.w3.org/2006/vcard/ns#Work", - X400: "http://www.w3.org/2006/vcard/ns#X400", - value: { - "@id": "http://www.w3.org/2006/vcard/ns#value", - "@type": "@id", - }, - hasPhoto: { - "@id": "http://www.w3.org/2006/vcard/ns#hasPhoto", - "@type": "@id", - }, - img: { - "@id": "http://xmlns.com/foaf/0.1/img", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - hasTelephone: { - "@id": "http://www.w3.org/2006/vcard/ns#hasTelephone", - "@type": "@id", - "@container": "@set", - }, - phone: { - "@id": "http://www.w3.org/2006/vcard/ns#phone", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - organizationName: { - "@id": "http://www.w3.org/2006/vcard/ns#organization-name", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - role: { - "@id": "http://www.w3.org/2006/vcard/ns#role", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - trustedApp: { - "@id": "http://www.w3.org/ns/auth/acl#trustedApp", - "@type": "@id", - "@container": "@set", - }, - mode: { - "@id": "http://www.w3.org/ns/auth/acl#mode", - "@container": "@set", - }, - Append: "http://www.w3.org/ns/auth/acl#Append", - Control: "http://www.w3.org/ns/auth/acl#Control", - Read: "http://www.w3.org/ns/auth/acl#Read", - Write: "http://www.w3.org/ns/auth/acl#Write", - origin: { - "@id": "http://www.w3.org/ns/auth/acl#origin", - "@type": "@id", - }, - key: { - "@id": "http://www.w3.org/ns/auth/cert#key", - "@type": "@id", - "@container": "@set", - }, - modulus: { - "@id": "http://www.w3.org/ns/auth/cert#modulus", - "@type": "http://www.w3.org/2001/XMLSchema#string", - }, - exponent: { - "@id": "http://www.w3.org/ns/auth/cert#exponent", - "@type": "http://www.w3.org/2001/XMLSchema#integer", - }, - inbox: { - "@id": "http://www.w3.org/ns/ldp#inbox", - "@type": "@id", - }, - preferencesFile: { - "@id": "http://www.w3.org/ns/pim/space#preferencesFile", - "@type": "@id", - }, - storage: { - "@id": "http://www.w3.org/ns/pim/space#storage", - "@type": "@id", - "@container": "@set", - }, - account: { - "@id": "http://www.w3.org/ns/solid/terms#account", - "@type": "@id", - }, - privateTypeIndex: { - "@id": "http://www.w3.org/ns/solid/terms#privateTypeIndex", - "@type": "@id", - "@container": "@set", - }, - publicTypeIndex: { - "@id": "http://www.w3.org/ns/solid/terms#publicTypeIndex", - "@type": "@id", - "@container": "@set", - }, - knows: { - "@id": "http://xmlns.com/foaf/0.1/knows", - "@type": "@id", - "@container": "@set", - }, -}; diff --git a/packages/demo-react/src/.ldo/solidProfile.schema.ts b/packages/demo-react/src/.ldo/solidProfile.schema.ts deleted file mode 100644 index 69466fc..0000000 --- a/packages/demo-react/src/.ldo/solidProfile.schema.ts +++ /dev/null @@ -1,749 +0,0 @@ -import { Schema } from "shexj"; - -/** - * ============================================================================= - * solidProfileSchema: ShexJ Schema for solidProfile - * ============================================================================= - */ -export const solidProfileSchema: Schema = { - type: "Schema", - shapes: [ - { - id: "https://shaperepo.com/schemas/solidProfile#SolidProfileShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - valueExpr: { - type: "NodeConstraint", - values: ["http://schema.org/Person"], - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "Defines the node as a Person (from Schema.org)", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - valueExpr: { - type: "NodeConstraint", - values: ["http://xmlns.com/foaf/0.1/Person"], - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "Defines the node as a Person (from foaf)", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#fn", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The formatted name of a person. Example: John Smith", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://xmlns.com/foaf/0.1/name", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "An alternate way to define a person's name.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#hasAddress", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#AddressShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The person's street address.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#hasEmail", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#EmailShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The person's email.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#hasPhoto", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "A link to the person's photo", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://xmlns.com/foaf/0.1/img", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "Photo link but in string form", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#hasTelephone", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#PhoneNumberShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "Person's telephone number", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#phone", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "An alternative way to define a person's telephone number using a string", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#organization-name", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The name of the organization with which the person is affiliated", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#role", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The name of the person's role in their organization", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/acl#trustedApp", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#TrustedAppShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A list of app origins that are trusted by this user", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/cert#key", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#RSAPublicKeyShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A list of RSA public keys that are associated with private keys the user holds.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/ldp#inbox", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The user's LDP inbox to which apps can post notifications", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/pim/space#preferencesFile", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The user's preferences", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/pim/space#storage", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The location of a Solid storage server related to this WebId", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/solid/terms#account", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The user's account", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/solid/terms#privateTypeIndex", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A registry of all types used on the user's Pod (for private access only)", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/solid/terms#publicTypeIndex", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A registry of all types used on the user's Pod (for public access)", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://xmlns.com/foaf/0.1/knows", - valueExpr: - "https://shaperepo.com/schemas/solidProfile#SolidProfileShape", - min: 0, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "A list of WebIds for all the people this user knows.", - }, - }, - ], - }, - ], - }, - extra: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"], - }, - }, - { - id: "https://shaperepo.com/schemas/solidProfile#AddressShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#country-name", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The name of the user's country of residence", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#locality", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The name of the user's locality (City, Town etc.) of residence", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#postal-code", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The user's postal code", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#region", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The name of the user's region (State, Province etc.) of residence", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#street-address", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The user's street address", - }, - }, - ], - }, - ], - }, - }, - }, - { - id: "https://shaperepo.com/schemas/solidProfile#EmailShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - valueExpr: { - type: "NodeConstraint", - values: [ - "http://www.w3.org/2006/vcard/ns#Dom", - "http://www.w3.org/2006/vcard/ns#Home", - "http://www.w3.org/2006/vcard/ns#ISDN", - "http://www.w3.org/2006/vcard/ns#Internet", - "http://www.w3.org/2006/vcard/ns#Intl", - "http://www.w3.org/2006/vcard/ns#Label", - "http://www.w3.org/2006/vcard/ns#Parcel", - "http://www.w3.org/2006/vcard/ns#Postal", - "http://www.w3.org/2006/vcard/ns#Pref", - "http://www.w3.org/2006/vcard/ns#Work", - "http://www.w3.org/2006/vcard/ns#X400", - ], - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The type of email.", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#value", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The value of an email as a mailto link (Example )", - }, - }, - ], - }, - ], - }, - extra: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"], - }, - }, - { - id: "https://shaperepo.com/schemas/solidProfile#PhoneNumberShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - valueExpr: { - type: "NodeConstraint", - values: [ - "http://www.w3.org/2006/vcard/ns#Dom", - "http://www.w3.org/2006/vcard/ns#Home", - "http://www.w3.org/2006/vcard/ns#ISDN", - "http://www.w3.org/2006/vcard/ns#Internet", - "http://www.w3.org/2006/vcard/ns#Intl", - "http://www.w3.org/2006/vcard/ns#Label", - "http://www.w3.org/2006/vcard/ns#Parcel", - "http://www.w3.org/2006/vcard/ns#Postal", - "http://www.w3.org/2006/vcard/ns#Pref", - "http://www.w3.org/2006/vcard/ns#Work", - "http://www.w3.org/2006/vcard/ns#X400", - ], - }, - min: 0, - max: 1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "They type of Phone Number", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/2006/vcard/ns#value", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: - "The value of a phone number as a tel link (Example )", - }, - }, - ], - }, - ], - }, - extra: ["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"], - }, - }, - { - id: "https://shaperepo.com/schemas/solidProfile#TrustedAppShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/acl#mode", - valueExpr: { - type: "NodeConstraint", - values: [ - "http://www.w3.org/ns/auth/acl#Append", - "http://www.w3.org/ns/auth/acl#Control", - "http://www.w3.org/ns/auth/acl#Read", - "http://www.w3.org/ns/auth/acl#Write", - ], - }, - min: 1, - max: -1, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The level of access provided to this origin", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/acl#origin", - valueExpr: { - type: "NodeConstraint", - nodeKind: "iri", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "The app origin the user trusts", - }, - }, - ], - }, - ], - }, - }, - }, - { - id: "https://shaperepo.com/schemas/solidProfile#RSAPublicKeyShape", - type: "ShapeDecl", - shapeExpr: { - type: "Shape", - expression: { - type: "EachOf", - expressions: [ - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/cert#modulus", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#string", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "RSA Modulus", - }, - }, - ], - }, - { - type: "TripleConstraint", - predicate: "http://www.w3.org/ns/auth/cert#exponent", - valueExpr: { - type: "NodeConstraint", - datatype: "http://www.w3.org/2001/XMLSchema#integer", - }, - annotations: [ - { - type: "Annotation", - predicate: "http://www.w3.org/2000/01/rdf-schema#comment", - object: { - value: "RSA Exponent", - }, - }, - ], - }, - ], - }, - }, - }, - ], -}; diff --git a/packages/demo-react/src/.ldo/solidProfile.shapeTypes.ts b/packages/demo-react/src/.ldo/solidProfile.shapeTypes.ts deleted file mode 100644 index 71426e4..0000000 --- a/packages/demo-react/src/.ldo/solidProfile.shapeTypes.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { ShapeType } from "@ldo/ldo"; -import { solidProfileSchema } from "./solidProfile.schema"; -import { solidProfileContext } from "./solidProfile.context"; -import { - SolidProfileShape, - AddressShape, - EmailShape, - PhoneNumberShape, - TrustedAppShape, - RSAPublicKeyShape, -} from "./solidProfile.typings"; - -/** - * ============================================================================= - * LDO ShapeTypes solidProfile - * ============================================================================= - */ - -/** - * SolidProfileShape ShapeType - */ -export const SolidProfileShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#SolidProfileShape", - context: solidProfileContext, -}; - -/** - * AddressShape ShapeType - */ -export const AddressShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#AddressShape", - context: solidProfileContext, -}; - -/** - * EmailShape ShapeType - */ -export const EmailShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#EmailShape", - context: solidProfileContext, -}; - -/** - * PhoneNumberShape ShapeType - */ -export const PhoneNumberShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#PhoneNumberShape", - context: solidProfileContext, -}; - -/** - * TrustedAppShape ShapeType - */ -export const TrustedAppShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#TrustedAppShape", - context: solidProfileContext, -}; - -/** - * RSAPublicKeyShape ShapeType - */ -export const RSAPublicKeyShapeShapeType: ShapeType = { - schema: solidProfileSchema, - shape: "https://shaperepo.com/schemas/solidProfile#RSAPublicKeyShape", - context: solidProfileContext, -}; diff --git a/packages/demo-react/src/.ldo/solidProfile.typings.ts b/packages/demo-react/src/.ldo/solidProfile.typings.ts deleted file mode 100644 index 535111b..0000000 --- a/packages/demo-react/src/.ldo/solidProfile.typings.ts +++ /dev/null @@ -1,293 +0,0 @@ -import { ContextDefinition } from "jsonld"; - -/** - * ============================================================================= - * Typescript Typings for solidProfile - * ============================================================================= - */ - -/** - * SolidProfileShape Type - */ -export interface SolidProfileShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * Defines the node as a Person (from Schema.org) | Defines the node as a Person (from foaf) - */ - type: ( - | { - "@id": "Person"; - } - | { - "@id": "Person2"; - } - )[]; - /** - * The formatted name of a person. Example: John Smith - */ - fn?: string; - /** - * An alternate way to define a person's name. - */ - name?: string; - /** - * The person's street address. - */ - hasAddress?: AddressShape[]; - /** - * The person's email. - */ - hasEmail?: EmailShape[]; - /** - * A link to the person's photo - */ - hasPhoto?: { - "@id": string; - }; - /** - * Photo link but in string form - */ - img?: string; - /** - * Person's telephone number - */ - hasTelephone?: PhoneNumberShape[]; - /** - * An alternative way to define a person's telephone number using a string - */ - phone?: string; - /** - * The name of the organization with which the person is affiliated - */ - organizationName?: string; - /** - * The name of the person's role in their organization - */ - role?: string; - /** - * A list of app origins that are trusted by this user - */ - trustedApp?: TrustedAppShape[]; - /** - * A list of RSA public keys that are associated with private keys the user holds. - */ - key?: RSAPublicKeyShape[]; - /** - * The user's LDP inbox to which apps can post notifications - */ - inbox: { - "@id": string; - }; - /** - * The user's preferences - */ - preferencesFile?: { - "@id": string; - }; - /** - * The location of a Solid storage server related to this WebId - */ - storage?: { - "@id": string; - }[]; - /** - * The user's account - */ - account?: { - "@id": string; - }; - /** - * A registry of all types used on the user's Pod (for private access only) - */ - privateTypeIndex?: { - "@id": string; - }[]; - /** - * A registry of all types used on the user's Pod (for public access) - */ - publicTypeIndex?: { - "@id": string; - }[]; - /** - * A list of WebIds for all the people this user knows. - */ - knows?: SolidProfileShape[]; -} - -/** - * AddressShape Type - */ -export interface AddressShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * The name of the user's country of residence - */ - countryName?: string; - /** - * The name of the user's locality (City, Town etc.) of residence - */ - locality?: string; - /** - * The user's postal code - */ - postalCode?: string; - /** - * The name of the user's region (State, Province etc.) of residence - */ - region?: string; - /** - * The user's street address - */ - streetAddress?: string; -} - -/** - * EmailShape Type - */ -export interface EmailShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * The type of email. - */ - type?: - | { - "@id": "Dom"; - } - | { - "@id": "Home"; - } - | { - "@id": "ISDN"; - } - | { - "@id": "Internet"; - } - | { - "@id": "Intl"; - } - | { - "@id": "Label"; - } - | { - "@id": "Parcel"; - } - | { - "@id": "Postal"; - } - | { - "@id": "Pref"; - } - | { - "@id": "Work"; - } - | { - "@id": "X400"; - }; - /** - * The value of an email as a mailto link (Example ) - */ - value: { - "@id": string; - }; -} - -/** - * PhoneNumberShape Type - */ -export interface PhoneNumberShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * They type of Phone Number - */ - type?: - | { - "@id": "Dom"; - } - | { - "@id": "Home"; - } - | { - "@id": "ISDN"; - } - | { - "@id": "Internet"; - } - | { - "@id": "Intl"; - } - | { - "@id": "Label"; - } - | { - "@id": "Parcel"; - } - | { - "@id": "Postal"; - } - | { - "@id": "Pref"; - } - | { - "@id": "Work"; - } - | { - "@id": "X400"; - }; - /** - * The value of a phone number as a tel link (Example ) - */ - value: { - "@id": string; - }; -} - -/** - * TrustedAppShape Type - */ -export interface TrustedAppShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * The level of access provided to this origin - */ - mode: ( - | { - "@id": "Append"; - } - | { - "@id": "Control"; - } - | { - "@id": "Read"; - } - | { - "@id": "Write"; - } - )[]; - /** - * The app origin the user trusts - */ - origin: { - "@id": string; - }; -} - -/** - * RSAPublicKeyShape Type - */ -export interface RSAPublicKeyShape { - "@id"?: string; - "@context"?: ContextDefinition; - /** - * RSA Modulus - */ - modulus: string; - /** - * RSA Exponent - */ - exponent: number; -} diff --git a/packages/demo-react/src/.shapes/post.shex b/packages/demo-react/src/.shapes/post.shex deleted file mode 100644 index ae75425..0000000 --- a/packages/demo-react/src/.shapes/post.shex +++ /dev/null @@ -1,23 +0,0 @@ -PREFIX rdf: -PREFIX rdfs: -PREFIX xsd: -PREFIX ex: -BASE - -ex:PostSh { - a [ ] ; - xsd:string? - // rdfs:label '''articleBody''' - // rdfs:comment '''The actual body of the article. ''' ; - xsd:date - // rdfs:label '''uploadDate''' - // rdfs:comment '''Date when this media object was uploaded to this site.''' ; - IRI ? - // rdfs:label '''image''' - // rdfs:comment '''A media object that encodes this CreativeWork. This property is a synonym for encoding.''' ; - IRI - // rdfs:label '''publisher''' - // rdfs:comment '''The publisher of the creative work.''' ; -} -// rdfs:label '''SocialMediaPost''' -// rdfs:comment '''A post to a social media platform, including blog posts, tweets, Facebook posts, etc.''' diff --git a/packages/demo-react/src/.shapes/solidProfile.shex b/packages/demo-react/src/.shapes/solidProfile.shex deleted file mode 100644 index cbc068c..0000000 --- a/packages/demo-react/src/.shapes/solidProfile.shex +++ /dev/null @@ -1,121 +0,0 @@ -PREFIX srs: -PREFIX foaf: -PREFIX rdfs: -PREFIX schem: -PREFIX vcard: -PREFIX xsd: -PREFIX acl: -PREFIX cert: -PREFIX ldp: -PREFIX sp: -PREFIX solid: - -srs:SolidProfileShape EXTRA a { - a [ schem:Person ] - // rdfs:comment "Defines the node as a Person (from Schema.org)" ; - a [ foaf:Person ] - // rdfs:comment "Defines the node as a Person (from foaf)" ; - vcard:fn xsd:string ? - // rdfs:comment "The formatted name of a person. Example: John Smith" ; - foaf:name xsd:string ? - // rdfs:comment "An alternate way to define a person's name." ; - vcard:hasAddress @srs:AddressShape * - // rdfs:comment "The person's street address." ; - vcard:hasEmail @srs:EmailShape * - // rdfs:comment "The person's email." ; - vcard:hasPhoto IRI ? - // rdfs:comment "A link to the person's photo" ; - foaf:img xsd:string ? - // rdfs:comment "Photo link but in string form" ; - vcard:hasTelephone @srs:PhoneNumberShape * - // rdfs:comment "Person's telephone number" ; - vcard:phone xsd:string ? - // rdfs:comment "An alternative way to define a person's telephone number using a string" ; - vcard:organization-name xsd:string ? - // rdfs:comment "The name of the organization with which the person is affiliated" ; - vcard:role xsd:string ? - // rdfs:comment "The name of the person's role in their organization" ; - acl:trustedApp @srs:TrustedAppShape * - // rdfs:comment "A list of app origins that are trusted by this user" ; - cert:key @srs:RSAPublicKeyShape * - // rdfs:comment "A list of RSA public keys that are associated with private keys the user holds." ; - ldp:inbox IRI - // rdfs:comment "The user's LDP inbox to which apps can post notifications" ; - sp:preferencesFile IRI ? - // rdfs:comment "The user's preferences" ; - sp:storage IRI * - // rdfs:comment "The location of a Solid storage server related to this WebId" ; - solid:account IRI ? - // rdfs:comment "The user's account" ; - solid:privateTypeIndex IRI * - // rdfs:comment "A registry of all types used on the user's Pod (for private access only)" ; - solid:publicTypeIndex IRI * - // rdfs:comment "A registry of all types used on the user's Pod (for public access)" ; - foaf:knows @srs:SolidProfileShape * - // rdfs:comment "A list of WebIds for all the people this user knows." ; -} - -srs:AddressShape { - vcard:country-name xsd:string ? - // rdfs:comment "The name of the user's country of residence" ; - vcard:locality xsd:string ? - // rdfs:comment "The name of the user's locality (City, Town etc.) of residence" ; - vcard:postal-code xsd:string ? - // rdfs:comment "The user's postal code" ; - vcard:region xsd:string ? - // rdfs:comment "The name of the user's region (State, Province etc.) of residence" ; - vcard:street-address xsd:string ? - // rdfs:comment "The user's street address" ; -} - -srs:EmailShape EXTRA a { - a [ - vcard:Dom - vcard:Home - vcard:ISDN - vcard:Internet - vcard:Intl - vcard:Label - vcard:Parcel - vcard:Postal - vcard:Pref - vcard:Work - vcard:X400 - ] ? - // rdfs:comment "The type of email." ; - vcard:value IRI - // rdfs:comment "The value of an email as a mailto link (Example )" ; -} - -srs:PhoneNumberShape EXTRA a { - a [ - vcard:Dom - vcard:Home - vcard:ISDN - vcard:Internet - vcard:Intl - vcard:Label - vcard:Parcel - vcard:Postal - vcard:Pref - vcard:Work - vcard:X400 - ] ? - // rdfs:comment "They type of Phone Number" ; - vcard:value IRI - // rdfs:comment "The value of a phone number as a tel link (Example )" ; -} - -srs:TrustedAppShape { - acl:mode [acl:Append acl:Control acl:Read acl:Write] + - // rdfs:comment "The level of access provided to this origin" ; - acl:origin IRI - // rdfs:comment "The app origin the user trusts" -} - -srs:RSAPublicKeyShape { - cert:modulus xsd:string - // rdfs:comment "RSA Modulus" ; - cert:exponent xsd:integer - // rdfs:comment "RSA Exponent" ; -} \ No newline at end of file diff --git a/packages/demo-react/src/App-old.tsx b/packages/demo-react/src/App-old.tsx deleted file mode 100644 index 721b93e..0000000 --- a/packages/demo-react/src/App-old.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import type { FunctionComponent } from "react"; -import React from "react"; -import { Router } from "./Layout"; -import { BrowserSolidLdoProvider } from "@ldo/solid-react"; - -const ProfileApp: FunctionComponent = () => { - return ( - - - - ); -}; -export default ProfileApp; diff --git a/packages/demo-react/src/App.tsx b/packages/demo-react/src/App.tsx deleted file mode 100644 index 4d00635..0000000 --- a/packages/demo-react/src/App.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import type { FunctionComponent } from "react"; -import React, { useCallback } from "react"; -import { - BrowserSolidLdoProvider, - useResource, - useSolidAuth, - useSubject, -} from "@ldo/solid-react"; -import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes"; -import { changeData, commitData } from "@ldo/solid"; - -// The base component for the app -const App: FunctionComponent = () => { - return ( - /* The application should be surrounded with the BrowserSolidLdoProvider - this will set up all the underlying infrastructure for the application */ - - - - ); -}; - -// A component that handles login -const Login: FunctionComponent = () => { - // Get login information using the "useSolidAuth" hook - const { login, logout, session } = useSolidAuth(); - - const onLogin = useCallback(() => { - const issuer = prompt("What is your Solid IDP?"); - // Call the "login" function to initiate login - if (issuer) login(issuer); - }, []); - - // You can use session.isLoggedIn to check if the user is logged in - if (session.isLoggedIn) { - return ( -
- {/* Get the user's webId from session.webId */} -

Logged in as {session.webId}

- {/* Use the logout function to log out */} - - -
- ); - } - return ; -}; - -const Profile: FunctionComponent = () => { - const { session } = useSolidAuth(); - const resource = useResource(session.webId); - const profile = useSubject(SolidProfileShapeShapeType, session.webId); - - const onNameChange = useCallback(async (e) => { - // Ensure that the - if (!profile || !resource) return; - const cProfile = changeData(profile, resource); - cProfile.name = e.target.value; - await commitData(cProfile); - }, []); - - return ; -}; - -export default App; diff --git a/packages/demo-react/src/Header.tsx b/packages/demo-react/src/Header.tsx deleted file mode 100644 index 49f751d..0000000 --- a/packages/demo-react/src/Header.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { useState } from "react"; -import type { FunctionComponent } from "react"; -import React from "react"; -import { useResource, useSolidAuth, useSubject } from "@ldo/solid-react"; -import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes"; -import { Link } from "react-router-dom"; - -const DEFAULT_ISSUER = "https://solidweb.me"; - -export const LoggedInHeader: FunctionComponent<{ webId: string }> = ({ - webId, -}) => { - const webIdResource = useResource(webId); - const profile = useSubject(SolidProfileShapeShapeType, webId); - const { logout } = useSolidAuth(); - return ( - <> - - Logged in as {webId}. Welcome{" "} - {webIdResource.isReading() ? "LOADING NAME" : profile.fn} - - - - ); -}; - -export const Header: FunctionComponent = () => { - const [issuer, setIssuer] = useState(DEFAULT_ISSUER); - const { login, signUp, session } = useSolidAuth(); - return ( -
-
- {session.isLoggedIn ? ( - - ) : ( - <> - setIssuer(e.target.value)} - /> - - - - )} -
-

- Blog - {" "} - Profile -

-
- ); -}; diff --git a/packages/demo-react/src/Layout.tsx b/packages/demo-react/src/Layout.tsx deleted file mode 100644 index 0521d3f..0000000 --- a/packages/demo-react/src/Layout.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { useSolidAuth } from "@ldo/solid-react"; -import React, { Fragment } from "react"; -import type { FunctionComponent } from "react"; -import { createBrowserRouter, Outlet, RouterProvider } from "react-router-dom"; -import { Blog } from "./blog/Blog"; -import { PostPage } from "./post/PostPage"; -import { Header } from "./Header"; -import { MainContainerProvider } from "./MainContainerProvider"; -import { Profile } from "./profile/Profile"; - -export const Layout: FunctionComponent = () => { - const { session } = useSolidAuth(); - return ( -
-
-
- - {session.isLoggedIn ? : } - -
- ); -}; - -const router = createBrowserRouter([ - { - element: , - children: [ - { - path: "/", - element: , - }, - { - path: "/media/:uri", - element: , - }, - { - path: "/profile", - element: , - }, - ], - }, -]); - -export const Router: FunctionComponent = () => { - const { ranInitialAuthCheck } = useSolidAuth(); - if (!ranInitialAuthCheck) { - return

Loading

; - } - return ; -}; diff --git a/packages/demo-react/src/MainContainerProvider.tsx b/packages/demo-react/src/MainContainerProvider.tsx deleted file mode 100644 index 5ebe2bf..0000000 --- a/packages/demo-react/src/MainContainerProvider.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React, { useState, useEffect, createContext } from "react"; -import type { FunctionComponent, PropsWithChildren } from "react"; -import type { Container, LeafUri } from "@ldo/solid"; -import { useSolidAuth, useLdo, useResource } from "@ldo/solid-react"; - -export const MainContainerContext = createContext( - undefined, -); - -const MainContainerSubProvider: FunctionComponent< - PropsWithChildren<{ uri?: string }> -> = ({ uri, children }) => { - const mainContainer = useResource(uri); - return ( - - {children} - - ); -}; - -export const MainContainerProvider: FunctionComponent = ({ - children, -}) => { - const [mainContainer, setMainContainer] = useState(); - const { session } = useSolidAuth(); - const { getResource } = useLdo(); - - useEffect(() => { - if (session.webId) { - const webIdResource = getResource(session.webId as LeafUri); - webIdResource.getRootContainer().then(async (rootContainer) => { - if (rootContainer.isError) { - alert(rootContainer.message); - return; - } - const mainContainer = getResource(`${rootContainer.uri}demo-react/`); - setMainContainer(mainContainer); - const createResult = await mainContainer.createIfAbsent(); - // Only set the access rules if the create was a success. - if (createResult.type === "createSuccess") { - await mainContainer.setWac({ - public: { - read: true, - write: false, - append: false, - control: false, - }, - authenticated: { - read: true, - write: false, - append: false, - control: false, - }, - agent: { - [session.webId!]: { - read: true, - write: true, - append: true, - control: true, - }, - }, - }); - } - }); - } - }, [session.webId]); - - return ( - - {children} - - ); -}; diff --git a/packages/demo-react/src/blog/Blog.tsx b/packages/demo-react/src/blog/Blog.tsx deleted file mode 100644 index d9f1009..0000000 --- a/packages/demo-react/src/blog/Blog.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { Fragment, useContext } from "react"; -import type { FunctionComponent } from "react"; -import { MainContainerContext } from "../MainContainerProvider"; -import { Post } from "../post/Post"; -import { MakePost } from "./MakePost"; - -export const Blog: FunctionComponent = () => { - const mainContainer = useContext(MainContainerContext); - if (mainContainer === undefined) { - return

Loading...

; - } - if (mainContainer.isDoingInitialFetch()) { - return

Loading Blob

; - } - - return ( -
-
- -
-
- {mainContainer.children().map((child) => ( - - -
-
- ))} -
- ); -}; diff --git a/packages/demo-react/src/blog/MakePost.tsx b/packages/demo-react/src/blog/MakePost.tsx deleted file mode 100644 index f782b95..0000000 --- a/packages/demo-react/src/blog/MakePost.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import React, { useCallback, useState, useRef } from "react"; -import type { FunctionComponent, FormEvent } from "react"; -import type { Container, Leaf, LeafUri } from "@ldo/solid"; -import { v4 } from "uuid"; -import { useLdo, useSolidAuth } from "@ldo/solid-react"; -import { PostShShapeType } from "../.ldo/post.shapeTypes"; - -export const MakePost: FunctionComponent<{ mainContainer: Container }> = ({ - mainContainer, -}) => { - const [message, setMessage] = useState(""); - const [selectedFile, setSelectedFile] = useState(); - const fileInputRef = useRef(null); - const { createData, commitData } = useLdo(); - const { session } = useSolidAuth(); - const onSubmit = useCallback( - async (e: FormEvent) => { - e.preventDefault(); - - // Create the container file - const mediaContainerResult = await mainContainer.createChildAndOverwrite( - `${v4()}/`, - ); - if (mediaContainerResult.isError) { - alert(mediaContainerResult.message); - return; - } - const mediaContainer = mediaContainerResult.resource; - - // Upload Image - let uploadedImage: Leaf | undefined; - if (selectedFile) { - const result = await mediaContainer.uploadChildAndOverwrite( - selectedFile.name as LeafUri, - selectedFile, - selectedFile.type, - ); - if (result.isError) { - alert(result.message); - await mediaContainer.delete(); - return; - } - uploadedImage = result.resource; - } - - // Create Post - const indexResource = mediaContainer.child("index.ttl"); - const post = createData( - PostShShapeType, - indexResource.uri, - indexResource, - ); - post.articleBody = message; - if (uploadedImage) { - post.image = { "@id": uploadedImage.uri }; - } - if (session.webId) { - post.publisher = { "@id": session.webId }; - } - post.type = { "@id": "SocialMediaPosting" }; - post.uploadDate = new Date().toISOString(); - const result = await commitData(post); - if (result.isError) { - alert(result.message); - } - - // Clear the UI after Upload - setMessage(""); - setSelectedFile(undefined); - if (fileInputRef.current) fileInputRef.current.value = ""; - }, - [message, selectedFile, session.webId], - ); - - return ( -
- setMessage(e.target.value)} - /> - setSelectedFile(e.target.files?.[0])} - /> - -
- ); -}; diff --git a/packages/demo-react/src/index.tsx b/packages/demo-react/src/index.tsx deleted file mode 100644 index d701043..0000000 --- a/packages/demo-react/src/index.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import ReactDOM from "react-dom/client"; -import App from "./App"; - -const root = ReactDOM.createRoot( - document.getElementById("root") as HTMLElement, -); -root.render(); diff --git a/packages/demo-react/src/post/Post.tsx b/packages/demo-react/src/post/Post.tsx deleted file mode 100644 index 53b3af4..0000000 --- a/packages/demo-react/src/post/Post.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React, { useCallback } from "react"; -import type { FunctionComponent } from "react"; -import { useLdo, useResource, useSubject } from "@ldo/solid-react"; -import { PostShShapeType } from "../.ldo/post.shapeTypes"; -import { useNavigate } from "react-router-dom"; -import { PostedBy } from "./PostedBy"; - -export const Post: FunctionComponent<{ uri: string }> = ({ uri }) => { - const navigate = useNavigate(); - const mediaResource = useResource(`${uri}index.ttl`); - const post = useSubject(PostShShapeType, mediaResource.uri); - const { getResource } = useLdo(); - const deletePost = useCallback(async () => { - const postContainer = getResource(uri); - const result = await postContainer.delete(); - if (result.isError) { - alert(result.message); - } - }, [uri]); - - if (mediaResource.isReading()) { - return

Loading Post...

; - } else if (mediaResource.status.isError) { - return

Error: {mediaResource.status.message}

; - } else if (mediaResource.isAbsent()) { - return

Post does not exist.

; - } - - return ( -
- {post.publisher?.["@id"] && } -
navigate(`/media/${encodeURIComponent(uri)}`)} - style={{ cursor: "pointer" }} - > - {post.articleBody &&

{post.articleBody}

} - {post.image && } -
- -
- ); -}; diff --git a/packages/demo-react/src/post/PostPage.tsx b/packages/demo-react/src/post/PostPage.tsx deleted file mode 100644 index bc5e144..0000000 --- a/packages/demo-react/src/post/PostPage.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import type { FunctionComponent } from "react"; -import { useNavigate, useParams } from "react-router-dom"; -import { Post } from "./Post"; - -export const PostPage: FunctionComponent = () => { - const navigate = useNavigate(); - const { uri } = useParams(); - - return ( -
- - {uri ? :

No URI Present

} -
- ); -}; diff --git a/packages/demo-react/src/post/PostedBy.tsx b/packages/demo-react/src/post/PostedBy.tsx deleted file mode 100644 index e11fda1..0000000 --- a/packages/demo-react/src/post/PostedBy.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import type { FunctionComponent } from "react"; -import React from "react"; -import { useResource, useSubject } from "@ldo/solid-react"; -import { SolidProfileShapeShapeType } from "../.ldo/solidProfile.shapeTypes"; - -export const PostedBy: FunctionComponent<{ webId: string }> = ({ webId }) => { - const webIdResource = useResource(webId); - const profile = useSubject(SolidProfileShapeShapeType, webId); - - if (webIdResource.isReading()) { - return

Loading Profile...

; - } else if (webIdResource.status.isError) { - return

Error: {webIdResource.status.message}

; - } - return

Posted By: {profile.fn}

; -}; diff --git a/packages/demo-react/src/profile/Profile.tsx b/packages/demo-react/src/profile/Profile.tsx deleted file mode 100644 index ae57f90..0000000 --- a/packages/demo-react/src/profile/Profile.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { - useLdo, - useResource, - useSolidAuth, - useSubject, -} from "@ldo/solid-react"; -import type { ChangeEvent } from "react"; -import React, { useCallback, type FunctionComponent } from "react"; -import { SolidProfileShapeShapeType } from "../.ldo/solidProfile.shapeTypes"; - -export const Profile: FunctionComponent = () => { - const { session } = useSolidAuth(); - const profile = useSubject(SolidProfileShapeShapeType, session.webId); - const webIdResource = useResource(session.webId); - const { changeData, commitData } = useLdo(); - - const onNameChange = useCallback( - async (e: ChangeEvent) => { - if (profile && webIdResource) { - const cProfile = changeData(profile, webIdResource); - cProfile.fn = e.target.value; - await commitData(cProfile); - } - }, - [profile, webIdResource], - ); - - return ( - <> - - - - ); -}; diff --git a/packages/demo-react/tsconfig.json b/packages/demo-react/tsconfig.json deleted file mode 100644 index 0b7eb4f..0000000 --- a/packages/demo-react/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" - }, - "include": [ - "./src" - ] -} \ No newline at end of file diff --git a/packages/solid-type-index/src/.ldo/profile.context.ts b/packages/solid-type-index/src/.ldo/profile.context.ts index e1e31a2..0d4014c 100644 --- a/packages/solid-type-index/src/.ldo/profile.context.ts +++ b/packages/solid-type-index/src/.ldo/profile.context.ts @@ -1,4 +1,4 @@ -import { LdoJsonldContext } from "@ldo/jsonld-dataset-proxy"; +import { LdoJsonldContext } from "@ldo/ldo"; /** * ============================================================================= diff --git a/packages/solid-type-index/src/.ldo/profile.typings.ts b/packages/solid-type-index/src/.ldo/profile.typings.ts index bca3f3b..85335b2 100644 --- a/packages/solid-type-index/src/.ldo/profile.typings.ts +++ b/packages/solid-type-index/src/.ldo/profile.typings.ts @@ -1,4 +1,4 @@ -import { ContextDefinition } from "jsonld"; +import { LdoJsonldContext, LdSet } from "@ldo/ldo"; /** * ============================================================================= @@ -11,17 +11,17 @@ import { ContextDefinition } from "jsonld"; */ export interface TypeIndexProfile { "@id"?: string; - "@context"?: ContextDefinition; + "@context"?: LdoJsonldContext; /** * A registry of all types used on the user's Pod (for private access only) */ - privateTypeIndex?: { + privateTypeIndex?: LdSet<{ "@id": string; - }[]; + }>; /** * A registry of all types used on the user's Pod (for public access) */ - publicTypeIndex?: { + publicTypeIndex?: LdSet<{ "@id": string; - }[]; + }>; } diff --git a/packages/solid-type-index/src/.ldo/typeIndex.context.ts b/packages/solid-type-index/src/.ldo/typeIndex.context.ts index e469629..c048a91 100644 --- a/packages/solid-type-index/src/.ldo/typeIndex.context.ts +++ b/packages/solid-type-index/src/.ldo/typeIndex.context.ts @@ -1,4 +1,4 @@ -import { LdoJsonldContext } from "@ldo/jsonld-dataset-proxy"; +import { LdoJsonldContext } from "@ldo/ldo"; /** * ============================================================================= @@ -7,7 +7,7 @@ import { LdoJsonldContext } from "@ldo/jsonld-dataset-proxy"; */ export const typeIndexContext: LdoJsonldContext = { type: { - "@id": "@type" + "@id": "@type", }, TypeIndex: { "@id": "http://www.w3.org/ns/solid/terms#TypeIndex", @@ -47,4 +47,18 @@ export const typeIndexContext: LdoJsonldContext = { }, }, }, + forClass: { + "@id": "http://www.w3.org/ns/solid/terms#forClass", + "@type": "@id", + }, + instance: { + "@id": "http://www.w3.org/ns/solid/terms#instance", + "@type": "@id", + "@isCollection": true, + }, + instanceContainer: { + "@id": "http://www.w3.org/ns/solid/terms#instanceContainer", + "@type": "@id", + "@isCollection": true, + }, }; diff --git a/packages/solid-type-index/src/.ldo/typeIndex.typings.ts b/packages/solid-type-index/src/.ldo/typeIndex.typings.ts index 53064ef..ba31a45 100644 --- a/packages/solid-type-index/src/.ldo/typeIndex.typings.ts +++ b/packages/solid-type-index/src/.ldo/typeIndex.typings.ts @@ -1,4 +1,4 @@ -import { ContextDefinition } from "jsonld"; +import { LdoJsonldContext, LdSet } from "@ldo/ldo"; /** * ============================================================================= @@ -11,18 +11,18 @@ import { ContextDefinition } from "jsonld"; */ export interface TypeIndexDocument { "@id"?: string; - "@context"?: ContextDefinition; + "@context"?: LdoJsonldContext; /** * Defines the node as a TypeIndex | Defines the node as a Listed Document */ - type: ( + type: LdSet< | { "@id": "TypeIndex"; } | { "@id": "ListedDocument"; } - )[]; + >; } /** @@ -30,7 +30,7 @@ export interface TypeIndexDocument { */ export interface TypeRegistration { "@id"?: string; - "@context"?: ContextDefinition; + "@context"?: LdoJsonldContext; /** * Defines this node as a Type Registration */ @@ -46,13 +46,13 @@ export interface TypeRegistration { /** * A specific resource that contains the class. */ - instance?: { + instance?: LdSet<{ "@id": string; - }[]; + }>; /** * Containers that contain resources with the class. */ - instanceContainer?: { + instanceContainer?: LdSet<{ "@id": string; - }[]; + }>; } diff --git a/packages/solid-type-index/src/getTypeIndex.ts b/packages/solid-type-index/src/getTypeIndex.ts index e34981e..0dc3346 100644 --- a/packages/solid-type-index/src/getTypeIndex.ts +++ b/packages/solid-type-index/src/getTypeIndex.ts @@ -6,11 +6,12 @@ import { TypeRegistrationShapeType } from "./.ldo/typeIndex.shapeTypes"; import { RDF_TYPE, TYPE_REGISTRATION } from "./constants"; import type { Options } from "./util/Options"; import { guaranteeOptions } from "./util/Options"; +import type { LdSet } from "@ldo/ldo"; export async function getTypeRegistrations( webId: string, options?: Options, -): Promise { +): Promise> { const { dataset } = guaranteeOptions(options); // Get Profile diff --git a/packages/solid-type-index/src/react/useInstanceUris.ts b/packages/solid-type-index/src/react/useInstanceUris.ts index 59717bc..68fa251 100644 --- a/packages/solid-type-index/src/react/useInstanceUris.ts +++ b/packages/solid-type-index/src/react/useInstanceUris.ts @@ -36,7 +36,7 @@ export function useInstanceUris(classUri: string): LeafUri[] { ); useEffect(() => { - getInstanceUris(classUri, typeRegistrations, { + getInstanceUris(classUri, typeRegistrations.toArray(), { solidLdoDataset: dataset, }).then(setLeafUris); }, [typeRegistrations]); diff --git a/packages/solid-type-index/src/setTypeIndex.ts b/packages/solid-type-index/src/setTypeIndex.ts index 1c784dc..c7dd714 100644 --- a/packages/solid-type-index/src/setTypeIndex.ts +++ b/packages/solid-type-index/src/setTypeIndex.ts @@ -12,6 +12,7 @@ import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes"; import type { Container } from "@ldo/solid"; import type { ISolidLdoDataset } from "@ldo/solid"; import type { NamedNode } from "@rdfjs/types"; +import { set } from "@ldo/ldo"; /** * ============================================================================= @@ -24,15 +25,15 @@ export async function initTypeIndex( ): Promise { const { dataset } = guaranteeOptions(options); const profile = await getProfile(webId, options); - if (!profile.privateTypeIndex?.length || !profile.publicTypeIndex?.length) { + if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) { const profileFolder = await dataset.getResource(webId).getParentContainer(); if (profileFolder?.isError) throw profileFolder; if (!profileFolder) throw new Error("No folder to save the type indexes to."); - if (!profile.privateTypeIndex?.length) { + if (!profile.privateTypeIndex?.size) { await createIndex(webId, profileFolder, dataset, true); } - if (!profile.publicTypeIndex?.length) { + if (!profile.publicTypeIndex?.size) { await createIndex(webId, profileFolder, dataset, false); } } @@ -80,16 +81,16 @@ export async function createIndex( .write(dataset.getResource(webId).uri) .fromSubject(webId); if (isPrivate) { - cProfile.privateTypeIndex?.push({ "@id": indexResource.uri }); + cProfile.privateTypeIndex?.add({ "@id": indexResource.uri }); } else { - cProfile.publicTypeIndex?.push({ "@id": indexResource.uri }); + cProfile.publicTypeIndex?.add({ "@id": indexResource.uri }); } const cTypeIndex = transaction .usingType(TypeIndexDocumentShapeType) .write(indexResource.uri) .fromSubject(indexResource.uri); - cTypeIndex.type = [{ "@id": "ListedDocument" }, { "@id": "TypeIndex" }]; + cTypeIndex.type = set({ "@id": "ListedDocument" }, { "@id": "TypeIndex" }); const commitResult = await transaction.commitToPod(); if (commitResult.isError) throw commitResult; } @@ -104,6 +105,13 @@ interface Instances { instanceContainer?: string[]; } +/** + * Adds an instance to a TypeRegistration + * @param indexUri The URI of the TypeIndex + * @param classUri The URI for the class the instance should be added to + * @param instances Objects representing the instances to add + * @param options Options + */ export function addRegistration( indexUri: string, classUri: string, @@ -119,13 +127,20 @@ export function addRegistration( // Add instances to type registration instances.instance?.forEach((instance) => { - typeRegistration.instance?.push({ "@id": instance }); + typeRegistration.instance?.add({ "@id": instance }); }); instances.instanceContainer?.forEach((instanceContainer) => { - typeRegistration.instanceContainer?.push({ "@id": instanceContainer }); + typeRegistration.instanceContainer?.add({ "@id": instanceContainer }); }); } +/** + * Removes instances from a TypeRegistration + * @param indexUri The URI of the TypeIndex + * @param classUri The URI for the class the instance should be removed from + * @param instances Objects representing the instances to remove + * @param options Options + */ export async function removeRegistration( indexUri: string, classUri: string, @@ -139,31 +154,28 @@ export async function removeRegistration( options, ); - console.log(typeRegistration["@id"]); - // Add instances to type registration - instances.instance?.forEach((instance) => { - typeRegistration.instance?.splice( - typeRegistration.instance.findIndex((val) => val["@id"] === instance), - 1, - ); + instances.instance?.forEach((instanceUri) => { + typeRegistration.instance?.delete({ "@id": instanceUri }); }); - instances.instanceContainer?.forEach((instanceContainer) => { - console.log("Splicing instanceContainers", instanceContainer); - typeRegistration.instanceContainer?.splice( - typeRegistration.instanceContainer.findIndex( - (val) => val["@id"] === instanceContainer, - ), - 1, - ); + instances.instanceContainer?.forEach((instanceContainerUri) => { + typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri }); }); } +/** + * Finds a TypeRegistration inside of a type index. If it doesn't exist, it + * creates one. + * @param indexUri The URI of the typeIndex + * @param classUri The URI of the class in question for the TypeRegistration + * @param options + * @returns The Type Index + */ export function findAppropriateTypeRegistration( indexUri: string, classUri: string, options?: Options, -) { +): TypeRegistration { const { dataset } = guaranteeOptions(options); // Check to see if its already in the index const existingRegistrationsUris: NamedNode[] = dataset diff --git a/packages/solid-type-index/test/General.test.tsx b/packages/solid-type-index/test/General.test.tsx index 7cf8380..48f6573 100644 --- a/packages/solid-type-index/test/General.test.tsx +++ b/packages/solid-type-index/test/General.test.tsx @@ -39,7 +39,7 @@ describe("General Tests", () => { }); const addressBookUris = await getInstanceUris( ADDRESS_BOOK, - typeRegistrations, + typeRegistrations.toArray(), { solidLdoDataset }, ); expect(addressBookUris).toEqual( @@ -48,9 +48,13 @@ describe("General Tests", () => { "https://example.com/myPublicAddressBook.ttl", ]), ); - const bookmarkUris = await getInstanceUris(BOOKMARK, typeRegistrations, { - solidLdoDataset, - }); + const bookmarkUris = await getInstanceUris( + BOOKMARK, + typeRegistrations.toArray(), + { + solidLdoDataset, + }, + ); expect(bookmarkUris).toEqual( expect.arrayContaining([MY_BOOKMARKS_1_URI, MY_BOOKMARKS_2_URI]), ); @@ -67,8 +71,8 @@ describe("General Tests", () => { .usingType(TypeIndexProfileShapeType) .fromSubject(WEB_ID); - expect(profile.privateTypeIndex?.[0]?.["@id"]).toBeDefined(); - expect(profile.publicTypeIndex?.[0]?.["@id"]).toBeDefined(); + expect(profile.privateTypeIndex?.toArray()[0]?.["@id"]).toBeDefined(); + expect(profile.publicTypeIndex?.toArray()[0]?.["@id"]).toBeDefined(); }); it("Adds to the typeIndex", async () => {