Refactor entity handling to preserve config while overriding type

Reworked `ensureEntity` to replace entities while maintaining their configuration and allowing type adjustments. Updated tests to verify type persistence and synchronization of entity properties.
This commit is contained in:
dswbx
2025-01-10 15:51:47 +01:00
parent 1d5f14fae0
commit e94e8d8bd1
10 changed files with 63 additions and 41 deletions

View File

@@ -140,7 +140,7 @@ export class Entity<
return this.fields.find((field) => field.name === name);
}
__experimental_replaceField(name: string, field: Field) {
__replaceField(name: string, field: Field) {
const index = this.fields.findIndex((f) => f.name === name);
if (index === -1) {
throw new Error(`Field "${name}" not found on entity "${this.name}"`);