Initial commit
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* Class model for Collection Interface
|
||||
*/
|
||||
import type {
|
||||
CollectionInterface,
|
||||
CollectionContentsInterface,
|
||||
CollectionPermissionsInterface,
|
||||
} from "@/types/collection";
|
||||
|
||||
export class CollectionObject implements CollectionInterface {
|
||||
|
||||
_data!: CollectionInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'chrono:collection',
|
||||
provider: null,
|
||||
service: null,
|
||||
in: null,
|
||||
id: null,
|
||||
label: null,
|
||||
description: null,
|
||||
priority: null,
|
||||
visibility: null,
|
||||
color: null,
|
||||
enabled: true,
|
||||
signature: null,
|
||||
permissions: {},
|
||||
contents: {},
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: CollectionInterface): CollectionObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): CollectionInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): CollectionObject {
|
||||
const cloned = new CollectionObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get '@type'(): string {
|
||||
return this._data['@type'];
|
||||
}
|
||||
|
||||
get provider(): string | null {
|
||||
return this._data.provider;
|
||||
}
|
||||
|
||||
set provider(value: string | null) {
|
||||
this._data.provider = value;
|
||||
}
|
||||
|
||||
get service(): string | null {
|
||||
return this._data.service;
|
||||
}
|
||||
|
||||
set service(value: string | null) {
|
||||
this._data.service = value;
|
||||
}
|
||||
|
||||
get in(): number | string | null {
|
||||
return this._data.in;
|
||||
}
|
||||
|
||||
set in(value: number | string | null) {
|
||||
this._data.in = value;
|
||||
}
|
||||
|
||||
get id(): number | string | null {
|
||||
return this._data.id;
|
||||
}
|
||||
|
||||
set id(value: number | string | null) {
|
||||
this._data.id = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get priority(): number | null {
|
||||
return this._data.priority;
|
||||
}
|
||||
|
||||
set priority(value: number | null) {
|
||||
this._data.priority = value;
|
||||
}
|
||||
|
||||
get visibility(): string | null {
|
||||
return this._data.visibility;
|
||||
}
|
||||
|
||||
set visibility(value: string | null) {
|
||||
this._data.visibility = value;
|
||||
}
|
||||
|
||||
get color(): string | null {
|
||||
return this._data.color;
|
||||
}
|
||||
|
||||
set color(value: string | null) {
|
||||
this._data.color = value;
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
return this._data.enabled;
|
||||
}
|
||||
|
||||
set enabled(value: boolean) {
|
||||
this._data.enabled = value;
|
||||
}
|
||||
|
||||
get signature(): string | null {
|
||||
return this._data.signature;
|
||||
}
|
||||
|
||||
set signature(value: string | null) {
|
||||
this._data.signature = value;
|
||||
}
|
||||
|
||||
get permissions(): CollectionPermissionsInterface {
|
||||
return this._data.permissions;
|
||||
}
|
||||
|
||||
set permissions(value: CollectionPermissionsInterface) {
|
||||
this._data.permissions = value;
|
||||
}
|
||||
|
||||
get contents(): CollectionContentsInterface {
|
||||
return this._data.contents;
|
||||
}
|
||||
|
||||
set contents(value: CollectionContentsInterface) {
|
||||
this._data.contents = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Class model for Entity Interface
|
||||
*/
|
||||
import type { EntityInterface } from "@/types/entity";
|
||||
import type { EventInterface } from "@/types/event";
|
||||
import type { TaskInterface } from "@/types/task";
|
||||
import type { JournalInterface } from "@/types/journal";
|
||||
import { EventObject } from "./event";
|
||||
import { TaskObject } from "./task";
|
||||
import { JournalObject } from "./journal";
|
||||
|
||||
export class EntityObject implements EntityInterface {
|
||||
|
||||
_data!: EntityInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'chrono:entity',
|
||||
version: 1,
|
||||
in: null,
|
||||
id: null,
|
||||
createdOn: null,
|
||||
createdBy: null,
|
||||
modifiedOn: null,
|
||||
modifiedBy: null,
|
||||
signature: null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EntityInterface): EntityObject {
|
||||
this._data = data;
|
||||
if (data.data) {
|
||||
const type = data.data.type;
|
||||
if (type === 'task') {
|
||||
this._data.data = new TaskObject().fromJson(data.data as TaskInterface);
|
||||
} else if (type === 'journal') {
|
||||
this._data.data = new JournalObject().fromJson(data.data as JournalInterface);
|
||||
} else {
|
||||
this._data.data = new EventObject().fromJson(data.data as EventInterface);
|
||||
}
|
||||
} else {
|
||||
this._data.data = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EntityInterface {
|
||||
const json = { ...this._data };
|
||||
if (this._data.data instanceof EventObject ||
|
||||
this._data.data instanceof TaskObject ||
|
||||
this._data.data instanceof JournalObject) {
|
||||
json.data = this._data.data.toJson();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
clone(): EntityObject {
|
||||
const cloned = new EntityObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get '@type'(): string {
|
||||
return this._data['@type'];
|
||||
}
|
||||
|
||||
get version(): number {
|
||||
return this._data.version;
|
||||
}
|
||||
|
||||
set version(value: number) {
|
||||
this._data.version = value;
|
||||
}
|
||||
|
||||
get in(): string | number | null {
|
||||
return this._data.in;
|
||||
}
|
||||
|
||||
set in(value: string | number | null) {
|
||||
this._data.in = value;
|
||||
}
|
||||
|
||||
get id(): string | number | null {
|
||||
return this._data.id;
|
||||
}
|
||||
|
||||
set id(value: string | number | null) {
|
||||
this._data.id = value;
|
||||
}
|
||||
|
||||
get createdOn(): Date | null {
|
||||
return this._data.createdOn;
|
||||
}
|
||||
|
||||
set createdOn(value: Date | null) {
|
||||
this._data.createdOn = value;
|
||||
}
|
||||
|
||||
get createdBy(): string | null {
|
||||
return this._data.createdBy;
|
||||
}
|
||||
|
||||
set createdBy(value: string | null) {
|
||||
this._data.createdBy = value;
|
||||
}
|
||||
|
||||
get modifiedOn(): Date | null {
|
||||
return this._data.modifiedOn;
|
||||
}
|
||||
|
||||
set modifiedOn(value: Date | null) {
|
||||
this._data.modifiedOn = value;
|
||||
}
|
||||
|
||||
get modifiedBy(): string | null {
|
||||
return this._data.modifiedBy;
|
||||
}
|
||||
|
||||
set modifiedBy(value: string | null) {
|
||||
this._data.modifiedBy = value;
|
||||
}
|
||||
|
||||
get signature(): string | null {
|
||||
return this._data.signature;
|
||||
}
|
||||
|
||||
set signature(value: string | null) {
|
||||
this._data.signature = value;
|
||||
}
|
||||
|
||||
get data(): EventObject | TaskObject | JournalObject | null {
|
||||
if (this._data.data instanceof EventObject ||
|
||||
this._data.data instanceof TaskObject ||
|
||||
this._data.data instanceof JournalObject) {
|
||||
return this._data.data;
|
||||
}
|
||||
|
||||
if (this._data.data) {
|
||||
const type = this._data.data.type;
|
||||
let hydrated;
|
||||
if (type === 'task') {
|
||||
hydrated = new TaskObject().fromJson(this._data.data as TaskInterface);
|
||||
} else if (type === 'journal') {
|
||||
hydrated = new JournalObject().fromJson(this._data.data as JournalInterface);
|
||||
} else {
|
||||
hydrated = new EventObject().fromJson(this._data.data as EventInterface);
|
||||
}
|
||||
this._data.data = hydrated;
|
||||
return hydrated;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
set data(value: EventObject | TaskObject | JournalObject | null) {
|
||||
this._data.data = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Class model for Event Physical Location Interface
|
||||
*/
|
||||
import type { EventLocationPhysicalInterface } from "@/types/event";
|
||||
|
||||
export class EventLocationPhysicalObject implements EventLocationPhysicalInterface {
|
||||
|
||||
_data!: EventLocationPhysicalInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
identifier: null
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventLocationPhysicalInterface): EventLocationPhysicalObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventLocationPhysicalInterface {
|
||||
const result: Partial<EventLocationPhysicalInterface> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventLocationPhysicalInterface];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventLocationPhysicalInterface;
|
||||
}
|
||||
|
||||
clone(): EventLocationPhysicalObject {
|
||||
const cloned = new EventLocationPhysicalObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get identifier(): string | null {
|
||||
return this._data.identifier;
|
||||
}
|
||||
|
||||
set identifier(value: string | null) {
|
||||
this._data.identifier = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label ?? null;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description ?? null;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get relation(): 'start' | 'end' | null {
|
||||
return this._data.relation ?? null;
|
||||
}
|
||||
|
||||
set relation(value: 'start' | 'end' | null) {
|
||||
this._data.relation = value;
|
||||
}
|
||||
|
||||
get timeZone(): string | null {
|
||||
return this._data.timeZone ?? null;
|
||||
}
|
||||
|
||||
set timeZone(value: string | null) {
|
||||
this._data.timeZone = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Class model for Event Virtual Location Interface
|
||||
*/
|
||||
import type { EventLocationVirtualInterface } from "@/types/event";
|
||||
|
||||
export class EventLocationVirtualObject implements EventLocationVirtualInterface {
|
||||
|
||||
_data!: EventLocationVirtualInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
identifier: null,
|
||||
location: ''
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventLocationVirtualInterface): EventLocationVirtualObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventLocationVirtualInterface {
|
||||
const result: Partial<EventLocationVirtualInterface> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventLocationVirtualInterface];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventLocationVirtualInterface;
|
||||
}
|
||||
|
||||
clone(): EventLocationVirtualObject {
|
||||
const cloned = new EventLocationVirtualObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get identifier(): string | null {
|
||||
return this._data.identifier;
|
||||
}
|
||||
|
||||
set identifier(value: string | null) {
|
||||
this._data.identifier = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label ?? null;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description ?? null;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get relation(): string | null {
|
||||
return this._data.relation ?? null;
|
||||
}
|
||||
|
||||
set relation(value: string | null) {
|
||||
this._data.relation = value;
|
||||
}
|
||||
|
||||
get location(): string {
|
||||
return this._data.location;
|
||||
}
|
||||
|
||||
set location(value: string) {
|
||||
this._data.location = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
/**
|
||||
* Class model for Event Mutation Interface
|
||||
*/
|
||||
import type {
|
||||
EventMutation,
|
||||
EventLocationPhysicalInterface,
|
||||
EventLocationVirtualInterface,
|
||||
EventOrganizerInterface,
|
||||
EventParticipantInterface,
|
||||
EventNotificationInterface
|
||||
} from "@/types/event";
|
||||
import { EventLocationPhysicalObject } from "./event-location-physical";
|
||||
import { EventLocationVirtualObject } from "./event-location-virtual";
|
||||
import { EventOrganizerObject } from "./event-organizer";
|
||||
import { EventParticipantObject } from "./event-participant";
|
||||
import { EventNotificationObject } from "./event-notification";
|
||||
import { generateKey } from "../utils/key-generator";
|
||||
|
||||
export class EventMutationObject implements EventMutation {
|
||||
|
||||
_data!: EventMutation;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
mutationId: null,
|
||||
mutationTz: null,
|
||||
mutationExclusion: null,
|
||||
sequence: null,
|
||||
timeZone: null,
|
||||
startsOn: null,
|
||||
startsTZ: null,
|
||||
endsOn: null,
|
||||
endsTZ: null,
|
||||
duration: null,
|
||||
timeless: null,
|
||||
label: null,
|
||||
description: null,
|
||||
locationsPhysical: {},
|
||||
locationsVirtual: {},
|
||||
availability: null,
|
||||
priority: null,
|
||||
sensitivity: null,
|
||||
color: null,
|
||||
tags: [],
|
||||
organizer: {
|
||||
realm: 'E',
|
||||
address: ''
|
||||
},
|
||||
participants: {},
|
||||
notifications: {}
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventMutation): EventMutationObject {
|
||||
this._data = JSON.parse(JSON.stringify(data));
|
||||
|
||||
// Convert organizer to object instance
|
||||
if (this._data.organizer) {
|
||||
this._data.organizer = new EventOrganizerObject().fromJson(this._data.organizer) as any;
|
||||
}
|
||||
|
||||
// Convert locations physical to object instances
|
||||
for (const key in this._data.locationsPhysical) {
|
||||
const loc = this._data.locationsPhysical[key];
|
||||
if (loc) {
|
||||
this._data.locationsPhysical[key] = new EventLocationPhysicalObject().fromJson(loc) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert locations virtual to object instances
|
||||
for (const key in this._data.locationsVirtual) {
|
||||
const loc = this._data.locationsVirtual[key];
|
||||
if (loc) {
|
||||
this._data.locationsVirtual[key] = new EventLocationVirtualObject().fromJson(loc) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert participants to object instances
|
||||
for (const key in this._data.participants) {
|
||||
const participant = this._data.participants[key];
|
||||
if (participant) {
|
||||
this._data.participants[key] = new EventParticipantObject().fromJson(participant) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert notifications to object instances
|
||||
for (const key in this._data.notifications) {
|
||||
const notification = this._data.notifications[key];
|
||||
if (notification) {
|
||||
this._data.notifications[key] = new EventNotificationObject().fromJson(notification) as any;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventMutation {
|
||||
return JSON.parse(JSON.stringify(this._data));
|
||||
}
|
||||
|
||||
clone(): EventMutationObject {
|
||||
const cloned = new EventMutationObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get mutationId(): string | null {
|
||||
return this._data.mutationId;
|
||||
}
|
||||
|
||||
set mutationId(value: string | null) {
|
||||
this._data.mutationId = value;
|
||||
}
|
||||
|
||||
get mutationTz(): string | null {
|
||||
return this._data.mutationTz;
|
||||
}
|
||||
|
||||
set mutationTz(value: string | null) {
|
||||
this._data.mutationTz = value;
|
||||
}
|
||||
|
||||
get mutationExclusion(): boolean | null {
|
||||
return this._data.mutationExclusion;
|
||||
}
|
||||
|
||||
set mutationExclusion(value: boolean | null) {
|
||||
this._data.mutationExclusion = value;
|
||||
}
|
||||
|
||||
get sequence(): number | null {
|
||||
return this._data.sequence;
|
||||
}
|
||||
|
||||
set sequence(value: number | null) {
|
||||
this._data.sequence = value;
|
||||
}
|
||||
|
||||
get timeZone(): string | null {
|
||||
return this._data.timeZone;
|
||||
}
|
||||
|
||||
set timeZone(value: string | null) {
|
||||
this._data.timeZone = value;
|
||||
}
|
||||
|
||||
get startsOn(): string | null {
|
||||
return this._data.startsOn;
|
||||
}
|
||||
|
||||
set startsOn(value: string | null) {
|
||||
this._data.startsOn = value;
|
||||
}
|
||||
|
||||
get startsTZ(): string | null {
|
||||
return this._data.startsTZ;
|
||||
}
|
||||
|
||||
set startsTZ(value: string | null) {
|
||||
this._data.startsTZ = value;
|
||||
}
|
||||
|
||||
get endsOn(): string | null {
|
||||
return this._data.endsOn;
|
||||
}
|
||||
|
||||
set endsOn(value: string | null) {
|
||||
this._data.endsOn = value;
|
||||
}
|
||||
|
||||
get endsTZ(): string | null {
|
||||
return this._data.endsTZ;
|
||||
}
|
||||
|
||||
set endsTZ(value: string | null) {
|
||||
this._data.endsTZ = value;
|
||||
}
|
||||
|
||||
get duration(): string | null {
|
||||
return this._data.duration;
|
||||
}
|
||||
|
||||
set duration(value: string | null) {
|
||||
this._data.duration = value;
|
||||
}
|
||||
|
||||
get timeless(): boolean | null {
|
||||
return this._data.timeless;
|
||||
}
|
||||
|
||||
set timeless(value: boolean | null) {
|
||||
this._data.timeless = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get locationsPhysical(): Record<string, EventLocationPhysicalObject> {
|
||||
return this._data.locationsPhysical as any;
|
||||
}
|
||||
|
||||
set locationsPhysical(value: Record<string, EventLocationPhysicalInterface|EventLocationPhysicalObject>) {
|
||||
this._data.locationsPhysical = {} as any;
|
||||
for (const key in value) {
|
||||
const loc = value[key];
|
||||
if (loc) {
|
||||
if (loc instanceof EventLocationPhysicalObject) {
|
||||
(this._data.locationsPhysical as any)[key] = loc;
|
||||
} else {
|
||||
(this._data.locationsPhysical as any)[key] = new EventLocationPhysicalObject().fromJson(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLocationPhysical(value?: EventLocationPhysicalInterface|EventLocationPhysicalObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let location: EventLocationPhysicalObject;
|
||||
|
||||
if (!value) {
|
||||
location = new EventLocationPhysicalObject();
|
||||
location.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventLocationPhysicalObject) {
|
||||
location = value;
|
||||
location.identifier = key;
|
||||
}
|
||||
else {
|
||||
location = new EventLocationPhysicalObject().fromJson(value);
|
||||
location.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.locationsPhysical as any)[key] = location;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeLocationPhysical(key: string): void {
|
||||
delete this._data.locationsPhysical[key];
|
||||
}
|
||||
|
||||
getLocationPhysical(key: string): EventLocationPhysicalObject | undefined {
|
||||
return this._data.locationsPhysical[key] as any;
|
||||
}
|
||||
|
||||
get locationsVirtual(): Record<string, EventLocationVirtualObject> {
|
||||
return this._data.locationsVirtual as any;
|
||||
}
|
||||
|
||||
set locationsVirtual(value: Record<string, EventLocationVirtualInterface|EventLocationVirtualObject>) {
|
||||
this._data.locationsVirtual = {} as any;
|
||||
for (const key in value) {
|
||||
const loc = value[key];
|
||||
if (loc) {
|
||||
if (loc instanceof EventLocationVirtualObject) {
|
||||
(this._data.locationsVirtual as any)[key] = loc;
|
||||
} else {
|
||||
(this._data.locationsVirtual as any)[key] = new EventLocationVirtualObject().fromJson(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLocationVirtual(value?: EventLocationVirtualInterface|EventLocationVirtualObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let location: EventLocationVirtualObject;
|
||||
|
||||
if (!value) {
|
||||
location = new EventLocationVirtualObject();
|
||||
location.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventLocationVirtualObject) {
|
||||
location = value;
|
||||
location.identifier = key;
|
||||
}
|
||||
else {
|
||||
location = new EventLocationVirtualObject().fromJson(value);
|
||||
location.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.locationsVirtual as any)[key] = location;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeLocationVirtual(key: string): void {
|
||||
delete this._data.locationsVirtual[key];
|
||||
}
|
||||
|
||||
getLocationVirtual(key: string): EventLocationVirtualObject | undefined {
|
||||
return this._data.locationsVirtual[key] as any;
|
||||
}
|
||||
|
||||
get availability(): 'free' | 'busy' | null {
|
||||
return this._data.availability;
|
||||
}
|
||||
|
||||
set availability(value: 'free' | 'busy' | null) {
|
||||
this._data.availability = value;
|
||||
}
|
||||
|
||||
get priority(): number | null {
|
||||
return this._data.priority;
|
||||
}
|
||||
|
||||
set priority(value: number | null) {
|
||||
this._data.priority = value;
|
||||
}
|
||||
|
||||
get sensitivity(): 'public' | 'private' | 'secret' | null {
|
||||
return this._data.sensitivity;
|
||||
}
|
||||
|
||||
set sensitivity(value: 'public' | 'private' | 'secret' | null) {
|
||||
this._data.sensitivity = value;
|
||||
}
|
||||
|
||||
get color(): string | null {
|
||||
return this._data.color;
|
||||
}
|
||||
|
||||
set color(value: string | null) {
|
||||
this._data.color = value;
|
||||
}
|
||||
|
||||
get tags(): string[] {
|
||||
return this._data.tags;
|
||||
}
|
||||
|
||||
set tags(value: string[]) {
|
||||
this._data.tags = value;
|
||||
}
|
||||
|
||||
addTag(tag: string): void {
|
||||
if (!this._data.tags.includes(tag)) {
|
||||
this._data.tags.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
removeTag(tag: string): void {
|
||||
const index = this._data.tags.indexOf(tag);
|
||||
if (index > -1) {
|
||||
this._data.tags.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get organizer(): EventOrganizerObject | null {
|
||||
return this._data.organizer as any;
|
||||
}
|
||||
|
||||
set organizer(value: EventOrganizerInterface|EventOrganizerObject|null) {
|
||||
if (!value) {
|
||||
this._data.organizer = null;
|
||||
} else if (value instanceof EventOrganizerObject) {
|
||||
this._data.organizer = value as any;
|
||||
} else {
|
||||
this._data.organizer = new EventOrganizerObject().fromJson(value) as any;
|
||||
}
|
||||
}
|
||||
|
||||
get participants(): Record<string, EventParticipantObject> {
|
||||
return this._data.participants as any;
|
||||
}
|
||||
|
||||
set participants(value: Record<string, EventParticipantInterface|EventParticipantObject>) {
|
||||
this._data.participants = {} as any;
|
||||
for (const key in value) {
|
||||
const participant = value[key];
|
||||
if (participant) {
|
||||
if (participant instanceof EventParticipantObject) {
|
||||
(this._data.participants as any)[key] = participant;
|
||||
} else {
|
||||
(this._data.participants as any)[key] = new EventParticipantObject().fromJson(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addParticipant(value?: EventParticipantInterface|EventParticipantObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let participant: EventParticipantObject;
|
||||
|
||||
if (!value) {
|
||||
participant = new EventParticipantObject();
|
||||
participant.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventParticipantObject) {
|
||||
participant = value;
|
||||
participant.identifier = key;
|
||||
}
|
||||
else {
|
||||
participant = new EventParticipantObject().fromJson(value);
|
||||
participant.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.participants as any)[key] = participant;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeParticipant(key: string): void {
|
||||
delete this._data.participants[key];
|
||||
}
|
||||
|
||||
getParticipant(key: string): EventParticipantObject | undefined {
|
||||
return this._data.participants[key] as any;
|
||||
}
|
||||
|
||||
get notifications(): Record<string, EventNotificationObject> {
|
||||
return this._data.notifications as any;
|
||||
}
|
||||
|
||||
set notifications(value: Record<string, EventNotificationInterface|EventNotificationObject>) {
|
||||
this._data.notifications = {} as any;
|
||||
for (const key in value) {
|
||||
const notification = value[key];
|
||||
if (notification) {
|
||||
if (notification instanceof EventNotificationObject) {
|
||||
(this._data.notifications as any)[key] = notification;
|
||||
} else {
|
||||
(this._data.notifications as any)[key] = new EventNotificationObject().fromJson(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addNotification(value?: EventNotificationInterface|EventNotificationObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let notification: EventNotificationObject;
|
||||
|
||||
if (!value) {
|
||||
notification = new EventNotificationObject();
|
||||
}
|
||||
else if (value instanceof EventNotificationObject) {
|
||||
notification = value;
|
||||
}
|
||||
else {
|
||||
notification = new EventNotificationObject().fromJson(value);
|
||||
}
|
||||
|
||||
(this._data.notifications as any)[key] = notification;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeNotification(key: string): void {
|
||||
delete this._data.notifications[key];
|
||||
}
|
||||
|
||||
getNotification(key: string): EventNotificationObject | undefined {
|
||||
return this._data.notifications[key] as any;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Class model for Event Notification Interface
|
||||
*/
|
||||
import type { EventNotificationInterface } from "@/types/event";
|
||||
|
||||
export class EventNotificationObject implements EventNotificationInterface {
|
||||
|
||||
_data!: EventNotificationInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
identifier: null,
|
||||
type: 'email',
|
||||
pattern: 'unknown'
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventNotificationInterface): EventNotificationObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventNotificationInterface {
|
||||
const result: Partial<EventNotificationInterface> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventNotificationInterface];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventNotificationInterface;
|
||||
}
|
||||
|
||||
clone(): EventNotificationObject {
|
||||
const cloned = new EventNotificationObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get identifier(): string | null {
|
||||
return this._data.identifier;
|
||||
}
|
||||
|
||||
set identifier(value: string | null) {
|
||||
this._data.identifier = value;
|
||||
}
|
||||
|
||||
get type(): 'visual' | 'audible' | 'email' {
|
||||
return this._data.type;
|
||||
}
|
||||
|
||||
set type(value: 'visual' | 'audible' | 'email') {
|
||||
this._data.type = value;
|
||||
}
|
||||
|
||||
get pattern(): 'absolute' | 'relative' | 'unknown' {
|
||||
return this._data.pattern;
|
||||
}
|
||||
|
||||
set pattern(value: 'absolute' | 'relative' | 'unknown') {
|
||||
this._data.pattern = value;
|
||||
if (value === 'absolute') {
|
||||
this._data.anchor = null;
|
||||
this._data.offset = null;
|
||||
} else if (value === 'relative') {
|
||||
this._data.when = null;
|
||||
} else {
|
||||
this._data.when = null;
|
||||
this._data.anchor = null;
|
||||
this._data.offset = null;
|
||||
}
|
||||
}
|
||||
|
||||
get when(): string | null {
|
||||
return this._data.when ?? null;
|
||||
}
|
||||
|
||||
set when(value: string | null) {
|
||||
this._data.pattern = 'absolute';
|
||||
this._data.anchor = null;
|
||||
this._data.offset = null;
|
||||
this._data.when = value;
|
||||
}
|
||||
|
||||
get anchor(): 'start' | 'end' | null {
|
||||
return this._data.anchor ?? null;
|
||||
}
|
||||
|
||||
set anchor(value: 'start' | 'end' | null) {
|
||||
this._data.pattern = 'relative';
|
||||
this._data.when = null;
|
||||
this._data.anchor = value;
|
||||
}
|
||||
|
||||
get offset(): string | null {
|
||||
return this._data.offset ?? null;
|
||||
}
|
||||
|
||||
set offset(value: string | null) {
|
||||
this._data.pattern = 'relative';
|
||||
this._data.anchor = 'start';
|
||||
this._data.when = null;
|
||||
this._data.offset = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
/**
|
||||
* Class model for Event Occurrence Interface
|
||||
*/
|
||||
import type { EventOccurrence } from "@/types/event";
|
||||
|
||||
export class EventOccurrenceObject implements EventOccurrence {
|
||||
|
||||
_data!: EventOccurrence;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
pattern: 'absolute',
|
||||
precision: 'daily',
|
||||
interval: 1,
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventOccurrence): EventOccurrenceObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventOccurrence {
|
||||
const result: Partial<EventOccurrence> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventOccurrence];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventOccurrence;
|
||||
}
|
||||
|
||||
clone(): EventOccurrenceObject {
|
||||
const cloned = new EventOccurrenceObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get pattern(): 'absolute' | 'relative' {
|
||||
return this._data.pattern;
|
||||
}
|
||||
|
||||
set pattern(value: 'absolute' | 'relative') {
|
||||
this._data.pattern = value;
|
||||
}
|
||||
|
||||
get precision(): 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly' | 'minutely' | 'secondly' {
|
||||
return this._data.precision;
|
||||
}
|
||||
|
||||
set precision(value: 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly' | 'minutely' | 'secondly') {
|
||||
this._data.precision = value;
|
||||
}
|
||||
|
||||
get interval(): number {
|
||||
return this._data.interval;
|
||||
}
|
||||
|
||||
set interval(value: number) {
|
||||
this._data.interval = value;
|
||||
}
|
||||
|
||||
get iterations(): number | null {
|
||||
return this._data.iterations ?? null;
|
||||
}
|
||||
|
||||
set iterations(value: number | null) {
|
||||
this._data.iterations = value;
|
||||
}
|
||||
|
||||
get concludes(): string | null {
|
||||
return this._data.concludes ?? null;
|
||||
}
|
||||
|
||||
set concludes(value: string | null) {
|
||||
this._data.concludes = value;
|
||||
}
|
||||
|
||||
get scale(): string | null {
|
||||
return this._data.scale ?? null;
|
||||
}
|
||||
|
||||
set scale(value: string | null) {
|
||||
this._data.scale = value;
|
||||
}
|
||||
|
||||
get onDayOfWeek(): number[] | null {
|
||||
return this._data.onDayOfWeek ?? null;
|
||||
}
|
||||
|
||||
set onDayOfWeek(value: number[] | null) {
|
||||
this._data.onDayOfWeek = value;
|
||||
}
|
||||
|
||||
addOnDayOfWeek(value: number): void {
|
||||
if (!this._data.onDayOfWeek) {
|
||||
this._data.onDayOfWeek = [];
|
||||
}
|
||||
if (!this._data.onDayOfWeek.includes(value)) {
|
||||
this._data.onDayOfWeek.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnDayOfWeek(value: number): void {
|
||||
if (!this._data.onDayOfWeek) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onDayOfWeek.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onDayOfWeek.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onDayOfMonth(): number[] | null {
|
||||
return this._data.onDayOfMonth ?? null;
|
||||
}
|
||||
|
||||
set onDayOfMonth(value: number[] | null) {
|
||||
this._data.onDayOfMonth = value;
|
||||
}
|
||||
|
||||
addOnDayOfMonth(value: number): void {
|
||||
if (!this._data.onDayOfMonth) {
|
||||
this._data.onDayOfMonth = [];
|
||||
}
|
||||
if (!this._data.onDayOfMonth.includes(value)) {
|
||||
this._data.onDayOfMonth.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnDayOfMonth(value: number): void {
|
||||
if (!this._data.onDayOfMonth) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onDayOfMonth.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onDayOfMonth.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onDayOfYear(): number[] | null {
|
||||
return this._data.onDayOfYear ?? null;
|
||||
}
|
||||
|
||||
set onDayOfYear(value: number[] | null) {
|
||||
this._data.onDayOfYear = value;
|
||||
}
|
||||
|
||||
addOnDayOfYear(value: number): void {
|
||||
if (!this._data.onDayOfYear) {
|
||||
this._data.onDayOfYear = [];
|
||||
}
|
||||
if (!this._data.onDayOfYear.includes(value)) {
|
||||
this._data.onDayOfYear.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnDayOfYear(value: number): void {
|
||||
if (!this._data.onDayOfYear) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onDayOfYear.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onDayOfYear.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onWeekOfMonth(): number[] | null {
|
||||
return this._data.onWeekOfMonth ?? null;
|
||||
}
|
||||
|
||||
set onWeekOfMonth(value: number[] | null) {
|
||||
this._data.onWeekOfMonth = value;
|
||||
}
|
||||
|
||||
addOnWeekOfMonth(value: number): void {
|
||||
if (!this._data.onWeekOfMonth) {
|
||||
this._data.onWeekOfMonth = [];
|
||||
}
|
||||
if (!this._data.onWeekOfMonth.includes(value)) {
|
||||
this._data.onWeekOfMonth.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnWeekOfMonth(value: number): void {
|
||||
if (!this._data.onWeekOfMonth) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onWeekOfMonth.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onWeekOfMonth.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onWeekOfYear(): number[] | null {
|
||||
return this._data.onWeekOfYear ?? null;
|
||||
}
|
||||
|
||||
set onWeekOfYear(value: number[] | null) {
|
||||
this._data.onWeekOfYear = value;
|
||||
}
|
||||
|
||||
addOnWeekOfYear(value: number): void {
|
||||
if (!this._data.onWeekOfYear) {
|
||||
this._data.onWeekOfYear = [];
|
||||
}
|
||||
if (!this._data.onWeekOfYear.includes(value)) {
|
||||
this._data.onWeekOfYear.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnWeekOfYear(value: number): void {
|
||||
if (!this._data.onWeekOfYear) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onWeekOfYear.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onWeekOfYear.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onMonthOfYear(): number[] | null {
|
||||
return this._data.onMonthOfYear ?? null;
|
||||
}
|
||||
|
||||
set onMonthOfYear(value: number[] | null) {
|
||||
this._data.onMonthOfYear = value;
|
||||
}
|
||||
|
||||
addOnMonthOfYear(value: number): void {
|
||||
if (!this._data.onMonthOfYear) {
|
||||
this._data.onMonthOfYear = [];
|
||||
}
|
||||
if (!this._data.onMonthOfYear.includes(value)) {
|
||||
this._data.onMonthOfYear.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnMonthOfYear(value: number): void {
|
||||
if (!this._data.onMonthOfYear) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onMonthOfYear.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onMonthOfYear.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onHour(): number[] | null {
|
||||
return this._data.onHour ?? null;
|
||||
}
|
||||
|
||||
set onHour(value: number[] | null) {
|
||||
this._data.onHour = value;
|
||||
}
|
||||
|
||||
addOnHour(value: number): void {
|
||||
if (!this._data.onHour) {
|
||||
this._data.onHour = [];
|
||||
}
|
||||
if (!this._data.onHour.includes(value)) {
|
||||
this._data.onHour.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnHour(value: number): void {
|
||||
if (!this._data.onHour) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onHour.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onHour.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onMinute(): number[] | null {
|
||||
return this._data.onMinute ?? null;
|
||||
}
|
||||
|
||||
set onMinute(value: number[] | null) {
|
||||
this._data.onMinute = value;
|
||||
}
|
||||
|
||||
addOnMinute(value: number): void {
|
||||
if (!this._data.onMinute) {
|
||||
this._data.onMinute = [];
|
||||
}
|
||||
if (!this._data.onMinute.includes(value)) {
|
||||
this._data.onMinute.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnMinute(value: number): void {
|
||||
if (!this._data.onMinute) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onMinute.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onMinute.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onSecond(): number[] | null {
|
||||
return this._data.onSecond ?? null;
|
||||
}
|
||||
|
||||
set onSecond(value: number[] | null) {
|
||||
this._data.onSecond = value;
|
||||
}
|
||||
|
||||
addOnSecond(value: number): void {
|
||||
if (!this._data.onSecond) {
|
||||
this._data.onSecond = [];
|
||||
}
|
||||
if (!this._data.onSecond.includes(value)) {
|
||||
this._data.onSecond.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnSecond(value: number): void {
|
||||
if (!this._data.onSecond) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onSecond.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onSecond.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get onPosition(): number[] | null {
|
||||
return this._data.onPosition ?? null;
|
||||
}
|
||||
|
||||
set onPosition(value: number[] | null) {
|
||||
this._data.onPosition = value;
|
||||
}
|
||||
|
||||
addOnPosition(value: number): void {
|
||||
if (!this._data.onPosition) {
|
||||
this._data.onPosition = [];
|
||||
}
|
||||
if (!this._data.onPosition.includes(value)) {
|
||||
this._data.onPosition.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
removeOnPosition(value: number): void {
|
||||
if (!this._data.onPosition) {
|
||||
return;
|
||||
}
|
||||
const index = this._data.onPosition.indexOf(value);
|
||||
if (index > -1) {
|
||||
this._data.onPosition.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Class model for Event Organizer Interface
|
||||
*/
|
||||
import type { EventOrganizerInterface } from "@/types/event";
|
||||
|
||||
export class EventOrganizerObject implements EventOrganizerInterface {
|
||||
|
||||
_data!: EventOrganizerInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
realm: 'E',
|
||||
address: ''
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventOrganizerInterface): EventOrganizerObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventOrganizerInterface {
|
||||
const result: Partial<EventOrganizerInterface> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventOrganizerInterface];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventOrganizerInterface;
|
||||
}
|
||||
|
||||
clone(): EventOrganizerObject {
|
||||
const cloned = new EventOrganizerObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get realm(): 'I' | 'E' {
|
||||
return this._data.realm;
|
||||
}
|
||||
|
||||
set realm(value: 'I' | 'E') {
|
||||
this._data.realm = value;
|
||||
}
|
||||
|
||||
get address(): string {
|
||||
return this._data.address;
|
||||
}
|
||||
|
||||
set address(value: string) {
|
||||
this._data.address = value;
|
||||
}
|
||||
|
||||
get name(): string | null {
|
||||
return this._data.name ?? null;
|
||||
}
|
||||
|
||||
set name(value: string | null) {
|
||||
this._data.name = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* Class model for Event Participant Interface
|
||||
*/
|
||||
import type { EventParticipantInterface } from "@/types/event";
|
||||
|
||||
export class EventParticipantObject implements EventParticipantInterface {
|
||||
|
||||
_data!: EventParticipantInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
identifier: null,
|
||||
realm: 'E',
|
||||
address: '',
|
||||
type: 'individual',
|
||||
status: 'none',
|
||||
roles: []
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventParticipantInterface): EventParticipantObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventParticipantInterface {
|
||||
const result: Partial<EventParticipantInterface> = {};
|
||||
|
||||
for (const key in this._data) {
|
||||
const value = this._data[key as keyof EventParticipantInterface];
|
||||
if (value !== null && value !== undefined) {
|
||||
(result as any)[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result as EventParticipantInterface;
|
||||
}
|
||||
|
||||
clone(): EventParticipantObject {
|
||||
const cloned = new EventParticipantObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get identifier(): string | null {
|
||||
return this._data.identifier;
|
||||
}
|
||||
|
||||
set identifier(value: string | null) {
|
||||
this._data.identifier = value;
|
||||
}
|
||||
|
||||
get realm(): 'I' | 'E' {
|
||||
return this._data.realm;
|
||||
}
|
||||
|
||||
set realm(value: 'I' | 'E') {
|
||||
this._data.realm = value;
|
||||
}
|
||||
|
||||
get name(): string | null {
|
||||
return this._data.name ?? null;
|
||||
}
|
||||
|
||||
set name(value: string | null) {
|
||||
this._data.name = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description ?? null;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get language(): string | null {
|
||||
return this._data.language ?? null;
|
||||
}
|
||||
|
||||
set language(value: string | null) {
|
||||
this._data.language = value;
|
||||
}
|
||||
|
||||
get address(): string {
|
||||
return this._data.address;
|
||||
}
|
||||
|
||||
set address(value: string) {
|
||||
this._data.address = value;
|
||||
}
|
||||
|
||||
get type(): 'unknown' | 'individual' | 'group' | 'resource' | 'location' {
|
||||
return this._data.type;
|
||||
}
|
||||
|
||||
set type(value: 'unknown' | 'individual' | 'group' | 'resource' | 'location') {
|
||||
this._data.type = value;
|
||||
}
|
||||
|
||||
get status(): 'none' | 'accepted' | 'declined' | 'tentative' | 'delegated' {
|
||||
return this._data.status;
|
||||
}
|
||||
|
||||
set status(value: 'none' | 'accepted' | 'declined' | 'tentative' | 'delegated') {
|
||||
this._data.status = value;
|
||||
}
|
||||
|
||||
get comment(): string | null {
|
||||
return this._data.comment ?? null;
|
||||
}
|
||||
|
||||
set comment(value: string | null) {
|
||||
this._data.comment = value;
|
||||
}
|
||||
|
||||
get roles(): ('owner' | 'chair' | 'attendee' | 'optional' | 'informational' | 'contact')[] {
|
||||
return this._data.roles;
|
||||
}
|
||||
|
||||
set roles(value: ('owner' | 'chair' | 'attendee' | 'optional' | 'informational' | 'contact')[]) {
|
||||
this._data.roles = value;
|
||||
}
|
||||
|
||||
addRole(role: 'owner' | 'chair' | 'attendee' | 'optional' | 'informational' | 'contact'): void {
|
||||
if (!this._data.roles.includes(role)) {
|
||||
this._data.roles.push(role);
|
||||
}
|
||||
}
|
||||
|
||||
removeRole(role: 'owner' | 'chair' | 'attendee' | 'optional' | 'informational' | 'contact'): void {
|
||||
const index = this._data.roles.indexOf(role);
|
||||
if (index > -1) {
|
||||
this._data.roles.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
hasRole(role: 'owner' | 'chair' | 'attendee' | 'optional' | 'informational' | 'contact'): boolean {
|
||||
return this._data.roles.includes(role);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
/**
|
||||
* Class model for Event Interface
|
||||
*/
|
||||
import type {
|
||||
EventInterface,
|
||||
EventLocationPhysicalInterface,
|
||||
EventLocationVirtualInterface,
|
||||
EventOrganizerInterface,
|
||||
EventParticipantInterface,
|
||||
EventNotificationInterface,
|
||||
EventOccurrence,
|
||||
EventMutation
|
||||
} from "@/types/event";
|
||||
import { EventLocationPhysicalObject } from "./event-location-physical";
|
||||
import { EventLocationVirtualObject } from "./event-location-virtual";
|
||||
import { EventOrganizerObject } from "./event-organizer";
|
||||
import { EventParticipantObject } from "./event-participant";
|
||||
import { EventNotificationObject } from "./event-notification";
|
||||
import { EventOccurrenceObject } from "./event-occurrence";
|
||||
import { EventMutationObject } from "./event-mutation";
|
||||
import { generateKey } from "../utils/key-generator";
|
||||
|
||||
export class EventObject implements EventInterface {
|
||||
|
||||
_data!: EventInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
type: 'event',
|
||||
version: 1,
|
||||
urid: null,
|
||||
created: null,
|
||||
modified: null,
|
||||
sequence: null,
|
||||
timeZone: null,
|
||||
startsOn: null,
|
||||
startsTZ: null,
|
||||
endsOn: null,
|
||||
endsTZ: null,
|
||||
duration: null,
|
||||
timeless: null,
|
||||
label: null,
|
||||
description: null,
|
||||
locationsPhysical: {},
|
||||
locationsVirtual: {},
|
||||
availability: null,
|
||||
sensitivity: null,
|
||||
priority: null,
|
||||
color: null,
|
||||
tags: [],
|
||||
organizer: null,
|
||||
participants: {},
|
||||
notifications: {},
|
||||
pattern: null,
|
||||
mutations: {}
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: EventInterface): EventObject {
|
||||
// Deep copy the data to avoid reference issues
|
||||
this._data = JSON.parse(JSON.stringify(data));
|
||||
|
||||
// Convert organizer to object instance
|
||||
if (this._data.organizer) {
|
||||
this._data.organizer = new EventOrganizerObject().fromJson(this._data.organizer) as any;
|
||||
}
|
||||
|
||||
// Convert locations physical to object instances
|
||||
for (const key in this._data.locationsPhysical) {
|
||||
const loc = this._data.locationsPhysical[key];
|
||||
if (loc) {
|
||||
this._data.locationsPhysical[key] = new EventLocationPhysicalObject().fromJson(loc) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert locations virtual to object instances
|
||||
for (const key in this._data.locationsVirtual) {
|
||||
const loc = this._data.locationsVirtual[key];
|
||||
if (loc) {
|
||||
this._data.locationsVirtual[key] = new EventLocationVirtualObject().fromJson(loc) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert participants to object instances
|
||||
for (const key in this._data.participants) {
|
||||
const participant = this._data.participants[key];
|
||||
if (participant) {
|
||||
this._data.participants[key] = new EventParticipantObject().fromJson(participant) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert notifications to object instances
|
||||
for (const key in this._data.notifications) {
|
||||
const notification = this._data.notifications[key];
|
||||
if (notification) {
|
||||
this._data.notifications[key] = new EventNotificationObject().fromJson(notification) as any;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert pattern to object instance
|
||||
if (this._data.pattern) {
|
||||
this._data.pattern = new EventOccurrenceObject().fromJson(this._data.pattern) as any;
|
||||
}
|
||||
|
||||
// Convert mutations to object instances
|
||||
for (const key in this._data.mutations) {
|
||||
const mutation = this._data.mutations[key];
|
||||
if (mutation) {
|
||||
this._data.mutations[key] = new EventMutationObject().fromJson(mutation) as any;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): EventInterface {
|
||||
// Return a deep copy to avoid external modifications
|
||||
return JSON.parse(JSON.stringify(this._data));
|
||||
}
|
||||
|
||||
clone(): EventObject {
|
||||
const cloned = new EventObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get type(): string {
|
||||
return this._data.type;
|
||||
}
|
||||
|
||||
get version(): number {
|
||||
return this._data.version;
|
||||
}
|
||||
|
||||
set version(value: number) {
|
||||
this._data.version = value;
|
||||
}
|
||||
|
||||
get urid(): string | null {
|
||||
return this._data.urid;
|
||||
}
|
||||
|
||||
set urid(value: string | null) {
|
||||
this._data.urid = value;
|
||||
}
|
||||
|
||||
get created(): string | null {
|
||||
return this._data.created;
|
||||
}
|
||||
|
||||
set created(value: string | null) {
|
||||
this._data.created = value;
|
||||
}
|
||||
|
||||
get modified(): string | null {
|
||||
return this._data.modified;
|
||||
}
|
||||
|
||||
set modified(value: string | null) {
|
||||
this._data.modified = value;
|
||||
}
|
||||
|
||||
get sequence(): number | null {
|
||||
return this._data.sequence;
|
||||
}
|
||||
|
||||
set sequence(value: number | null) {
|
||||
this._data.sequence = value;
|
||||
}
|
||||
|
||||
get timeZone(): string | null {
|
||||
return this._data.timeZone;
|
||||
}
|
||||
|
||||
set timeZone(value: string | null) {
|
||||
this._data.timeZone = value;
|
||||
}
|
||||
|
||||
get startsOn(): string | null {
|
||||
return this._data.startsOn;
|
||||
}
|
||||
|
||||
set startsOn(value: string | null) {
|
||||
this._data.startsOn = value;
|
||||
}
|
||||
|
||||
get startsTZ(): string | null {
|
||||
return this._data.startsTZ;
|
||||
}
|
||||
|
||||
set startsTZ(value: string | null) {
|
||||
this._data.startsTZ = value;
|
||||
}
|
||||
|
||||
get endsOn(): string | null {
|
||||
return this._data.endsOn;
|
||||
}
|
||||
|
||||
set endsOn(value: string | null) {
|
||||
this._data.endsOn = value;
|
||||
}
|
||||
|
||||
get endsTZ(): string | null {
|
||||
return this._data.endsTZ;
|
||||
}
|
||||
|
||||
set endsTZ(value: string | null) {
|
||||
this._data.endsTZ = value;
|
||||
}
|
||||
|
||||
get duration(): string | null {
|
||||
return this._data.duration;
|
||||
}
|
||||
|
||||
set duration(value: string | null) {
|
||||
this._data.duration = value;
|
||||
}
|
||||
|
||||
get timeless(): boolean | null {
|
||||
return this._data.timeless;
|
||||
}
|
||||
|
||||
set timeless(value: boolean | null) {
|
||||
this._data.timeless = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get availability(): 'free' | 'busy' | null {
|
||||
return this._data.availability;
|
||||
}
|
||||
|
||||
set availability(value: 'free' | 'busy' | null) {
|
||||
this._data.availability = value;
|
||||
}
|
||||
|
||||
get sensitivity(): 'public' | 'private' | 'secret' | null {
|
||||
return this._data.sensitivity;
|
||||
}
|
||||
|
||||
set sensitivity(value: 'public' | 'private' | 'secret' | null) {
|
||||
this._data.sensitivity = value;
|
||||
}
|
||||
|
||||
get priority(): number | null {
|
||||
return this._data.priority;
|
||||
}
|
||||
|
||||
set priority(value: number | null) {
|
||||
this._data.priority = value;
|
||||
}
|
||||
|
||||
get color(): string | null {
|
||||
return this._data.color;
|
||||
}
|
||||
|
||||
set color(value: string | null) {
|
||||
this._data.color = value;
|
||||
}
|
||||
|
||||
get locationsPhysical(): Record<string, EventLocationPhysicalObject> {
|
||||
return this._data.locationsPhysical as any;
|
||||
}
|
||||
|
||||
set locationsPhysical(value: Record<string, EventLocationPhysicalInterface|EventLocationPhysicalObject>) {
|
||||
this._data.locationsPhysical = {} as any;
|
||||
for (const key in value) {
|
||||
const loc = value[key];
|
||||
if (loc) {
|
||||
if (loc instanceof EventLocationPhysicalObject) {
|
||||
(this._data.locationsPhysical as any)[key] = loc;
|
||||
} else {
|
||||
(this._data.locationsPhysical as any)[key] = new EventLocationPhysicalObject().fromJson(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLocationPhysical(value?: EventLocationPhysicalInterface|EventLocationPhysicalObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let location: EventLocationPhysicalObject;
|
||||
|
||||
if (!value) {
|
||||
location = new EventLocationPhysicalObject();
|
||||
location.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventLocationPhysicalObject) {
|
||||
location = value;
|
||||
location.identifier = key;
|
||||
}
|
||||
else {
|
||||
location = new EventLocationPhysicalObject().fromJson(value);
|
||||
location.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.locationsPhysical as any)[key] = location;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeLocationPhysical(key: string): void {
|
||||
delete this._data.locationsPhysical[key];
|
||||
}
|
||||
|
||||
getLocationPhysical(key: string): EventLocationPhysicalObject | undefined {
|
||||
return this._data.locationsPhysical[key] as any;
|
||||
}
|
||||
|
||||
get locationsVirtual(): Record<string, EventLocationVirtualObject> {
|
||||
return this._data.locationsVirtual as any;
|
||||
}
|
||||
|
||||
set locationsVirtual(value: Record<string, EventLocationVirtualInterface|EventLocationVirtualObject>) {
|
||||
this._data.locationsVirtual = {} as any;
|
||||
for (const key in value) {
|
||||
const loc = value[key];
|
||||
if (loc) {
|
||||
if (loc instanceof EventLocationVirtualObject) {
|
||||
(this._data.locationsVirtual as any)[key] = loc;
|
||||
} else {
|
||||
(this._data.locationsVirtual as any)[key] = new EventLocationVirtualObject().fromJson(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLocationVirtual(value?: EventLocationVirtualInterface|EventLocationVirtualObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let location: EventLocationVirtualObject;
|
||||
|
||||
if (!value) {
|
||||
location = new EventLocationVirtualObject();
|
||||
location.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventLocationVirtualObject) {
|
||||
location = value;
|
||||
location.identifier = key;
|
||||
}
|
||||
else {
|
||||
location = new EventLocationVirtualObject().fromJson(value);
|
||||
location.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.locationsVirtual as any)[key] = location;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeLocationVirtual(key: string): void {
|
||||
delete this._data.locationsVirtual[key];
|
||||
}
|
||||
|
||||
getLocationVirtual(key: string): EventLocationVirtualObject | undefined {
|
||||
return this._data.locationsVirtual[key] as any;
|
||||
}
|
||||
|
||||
get tags(): string[] {
|
||||
return this._data.tags;
|
||||
}
|
||||
|
||||
set tags(value: string[]) {
|
||||
this._data.tags = value;
|
||||
}
|
||||
|
||||
addTag(tag: string): void {
|
||||
if (!this._data.tags.includes(tag)) {
|
||||
this._data.tags.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
removeTag(tag: string): void {
|
||||
const index = this._data.tags.indexOf(tag);
|
||||
if (index > -1) {
|
||||
this._data.tags.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
get organizer(): EventOrganizerObject {
|
||||
return this._data.organizer as any;
|
||||
}
|
||||
|
||||
set organizer(value: EventOrganizerInterface|EventOrganizerObject) {
|
||||
if (value instanceof EventOrganizerObject) {
|
||||
(this._data.organizer as any) = value;
|
||||
} else {
|
||||
(this._data.organizer as any) = new EventOrganizerObject().fromJson(value);
|
||||
}
|
||||
}
|
||||
|
||||
get participants(): Record<string, EventParticipantObject> {
|
||||
return this._data.participants as any;
|
||||
}
|
||||
|
||||
set participants(value: Record<string, EventParticipantInterface|EventParticipantObject>) {
|
||||
this._data.participants = {} as any;
|
||||
for (const key in value) {
|
||||
const participant = value[key];
|
||||
if (participant) {
|
||||
if (participant instanceof EventParticipantObject) {
|
||||
(this._data.participants as any)[key] = participant;
|
||||
} else {
|
||||
(this._data.participants as any)[key] = new EventParticipantObject().fromJson(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getParticipant(key: string): EventParticipantObject | undefined {
|
||||
return this._data.participants[key] as any;
|
||||
}
|
||||
|
||||
addParticipant(value?: EventParticipantInterface|EventParticipantObject|null, key?: string): string {
|
||||
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let participant: EventParticipantObject;
|
||||
|
||||
if (!value) {
|
||||
participant = new EventParticipantObject();
|
||||
participant.identifier = key;
|
||||
}
|
||||
else if (value instanceof EventParticipantObject) {
|
||||
participant = value;
|
||||
participant.identifier = key;
|
||||
}
|
||||
else {
|
||||
participant = new EventParticipantObject().fromJson(value);
|
||||
participant.identifier = key;
|
||||
}
|
||||
|
||||
(this._data.participants as any)[key] = participant;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeParticipant(key: string): void {
|
||||
delete this._data.participants[key];
|
||||
}
|
||||
|
||||
get notifications(): Record<string, EventNotificationObject> {
|
||||
return this._data.notifications as any;
|
||||
}
|
||||
|
||||
set notifications(value: Record<string, EventNotificationInterface|EventNotificationObject>) {
|
||||
this._data.notifications = {} as any;
|
||||
for (const key in value) {
|
||||
const notification = value[key];
|
||||
if (notification) {
|
||||
if (notification instanceof EventNotificationObject) {
|
||||
(this._data.notifications as any)[key] = notification;
|
||||
} else {
|
||||
(this._data.notifications as any)[key] = new EventNotificationObject().fromJson(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addNotification(value?: EventNotificationInterface|EventNotificationObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let notification: EventNotificationObject;
|
||||
|
||||
if (!value) {
|
||||
notification = new EventNotificationObject();
|
||||
}
|
||||
else if (value instanceof EventNotificationObject) {
|
||||
notification = value;
|
||||
}
|
||||
else {
|
||||
notification = new EventNotificationObject().fromJson(value);
|
||||
}
|
||||
|
||||
(this._data.notifications as any)[key] = notification;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeNotification(key: string): void {
|
||||
delete this._data.notifications[key];
|
||||
}
|
||||
|
||||
getNotification(key: string): EventNotificationObject | undefined {
|
||||
return this._data.notifications[key] as any;
|
||||
}
|
||||
|
||||
get pattern(): EventOccurrenceObject | null {
|
||||
return this._data.pattern as any;
|
||||
}
|
||||
|
||||
set pattern(value: EventOccurrence|EventOccurrenceObject|null) {
|
||||
if (!value) {
|
||||
this._data.pattern = null;
|
||||
} else if (value instanceof EventOccurrenceObject) {
|
||||
this._data.pattern = value as any;
|
||||
} else {
|
||||
this._data.pattern = new EventOccurrenceObject().fromJson(value) as any;
|
||||
}
|
||||
}
|
||||
|
||||
get mutations(): Record<string, EventMutationObject> {
|
||||
return this._data.mutations as any;
|
||||
}
|
||||
|
||||
set mutations(value: Record<string, EventMutation|EventMutationObject>) {
|
||||
this._data.mutations = {} as any;
|
||||
for (const key in value) {
|
||||
const mutation = value[key];
|
||||
if (mutation) {
|
||||
if (mutation instanceof EventMutationObject) {
|
||||
(this._data.mutations as any)[key] = mutation;
|
||||
} else {
|
||||
(this._data.mutations as any)[key] = new EventMutationObject().fromJson(mutation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addMutation(value?: EventMutation|EventMutationObject|null, key?: string): string {
|
||||
if (!key) {
|
||||
key = generateKey();
|
||||
}
|
||||
|
||||
let mutation: EventMutationObject;
|
||||
|
||||
if (!value) {
|
||||
mutation = new EventMutationObject();
|
||||
}
|
||||
else if (value instanceof EventMutationObject) {
|
||||
mutation = value;
|
||||
}
|
||||
else {
|
||||
mutation = new EventMutationObject().fromJson(value);
|
||||
}
|
||||
|
||||
(this._data.mutations as any)[key] = mutation;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
removeMutation(key: string): void {
|
||||
delete this._data.mutations[key];
|
||||
}
|
||||
|
||||
getMutation(key: string): EventMutationObject | undefined {
|
||||
return this._data.mutations[key] as any;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Central export point for all Chrono Manager models
|
||||
*/
|
||||
|
||||
export { Collection } from './collection';
|
||||
export { Entity } from './entity';
|
||||
export { Event } from './event';
|
||||
export { Task } from './task';
|
||||
export { Journal } from './journal';
|
||||
export { Provider } from './provider';
|
||||
export { Service } from './service';
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Class model for Journal Interface
|
||||
*/
|
||||
import type {
|
||||
JournalInterface,
|
||||
JournalAttachment
|
||||
} from "@/types/journal";
|
||||
|
||||
export class JournalObject implements JournalInterface {
|
||||
|
||||
_data!: JournalInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
type: 'journal',
|
||||
version: 0,
|
||||
urid: null,
|
||||
created: null,
|
||||
modified: null,
|
||||
label: null,
|
||||
description: null,
|
||||
content: null,
|
||||
startsOn: null,
|
||||
endsOn: null,
|
||||
status: null,
|
||||
visibility: null,
|
||||
attachments: {},
|
||||
tags: [],
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: JournalInterface): JournalObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): JournalInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): JournalObject {
|
||||
const cloned = new JournalObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get type(): string {
|
||||
return this._data.type;
|
||||
}
|
||||
|
||||
get version(): number {
|
||||
return this._data.version;
|
||||
}
|
||||
|
||||
set version(value: number) {
|
||||
this._data.version = value;
|
||||
}
|
||||
|
||||
get urid(): string | null {
|
||||
return this._data.urid;
|
||||
}
|
||||
|
||||
set urid(value: string | null) {
|
||||
this._data.urid = value;
|
||||
}
|
||||
|
||||
get created(): Date | null {
|
||||
return this._data.created;
|
||||
}
|
||||
|
||||
set created(value: Date | null) {
|
||||
this._data.created = value;
|
||||
}
|
||||
|
||||
get modified(): Date | null {
|
||||
return this._data.modified;
|
||||
}
|
||||
|
||||
set modified(value: Date | null) {
|
||||
this._data.modified = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get content(): string | null {
|
||||
return this._data.content;
|
||||
}
|
||||
|
||||
set content(value: string | null) {
|
||||
this._data.content = value;
|
||||
}
|
||||
|
||||
get startsOn(): Date | null {
|
||||
return this._data.startsOn;
|
||||
}
|
||||
|
||||
set startsOn(value: Date | null) {
|
||||
this._data.startsOn = value;
|
||||
}
|
||||
|
||||
get endsOn(): Date | null {
|
||||
return this._data.endsOn;
|
||||
}
|
||||
|
||||
set endsOn(value: Date | null) {
|
||||
this._data.endsOn = value;
|
||||
}
|
||||
|
||||
get status(): string | null {
|
||||
return this._data.status;
|
||||
}
|
||||
|
||||
set status(value: string | null) {
|
||||
this._data.status = value;
|
||||
}
|
||||
|
||||
get visibility(): string | null {
|
||||
return this._data.visibility;
|
||||
}
|
||||
|
||||
set visibility(value: string | null) {
|
||||
this._data.visibility = value;
|
||||
}
|
||||
|
||||
get attachments(): Record<string, JournalAttachment> {
|
||||
return this._data.attachments;
|
||||
}
|
||||
|
||||
set attachments(value: Record<string, JournalAttachment>) {
|
||||
this._data.attachments = value;
|
||||
}
|
||||
|
||||
get tags(): string[] {
|
||||
return this._data.tags;
|
||||
}
|
||||
|
||||
set tags(value: string[]) {
|
||||
this._data.tags = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Class model for Provider Interface
|
||||
*/
|
||||
import type { ProviderCapabilitiesInterface, ProviderInterface } from "@/types/provider";
|
||||
|
||||
export class ProviderObject implements ProviderInterface {
|
||||
|
||||
_data!: ProviderInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'chrono:provider',
|
||||
id: '',
|
||||
label: '',
|
||||
capabilities: {},
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: ProviderInterface): ProviderObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): ProviderInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): ProviderObject {
|
||||
const cloned = new ProviderObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
capable(capability: keyof ProviderCapabilitiesInterface): boolean {
|
||||
return !!(this._data.capabilities && this._data.capabilities[capability]);
|
||||
}
|
||||
|
||||
capability(capability: keyof ProviderCapabilitiesInterface): any | null {
|
||||
if (this._data.capabilities) {
|
||||
return this._data.capabilities[capability];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Immutable Properties */
|
||||
|
||||
get '@type'(): string {
|
||||
return this._data['@type'];
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this._data.id;
|
||||
}
|
||||
|
||||
get label(): string {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
get capabilities(): ProviderCapabilitiesInterface {
|
||||
return this._data.capabilities;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Class model for Service Interface
|
||||
*/
|
||||
import type { ServiceCapabilitiesInterface, ServiceInterface } from "@/types/service";
|
||||
|
||||
export class ServiceObject implements ServiceInterface {
|
||||
|
||||
_data!: ServiceInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'chrono:service',
|
||||
provider: '',
|
||||
id: '',
|
||||
label: '',
|
||||
capabilities: {},
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: ServiceInterface): ServiceObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): ServiceInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): ServiceObject {
|
||||
const cloned = new ServiceObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
capable(capability: keyof ServiceCapabilitiesInterface): boolean {
|
||||
return !!(this._data.capabilities && this._data.capabilities[capability]);
|
||||
}
|
||||
|
||||
capability(capability: keyof ServiceCapabilitiesInterface): any | null {
|
||||
if (this._data.capabilities) {
|
||||
return this._data.capabilities[capability];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Immutable Properties */
|
||||
|
||||
get '@type'(): string {
|
||||
return this._data['@type'];
|
||||
}
|
||||
|
||||
get provider(): string {
|
||||
return this._data.provider;
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this._data.id;
|
||||
}
|
||||
|
||||
get label(): string {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
get capabilities(): ServiceCapabilitiesInterface | undefined {
|
||||
return this._data.capabilities;
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
return this._data.enabled;
|
||||
}
|
||||
|
||||
set enabled(value: boolean) {
|
||||
this._data.enabled = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* Class model for Task Interface
|
||||
*/
|
||||
import type {
|
||||
TaskInterface,
|
||||
TaskSubtask,
|
||||
TaskAttachment,
|
||||
TaskRecurrence
|
||||
} from "@/types/task";
|
||||
|
||||
export class TaskObject implements TaskInterface {
|
||||
|
||||
_data!: TaskInterface;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
type: 'task',
|
||||
version: 0,
|
||||
urid: null,
|
||||
created: null,
|
||||
modified: null,
|
||||
label: null,
|
||||
description: null,
|
||||
startsOn: null,
|
||||
dueOn: null,
|
||||
completedOn: null,
|
||||
status: null,
|
||||
priority: null,
|
||||
progress: null,
|
||||
color: null,
|
||||
recurrence: null,
|
||||
subtasks: {},
|
||||
attachments: {},
|
||||
tags: [],
|
||||
notes: null,
|
||||
};
|
||||
}
|
||||
|
||||
fromJson(data: TaskInterface): TaskObject {
|
||||
this._data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
toJson(): TaskInterface {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
clone(): TaskObject {
|
||||
const cloned = new TaskObject();
|
||||
cloned._data = JSON.parse(JSON.stringify(this._data));
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/** Properties */
|
||||
|
||||
get type(): string {
|
||||
return this._data.type;
|
||||
}
|
||||
|
||||
get version(): number {
|
||||
return this._data.version;
|
||||
}
|
||||
|
||||
set version(value: number) {
|
||||
this._data.version = value;
|
||||
}
|
||||
|
||||
get urid(): string | null {
|
||||
return this._data.urid;
|
||||
}
|
||||
|
||||
set urid(value: string | null) {
|
||||
this._data.urid = value;
|
||||
}
|
||||
|
||||
get created(): Date | null {
|
||||
return this._data.created;
|
||||
}
|
||||
|
||||
set created(value: Date | null) {
|
||||
this._data.created = value;
|
||||
}
|
||||
|
||||
get modified(): Date | null {
|
||||
return this._data.modified;
|
||||
}
|
||||
|
||||
set modified(value: Date | null) {
|
||||
this._data.modified = value;
|
||||
}
|
||||
|
||||
get label(): string | null {
|
||||
return this._data.label;
|
||||
}
|
||||
|
||||
set label(value: string | null) {
|
||||
this._data.label = value;
|
||||
}
|
||||
|
||||
get description(): string | null {
|
||||
return this._data.description;
|
||||
}
|
||||
|
||||
set description(value: string | null) {
|
||||
this._data.description = value;
|
||||
}
|
||||
|
||||
get startsOn(): Date | null {
|
||||
return this._data.startsOn;
|
||||
}
|
||||
|
||||
set startsOn(value: Date | null) {
|
||||
this._data.startsOn = value;
|
||||
}
|
||||
|
||||
get dueOn(): Date | null {
|
||||
return this._data.dueOn;
|
||||
}
|
||||
|
||||
set dueOn(value: Date | null) {
|
||||
this._data.dueOn = value;
|
||||
}
|
||||
|
||||
get completedOn(): Date | null {
|
||||
return this._data.completedOn;
|
||||
}
|
||||
|
||||
set completedOn(value: Date | null) {
|
||||
this._data.completedOn = value;
|
||||
}
|
||||
|
||||
get status(): string | null {
|
||||
return this._data.status;
|
||||
}
|
||||
|
||||
set status(value: string | null) {
|
||||
this._data.status = value;
|
||||
}
|
||||
|
||||
get priority(): number | null {
|
||||
return this._data.priority;
|
||||
}
|
||||
|
||||
set priority(value: number | null) {
|
||||
this._data.priority = value;
|
||||
}
|
||||
|
||||
get progress(): number | null {
|
||||
return this._data.progress;
|
||||
}
|
||||
|
||||
set progress(value: number | null) {
|
||||
this._data.progress = value;
|
||||
}
|
||||
|
||||
get color(): string | null {
|
||||
return this._data.color;
|
||||
}
|
||||
|
||||
set color(value: string | null) {
|
||||
this._data.color = value;
|
||||
}
|
||||
|
||||
get recurrence(): TaskRecurrence | null {
|
||||
return this._data.recurrence;
|
||||
}
|
||||
|
||||
set recurrence(value: TaskRecurrence | null) {
|
||||
this._data.recurrence = value;
|
||||
}
|
||||
|
||||
get subtasks(): Record<string, TaskSubtask> {
|
||||
return this._data.subtasks;
|
||||
}
|
||||
|
||||
set subtasks(value: Record<string, TaskSubtask>) {
|
||||
this._data.subtasks = value;
|
||||
}
|
||||
|
||||
get attachments(): Record<string, TaskAttachment> {
|
||||
return this._data.attachments;
|
||||
}
|
||||
|
||||
set attachments(value: Record<string, TaskAttachment>) {
|
||||
this._data.attachments = value;
|
||||
}
|
||||
|
||||
get tags(): string[] {
|
||||
return this._data.tags;
|
||||
}
|
||||
|
||||
set tags(value: string[]) {
|
||||
this._data.tags = value;
|
||||
}
|
||||
|
||||
get notes(): string | null {
|
||||
return this._data.notes;
|
||||
}
|
||||
|
||||
set notes(value: string | null) {
|
||||
this._data.notes = value;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user