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

26 lines
772 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);
2026-10-10 10:01:58 +00:00
if (!(id.isSuccess && name.isSuccess)) {
throw new Error("Sección de plantilla persistida inconsistente.");
}
2026-10-10 10:01:58 +00:00
return new TemplateSection({ name: name.data, description: input.description }, id.data);
}
2026-10-10 10:01:58 +00:00
get name() {
return this.props.name;
}
2026-10-10 10:01:58 +00:00
get description() {
return this.props.description;
}
}