Initial commit

This commit is contained in:
root
2025-12-21 09:55:58 -05:00
committed by Sebastian Krupinski
commit 169b7b4c91
57 changed files with 10105 additions and 0 deletions

107
src/models/entity.ts Normal file
View File

@@ -0,0 +1,107 @@
/**
* Class model for Message/Entity Interface
*/
import type { EntityInterface } from "@/types/entity";
import type { MessageInterface, MessagePartInterface } from "@/types/message";
import { MessageObject } from "./message";
export class EntityObject {
_data!: EntityInterface<MessageInterface>;
_message!: MessageObject;
constructor() {
this._data = {
'@type': 'mail.entity',
provider: '',
service: '',
collection: '',
identifier: '',
signature: null,
created: null,
modified: null,
properties: {
'@type': 'mail.message',
version: 1,
urid: '',
size: 0,
receivedDate: undefined,
date: undefined,
subject: '',
snippet: '',
from: undefined,
to: [],
cc: [],
bcc: [],
replyTo: [],
flags: {},
body: undefined,
attachments: [],
}
};
}
fromJson(data: EntityInterface<MessageInterface>): EntityObject {
this._data = data;
return this;
}
toJson(): EntityInterface<MessageInterface> {
return this._data;
}
clone(): EntityObject {
const cloned = new EntityObject();
cloned._data = {
...this._data,
properties: { ...this._data.properties }
};
return cloned;
}
/** Metadata Properties */
get provider(): string {
return this._data.provider;
}
get service(): string {
return this._data.service;
}
get collection(): string|number {
return this._data.collection;
}
get identifier(): string|number {
return this._data.identifier;
}
get signature(): string | null {
return this._data.signature;
}
get created(): string | null {
return this._data.created;
}
get modified(): string | null {
return this._data.modified;
}
/** Message Object Properties */
get properties(): MessageObject {
if (!this._message) {
this._message = new MessageObject(this._data.properties);
}
return this._message;
}
// Alias for backward compatibility
get object(): MessageObject {
return this.properties;
}
}