diff --git a/package-lock.json b/package-lock.json index 2cbea6637..3606c550b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "passbolt-styleguide", - "version": "4.8.0-alpha.8", + "version": "4.8.0-alpha.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "passbolt-styleguide", - "version": "4.8.0-alpha.8", + "version": "4.8.0-alpha.9", "license": "AGPL-3.0", "dependencies": { "@testing-library/dom": "^8.11.3", diff --git a/package.json b/package.json index e625cd156..12ec7cfa6 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "passbolt-styleguide", - "version": "4.8.0-alpha.8", + "version": "4.8.0-alpha.9", "license": "AGPL-3.0", "copyright": "Copyright 2023 Passbolt SA", "description": "Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.", diff --git a/src/shared/models/entity/abstract/entityV2Collection.js b/src/shared/models/entity/abstract/entityV2Collection.js index 119ed918f..02f8bbf40 100644 --- a/src/shared/models/entity/abstract/entityV2Collection.js +++ b/src/shared/models/entity/abstract/entityV2Collection.js @@ -20,11 +20,29 @@ class EntityV2Collection extends EntityCollection { /** * Retrieve the entity class this collection is handling * @return {Class} + * @abstract */ get entityClass() { throw new Error("The collection class should declare the entity class that is handled."); } + /** + * @inheritDoc + * The EntityV2 collection will push the dtos into the collection. + * @throws {EntityCollectionError} If a item does not validate its entity schema. + * @throws {EntityCollectionError} If a item does not validate the collection validation build rules. + */ + constructor(dtos = [], options = {}) { + super(dtos, options); + /* + * Push the items into the collection. + * Use the the _props property where EntityCollection V1 clone the dtos into. + * Delete it after usage. + */ + this.pushMany(this._props, {...options, clone: false}); + this._props = null; + } + /** * Build or clone entity. * @param {object|Entity} data The data of the item to push diff --git a/src/shared/models/entity/abstract/entityV2Collection.test.data.js b/src/shared/models/entity/abstract/entityV2Collection.test.data.js index d3abeba32..d3454850b 100644 --- a/src/shared/models/entity/abstract/entityV2Collection.test.data.js +++ b/src/shared/models/entity/abstract/entityV2Collection.test.data.js @@ -20,10 +20,9 @@ export class TestEntityV2Collection extends EntityV2Collection { return TestEntity; } - constructor(dto, options = {}) { - super(EntitySchema.validate(TestEntityV2Collection.name, dto, TestEntityV2Collection.getSchema()), options); - this.pushMany(this._props, {...options, clone: false}); - this._props = null; + constructor(dtos = [], options = {}) { + dtos = EntitySchema.validate(TestEntityV2Collection.name, dtos, TestEntityV2Collection.getSchema()); + super(dtos, options); } /**