parent
3c2c952562
commit
86b288dc07
@ -0,0 +1,32 @@ |
||||
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", |
||||
"@container": "@set", |
||||
}, |
||||
}; |
@ -0,0 +1,155 @@ |
||||
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.", |
||||
}, |
||||
}, |
||||
], |
||||
}, |
||||
}, |
||||
], |
||||
}; |
@ -0,0 +1,19 @@ |
||||
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<PostSh> = { |
||||
schema: postSchema, |
||||
shape: "https://example.com/PostSh", |
||||
context: postContext, |
||||
}; |
@ -0,0 +1,45 @@ |
||||
import { LdSet, LdoJsonldContext } from "@ldo/ldo"; |
||||
|
||||
/** |
||||
* ============================================================================= |
||||
* Typescript Typings for post |
||||
* ============================================================================= |
||||
*/ |
||||
|
||||
/** |
||||
* PostSh Type |
||||
*/ |
||||
export interface PostSh { |
||||
"@id"?: string; |
||||
"@context"?: LdoJsonldContext; |
||||
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: LdSet<{ |
||||
"@id": string; |
||||
}>; |
||||
} |
@ -0,0 +1,459 @@ |
||||
import { LdoJsonldContext } from "@ldo/ldo"; |
||||
|
||||
/** |
||||
* ============================================================================= |
||||
* solidProfileContext: JSONLD Context for solidProfile |
||||
* ============================================================================= |
||||
*/ |
||||
export const solidProfileContext: LdoJsonldContext = { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
Person: { |
||||
"@id": "http://schema.org/Person", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
hasEmail: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#hasEmail", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
key: { |
||||
"@id": "http://www.w3.org/ns/auth/cert#key", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
account: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#account", |
||||
"@type": "@id", |
||||
}, |
||||
privateTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#privateTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
publicTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#publicTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
knows: { |
||||
"@id": "http://xmlns.com/foaf/0.1/knows", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
}, |
||||
}, |
||||
Person2: { |
||||
"@id": "http://xmlns.com/foaf/0.1/Person", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
hasEmail: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#hasEmail", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
key: { |
||||
"@id": "http://www.w3.org/ns/auth/cert#key", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
account: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#account", |
||||
"@type": "@id", |
||||
}, |
||||
privateTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#privateTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
publicTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#publicTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
knows: { |
||||
"@id": "http://xmlns.com/foaf/0.1/knows", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
}, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
Dom: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Dom", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Home: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Home", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
ISDN: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#ISDN", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Internet: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Internet", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Intl: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Intl", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Label: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Label", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Parcel: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Parcel", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Postal: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Postal", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Pref: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Pref", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
Work: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#Work", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
X400: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#X400", |
||||
"@context": { |
||||
type: { |
||||
"@id": "@type", |
||||
}, |
||||
value: { |
||||
"@id": "http://www.w3.org/2006/vcard/ns#value", |
||||
"@type": "@id", |
||||
}, |
||||
}, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
mode: { |
||||
"@id": "http://www.w3.org/ns/auth/acl#mode", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
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", |
||||
"@isCollection": true, |
||||
}, |
||||
account: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#account", |
||||
"@type": "@id", |
||||
}, |
||||
privateTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#privateTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
publicTypeIndex: { |
||||
"@id": "http://www.w3.org/ns/solid/terms#publicTypeIndex", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
knows: { |
||||
"@id": "http://xmlns.com/foaf/0.1/knows", |
||||
"@type": "@id", |
||||
"@isCollection": true, |
||||
}, |
||||
}; |
@ -0,0 +1,749 @@ |
||||
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 <mailto:jane@example.com>)", |
||||
}, |
||||
}, |
||||
], |
||||
}, |
||||
], |
||||
}, |
||||
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 <tel:555-555-5555>)", |
||||
}, |
||||
}, |
||||
], |
||||
}, |
||||
], |
||||
}, |
||||
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", |
||||
}, |
||||
}, |
||||
], |
||||
}, |
||||
], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
@ -0,0 +1,71 @@ |
||||
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<SolidProfileShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#SolidProfileShape", |
||||
context: solidProfileContext, |
||||
}; |
||||
|
||||
/** |
||||
* AddressShape ShapeType |
||||
*/ |
||||
export const AddressShapeShapeType: ShapeType<AddressShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#AddressShape", |
||||
context: solidProfileContext, |
||||
}; |
||||
|
||||
/** |
||||
* EmailShape ShapeType |
||||
*/ |
||||
export const EmailShapeShapeType: ShapeType<EmailShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#EmailShape", |
||||
context: solidProfileContext, |
||||
}; |
||||
|
||||
/** |
||||
* PhoneNumberShape ShapeType |
||||
*/ |
||||
export const PhoneNumberShapeShapeType: ShapeType<PhoneNumberShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#PhoneNumberShape", |
||||
context: solidProfileContext, |
||||
}; |
||||
|
||||
/** |
||||
* TrustedAppShape ShapeType |
||||
*/ |
||||
export const TrustedAppShapeShapeType: ShapeType<TrustedAppShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#TrustedAppShape", |
||||
context: solidProfileContext, |
||||
}; |
||||
|
||||
/** |
||||
* RSAPublicKeyShape ShapeType |
||||
*/ |
||||
export const RSAPublicKeyShapeShapeType: ShapeType<RSAPublicKeyShape> = { |
||||
schema: solidProfileSchema, |
||||
shape: "https://shaperepo.com/schemas/solidProfile#RSAPublicKeyShape", |
||||
context: solidProfileContext, |
||||
}; |
@ -0,0 +1,293 @@ |
||||
import { LdoJsonldContext, LdSet } from "@ldo/ldo"; |
||||
|
||||
/** |
||||
* ============================================================================= |
||||
* Typescript Typings for solidProfile |
||||
* ============================================================================= |
||||
*/ |
||||
|
||||
/** |
||||
* SolidProfileShape Type |
||||
*/ |
||||
export interface SolidProfileShape { |
||||
"@id"?: string; |
||||
"@context"?: LdoJsonldContext; |
||||
/** |
||||
* Defines the node as a Person (from Schema.org) | Defines the node as a Person (from foaf) |
||||
*/ |
||||
type: LdSet< |
||||
| { |
||||
"@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?: LdSet<AddressShape>; |
||||
/** |
||||
* The person's email. |
||||
*/ |
||||
hasEmail?: LdSet<EmailShape>; |
||||
/** |
||||
* A link to the person's photo |
||||
*/ |
||||
hasPhoto?: { |
||||
"@id": string; |
||||
}; |
||||
/** |
||||
* Photo link but in string form |
||||
*/ |
||||
img?: string; |
||||
/** |
||||
* Person's telephone number |
||||
*/ |
||||
hasTelephone?: LdSet<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?: LdSet<TrustedAppShape>; |
||||
/** |
||||
* A list of RSA public keys that are associated with private keys the user holds. |
||||
*/ |
||||
key?: LdSet<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?: LdSet<{ |
||||
"@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?: LdSet<{ |
||||
"@id": string; |
||||
}>; |
||||
/** |
||||
* A registry of all types used on the user's Pod (for public access) |
||||
*/ |
||||
publicTypeIndex?: LdSet<{ |
||||
"@id": string; |
||||
}>; |
||||
/** |
||||
* A list of WebIds for all the people this user knows. |
||||
*/ |
||||
knows?: LdSet<SolidProfileShape>; |
||||
} |
||||
|
||||
/** |
||||
* AddressShape Type |
||||
*/ |
||||
export interface AddressShape { |
||||
"@id"?: string; |
||||
"@context"?: LdoJsonldContext; |
||||
/** |
||||
* 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"?: LdoJsonldContext; |
||||
/** |
||||
* 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 <mailto:jane@example.com>) |
||||
*/ |
||||
value: { |
||||
"@id": string; |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* PhoneNumberShape Type |
||||
*/ |
||||
export interface PhoneNumberShape { |
||||
"@id"?: string; |
||||
"@context"?: LdoJsonldContext; |
||||
/** |
||||
* 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 <tel:555-555-5555>) |
||||
*/ |
||||
value: { |
||||
"@id": string; |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* TrustedAppShape Type |
||||
*/ |
||||
export interface TrustedAppShape { |
||||
"@id"?: string; |
||||
"@context"?: LdoJsonldContext; |
||||
/** |
||||
* The level of access provided to this origin |
||||
*/ |
||||
mode: LdSet< |
||||
| { |
||||
"@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"?: LdoJsonldContext; |
||||
/** |
||||
* RSA Modulus |
||||
*/ |
||||
modulus: string; |
||||
/** |
||||
* RSA Exponent |
||||
*/ |
||||
exponent: number; |
||||
} |
@ -1,29 +1,34 @@ |
||||
<script lang="ts"> |
||||
import { myExampleFunction, myReactiveStore } from "@ldo/svelte"; |
||||
import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes"; |
||||
// Assuming these are the Svelte-specific functions/stores from your @ldo/svelte library |
||||
import { useResource, useSubject } from "./ldoSvelteMethods"; |
||||
const SAMPLE_DATA_URI = |
||||
"http://example.com/example/link-query/main-profile.ttl"; |
||||
const resource = useResource(SAMPLE_DATA_URI); |
||||
|
||||
let message = "Testing @ldo/svelte library!"; |
||||
|
||||
myExampleFunction(); |
||||
myReactiveStore(); |
||||
|
||||
// Example of using a function from your library |
||||
// if (typeof myExampleFunction === 'function') { |
||||
// message = myExampleFunction(); |
||||
// } |
||||
|
||||
// Example of subscribing to a store from your library |
||||
// let storeValue: any; |
||||
// if (myReactiveStore && typeof myReactiveStore.subscribe === 'function') { |
||||
// const unsubscribe = myReactiveStore.subscribe(value => { |
||||
// storeValue = value; |
||||
// }); |
||||
// // Clean up subscription on component destroy |
||||
// import { onDestroy } from 'svelte'; |
||||
// onDestroy(unsubscribe); |
||||
// } |
||||
const webId = `${SAMPLE_DATA_URI}#me`; |
||||
const profile = useSubject(SolidProfileShapeShapeType, webId); |
||||
$: friendArray = $profile?.knows?.toArray() || []; |
||||
$: firstFriendId = |
||||
friendArray.length > 0 ? friendArray[0]?.["@id"] : undefined; |
||||
</script> |
||||
|
||||
<main> |
||||
<h1>@ldo/svelte Example App</h1> |
||||
<p>{message}</p> |
||||
</main> |
||||
{#if $resource.isLoading() || !$profile} |
||||
<p>loading</p> |
||||
{:else} |
||||
<div> |
||||
{#if firstFriendId} |
||||
<p>{firstFriendId}</p> |
||||
{:else} |
||||
<p>No friend found or friend has no @id.</p> |
||||
{/if} |
||||
|
||||
<ul> |
||||
{#each friendArray as friend (friend["@id"])} |
||||
<li>{friend["@id"]}</li> |
||||
{:else} |
||||
<li>No friends listed.</li> |
||||
{/each} |
||||
</ul> |
||||
</div> |
||||
{/if} |
||||
|
@ -0,0 +1,13 @@ |
||||
import { createLdoSvelteMethods } from "@ldo/svelte"; |
||||
import { solidConnectedPlugin } from "@ldo/connected-solid"; |
||||
|
||||
export const { |
||||
dataset, |
||||
useLdo, |
||||
useMatchObject, |
||||
useMatchSubject, |
||||
useResource, |
||||
useSubject, |
||||
useSubscribeToResource, |
||||
useLinkQuery, |
||||
} = createLdoSvelteMethods([solidConnectedPlugin]); |
@ -0,0 +1,52 @@ |
||||
{ |
||||
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld", |
||||
"import": [ |
||||
"css:config/app/init/initialize-intro.json", |
||||
"css:config/app/main/default.json", |
||||
"css:config/app/variables/default.json", |
||||
"css:config/http/handler/default.json", |
||||
"css:config/http/middleware/default.json", |
||||
"css:config/http/notifications/all.json", |
||||
"css:config/http/server-factory/http.json", |
||||
"css:config/http/static/default.json", |
||||
"css:config/identity/access/public.json", |
||||
"css:config/identity/email/default.json", |
||||
"css:config/identity/handler/default.json", |
||||
"css:config/identity/oidc/default.json", |
||||
"css:config/identity/ownership/token.json", |
||||
"css:config/identity/pod/static.json", |
||||
"css:config/ldp/authentication/dpop-bearer.json", |
||||
"css:config/ldp/authorization/webacl.json", |
||||
"css:config/ldp/handler/default.json", |
||||
"css:config/ldp/metadata-parser/default.json", |
||||
"css:config/ldp/metadata-writer/default.json", |
||||
"css:config/ldp/modes/default.json", |
||||
"css:config/storage/backend/memory.json", |
||||
"css:config/storage/key-value/resource-store.json", |
||||
"css:config/storage/location/root.json", |
||||
"css:config/storage/middleware/default.json", |
||||
"css:config/util/auxiliary/acl.json", |
||||
"css:config/util/identifiers/suffix.json", |
||||
"css:config/util/index/default.json", |
||||
"css:config/util/logging/winston.json", |
||||
"css:config/util/representation-conversion/default.json", |
||||
"css:config/util/resource-locker/memory.json", |
||||
"css:config/util/variables/default.json" |
||||
], |
||||
"@graph": [ |
||||
{ |
||||
"comment": "A Solid server that stores its resources in memory and uses WAC for authorization." |
||||
}, |
||||
{ |
||||
"comment": "The location of the new pod templates folder.", |
||||
"@type": "Override", |
||||
"overrideInstance": { |
||||
"@id": "urn:solid-server:default:PodResourcesGenerator" |
||||
}, |
||||
"overrideParameters": { |
||||
"@type": "StaticFolderGenerator", |
||||
"templateFolder": "./example/test-server/configs/template" |
||||
} |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,9 @@ |
||||
[ |
||||
{ |
||||
"email": "hello@example.com", |
||||
"password": "abc123", |
||||
"pods": [ |
||||
{ "name": "example" } |
||||
] |
||||
} |
||||
] |
@ -0,0 +1,13 @@ |
||||
@prefix : <#>. |
||||
@prefix acl: <http://www.w3.org/ns/auth/acl#>. |
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. |
||||
@prefix eve: <./>. |
||||
@prefix c: <./profile/card#>. |
||||
|
||||
:ControlReadWrite |
||||
a acl:Authorization; |
||||
acl:accessTo eve:; |
||||
acl:agent c:me, <mailto:info@o.team>; |
||||
acl:agentClass foaf:Agent; |
||||
acl:default eve:; |
||||
acl:mode acl:Control, acl:Read, acl:Write. |
@ -0,0 +1,7 @@ |
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . |
||||
@prefix : <#> . |
||||
|
||||
:me a foaf:Person ; |
||||
foaf:name "Main User" ; |
||||
foaf:mbox <mailto:main@example.org> ; |
||||
foaf:knows <http://localhost:3002/example/link-query/other-profile.ttl#me> . |
@ -0,0 +1,7 @@ |
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . |
||||
@prefix : <#> . |
||||
|
||||
:me a foaf:Person ; |
||||
foaf:name "Other User" ; |
||||
foaf:mbox <mailto:other@example.org> ; |
||||
foaf:knows <http://localhost:3002/example/link-query/main-profile.ttl#me> . |
@ -0,0 +1,7 @@ |
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . |
||||
@prefix : <#> . |
||||
|
||||
:me a foaf:Person ; |
||||
foaf:name "Third User" ; |
||||
foaf:mbox <mailto:third@example.org> ; |
||||
foaf:knows <http://localhost:3002/example/link-query/main-profile.ttl#me> . |
@ -0,0 +1,19 @@ |
||||
# ACL resource for the WebID profile document |
||||
@prefix acl: <http://www.w3.org/ns/auth/acl#>. |
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. |
||||
|
||||
# The WebID profile is readable by the public. |
||||
# This is required for discovery and verification, |
||||
# e.g. when checking identity providers. |
||||
<#public> |
||||
a acl:Authorization; |
||||
acl:agentClass foaf:Agent; |
||||
acl:accessTo <./card>; |
||||
acl:mode acl:Read. |
||||
|
||||
# The owner has full access to the profile |
||||
<#owner> |
||||
a acl:Authorization; |
||||
acl:agent <{{webId}}>; |
||||
acl:accessTo <./card>; |
||||
acl:mode acl:Read, acl:Write, acl:Control. |
@ -0,0 +1,18 @@ |
||||
import { createApp } from "@ldo/test-solid-server/dist/createServer"; |
||||
import path from "path"; |
||||
import { fileURLToPath } from "url"; |
||||
|
||||
const __filename = fileURLToPath(import.meta.url); |
||||
const __dirname = path.dirname(__filename); |
||||
|
||||
async function run() { |
||||
const app = await createApp( |
||||
3004, |
||||
path.join( |
||||
__dirname, |
||||
"./configs/components-config/unauthenticatedServer.json", |
||||
), |
||||
); |
||||
await app.start(); |
||||
} |
||||
run(); |
@ -0,0 +1,77 @@ |
||||
/* eslint-disable @typescript-eslint/no-explicit-any */ |
||||
import { createUseLdo } from "./methods/useLdo"; |
||||
import { |
||||
createConnectedLdoDataset, |
||||
type ConnectedPlugin, |
||||
} from "@ldo/connected"; |
||||
import { createUseMatchObject } from "./methods/useMatchObject"; |
||||
import { createUseMatchSubject } from "./methods/useMatchSubject"; |
||||
import { createUseResource } from "./methods/useResource"; |
||||
import { createUseSubject } from "./methods/useSubject"; |
||||
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource"; |
||||
import { createUseLinkQuery } from "./methods/useLinkQuery"; |
||||
|
||||
/** |
||||
* A function that creates all common react functions given specific plugin. |
||||
* |
||||
* @example |
||||
* `methods.ts` |
||||
* ```tyepscript
|
||||
* import { solidConnectedPlugin } from "@ldo/connected-solid"; |
||||
* import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph"; |
||||
* import { createLdoReactMethods } from "@ldo/react"; |
||||
* |
||||
* // Export the results to be used in the reset of the application
|
||||
* export const { |
||||
* dataset, |
||||
* useLdo, |
||||
* useMatchObject, |
||||
* useMatchSubject, |
||||
* useResource, |
||||
* useSubject, |
||||
* useSubscribeToResource, |
||||
* useLinkQuery, |
||||
* } = createLdoReactMethods([ |
||||
* solidConnectedPlugin, |
||||
* nextGraphConnectedPlugin |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* `App.tsx` |
||||
* ```typescript
|
||||
* import react, { FunctionComponent } from "react"; |
||||
* import { PostShShapeType } from "./.ldo/posts.shapeType.ts"; |
||||
* import { useResource, useSubject } from "./methods.ts"; |
||||
* |
||||
* const UseSubjectTest: FunctionComponent = () => { |
||||
* const resource = useResource(SAMPLE_DATA_URI); |
||||
* const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`); |
||||
* if (resource.isLoading() || !post) return <p>loading</p>; |
||||
* |
||||
* return ( |
||||
* <ul> |
||||
* {post.publisher.map((publisher) => { |
||||
* return <li key={publisher["@id"]}>{publisher["@id"]}</li>; |
||||
* })} |
||||
* </ul> |
||||
* ); |
||||
* }; |
||||
* ``` |
||||
*/ |
||||
export function createLdoSvelteMethods< |
||||
Plugins extends ConnectedPlugin<any, any, any, any>[], |
||||
>(plugins: Plugins) { |
||||
const dataset = createConnectedLdoDataset(plugins); |
||||
dataset.setMaxListeners(1000); |
||||
|
||||
return { |
||||
dataset, |
||||
useLdo: createUseLdo(dataset), |
||||
useMatchObject: createUseMatchObject(dataset), |
||||
useMatchSubject: createUseMatchSubject(dataset), |
||||
useResource: createUseResource(dataset), |
||||
useSubject: createUseSubject(dataset), |
||||
useSubscribeToResource: createUseSubscribeToResource(dataset), |
||||
useLinkQuery: createUseLinkQuery(dataset), |
||||
}; |
||||
} |
@ -1,7 +1,9 @@ |
||||
export function myExampleFunction() { |
||||
console.log("Hello Example Function"); |
||||
} |
||||
export * from "./createLdoSvelteMethods"; |
||||
|
||||
export function myReactiveStore() { |
||||
console.log("Hello Example Store"); |
||||
} |
||||
export * from "./methods/useLdo"; |
||||
export * from "./methods/useMatchObject"; |
||||
export * from "./methods/useMatchSubject"; |
||||
export * from "./methods/useResource"; |
||||
export * from "./methods/useSubject"; |
||||
export * from "./methods/useSubscribeToResource"; |
||||
export * from "./methods/useLinkQuery"; |
||||
|
@ -0,0 +1,147 @@ |
||||
import { |
||||
// changeData,
|
||||
type ConnectedLdoDataset, |
||||
type ConnectedLdoTransactionDataset, |
||||
type ConnectedPlugin, |
||||
} from "@ldo/connected"; |
||||
import { type LdoBase, type ShapeType } from "@ldo/ldo"; |
||||
import type { SubjectNode } from "@ldo/rdf-utils"; |
||||
|
||||
/** |
||||
* The methods returned by useLdo |
||||
*/ |
||||
export interface UseLdoMethods<Plugins extends ConnectedPlugin[]> { |
||||
/** |
||||
* A ConnectedLdoDataset |
||||
*/ |
||||
dataset: ConnectedLdoDataset<Plugins>; |
||||
/** |
||||
* Retireves a representation of a Resource at the given URI. This resource |
||||
* represents the current state of the resource: whether it is currently |
||||
* fetched or in the process of fetching as well as some information about it. |
||||
* |
||||
* @param uri - the URI of the resource |
||||
* @param pluginName - optionally, force this function to choose a specific |
||||
* plugin to use rather than perform content negotiation. |
||||
* |
||||
* @returns a Resource |
||||
*/ |
||||
getResource: ConnectedLdoDataset<Plugins>["getResource"]; |
||||
/** |
||||
* Sets conetext for a specific plugin |
||||
* |
||||
* @param pluginName - the name of the plugin |
||||
* @param context - the context for this specific plugin |
||||
*/ |
||||
setContext: ConnectedLdoDataset<Plugins>["setContext"]; |
||||
/** |
||||
* Gets a linked data object based on the subject |
||||
*/ |
||||
getSubject<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject: string | SubjectNode, |
||||
): Type; |
||||
/** |
||||
* Shorthand for connectedLdoDataset |
||||
* .usingType(shapeType) |
||||
* .write(...resources.map((r) => r.uri)) |
||||
* .fromSubject(subject); |
||||
* @param shapeType - The shapetype to represent the data |
||||
* @param subject - A subject URI |
||||
* @param resources - The resources changes to should written to |
||||
*/ |
||||
createData<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject: string | SubjectNode, |
||||
resource: Plugins[number]["types"]["resource"], |
||||
...additionalResources: Plugins[number]["types"]["resource"][] |
||||
): Type; |
||||
/** |
||||
* Returns a writable LinkedDataObject given a linked data object |
||||
*/ |
||||
changeData<Type extends LdoBase>( |
||||
input: Type, |
||||
resource: Plugins[number]["types"]["resource"], |
||||
...additionalResources: Plugins[number]["types"]["resource"][] |
||||
): Type; |
||||
/** |
||||
* Commits the data of a writable Linke Data Object back to the remote. |
||||
*/ |
||||
commitData( |
||||
input: LdoBase, |
||||
): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]>; |
||||
} |
||||
|
||||
/** |
||||
* @internal |
||||
* Creates the useLdoHook |
||||
*/ |
||||
export function createUseLdo<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
) { |
||||
throw new Error("Not Implemented"); |
||||
// const toReturn = {
|
||||
// dataset,
|
||||
// /**
|
||||
// * Gets a resource
|
||||
// */
|
||||
// getResource: dataset.getResource.bind(dataset),
|
||||
// /**
|
||||
// * Set the context
|
||||
// */
|
||||
// setContext: dataset.setContext.bind(dataset),
|
||||
// /**
|
||||
// * Returns a Linked Data Object for a subject
|
||||
// * @param shapeType The shape type for the data
|
||||
// * @param subject Subject Node
|
||||
// * @returns A Linked Data Object
|
||||
// */
|
||||
// getSubject<Type extends LdoBase>(
|
||||
// shapeType: ShapeType<Type>,
|
||||
// subject: string | SubjectNode,
|
||||
// ): Type {
|
||||
// return dataset.usingType(shapeType).fromSubject(subject);
|
||||
// },
|
||||
// /**
|
||||
// * Begins tracking changes to eventually commit for a new subject
|
||||
// * @param shapeType The shape type that defines the created data
|
||||
// * @param subject The RDF subject for a Linked Data Object
|
||||
// * @param resources Any number of resources to which this data should be written
|
||||
// * @returns A Linked Data Object to modify and commit
|
||||
// */
|
||||
// createData<Type extends LdoBase>(
|
||||
// shapeType: ShapeType<Type>,
|
||||
// subject: string | SubjectNode,
|
||||
// resource: Plugins[number]["types"]["resource"],
|
||||
// ...additionalResources: Plugins[number]["types"]["resource"][]
|
||||
// ): Type {
|
||||
// return dataset.createData(
|
||||
// shapeType,
|
||||
// subject,
|
||||
// resource,
|
||||
// ...additionalResources,
|
||||
// );
|
||||
// },
|
||||
// /**
|
||||
// * Begins tracking changes to eventually commit
|
||||
// * @param input A linked data object to track changes on
|
||||
// * @param resources
|
||||
// */
|
||||
// changeData: changeData,
|
||||
// /**
|
||||
// * Commits the transaction to the global dataset, syncing all subscribing
|
||||
// * components and Solid Pods
|
||||
// */
|
||||
// commitData(
|
||||
// input: LdoBase,
|
||||
// ): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]> {
|
||||
// const inputDataset = getDataset(
|
||||
// input,
|
||||
// ) as ConnectedLdoTransactionDataset<Plugins>;
|
||||
// return inputDataset.commitToRemote();
|
||||
// },
|
||||
// };
|
||||
// return function useLdo(): UseLdoMethods<Plugins> {
|
||||
// throw new Error("Not Implemented");
|
||||
// };
|
||||
} |
@ -0,0 +1,34 @@ |
||||
import type { |
||||
ConnectedLdoDataset, |
||||
ConnectedPlugin, |
||||
ExpandDeep, |
||||
LQInput, |
||||
LQReturn, |
||||
} from "@ldo/connected"; |
||||
import type { LdoBase, ShapeType } from "@ldo/ldo"; |
||||
import type { SubjectNode } from "@ldo/rdf-utils"; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useMatchSubject function. |
||||
*/ |
||||
export function createUseLinkQuery<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
) { |
||||
/** |
||||
* Returns an array of matching linked data objects. Triggers a rerender if |
||||
* the data is updated. |
||||
*/ |
||||
return function useQueryLink< |
||||
Type extends LdoBase, |
||||
QueryInput extends LQInput<Type>, |
||||
>( |
||||
shapeType: ShapeType<Type>, |
||||
startingResource: string, |
||||
startingSubject: SubjectNode | string, |
||||
linkQuery: QueryInput, |
||||
): ExpandDeep<LQReturn<Type, QueryInput>> | undefined { |
||||
throw new Error("Not Implemented"); |
||||
}; |
||||
} |
@ -0,0 +1,25 @@ |
||||
import type { LdoBase, LdSet, ShapeType } from "@ldo/ldo"; |
||||
import type { QuadMatch } from "@ldo/rdf-utils"; |
||||
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected"; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useMatchObject function |
||||
*/ |
||||
export function createUseMatchObject<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
) { |
||||
/** |
||||
* Returns an array of matching items and triggers a rerender when that data |
||||
* is updated. |
||||
*/ |
||||
return function useMatchObject<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject?: QuadMatch[0] | string, |
||||
predicate?: QuadMatch[1] | string, |
||||
graph?: QuadMatch[3] | string, |
||||
): LdSet<Type> { |
||||
throw new Error("Not Implemented"); |
||||
}; |
||||
} |
@ -0,0 +1,25 @@ |
||||
import type { LdoBase, LdSet, ShapeType } from "@ldo/ldo"; |
||||
import type { QuadMatch } from "@ldo/rdf-utils"; |
||||
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected"; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useMatchSubject function. |
||||
*/ |
||||
export function createUseMatchSubject<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
) { |
||||
/** |
||||
* Returns an array of matching linked data objects. Triggers a rerender if |
||||
* the data is updated. |
||||
*/ |
||||
return function useMatchSubject<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
predicate?: QuadMatch[1] | string, |
||||
object?: QuadMatch[2] | string, |
||||
graph?: QuadMatch[3] | string, |
||||
): LdSet<Type> { |
||||
throw new Error("Not Implemented"); |
||||
}; |
||||
} |
@ -0,0 +1,94 @@ |
||||
import type { |
||||
ConnectedLdoDataset, |
||||
ConnectedPlugin, |
||||
GetResourceReturnType, |
||||
} from "@ldo/connected"; |
||||
import { writable, type Readable } from "svelte/store"; |
||||
|
||||
export interface UseResourceOptions<Name> { |
||||
pluginName?: Name; |
||||
suppressInitialRead?: boolean; |
||||
reloadOnMount?: boolean; |
||||
subscribe?: boolean; |
||||
} |
||||
|
||||
export type useResourceType<Plugins extends ConnectedPlugin[]> = { |
||||
< |
||||
Name extends Plugins[number]["name"], |
||||
Plugin extends Extract<Plugins[number], { name: Name }>, |
||||
UriType extends string, |
||||
>( |
||||
uri: UriType, |
||||
options?: UseResourceOptions<Name>, |
||||
): Readable<GetResourceReturnType<Plugin, UriType>>; |
||||
< |
||||
Name extends Plugins[number]["name"], |
||||
Plugin extends Extract<Plugins[number], { name: Name }>, |
||||
UriType extends string, |
||||
>( |
||||
uri?: UriType, |
||||
options?: UseResourceOptions<Name>, |
||||
): Readable<GetResourceReturnType<Plugin, UriType> | undefined>; |
||||
}; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useResource function. |
||||
*/ |
||||
export function createUseResource<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
): useResourceType<Plugins> { |
||||
/** |
||||
* Returns a resource and triggers a rerender if that resource is updated. |
||||
*/ |
||||
return function useResource< |
||||
Name extends Plugins[number]["name"], |
||||
Plugin extends Extract<Plugins[number], { name: Name }>, |
||||
UriType extends string, |
||||
>( |
||||
uri?: UriType, |
||||
options?: UseResourceOptions<Name>, |
||||
): Readable<GetResourceReturnType<Plugin, UriType> | undefined> { |
||||
let resource: GetResourceReturnType<Plugin, UriType> | undefined; |
||||
// Get the resource based on incoming data
|
||||
if (uri) { |
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
resource = dataset.getResource(uri) as any; |
||||
// Run read operations if necissary
|
||||
if (!options?.suppressInitialRead) { |
||||
if (options?.reloadOnMount) { |
||||
resource!.read(); |
||||
} else { |
||||
resource!.readIfUnfetched(); |
||||
} |
||||
} |
||||
} else { |
||||
resource = undefined; |
||||
} |
||||
|
||||
// The Svelte store
|
||||
const store = writable<GetResourceReturnType<Plugin, UriType> | undefined>( |
||||
resource, |
||||
(set) => { |
||||
const onResourceUpdate = () => { |
||||
set(resource); |
||||
}; |
||||
|
||||
if (resource) { |
||||
resource.on("update", onResourceUpdate); |
||||
|
||||
// TODO: handle subscriptions
|
||||
|
||||
return () => { |
||||
resource.off("update", onResourceUpdate); |
||||
}; |
||||
} |
||||
}, |
||||
); |
||||
|
||||
return { |
||||
subscribe: store.subscribe, |
||||
}; |
||||
}; |
||||
} |
@ -0,0 +1,48 @@ |
||||
import type { SubjectNode } from "@ldo/rdf-utils"; |
||||
import type { ShapeType } from "@ldo/ldo"; |
||||
import type { LdoBuilder } from "@ldo/ldo"; |
||||
import type { LdoBase } from "@ldo/ldo"; |
||||
|
||||
import { useTrackingProxy } from "../util/useTrackingProxy"; |
||||
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected"; |
||||
import type { Readable } from "svelte/store"; |
||||
|
||||
export type useSubjectType = { |
||||
<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject: string | SubjectNode, |
||||
): Readable<Type>; |
||||
<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject?: string | SubjectNode, |
||||
): Readable<Type | undefined>; |
||||
<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject?: string | SubjectNode, |
||||
): Readable<Type | undefined>; |
||||
}; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useSubject function. |
||||
*/ |
||||
export function createUseSubject<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
): useSubjectType { |
||||
/** |
||||
* Returns a Linked Data Object based on the provided subject. Triggers a |
||||
* rerender if the data is udpated. |
||||
*/ |
||||
return function useSubject<Type extends LdoBase>( |
||||
shapeType: ShapeType<Type>, |
||||
subject?: string | SubjectNode, |
||||
): Readable<Type | undefined> { |
||||
const fromSubject = (builder: LdoBuilder<Type>) => { |
||||
if (!subject) return; |
||||
return builder.fromSubject(subject); |
||||
}; |
||||
|
||||
return useTrackingProxy(shapeType, fromSubject, dataset); |
||||
}; |
||||
} |
@ -0,0 +1,17 @@ |
||||
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected"; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* Creates a useSubscribeToResource function. |
||||
*/ |
||||
export function createUseSubscribeToResource<Plugins extends ConnectedPlugin[]>( |
||||
dataset: ConnectedLdoDataset<Plugins>, |
||||
) { |
||||
/** |
||||
* Starts a subscription to a resource. |
||||
*/ |
||||
return function useSubscribeToResource(...uris: string[]): void { |
||||
throw new Error("Not Implemented"); |
||||
}; |
||||
} |
@ -0,0 +1,44 @@ |
||||
import type { LdoBuilder } from "@ldo/ldo"; |
||||
import type { LdoBase, LdoDataset, ShapeType } from "@ldo/ldo"; |
||||
import { createTrackingProxyBuilder } from "@ldo/connected"; |
||||
import { writable, type Readable } from "svelte/store"; |
||||
import type { nodeEventListener } from "@ldo/subscribable-dataset"; |
||||
|
||||
/** |
||||
* @internal |
||||
* |
||||
* A hook for tracking proxies |
||||
*/ |
||||
export function useTrackingProxy<Type extends LdoBase, ReturnType>( |
||||
shapeType: ShapeType<Type>, |
||||
createLdo: (builder: LdoBuilder<Type>) => ReturnType, |
||||
dataset: LdoDataset, |
||||
): Readable<ReturnType> { |
||||
const forceUpdateInfo: { |
||||
set?: (item: ReturnType) => void; |
||||
ldo?: ReturnType; |
||||
} = {}; |
||||
|
||||
const forceUpdate: nodeEventListener = () => { |
||||
dataset.removeListenerFromAllEvents(forceUpdate); |
||||
const builder = createTrackingProxyBuilder(dataset, shapeType, forceUpdate); |
||||
const linkedDataObject = createLdo(builder); |
||||
forceUpdateInfo.ldo = linkedDataObject; |
||||
if (forceUpdateInfo.set && forceUpdateInfo.ldo) |
||||
forceUpdateInfo.set(forceUpdateInfo.ldo); |
||||
}; |
||||
forceUpdate({}, "", [undefined, undefined, undefined, undefined]); |
||||
|
||||
// The Svelte store
|
||||
const store = writable<ReturnType>(forceUpdateInfo.ldo, (set) => { |
||||
forceUpdateInfo.set = set; |
||||
|
||||
return () => { |
||||
dataset.removeListenerFromAllEvents(forceUpdate); |
||||
}; |
||||
}); |
||||
|
||||
return { |
||||
subscribe: store.subscribe, |
||||
}; |
||||
} |
Loading…
Reference in new issue