Initial commit

This commit is contained in:
root
2025-12-21 09:53:16 -05:00
committed by Sebastian Krupinski
commit a7ccac98a2
43 changed files with 6391 additions and 0 deletions
+139
View File
@@ -0,0 +1,139 @@
/**
* Class model for Collection Interface
*/
import type {
CollectionInterface,
CollectionContentsInterface,
CollectionPermissionsInterface,
CollectionRolesInterface
} from "@/types/collection";
export class CollectionObject implements CollectionInterface {
_data!: CollectionInterface;
constructor() {
this._data = {
'@type': 'people:collection',
provider: null,
service: null,
in: null,
id: null,
label: null,
description: null,
priority: null,
visibility: null,
color: null,
enabled: false,
signature: null,
permissions: {},
roles: {},
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
}
/** Immutable Properties */
get '@type'(): string {
return this._data['@type'];
}
get provider(): string | null {
return this._data.provider
}
get service(): string | null {
return this._data.service
}
get in(): number | string | null {
return this._data.in
}
get id(): number | string | null {
return this._data.id
}
get signature(): string | null {
return this._data.signature
}
get permissions(): CollectionPermissionsInterface {
return this._data.permissions
}
get roles(): CollectionRolesInterface {
return this._data.roles
}
get contents(): CollectionContentsInterface {
return this._data.contents
}
/** Mutable Properties */
get label(): string | null {
return this._data.label
}
set label(value: string ) {
this._data.label = value
}
get description(): string | null {
return this._data.description
}
set description(value: string ) {
this._data.description = value
}
get priority(): number | null {
return this._data.priority
}
set priority(value: number ) {
this._data.priority = value
}
get visibility(): string | null {
return this._data.visibility
}
set visibility(value: string ) {
this._data.visibility = value
}
get color(): string | null {
return this._data.color
}
set color(value: string ) {
this._data.color = value
}
get enabled(): boolean {
return this._data.enabled
}
set enabled(value: boolean ) {
this._data.enabled = value
}
}
+153
View File
@@ -0,0 +1,153 @@
/**
* Class model for Entity Interface
*/
import type { EntityInterface } from "@/types/entity";
import type { IndividualInterface } from "@/types/individual";
import type { OrganizationInterface } from "@/types/organization";
import type { GroupInterface } from "@/types/group";
import { IndividualObject } from "./individual";
import { OrganizationObject } from "./organization";
import { GroupObject } from "./group";
export class EntityObject implements EntityInterface {
_data!: EntityInterface;
constructor() {
this._data = {
'@type': 'people: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 === 'organization') {
this._data.data = new OrganizationObject().fromJson(data.data as OrganizationInterface);
} else if (type === 'group') {
this._data.data = new GroupObject().fromJson(data.data as GroupInterface);
} else {
this._data.data = new IndividualObject().fromJson(data.data as IndividualInterface);
}
} else {
this._data.data = null;
}
return this;
}
toJson(): EntityInterface {
const json = { ...this._data };
if (this._data.data instanceof IndividualObject ||
this._data.data instanceof OrganizationObject ||
this._data.data instanceof GroupObject) {
json.data = this._data.data.toJson();
}
return json;
}
clone(): EntityObject {
const cloned = new EntityObject()
cloned._data = JSON.parse(JSON.stringify(this._data))
return cloned
}
/** Immutable Properties */
get '@type'(): string {
return this._data['@type'];
}
get in(): number | string | null {
return this._data.in;
}
get id(): number | string | null {
return this._data.id;
}
get version(): number {
return this._data.version;
}
get createdOn(): Date | null {
return this._data.createdOn;
}
get createdBy(): string | null {
return this._data.createdBy;
}
get modifiedOn(): Date | null {
return this._data.modifiedOn;
}
get modifiedBy(): string | null {
return this._data.modifiedBy;
}
get signature(): string | null {
return this._data.signature;
}
/** Mutable Properties */
set createdOn(value: Date | null) {
this._data.createdOn = value;
}
set createdBy(value: string | null) {
this._data.createdBy = value;
}
set modifiedOn(value: Date | null) {
this._data.modifiedOn = value;
}
set modifiedBy(value: string | null) {
this._data.modifiedBy = value;
}
set signature(value: string | null) {
this._data.signature = value;
}
get data(): IndividualObject | OrganizationObject | GroupObject | null {
if (this._data.data instanceof IndividualObject ||
this._data.data instanceof OrganizationObject ||
this._data.data instanceof GroupObject) {
return this._data.data;
}
if (this._data.data) {
const type = this._data.data.type;
let hydrated;
if (type === 'organization') {
hydrated = new OrganizationObject().fromJson(this._data.data as OrganizationInterface);
} else if (type === 'group') {
hydrated = new GroupObject().fromJson(this._data.data as GroupInterface);
} else {
hydrated = new IndividualObject().fromJson(this._data.data as IndividualInterface);
}
this._data.data = hydrated;
return hydrated;
}
return null;
}
set data(value: IndividualObject | OrganizationObject | GroupObject | null) {
this._data.data = value;
}
}
+262
View File
@@ -0,0 +1,262 @@
/**
* Class model for Group Interface
*/
import { reactive } from 'vue'
import { generateUrid, generateKey } from "../utils/key-generator";
import type {
GroupInterface,
GroupName,
GroupMember,
GroupVirtualLocation,
GroupMedia,
GroupNote
} from '@/types/group';
export class GroupObject implements GroupInterface {
_data: GroupInterface;
constructor() {
this._data = reactive({
type: 'group',
version: 1,
urid: generateUrid(),
created: null,
modified: null,
label: '',
names: {
full: null,
sort: null,
aliases: []
},
members: {},
virtualLocations: {},
media: {},
tags: [],
notes: {},
});
}
fromJson(data: GroupInterface): GroupObject {
// Normalize arrays to Records for properties that should be Record types
const normalized = {
...data,
members: Array.isArray(data.members) ? {} : (data.members || {}),
virtualLocations: Array.isArray(data.virtualLocations) ? {} : (data.virtualLocations || {}),
media: Array.isArray(data.media) ? {} : (data.media || {}),
notes: Array.isArray(data.notes) ? {} : (data.notes || {}),
};
this._data = reactive(normalized);
return this;
}
toJson(): GroupInterface {
return this._data;
}
clone(): GroupObject {
const cloned = new GroupObject()
cloned._data = JSON.parse(JSON.stringify(this._data))
return cloned
}
/** Immutable Properties */
get type(): string {
return this._data.type;
}
get version(): number {
return this._data.version;
}
get urid(): string | null {
return this._data.urid;
}
/** Mutable Properties */
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 names(): GroupName {
return this._data.names;
}
set names(value: GroupName) {
this._data.names = value;
}
get members(): Record<string, GroupMember> {
return this._data.members;
}
set members(value: Record<string, GroupMember>) {
this._data.members = value;
}
get virtualLocations(): Record<string, GroupVirtualLocation> {
return this._data.virtualLocations;
}
set virtualLocations(value: Record<string, GroupVirtualLocation>) {
this._data.virtualLocations = value;
}
get media(): Record<string, GroupMedia> {
return this._data.media;
}
set media(value: Record<string, GroupMedia>) {
this._data.media = value;
}
get tags(): string[] {
return this._data.tags;
}
set tags(value: string[]) {
this._data.tags = value;
}
get notes(): Record<string, GroupNote> {
return this._data.notes;
}
set notes(value: Record<string, GroupNote>) {
this._data.notes = value;
}
/**
* Mutation helpers for complex properties
*/
addMember(initial?: Partial<GroupMember>): string {
const members = this._data.members || (this._data.members = {});
const key = generateKey();
members[key] = {
entityId: null,
role: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeMember(key: string): void {
if (this._data.members) {
delete this._data.members[key];
}
}
addVirtualLocation(initial?: Partial<GroupVirtualLocation>): string {
const virtualLocations = this._data.virtualLocations || (this._data.virtualLocations = {});
const key = generateKey();
virtualLocations[key] = {
location: null,
label: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeVirtualLocation(key: string): void {
if (this._data.virtualLocations) {
delete this._data.virtualLocations[key];
}
}
addMedia(initial?: Partial<GroupMedia>): string {
const media = this._data.media || (this._data.media = {});
const key = generateKey();
media[key] = {
type: "logo",
kind: "logo",
uri: "",
mediaType: null,
contexts: null,
pref: null,
label: null,
...initial,
};
return key;
}
removeMedia(key: string): void {
if (this._data.media) {
delete this._data.media[key];
}
}
addNote(initial?: Partial<GroupNote>): string {
const notes = this._data.notes || (this._data.notes = {});
const key = generateKey();
notes[key] = {
content: null,
date: null,
authorUri: null,
authorName: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeNote(key: string): void {
if (this._data.notes) {
delete this._data.notes[key];
}
}
addTag(value: string): void {
const tags = this._data.tags || (this._data.tags = []);
tags.push(value);
}
removeTag(value: string): void {
const tags = this._data.tags;
const index = tags.indexOf(value);
if (index >= 0) {
tags.splice(index, 1);
}
}
addAlias(value: string): void {
const aliases = this._data.names.aliases || (this._data.names.aliases = []);
aliases.push(value);
}
removeAlias(value: string): void {
const aliases = this._data.names.aliases;
const index = aliases.indexOf(value);
if (index >= 0) {
aliases.splice(index, 1);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
/**
* Central export point for all People Manager models
*/
export { CollectionObject } from './collection';
export { EntityObject } from './entity';
export { GroupObject } from './group';
export { IndividualObject } from './individual';
export { OrganizationObject } from './organization';
export { ProviderObject } from './provider';
export { ServiceObject } from './service';
+483
View File
@@ -0,0 +1,483 @@
/**
* Class model for Individual Interface
*/
import { reactive } from 'vue'
import { generateUrid, generateKey } from "../utils/key-generator";
import type {
IndividualAnniversary,
IndividualCrypto,
IndividualEmail,
IndividualInterface,
IndividualLanguage,
IndividualMedia,
IndividualName,
IndividualNote,
IndividualOrganization,
IndividualPhone,
IndividualPhysicalLocation,
IndividualTitle,
IndividualVirtualLocation
} from "@/types/individual";
export class IndividualObject implements IndividualInterface {
_data: IndividualInterface;
constructor() {
this._data = reactive({
type: 'individual',
version: 1,
urid: generateUrid(),
created: null,
modified: null,
label: '',
names: {
family: null,
given: null,
additional: null,
prefix: null,
suffix: null,
phoneticFamily: null,
phoneticGiven: null,
phoneticAdditional: null,
aliases: []
},
titles: {},
anniversaries: [],
physicalLocations: {},
phones: {},
emails: {},
virtualLocations: {},
media: {},
organizations: {},
tags: [],
notes: {},
language: null,
languages: [],
crypto: {},
});
}
fromJson(data: IndividualInterface) : IndividualObject {
// Normalize arrays to Records for properties that should be Record types
const normalized = {
...data,
titles: Array.isArray(data.titles) ? {} : (data.titles || {}),
physicalLocations: Array.isArray(data.physicalLocations) ? {} : (data.physicalLocations || {}),
phones: Array.isArray(data.phones) ? {} : (data.phones || {}),
emails: Array.isArray(data.emails) ? {} : (data.emails || {}),
virtualLocations: Array.isArray(data.virtualLocations) ? {} : (data.virtualLocations || {}),
media: Array.isArray(data.media) ? {} : (data.media || {}),
notes: Array.isArray(data.notes) ? {} : (data.notes || {}),
crypto: Array.isArray(data.crypto) ? {} : (data.crypto || {}),
};
this._data = reactive(normalized);
return this;
}
toJson(): IndividualInterface {
return this._data;
}
clone(): IndividualObject {
const cloned = new IndividualObject()
cloned._data = JSON.parse(JSON.stringify(this._data))
return cloned
}
/** Immutable Properties */
get type(): string {
return this._data.type;
}
get version(): number {
return this._data.version;
}
get urid(): string | null {
return this._data.urid;
}
/** Mutable Properties */
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 names(): IndividualName {
return this._data.names;
}
set names(value: IndividualName) {
this._data.names = value;
}
get titles(): Record<string, IndividualTitle> {
return this._data.titles;
}
set titles(value: Record<string, IndividualTitle>) {
this._data.titles = value;
}
get anniversaries(): IndividualAnniversary[] {
return this._data.anniversaries;
}
set anniversaries(value: IndividualAnniversary[]) {
this._data.anniversaries = value;
}
get physicalLocations(): Record<string, IndividualPhysicalLocation> {
return this._data.physicalLocations;
}
set physicalLocations(value: Record<string, IndividualPhysicalLocation>) {
this._data.physicalLocations = value;
}
get phones(): Record<string, IndividualPhone> {
return this._data.phones;
}
set phones(value: Record<string, IndividualPhone>) {
this._data.phones = value;
}
get emails(): Record<string, IndividualEmail> {
return this._data.emails;
}
set emails(value: Record<string, IndividualEmail>) {
this._data.emails = value;
}
get virtualLocations(): Record<string, IndividualVirtualLocation> {
return this._data.virtualLocations;
}
set virtualLocations(value: Record<string, IndividualVirtualLocation>) {
this._data.virtualLocations = value;
}
get media(): Record<string, IndividualMedia> {
return this._data.media;
}
set media(value: Record<string, IndividualMedia>) {
this._data.media = value;
}
get organizations(): Record<string, IndividualOrganization> {
return this._data.organizations;
}
set organizations(value: Record<string, IndividualOrganization>) {
this._data.organizations = value;
}
get tags(): string[] {
return this._data.tags;
}
set tags(value: string[]) {
this._data.tags = value;
}
get notes(): Record<string, IndividualNote> {
return this._data.notes;
}
set notes(value: Record<string, IndividualNote>) {
this._data.notes = value;
}
get language(): string | null {
return this._data.language;
}
set language(value: string | null) {
this._data.language = value;
}
get languages(): IndividualLanguage[] {
return this._data.languages;
}
set languages(value: IndividualLanguage[]) {
this._data.languages = value;
}
get crypto(): Record<string, IndividualCrypto> {
return this._data.crypto;
}
set crypto(value: Record<string, IndividualCrypto>) {
this._data.crypto = value;
}
/**
* Mutation helpers for complex properties
*/
addTitle(initial?: Partial<IndividualTitle>): string {
if (!this._data.titles) {
this._data.titles = {};
}
const key = generateKey();
this._data.titles[key] = {
kind: null,
label: null,
relation: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeTitle(key: string): void {
if (this._data.titles) {
delete this._data.titles[key];
}
}
addAnniversary(initial?: Partial<IndividualAnniversary>): number {
const anniversaries = this._data.anniversaries || (this._data.anniversaries = []);
const entry: IndividualAnniversary = {
type: null,
when: null,
location: null,
...initial,
};
anniversaries.push(entry);
return anniversaries.length - 1;
}
removeAnniversary(index: number): void {
const anniversaries = this._data.anniversaries;
if (index >= 0 && index < anniversaries.length) {
anniversaries.splice(index, 1);
}
}
addPhysicalLocation(initial?: Partial<IndividualPhysicalLocation>): string {
const locations = this._data.physicalLocations || (this._data.physicalLocations = {});
const key = generateKey();
locations[key] = {
box: null,
unit: null,
street: null,
locality: null,
region: null,
code: null,
country: null,
label: null,
coordinates: null,
timeZone: null,
context: null,
priority: null,
...initial,
};
return key;
}
removePhysicalLocation(key: string): void {
if (this._data.physicalLocations) {
delete this._data.physicalLocations[key];
}
}
addPhone(initial?: Partial<IndividualPhone>): string {
const phones = this._data.phones || (this._data.phones = {});
const key = generateKey();
phones[key] = {
number: null,
label: null,
context: null,
priority: null,
...initial,
};
return key;
}
removePhone(key: string): void {
if (this._data.phones) {
delete this._data.phones[key];
}
}
addEmail(initial?: Partial<IndividualEmail>): string {
const emails = this._data.emails || (this._data.emails = {});
const key = generateKey();
emails[key] = {
address: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeEmail(key: string): void {
if (this._data.emails) {
delete this._data.emails[key];
}
}
addVirtualLocation(initial?: Partial<IndividualVirtualLocation>): string {
const virtualLocations = this._data.virtualLocations || (this._data.virtualLocations = {});
const key = generateKey();
virtualLocations[key] = {
location: null,
label: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeVirtualLocation(key: string): void {
if (this._data.virtualLocations) {
delete this._data.virtualLocations[key];
}
}
addMedia(initial?: Partial<IndividualMedia>): string {
const media = this._data.media || (this._data.media = {});
const key = generateKey();
media[key] = {
type: "photo",
kind: "photo",
uri: "",
mediaType: null,
contexts: null,
pref: null,
label: null,
...initial,
};
return key;
}
removeMedia(key: string): void {
if (this._data.media) {
delete this._data.media[key];
}
}
addOrganization(initial?: Partial<IndividualOrganization>): string {
const organizations = this._data.organizations || (this._data.organizations = {});
const key = generateKey();
organizations[key] = {
Label: null,
Units: [],
sortName: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeOrganization(key: string): void {
if (this._data.organizations) {
delete this._data.organizations[key];
}
}
addNote(initial?: Partial<IndividualNote>): string {
const notes = this._data.notes || (this._data.notes = {});
const key = generateKey();
notes[key] = {
content: null,
date: null,
authorUri: null,
authorName: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeNote(key: string): void {
if (this._data.notes) {
delete this._data.notes[key];
}
}
addLanguage(initial?: Partial<IndividualLanguage>): number {
const languages = this._data.languages || (this._data.languages = []);
const entry: IndividualLanguage = {
Data: null,
Id: null,
Priority: null,
Context: null,
...initial,
};
languages.push(entry);
return languages.length - 1;
}
removeLanguage(index: number): void {
const languages = this._data.languages;
if (index >= 0 && index < languages.length) {
languages.splice(index, 1);
}
}
addCrypto(initial?: Partial<IndividualCrypto>): string {
const cryptoEntries = this._data.crypto || (this._data.crypto = {});
const key = generateKey();
cryptoEntries[key] = {
data: null,
type: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeCrypto(key: string): void {
if (this._data.crypto) {
delete this._data.crypto[key];
}
}
addTag(value: string): void {
const tags = this._data.tags || (this._data.tags = []);
tags.push(value);
}
removeTag(value: string): void {
const tags = this._data.tags;
const index = tags.indexOf(value);
if (index >= 0) {
tags.splice(index, 1);
}
}
}
+359
View File
@@ -0,0 +1,359 @@
/**
* Class model for Organization Interface
*/
import { reactive } from 'vue'
import { generateUrid, generateKey } from "../utils/key-generator";
import type {
OrganizationInterface,
OrganizationName,
OrganizationPhysicalLocation,
OrganizationPhone,
OrganizationEmail,
OrganizationVirtualLocation,
OrganizationMedia,
OrganizationNote,
OrganizationCrypto
} from "@/types/organization";
export class OrganizationObject implements OrganizationInterface {
_data: OrganizationInterface;
constructor() {
this._data = reactive({
type: 'organization',
version: 1,
urid: generateUrid(),
created: null,
modified: null,
label: '',
names: {
full: null,
sort: null,
aliases: []
},
physicalLocations: {},
phones: {},
emails: {},
virtualLocations: {},
media: {},
tags: [],
notes: {},
crypto: {},
});
}
fromJson(data: OrganizationInterface): OrganizationObject {
// Normalize arrays to Records for properties that should be Record types
const normalized = {
...data,
physicalLocations: Array.isArray(data.physicalLocations) ? {} : (data.physicalLocations || {}),
phones: Array.isArray(data.phones) ? {} : (data.phones || {}),
emails: Array.isArray(data.emails) ? {} : (data.emails || {}),
virtualLocations: Array.isArray(data.virtualLocations) ? {} : (data.virtualLocations || {}),
media: Array.isArray(data.media) ? {} : (data.media || {}),
notes: Array.isArray(data.notes) ? {} : (data.notes || {}),
crypto: Array.isArray(data.crypto) ? {} : (data.crypto || {}),
};
this._data = reactive(normalized);
return this;
}
toJson(): OrganizationInterface {
return this._data;
}
clone(): OrganizationObject {
const cloned = new OrganizationObject()
cloned._data = JSON.parse(JSON.stringify(this._data))
return cloned
}
/** Immutable Properties */
get type(): string {
return this._data.type;
}
get version(): number {
return this._data.version;
}
get urid(): string | null {
return this._data.urid;
}
/** Mutable Properties */
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 names(): OrganizationName {
return this._data.names;
}
set names(value: OrganizationName) {
this._data.names = value;
}
get physicalLocations(): Record<string, OrganizationPhysicalLocation> {
return this._data.physicalLocations;
}
set physicalLocations(value: Record<string, OrganizationPhysicalLocation>) {
this._data.physicalLocations = value;
}
get phones(): Record<string, OrganizationPhone> {
return this._data.phones;
}
set phones(value: Record<string, OrganizationPhone>) {
this._data.phones = value;
}
get emails(): Record<string, OrganizationEmail> {
return this._data.emails;
}
set emails(value: Record<string, OrganizationEmail>) {
this._data.emails = value;
}
get virtualLocations(): Record<string, OrganizationVirtualLocation> {
return this._data.virtualLocations;
}
set virtualLocations(value: Record<string, OrganizationVirtualLocation>) {
this._data.virtualLocations = value;
}
get media(): Record<string, OrganizationMedia> {
return this._data.media;
}
set media(value: Record<string, OrganizationMedia>) {
this._data.media = value;
}
get tags(): string[] {
return this._data.tags;
}
set tags(value: string[]) {
this._data.tags = value;
}
get notes(): Record<string, OrganizationNote> {
return this._data.notes;
}
set notes(value: Record<string, OrganizationNote>) {
this._data.notes = value;
}
get crypto(): Record<string, OrganizationCrypto> {
return this._data.crypto;
}
set crypto(value: Record<string, OrganizationCrypto>) {
this._data.crypto = value;
}
/**
* Mutation helpers for complex properties
*/
addPhysicalLocation(initial?: Partial<OrganizationPhysicalLocation>): string {
const locations = this._data.physicalLocations || (this._data.physicalLocations = {});
const key = generateKey();
locations[key] = {
box: null,
unit: null,
street: null,
locality: null,
region: null,
code: null,
country: null,
label: null,
coordinates: null,
timeZone: null,
context: null,
priority: null,
...initial,
};
return key;
}
removePhysicalLocation(key: string): void {
if (this._data.physicalLocations) {
delete this._data.physicalLocations[key];
}
}
addPhone(initial?: Partial<OrganizationPhone>): string {
const phones = this._data.phones || (this._data.phones = {});
const key = generateKey();
phones[key] = {
number: null,
label: null,
context: null,
priority: null,
...initial,
};
return key;
}
removePhone(key: string): void {
if (this._data.phones) {
delete this._data.phones[key];
}
}
addEmail(initial?: Partial<OrganizationEmail>): string {
const emails = this._data.emails || (this._data.emails = {});
const key = generateKey();
emails[key] = {
address: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeEmail(key: string): void {
if (this._data.emails) {
delete this._data.emails[key];
}
}
addVirtualLocation(initial?: Partial<OrganizationVirtualLocation>): string {
const virtualLocations = this._data.virtualLocations || (this._data.virtualLocations = {});
const key = generateKey();
virtualLocations[key] = {
location: null,
label: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeVirtualLocation(key: string): void {
if (this._data.virtualLocations) {
delete this._data.virtualLocations[key];
}
}
addMedia(initial?: Partial<OrganizationMedia>): string {
const media = this._data.media || (this._data.media = {});
const key = generateKey();
media[key] = {
type: "logo",
kind: "logo",
uri: "",
mediaType: null,
contexts: null,
pref: null,
label: null,
...initial,
};
return key;
}
removeMedia(key: string): void {
if (this._data.media) {
delete this._data.media[key];
}
}
addNote(initial?: Partial<OrganizationNote>): string {
const notes = this._data.notes || (this._data.notes = {});
const key = generateKey();
notes[key] = {
content: null,
date: null,
authorUri: null,
authorName: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeNote(key: string): void {
if (this._data.notes) {
delete this._data.notes[key];
}
}
addCrypto(initial?: Partial<OrganizationCrypto>): string {
const cryptoEntries = this._data.crypto || (this._data.crypto = {});
const key = generateKey();
cryptoEntries[key] = {
data: null,
type: null,
context: null,
priority: null,
...initial,
};
return key;
}
removeCrypto(key: string): void {
if (this._data.crypto) {
delete this._data.crypto[key];
}
}
addTag(value: string): void {
const tags = this._data.tags || (this._data.tags = []);
tags.push(value);
}
removeTag(value: string): void {
const tags = this._data.tags;
const index = tags.indexOf(value);
if (index >= 0) {
tags.splice(index, 1);
}
}
addAlias(value: string): void {
const aliases = this._data.names.aliases || (this._data.names.aliases = []);
aliases.push(value);
}
removeAlias(value: string): void {
const aliases = this._data.names.aliases;
const index = aliases.indexOf(value);
if (index >= 0) {
aliases.splice(index, 1);
}
}
}
+61
View File
@@ -0,0 +1,61 @@
/**
* Class model for Provider Interface
*/
import type {
ProviderInterface,
ProviderCapabilitiesInterface
} from "@/types/provider";
export class ProviderObject implements ProviderInterface {
_data!: ProviderInterface;
constructor() {
this._data = {
'@type': 'people:provider',
id: '',
label: '',
capabilities: {},
};
}
fromJson(data: ProviderInterface): ProviderObject {
this._data = data;
return this;
}
toJson(): ProviderInterface {
return this._data;
}
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;
}
}
+81
View File
@@ -0,0 +1,81 @@
/**
* Class model for Service Interface
*/
import type {
ServiceInterface,
ServiceCapabilitiesInterface
} from "@/types/service";
export class ServiceObject implements ServiceInterface {
_data!: ServiceInterface;
constructor() {
this._data = {
'@type': 'people:service',
provider: '',
id: '',
label: '',
capabilities: {},
enabled: false,
};
}
fromJson(data: ServiceInterface): ServiceObject {
this._data = data;
return this;
}
toJson(): ServiceInterface {
return this._data;
}
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 capabilities(): ServiceCapabilitiesInterface | undefined {
return this._data.capabilities;
}
/** Mutable Properties */
get label(): string {
return this._data.label;
}
set label(value: string) {
this._data.label = value;
}
get enabled(): boolean {
return this._data.enabled;
}
set enabled(value: boolean) {
this._data.enabled = value;
}
}