feat: lots more improvements
Some checks failed
JS Unit Tests / test (pull_request) Failing after 29s
Build Test / test (pull_request) Successful in 31s
PHP Unit Tests / test (pull_request) Successful in 1m12s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-04-25 15:41:16 -04:00
parent 86e4772d45
commit 99a68737d1
26 changed files with 902 additions and 596 deletions

View File

@@ -3,11 +3,12 @@
*/
import type { CollectionInterface, CollectionModelInterface, CollectionPropertiesInterface, CollectionPropertiesModelInterface } from "@/types/collection";
import { clonePlain } from './clone-plain';
export class CollectionObject implements CollectionModelInterface {
_data!: CollectionInterface<CollectionPropertiesInterface>;
_properties!: CollectionPropertiesObject;
_properties: CollectionPropertiesObject | undefined = undefined;
constructor() {
this._data = {
@@ -22,29 +23,24 @@ export class CollectionObject implements CollectionModelInterface {
}
fromJson(data: CollectionInterface): CollectionObject {
this._data = data;
this._data = clonePlain(data);
this._properties = undefined;
return this;
}
toJson(): CollectionInterface {
const json = {
...this._data
};
if (this._properties) {
json.properties = this._properties.toJson();
}
return json;
const json = this._properties
? {
...this._data,
properties: this._properties.toJson(),
}
: this._data;
return clonePlain(json);
}
clone(): CollectionObject {
const cloned = new CollectionObject();
cloned._data = {
...this._data,
};
if (this._properties) {
cloned._properties = this._properties.clone();
}
return cloned;
return new CollectionObject().fromJson(this.toJson());
}
/** Immutable Properties */
@@ -112,18 +108,16 @@ export class CollectionPropertiesObject implements CollectionPropertiesModelInte
}
fromJson(data: CollectionPropertiesInterface): CollectionPropertiesObject {
this._data = data;
this._data = clonePlain(data);
return this;
}
toJson(): CollectionPropertiesInterface {
return this._data;
return clonePlain(this._data);
}
clone(): CollectionPropertiesObject {
const cloned = new CollectionPropertiesObject();
cloned._data = { ...this._data };
return cloned;
return new CollectionPropertiesObject().fromJson(this.toJson());
}
/** Immutable Properties */