refactor: front end

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-03-28 12:47:21 -04:00
parent 28e5cce23a
commit ccb781f933
38 changed files with 4909 additions and 2897 deletions

View File

@@ -1,7 +1,15 @@
/**
* Class model for Service Interface
*/
import type { ServiceInterface } from "@/types/service";
import type {
ServiceInterface,
ServiceCapabilitiesInterface,
ServiceIdentity,
ServiceLocation
} from "@/types/service";
import { Identity } from './identity';
import { Location } from './location';
export class ServiceObject implements ServiceInterface {
@@ -9,11 +17,12 @@ export class ServiceObject implements ServiceInterface {
constructor() {
this._data = {
'@type': 'files:service',
id: '',
'@type': 'documents:service',
provider: '',
label: '',
rootId: '',
identifier: null,
label: null,
enabled: false,
capabilities: {}
};
}
@@ -26,10 +35,16 @@ export class ServiceObject implements 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 {
const value = this._data.capabilities?.[capability];
return value !== undefined && value !== false;
}
capability(capability: keyof ServiceCapabilitiesInterface): any | null {
if (this._data.capabilities) {
return this._data.capabilities[capability];
}
return null;
}
/** Immutable Properties */
@@ -38,20 +53,76 @@ export class ServiceObject implements ServiceInterface {
return this._data['@type'];
}
get id(): string {
return this._data.id;
}
get provider(): string {
return this._data.provider;
}
get label(): string {
get identifier(): string | number | null {
return this._data.identifier;
}
get capabilities(): ServiceCapabilitiesInterface | undefined {
return this._data.capabilities;
}
/** Mutable Properties */
get label(): string | null {
return this._data.label;
}
get rootId(): string {
return this._data.rootId;
set label(value: string | null) {
this._data.label = value;
}
get enabled(): boolean {
return this._data.enabled;
}
set enabled(value: boolean) {
this._data.enabled = value;
}
get location(): ServiceLocation | null {
return this._data.location ?? null;
}
set location(value: ServiceLocation | null) {
this._data.location = value;
}
get identity(): ServiceIdentity | null {
return this._data.identity ?? null;
}
set identity(value: ServiceIdentity | null) {
this._data.identity = value;
}
get auxiliary(): Record<string, any> {
return this._data.auxiliary ?? {};
}
set auxiliary(value: Record<string, any>) {
this._data.auxiliary = value;
}
/** Helper Methods */
/**
* Get identity as a class instance for easier manipulation
*/
getIdentity(): Identity | null {
if (!this._data.identity) return null;
return Identity.fromJson(this._data.identity);
}
/**
* Get location as a class instance for easier manipulation
*/
getLocation(): Location | null {
if (!this._data.location) return null;
return Location.fromJson(this._data.location);
}
}