import { getStringNoLocale, getUrl, getDatetime, type Thing } from '@inrupt/solid-client'; import { SCHEMA_INRUPT } from '@inrupt/vocab-common-rdf'; const SCHEMA_CUSTOM = { // Types ScheduleAction: 'http://schema.org/ScheduleAction', // Properties scheduledTime: 'http://schema.org/scheduledTime', actionStatus: 'http://schema.org/actionStatus', // Enumeration types ActionStatusType: { active: 'http://schema.org/ActiveActionStatus', done: 'http://schema.org/CompletedActionStatus' } }; export class Task { type = SCHEMA_CUSTOM.ScheduleAction; done: boolean; name: string | null; datetime: Date | null; constructor(taskInput: Thing) { this.name = getStringNoLocale(taskInput, SCHEMA_INRUPT.name); this.done = getUrl(taskInput, SCHEMA_CUSTOM.actionStatus) === SCHEMA_CUSTOM.ActionStatusType.done; this.datetime = getDatetime(taskInput, SCHEMA_CUSTOM.scheduledTime); } serialize() { // TODO could be improved return JSON.parse(JSON.stringify(this)); } }