refactor: standardize frontend

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-24 17:38:48 -05:00
parent 20d3a46d7b
commit 0c4c9e52cd
24 changed files with 2448 additions and 1232 deletions
+57 -10
View File
@@ -4,8 +4,12 @@
import type {
ServiceInterface,
ServiceCapabilitiesInterface
ServiceCapabilitiesInterface,
ServiceIdentity,
ServiceLocation
} from "@/types/service";
import { Identity } from './identity';
import { Location } from './location';
export class ServiceObject implements ServiceInterface {
@@ -15,10 +19,10 @@ export class ServiceObject implements ServiceInterface {
this._data = {
'@type': 'people:service',
provider: '',
id: '',
label: '',
capabilities: {},
identifier: null,
label: null,
enabled: false,
capabilities: {}
};
}
@@ -32,7 +36,8 @@ export class ServiceObject implements ServiceInterface {
}
capable(capability: keyof ServiceCapabilitiesInterface): boolean {
return !!(this._data.capabilities && this._data.capabilities[capability]);
const value = this._data.capabilities?.[capability];
return value !== undefined && value !== false;
}
capability(capability: keyof ServiceCapabilitiesInterface): any | null {
@@ -52,8 +57,8 @@ export class ServiceObject implements ServiceInterface {
return this._data.provider;
}
get id(): string {
return this._data.id;
get identifier(): string | number | null {
return this._data.identifier;
}
get capabilities(): ServiceCapabilitiesInterface | undefined {
@@ -62,11 +67,11 @@ export class ServiceObject implements ServiceInterface {
/** Mutable Properties */
get label(): string {
get label(): string | null {
return this._data.label;
}
set label(value: string) {
set label(value: string | null) {
this._data.label = value;
}
@@ -78,4 +83,46 @@ export class ServiceObject implements ServiceInterface {
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);
}
}