Skip to content
Open
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 { ObjectMapping } from "rdfjs-wrapper"
import { TermAs, TermFrom } 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, ObjectMapping.as(Policy), ObjectMapping.as(Policy))
return this.objects(ACP.apply, TermAs.instance(Policy), TermFrom.instance)
}
}
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 { ValueMapping, TermMapping, ObjectMapping } from "rdfjs-wrapper"
import { NamedNodeAs, NamedNodeFrom, TermAs, TermFrom } 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, ObjectMapping.as(AccessControl), ObjectMapping.as(AccessControl))
return this.objects(ACP.accessControl, TermAs.instance(AccessControl), TermFrom.instance)
}

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

set resource(v: string) {
this.overwriteNullable(ACP.resource, v, TermMapping.stringToIri)
this.overwriteNullable(ACP.resource, v, NamedNodeFrom.string)
}
}
2 changes: 1 addition & 1 deletion app/lib/class/AcrDataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatasetWrapper } from "rdfjs-wrapper"
import { DatasetWrapper } from "@rdfjs/wrapper"
import { AccessControlResource } from "@/app/lib/class/AccessControlResource";
import { ACP } from "@/app/lib/class/Vocabulary"

Expand Down
40 changes: 20 additions & 20 deletions app/lib/class/Agent.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { TermMapping, ValueMapping, TermWrapper, ObjectMapping } from "rdfjs-wrapper"
import { LiteralAs, NamedNodeAs, NamedNodeFrom, TermAs, TermWrapper } 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, ValueMapping.literalToString)
return this.singularNullable(VCARD.fn, LiteralAs.string)
}

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

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

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

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

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

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

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

get name(): string | null {
return this.vcardFn ?? this.foafName ?? this.term.value.split("/").pop()?.split("#")[0] ?? null
return this.vcardFn ?? this.foafName ?? this.value.split("/").pop()?.split("#")[0] ?? null
}

get storageUrls(): Set<string> {
Expand All @@ -44,44 +44,44 @@ export class Agent extends TermWrapper {
}

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

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

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

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

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

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

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

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

class HasValue extends TermWrapper {
get value(): string {
return this.hasValue ?? this.term.value
get actualValue(): string {
return this.hasValue ?? this.value
}

get hasValue(): string | undefined {
return this.singularNullable(VCARD.hasValue, ValueMapping.iriToString)
return this.singularNullable(VCARD.hasValue, NamedNodeAs.string)
}
}
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 { ObjectMapping } from "rdfjs-wrapper"
import { TermAs, TermFrom } 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, ObjectMapping.as(Resource), ObjectMapping.as(Resource))
return this.objects(LDP.contains, TermAs.instance(Resource), TermFrom.instance)
}
}
2 changes: 1 addition & 1 deletion app/lib/class/ContainerDataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatasetWrapper } from "rdfjs-wrapper"
import { DatasetWrapper } from "@rdfjs/wrapper"
import { Container } from "@/app/lib/class/Container"
import { LDP } from "@/app/lib/class/Vocabulary"

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 { TermMapping, ValueMapping } from "rdfjs-wrapper"
import { NamedNodeAs, NamedNodeFrom } 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, ValueMapping.iriToString, TermMapping.stringToIri)
return this.objects(ACP.agent, NamedNodeAs.string, NamedNodeFrom.string)
}
}
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 { TermMapping, ValueMapping, ObjectMapping } from "rdfjs-wrapper"
import { NamedNodeAs, NamedNodeFrom, TermAs, TermFrom } 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, ValueMapping.iriToString, TermMapping.stringToIri)
return this.objects(ACP.allow, NamedNodeAs.string, NamedNodeFrom.string)
}

get anyOf(): Set<Matcher> {
return this.objects(ACP.anyOf, ObjectMapping.as(Matcher), ObjectMapping.as(Matcher))
return this.objects(ACP.anyOf, TermAs.instance(Matcher), TermFrom.instance)
}
}
16 changes: 8 additions & 8 deletions app/lib/class/Resource.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TermMapping, ValueMapping, TermWrapper } from "rdfjs-wrapper"
import { LiteralAs, NamedNodeAs, NamedNodeFrom, TermWrapper } from "@rdfjs/wrapper"
import { DC, POSIX, RDF, RDFS } from "@/app/lib/class/Vocabulary"
import { extractNameFromUrl, FileType } from "@/app/lib/helpers"

export class Resource extends TermWrapper {
#ianaMediaTypePattern = /^http:\/\/www\.w3\.org\/ns\/iana\/media-types\/(.+)#Resource$/;

get id(): string {
return this.term.value
return this.value
}

get isContainer(): boolean {
Expand All @@ -18,35 +18,35 @@ export class Resource extends TermWrapper {
}

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

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

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

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

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

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

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

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

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 { TermMapping, ValueMapping, TermWrapper } from "rdfjs-wrapper"
import { NamedNodeAs, NamedNodeFrom, 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, ValueMapping.iriToString, TermMapping.stringToIri)
return this.objects(RDF.type, NamedNodeAs.string, NamedNodeFrom.string)
}
}
2 changes: 1 addition & 1 deletion app/lib/class/WebIdDataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatasetWrapper } from "rdfjs-wrapper"
import { DatasetWrapper } from "@rdfjs/wrapper"
import { Agent } from "@/app/lib/class/Agent"
import { SOLID } from "@/app/lib/class/Vocabulary"

Expand Down
Loading