metis-desk/modules/resources/src/api/domain/template-section.entity.ts

22 lines
768 B
TypeScript
Raw Normal View History

import { DomainEntity, Name, UniqueID } from "@repo/rdx-ddd";
import type { TemplateSectionData } from "./template-sections";
/** Entidad interna de la plantilla, persistida junto a su definición JSON. */
export class TemplateSection extends DomainEntity<{ name: Name; description: string }> {
static rehydrate(input: TemplateSectionData) {
const id = UniqueID.create(input.id);
const name = Name.create(input.name, 100);
if (!(id.isSuccess && name.isSuccess)) {
throw new Error("Sección de plantilla persistida inconsistente.");
}
return new TemplateSection({ name: name.data, description: input.description }, id.data);
}
get name() {
return this.props.name;
}
get description() {
return this.props.description;
}
}