refactor: use resource identifiers
Some checks failed
Build Test / test (pull_request) Successful in 26s
JS Unit Tests / test (pull_request) Failing after 29s
PHP Unit Tests / test (pull_request) Successful in 56s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-14 22:34:18 -04:00
parent 69d4b2f42c
commit c7ef2c5495
13 changed files with 425 additions and 621 deletions

View File

@@ -4,6 +4,7 @@
import type { CollectionInterface, CollectionModelInterface, CollectionPropertiesInterface, CollectionPropertiesModelInterface } from "@/types/collection";
import { clonePlain } from './clone-plain';
import type { CollectionIdentifier, ServiceIdentifier } from "@/services";
export class CollectionObject implements CollectionModelInterface {
@@ -49,16 +50,16 @@ export class CollectionObject implements CollectionModelInterface {
return this._data.provider;
}
get service(): string | number {
return this._data.service;
get service(): ServiceIdentifier {
return this._data.service as ServiceIdentifier;
}
get collection(): string | number | null {
return this._data.collection;
get collection(): CollectionIdentifier | null {
return this._data.collection as CollectionIdentifier | null;
}
get identifier(): string | number {
return this._data.identifier;
get identifier(): CollectionIdentifier {
return this._data.identifier as CollectionIdentifier;
}
get signature(): string | null | undefined {

View File

@@ -6,6 +6,7 @@ import type { EntityInterface, EntityModelInterface } from "@/types/entity";
import type { MessageInterface } from "@/types/message";
import { MessageObject } from "./message";
import { clonePlain } from './clone-plain';
import type { CollectionIdentifier, EntityIdentifier, ServiceIdentifier } from "@/services";
export class EntityObject implements EntityModelInterface {
@@ -18,8 +19,8 @@ export class EntityObject implements EntityModelInterface {
version: 1,
provider: '',
service: '',
collection: '',
identifier: '',
collection: null,
identifier: null,
signature: null,
created: null,
modified: null,
@@ -54,16 +55,16 @@ export class EntityObject implements EntityModelInterface {
return this._data.provider;
}
get service(): string {
return this._data.service;
get service(): ServiceIdentifier {
return this._data.service as ServiceIdentifier;
}
get collection(): string|number {
return this._data.collection;
get collection(): CollectionIdentifier {
return this._data.collection as CollectionIdentifier;
}
get identifier(): string|number {
return this._data.identifier;
get identifier(): EntityIdentifier {
return this._data.identifier as EntityIdentifier;
}
get signature(): string | null {

View File

@@ -48,38 +48,46 @@ export class MessageObject implements MessageModelInterface {
/** Properties */
get size(): number {
return this._data.size ?? 0;
}
get headers(): Record<string, string> {
return clonePlain(this._data.headers ?? {});
}
get urid(): string | null{
return this._data.urid ?? null;
}
get size(): number {
return this._data.size ?? 0;
get inReplyTo(): string | null {
return this._data.inReplyTo ?? null;
}
get receivedDate(): string | null {
return this._data.receivedDate ?? null;
get references(): string | null {
return this._data.references ?? null;
}
get sentDate(): string | null {
return this._data.sentDate ?? null;
get received(): string | null {
return this._data.received ?? null;
}
get date(): string | null {
return this._data.date ?? null;
get sent(): string | null {
return this._data.sent ?? null;
}
get subject(): string | null {
return this._data.subject ?? null;
}
get snippet(): string | null {
return this._data.snippet ?? null;
get sender(): MessageAddressObject | null {
return this._data.sender ? new MessageAddressObject(this._data.sender) : null;
}
get from(): MessageAddressObject | null {
return this._data.from ? new MessageAddressObject(this._data.from) : null;
}
get replyTo(): Array<MessageAddressObject> | null {
return this._data.replyTo ? this._data.replyTo.map(addr => new MessageAddressObject(addr)) : null;
}
get to(): Array<MessageAddressObject> | null {
return this._data.to ? this._data.to.map(addr => new MessageAddressObject(addr)) : null;
}
@@ -92,12 +100,8 @@ export class MessageObject implements MessageModelInterface {
return this._data.bcc ? this._data.bcc.map(addr => new MessageAddressObject(addr)) : null;
}
get replyTo(): Array<MessageAddressObject> | null {
return this._data.replyTo ? this._data.replyTo.map(addr => new MessageAddressObject(addr)) : null;
}
get flags(): { read?: boolean; flagged?: boolean; answered?: boolean; draft?: boolean } | {} {
return clonePlain(this._data.flags ?? {});
get subject(): string | null {
return this._data.subject ?? null;
}
get body(): MessagePartObject | null {
@@ -115,6 +119,10 @@ export class MessageObject implements MessageModelInterface {
return this._data.attachments ? this._data.attachments.map(att => new MessagePartObject(att)) : [];
}
get flags(): { read?: boolean; flagged?: boolean; answered?: boolean; draft?: boolean } | {} {
return clonePlain(this._data.flags ?? {});
}
/** Helper methods */
get isRead(): boolean {