2025-02-04 14:58:33 +00:00
|
|
|
import { DomainEntity, Result, UniqueID } from "@common/domain";
|
|
|
|
|
|
|
|
|
|
export interface ITabContextProps {
|
|
|
|
|
tabId: UniqueID;
|
|
|
|
|
userId: UniqueID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITabContext {
|
|
|
|
|
tabId: UniqueID;
|
|
|
|
|
userId: UniqueID;
|
|
|
|
|
|
|
|
|
|
toPersistenceData(): any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TabContext extends DomainEntity<ITabContextProps> implements ITabContext {
|
|
|
|
|
static create(props: ITabContextProps, id?: UniqueID): Result<TabContext, Error> {
|
|
|
|
|
return Result.ok(new this(props, id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get tabId(): UniqueID {
|
|
|
|
|
return this._props.tabId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get userId(): UniqueID {
|
|
|
|
|
return this._props.userId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 🔹 Devuelve una representación lista para persistencia
|
|
|
|
|
*/
|
|
|
|
|
toPersistenceData(): any {
|
|
|
|
|
return {
|
|
|
|
|
id: this._id.toString(),
|
2025-02-05 20:40:59 +00:00
|
|
|
tab_id: this.tabId.toString(),
|
2025-02-04 14:58:33 +00:00
|
|
|
user_id: this.userId.toString(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|