Initial commit

This commit is contained in:
root
2025-12-21 09:59:17 -05:00
committed by Sebastian Krupinski
commit 974d3fe11b
53 changed files with 7555 additions and 0 deletions
+77
View File
@@ -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;
}
}