Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/lib/class/AccessControl.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TermWrapper } from "rdfjs-wrapper"
import { ObjectMapping } from "rdfjs-wrapper"
import { Policy } from "@/app/lib/class/Policy"
import { ACP } from "@/app/lib/class/Vocabulary"
import { Typed } from "@/app/lib/class/Typed";

export class AccessControl extends Typed {
get apply(): Set<Policy> {
return this.objects(ACP.apply, TermWrapper.as(Policy), TermWrapper.as(Policy))
return this.objects(ACP.apply, ObjectMapping.as(Policy), ObjectMapping.as(Policy))
}
}
8 changes: 4 additions & 4 deletions app/lib/class/AccessControlResource.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ValueMappings, TermMappings, TermWrapper } from "rdfjs-wrapper"
import { ValueMapping, TermMapping, ObjectMapping } from "rdfjs-wrapper"
import { AccessControl } from "@/app/lib/class/AccessControl"
import { ACP } from "@/app/lib/class/Vocabulary"
import { Typed } from "@/app/lib/class/Typed"

export class AccessControlResource extends Typed {
get accessControl(): Set<AccessControl> {
return this.objects(ACP.accessControl, TermWrapper.as(AccessControl), TermWrapper.as(AccessControl))
return this.objects(ACP.accessControl, ObjectMapping.as(AccessControl), ObjectMapping.as(AccessControl))
}

get resource(): string | undefined {
return this.singularNullable(ACP.resource, ValueMappings.iriToString)
return this.singularNullable(ACP.resource, ValueMapping.iriToString)
}

set resource(v: string) {
this.overwriteNullable(ACP.resource, v, TermMappings.stringToIri)
this.overwriteNullable(ACP.resource, v, TermMapping.stringToIri)
}
}
8 changes: 4 additions & 4 deletions app/lib/class/AcrDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ACP } from "@/app/lib/class/Vocabulary"
export class AcrDataset extends DatasetWrapper {
get acr(): AccessControlResource | undefined {
const subjects = new Set([
...this.instancesOf(AccessControlResource, ACP.AccessControlResource),
...this.subjectsOf(AccessControlResource, ACP.resource),
...this.subjectsOf(AccessControlResource, ACP.accessControl),
...this.subjectsOf(AccessControlResource, ACP.memberAccessControl)
...this.instancesOf(ACP.AccessControlResource, AccessControlResource),
...this.subjectsOf(ACP.resource, AccessControlResource),
...this.subjectsOf(ACP.accessControl, AccessControlResource),
...this.subjectsOf(ACP.memberAccessControl, AccessControlResource)
])

for (const subject of subjects) {
Expand Down
30 changes: 15 additions & 15 deletions app/lib/class/Agent.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { TermMappings, ValueMappings, TermWrapper } from "rdfjs-wrapper"
import { TermMapping, ValueMapping, TermWrapper, ObjectMapping } from "rdfjs-wrapper"
import { FOAF, PIM, SOLID, VCARD } from "@/app/lib/class/Vocabulary"

export class Agent extends TermWrapper {
get vcardFn(): string | undefined {
return this.singularNullable(VCARD.fn, ValueMappings.literalToString)
return this.singularNullable(VCARD.fn, ValueMapping.literalToString)
}

get vcardHasUrl(): string | undefined {
return this.singularNullable(VCARD.hasUrl, ValueMappings.iriToString)
return this.singularNullable(VCARD.hasUrl, ValueMapping.iriToString)
}

get organization(): string | null {
return this.singularNullable(VCARD.organizationName, ValueMappings.iriToString) ?? null
return this.singularNullable(VCARD.organizationName, ValueMapping.iriToString) ?? null
}

get role(): string | null {
return this.singularNullable(VCARD.role, ValueMappings.iriToString) ?? null
return this.singularNullable(VCARD.role, ValueMapping.iriToString) ?? null
}

get title(): string | null {
return this.singularNullable(VCARD.title, ValueMappings.literalToString) ?? null
return this.singularNullable(VCARD.title, ValueMapping.literalToString) ?? null
}

get phone(): string | null {
return this.hasTelephone?.value ?? null
}

get hasTelephone(): HasValue | undefined {
return this.singularNullable(VCARD.hasTelephone, TermWrapper.as(HasValue))
return this.singularNullable(VCARD.hasTelephone, ObjectMapping.as(HasValue))
}

get foafName(): string | undefined {
return this.singularNullable(FOAF.fname, ValueMappings.literalToString)
return this.singularNullable(FOAF.fname, ValueMapping.literalToString)
}

get name(): string | null {
Expand All @@ -44,35 +44,35 @@ export class Agent extends TermWrapper {
}

get foafHomepage(): string | undefined {
return this.singularNullable(FOAF.homepage, ValueMappings.literalToString)
return this.singularNullable(FOAF.homepage, ValueMapping.literalToString)
}

get website(): string | null {
return this.vcardHasUrl ?? this.foafHomepage ?? null
}

get photoUrl(): string | null {
return this.singularNullable(VCARD.hasPhoto, ValueMappings.literalToString) ?? null
return this.singularNullable(VCARD.hasPhoto, ValueMapping.literalToString) ?? null
}

get pimStorage(): Set<string> {
return this.objects(PIM.storage, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(PIM.storage, ValueMapping.iriToString, TermMapping.stringToIri)
}

get solidStorage(): Set<string> {
return this.objects(SOLID.storage, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(SOLID.storage, ValueMapping.iriToString, TermMapping.stringToIri)
}

get email(): string | null {
return this.hasEmail?.value ?? null
}

get hasEmail(): HasValue | undefined {
return this.singularNullable(VCARD.hasEmail, TermWrapper.as(HasValue))
return this.singularNullable(VCARD.hasEmail, ObjectMapping.as(HasValue))
}

get knows(): Set<string> {
return this.objects(FOAF.knows, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(FOAF.knows, ValueMapping.iriToString, TermMapping.stringToIri)
}
}

Expand All @@ -82,6 +82,6 @@ class HasValue extends TermWrapper {
}

get hasValue(): string | undefined {
return this.singularNullable(VCARD.hasValue, ValueMappings.iriToString)
return this.singularNullable(VCARD.hasValue, ValueMapping.iriToString)
}
}
4 changes: 2 additions & 2 deletions app/lib/class/Container.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TermWrapper } from "rdfjs-wrapper"
import { ObjectMapping } from "rdfjs-wrapper"
import { Resource } from "@/app/lib/class/Resource"
import { LDP } from "@/app/lib/class/Vocabulary"

export class Container extends Resource {
public get contains(): Set<Resource> {
return this.objects(LDP.contains, TermWrapper.as(Resource), TermWrapper.as(Resource))
return this.objects(LDP.contains, ObjectMapping.as(Resource), ObjectMapping.as(Resource))
}
}
2 changes: 1 addition & 1 deletion app/lib/class/ContainerDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class ContainerDataset extends DatasetWrapper {
// TODO: Consider that this might be undefined if there are no contained resources. We might need different matching.
get container(): Container | undefined {
// Return the first container in the dataset
for (const s of this.subjectsOf(Container, LDP.contains)) {
for (const s of this.subjectsOf(LDP.contains, Container)) {
return s;
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/lib/class/Matcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TermMappings, ValueMappings } from "rdfjs-wrapper"
import { TermMapping, ValueMapping } from "rdfjs-wrapper"
import { ACP } from "@/app/lib/class/Vocabulary"
import { Typed } from "@/app/lib/class/Typed"

export class Matcher extends Typed {
get agent(): Set<string> {
return this.objects(ACP.agent, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(ACP.agent, ValueMapping.iriToString, TermMapping.stringToIri)
}
}
6 changes: 3 additions & 3 deletions app/lib/class/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { TermMappings, ValueMappings, TermWrapper } from "rdfjs-wrapper"
import { TermMapping, ValueMapping, ObjectMapping } from "rdfjs-wrapper"
import { Matcher } from "@/app/lib/class/Matcher"
import { ACP } from "@/app/lib/class/Vocabulary"
import { Typed } from "@/app/lib/class/Typed"

export class Policy extends Typed {
get allow(): Set<string> {
return this.objects(ACP.allow, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(ACP.allow, ValueMapping.iriToString, TermMapping.stringToIri)
}

get anyOf(): Set<Matcher> {
return this.objects(ACP.anyOf, TermWrapper.as(Matcher), TermWrapper.as(Matcher))
return this.objects(ACP.anyOf, ObjectMapping.as(Matcher), ObjectMapping.as(Matcher))
}
}
14 changes: 7 additions & 7 deletions app/lib/class/Resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TermMappings, ValueMappings, TermWrapper } from "rdfjs-wrapper"
import { TermMapping, ValueMapping, TermWrapper } from "rdfjs-wrapper"
import { DC, POSIX, RDF, RDFS } from "@/app/lib/class/Vocabulary"
import { extractNameFromUrl, FileType } from "@/app/lib/helpers"

Expand All @@ -18,35 +18,35 @@ export class Resource extends TermWrapper {
}

get title(): string | undefined {
return this.singularNullable(DC.title, ValueMappings.literalToString)
return this.singularNullable(DC.title, ValueMapping.literalToString)
}

get label(): string | undefined {
return this.singularNullable(RDFS.label, ValueMappings.literalToString)
return this.singularNullable(RDFS.label, ValueMapping.literalToString)
}

get name(): string {
return this.title ?? this.label ?? extractNameFromUrl(this.id)
}

get modified(): Date | undefined {
return this.singularNullable(DC.modified, ValueMappings.literalToDate)
return this.singularNullable(DC.modified, ValueMapping.literalToDate)
}

get mtime(): Date | undefined {
return this.singularNullable(POSIX.mtime, ValueMappings.literalToDate)
return this.singularNullable(POSIX.mtime, ValueMapping.literalToDate)
}

get lastModified(): Date | undefined {
return this.modified ?? this.mtime
}

get size(): number | undefined {
return this.singularNullable(POSIX.size, ValueMappings.literalToNumber)
return this.singularNullable(POSIX.size, ValueMapping.literalToNumber)
}

get type(): Set<string> {
return this.objects(RDF.type, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(RDF.type, ValueMapping.iriToString, TermMapping.stringToIri)
}

get mimeType(): string | undefined {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/class/Typed.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TermMappings, ValueMappings, TermWrapper } from "rdfjs-wrapper"
import { TermMapping, ValueMapping, TermWrapper } from "rdfjs-wrapper"
import { RDF } from "@/app/lib/class/Vocabulary"

export class Typed extends TermWrapper {
get type(): Set<string> {
return this.objects(RDF.type, ValueMappings.iriToString, TermMappings.stringToIri)
return this.objects(RDF.type, ValueMapping.iriToString, TermMapping.stringToIri)
}
}
116 changes: 57 additions & 59 deletions app/lib/class/Vocabulary.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,66 @@
import { DataFactory } from "n3"
export const ACP = {
resource: "http://www.w3.org/ns/solid/acp#resource",
accessControl: "http://www.w3.org/ns/solid/acp#accessControl",
memberAccessControl: "http://www.w3.org/ns/solid/acp#memberAccessControl",
AccessControlResource: "http://www.w3.org/ns/solid/acp#AccessControlResource",
apply: "http://www.w3.org/ns/solid/acp#apply",
anyOf: "http://www.w3.org/ns/solid/acp#anyOf",
agent: "http://www.w3.org/ns/solid/acp#agent",
Matcher: "http://www.w3.org/ns/solid/acp#Matcher",
Policy: "http://www.w3.org/ns/solid/acp#Policy",
allow: "http://www.w3.org/ns/solid/acp#allow",
mode: "http://www.w3.org/ns/solid/acp#mode",
AccessControl: "http://www.w3.org/ns/solid/acp#AccessControl",
} as const

export class ACP {
static resource = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#resource")
static accessControl = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#accessControl")
static memberAccessControl = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#memberAccessControl")
static AccessControlResource = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#AccessControlResource")
static apply = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#apply")
static anyOf = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#anyOf")
static agent = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#agent")
static Matcher = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#Matcher")
static Policy = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#Policy")
static allow = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#allow")
static mode = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#mode")
static AccessControl = DataFactory.namedNode("http://www.w3.org/ns/solid/acp#AccessControl")
}
export const DC = {
modified: "http://purl.org/dc/terms/modified",
title: "http://purl.org/dc/terms/title",
} as const

export class DC {
static modified = DataFactory.namedNode("http://purl.org/dc/terms/modified")
static title = DataFactory.namedNode("http://purl.org/dc/terms/title")
}
export const FOAF = {
isPrimaryTopicOf: "http://xmlns.com/foaf/0.1/isPrimaryTopicOf",
primaryTopic: "http://xmlns.com/foaf/0.1/primaryTopic",
fname: "http://xmlns.com/foaf/0.1/name",
email: "http://xmlns.com/foaf/0.1/email",
homepage: "http://xmlns.com/foaf/0.1/homepage",
knows: "http://xmlns.com/foaf/0.1/knows",
} as const

export class FOAF {
static isPrimaryTopicOf = DataFactory.namedNode("http://xmlns.com/foaf/0.1/isPrimaryTopicOf")
static primaryTopic = DataFactory.namedNode("http://xmlns.com/foaf/0.1/primaryTopic")
static fname = DataFactory.namedNode("http://xmlns.com/foaf/0.1/name")
static email = DataFactory.namedNode("http://xmlns.com/foaf/0.1/email")
static homepage = DataFactory.namedNode("http://xmlns.com/foaf/0.1/homepage")
static knows = DataFactory.namedNode("http://xmlns.com/foaf/0.1/knows")
}
export const LDP = {
contains: "http://www.w3.org/ns/ldp#contains",
} as const

export class LDP {
static contains = DataFactory.namedNode("http://www.w3.org/ns/ldp#contains")
}
export const PIM = {
storage: "http://www.w3.org/ns/pim/space#storage",
} as const

export class PIM {
static storage = DataFactory.namedNode("http://www.w3.org/ns/pim/space#storage")
}
export const POSIX = {
size: "http://www.w3.org/ns/posix/stat#size",
mtime: "http://www.w3.org/ns/posix/stat#mtime",
} as const

export class POSIX {
static size = DataFactory.namedNode("http://www.w3.org/ns/posix/stat#size")
static mtime = DataFactory.namedNode("http://www.w3.org/ns/posix/stat#mtime")
}
export const RDF = {
type: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
} as const

export class RDF {
static type = DataFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
}
export const RDFS = {
label: "http://www.w3.org/2000/01/rdf-schema#label",
} as const

export class RDFS {
static label = DataFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#label")
}
export const SOLID = {
oidcIssuer: "http://www.w3.org/ns/solid/terms#oidcIssuer",
storage: "http://www.w3.org/ns/solid/terms#storage",
} as const

export class SOLID {
static oidcIssuer = DataFactory.namedNode("http://www.w3.org/ns/solid/terms#oidcIssuer")
static storage = DataFactory.namedNode("http://www.w3.org/ns/solid/terms#storage")
}

export class VCARD {
static fn = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#fn")
static hasEmail = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#hasEmail")
static hasValue = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#hasValue")
static hasPhoto = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#hasPhoto")
static hasTelephone = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#hasTelephone")
static title = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#title")
static hasUrl = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#hasUrl")
static organizationName = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#organization-name")
static role = DataFactory.namedNode("http://www.w3.org/2006/vcard/ns#organization-name")
}
export const VCARD = {
fn: "http://www.w3.org/2006/vcard/ns#fn",
hasEmail: "http://www.w3.org/2006/vcard/ns#hasEmail",
hasValue: "http://www.w3.org/2006/vcard/ns#hasValue",
hasPhoto: "http://www.w3.org/2006/vcard/ns#hasPhoto",
hasTelephone: "http://www.w3.org/2006/vcard/ns#hasTelephone",
title: "http://www.w3.org/2006/vcard/ns#title",
hasUrl: "http://www.w3.org/2006/vcard/ns#hasUrl",
organizationName: "http://www.w3.org/2006/vcard/ns#organization-name",
role: "http://www.w3.org/2006/vcard/ns#organization-name",
} as const
4 changes: 2 additions & 2 deletions app/lib/class/WebIdDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { DatasetWrapper } from "rdfjs-wrapper"
import { Agent } from "@/app/lib/class/Agent"
import { SOLID } from "@/app/lib/class/Vocabulary"

export class WebIdDataset extends DatasetWrapper{
export class WebIdDataset extends DatasetWrapper {
get mainSubject(): Agent | undefined {
// TODO: Fix with FOAF: Primary topic either via Inrupt or spec because this does not work with Inrupt WebID
// TODO: do the isPrimaryTopicOf route and the primaryTopic (maybe)
// Or not because all WebIDs will have an issuer (otherwise also needs to restrict to the document URL as subject or object to realise the benefit)
for (const s of this.subjectsOf(Agent, SOLID.oidcIssuer)) {
for (const s of this.subjectsOf(SOLID.oidcIssuer, Agent)) {
return s;
}
}
Expand Down
Loading