diff --git a/app/models/item.ts b/app/models/item.ts index 5c4982d8..46765bd2 100644 --- a/app/models/item.ts +++ b/app/models/item.ts @@ -17,3 +17,20 @@ export type Item = z.infer; export type ItemWithId = Required; export type ItemType = Pick["type"]; + +export class ItemEntity implements Item { + private constructor( + public readonly id: string | undefined, + public readonly name: string, + public readonly price: number, + public readonly type: ItemType, + ) {} + + static createNew({ name, price, type }: Item): ItemEntity { + return new ItemEntity(undefined, name, price, type); + } + + static fromItem(item: ItemWithId): ItemEntity { + return new ItemEntity(item.id, item.name, item.price, item.type); + } +}