Several serialization and deserialization fixes

This commit is contained in:
barsdeveloper
2023-04-15 12:20:53 +02:00
parent d10589f0bd
commit baf40a9094
17 changed files with 366 additions and 149 deletions

View File

@@ -49,10 +49,19 @@ export default class IEntity {
const Self = /** @type {EntityConstructor} */(this.constructor)
let attributes = Self.attributes
if (values.attributes) {
let attributes = { ...Self.attributes }
Utility.mergeArrays(Object.keys(attributes), Object.keys(values.attributes))
.forEach(k => attributes[k] = {
...attributes[k],
...values.attributes[k]
.forEach(k => {
attributes[k] = {
...IEntity.defaultAttribute,
...attributes[k],
...values.attributes[k]
}
if (!attributes[k].type) {
attributes[k].type = values[k] instanceof Array
? [Utility.getType(values[k][0])]
: Utility.getType(values[k])
}
})
IEntity.defineAttributes(this, attributes)
}