@vived/core 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AppObject/AppObjectEntityRepo.js +16 -2
- package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +1 -1
- package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js +3 -4
- package/dist/cjs/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
- package/dist/esm/AppObject/AppObjectEntityRepo.js +16 -2
- package/dist/esm/AppObject/AppObjectEntityRepo.js.map +1 -1
- package/dist/esm/ExampleFeature/Entities/ExampleRepo.js +3 -4
- package/dist/esm/ExampleFeature/Entities/ExampleRepo.js.map +1 -1
- package/dist/types/AppObject/AppObjectEntityRepo.d.ts +9 -1
- package/dist/types/AppObject/AppObjectEntityRepo.d.ts.map +1 -1
- package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts +1 -1
- package/dist/types/ExampleFeature/Entities/ExampleRepo.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -165,6 +165,19 @@ class AppObjectEntityRepo extends AppObjectEntity_1.AppObjectEntity {
|
|
|
165
165
|
this.getAll = () => {
|
|
166
166
|
return Array.from(this.entityLookup.values());
|
|
167
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Gets an entity by ID, or creates it if it doesn't exist.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} id - The ID of the entity to get or create
|
|
172
|
+
* @returns {T} The existing or newly created entity
|
|
173
|
+
*/
|
|
174
|
+
this.getOrCreate = (id) => {
|
|
175
|
+
const existing = this.getById(id);
|
|
176
|
+
if (existing) {
|
|
177
|
+
return existing;
|
|
178
|
+
}
|
|
179
|
+
return this.create(id);
|
|
180
|
+
};
|
|
168
181
|
}
|
|
169
182
|
/**
|
|
170
183
|
* Adds an entity to the repository.
|
|
@@ -195,7 +208,8 @@ class AppObjectEntityRepo extends AppObjectEntity_1.AppObjectEntity {
|
|
|
195
208
|
*/
|
|
196
209
|
create(id) {
|
|
197
210
|
const idToUse = id ?? (0, Utilities_1.generateUniqueID)();
|
|
198
|
-
const
|
|
211
|
+
const ao = this.appObjects.getOrCreate(idToUse);
|
|
212
|
+
const entity = this.entityFactory(ao);
|
|
199
213
|
this.add(entity);
|
|
200
214
|
return entity;
|
|
201
215
|
}
|
|
@@ -209,7 +223,7 @@ class AppObjectEntityRepo extends AppObjectEntity_1.AppObjectEntity {
|
|
|
209
223
|
* @returns {T} A new entity instance
|
|
210
224
|
* @throws {Error} If not overridden in derived class
|
|
211
225
|
*/
|
|
212
|
-
entityFactory(
|
|
226
|
+
entityFactory(appObject) {
|
|
213
227
|
// Override this method in derived classes to provide entity creation logic
|
|
214
228
|
throw new Error("Entity factory not implemented.");
|
|
215
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAC3C,4CAAgD;AAChD,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,mBAEX,SAAQ,iCAAe;IAFzB;;QAGU,iBAAY,GAAG,IAAI,GAAG,EAAa,CAAC;QAEpC,2BAAsB,GAAG,IAAI,uBAAY,EAAK,CAAC;QACvD;;;;WAIG;QACH,2BAAsB,GAAG,CAAC,QAAkC,EAAE,EAAE;YAC9D,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC;QAEF;;;;WAIG;QACH,8BAAyB,GAAG,CAAC,QAAkC,EAAQ,EAAE;YACvE,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEM,6BAAwB,GAAG,IAAI,uBAAY,EAAK,CAAC;QACzD;;;;WAIG;QACH,6BAAwB,GAAG,CAAC,QAAoC,EAAE,EAAE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C7C,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAW;QAChB,MAAM,OAAO,GAAG,EAAE,IAAI,IAAA,4BAAgB,GAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAU;QACtB,2EAA2E;QAC3E,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CA8EF;AAjMD,kDAiMC","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { generateUniqueID } from \"../Utilities\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * A repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class provides a centralized way to store, retrieve, and manage\r\n * entities that are associated with specific AppObjects. It implements the observer\r\n * pattern to notify listeners when entities are added or removed.\r\n *\r\n * Derived classes should override the `entityFactory` method to provide custom\r\n * entity creation logic for the `create` method.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntity\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a custom repository with entity factory\r\n * class PlayerRepo extends AppObjectEntityRepo<PlayerEntity> {\r\n * entityFactory(id: string): PlayerEntity {\r\n * const appObject = makeAppObject(id, this.appObjects);\r\n * return new PlayerEntity(appObject);\r\n * }\r\n * }\r\n *\r\n * const playerRepo = new PlayerRepo(repoAppObject);\r\n *\r\n * // Create a new player with auto-generated ID\r\n * const player = playerRepo.create();\r\n *\r\n * // Create a new player with specific ID\r\n * const specificPlayer = playerRepo.create(\"player1\");\r\n *\r\n * // Get a player by its ID\r\n * const retrievedPlayer = playerRepo.getById(\"player1\");\r\n * ```\r\n */\r\nexport class AppObjectEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntity {\r\n private entityLookup = new Map<string, T>();\r\n\r\n private onEntityAddedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is added to the repository.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added\r\n */\r\n addEntityAddedObserver = (observer: (addedEntity: T) => void) => {\r\n this.onEntityAddedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity addition notifications.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityAddedObserver = (observer: (addedEntity: T) => void): void => {\r\n this.onEntityAddedObservers.remove(observer);\r\n };\r\n\r\n private onEntityRemovedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is removed from the repository.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed\r\n */\r\n addEntityRemovedObserver = (observer: (removedEntity: T) => void) => {\r\n this.onEntityRemovedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity removal notifications.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityRemovedObserver = (\r\n observer: (removedEntity: T) => void\r\n ): void => {\r\n this.onEntityRemovedObservers.remove(observer);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given ID, false otherwise\r\n */\r\n has = (id: string): boolean => {\r\n return this.entityLookup.has(id);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise\r\n * @deprecated Use has instead\r\n */\r\n hasForAppObject = (appObjectID: string): boolean => {\r\n return this.has(appObjectID);\r\n };\r\n\r\n /**\r\n * Adds an entity to the repository.\r\n *\r\n * If an entity with the same AppObject ID already exists, it is replaced.\r\n * Notifies all registered observers after the entity is added.\r\n *\r\n * @param {T} entity - The entity to add\r\n */\r\n add(entity: T) {\r\n const existing = this.entityLookup.get(entity.appObject.id);\r\n if (existing) {\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n }\r\n\r\n this.entityLookup.set(entity.appObject.id, entity);\r\n entity.addChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityAddedObservers.notify(entity);\r\n }\r\n\r\n /**\r\n * Creates a new entity with the specified or auto-generated ID and adds it to the repository.\r\n *\r\n * This method uses the `entityFactory` method to create the entity instance.\r\n * If no ID is provided, a unique ID is generated automatically.\r\n *\r\n * @param {string} [id] - Optional ID for the entity. If not provided, a unique ID is generated.\r\n * @returns {T} The newly created entity\r\n */\r\n create(id?: string): T {\r\n const idToUse = id ?? generateUniqueID();\r\n const entity = this.entityFactory(idToUse);\r\n this.add(entity);\r\n return entity;\r\n }\r\n\r\n /**\r\n * Factory method for creating entity instances.\r\n *\r\n * This method must be overridden in derived classes to provide custom entity creation logic.\r\n * It is called by the `create` method to instantiate new entities.\r\n *\r\n * @param {string} id - The ID to use for the new entity\r\n * @returns {T} A new entity instance\r\n * @throws {Error} If not overridden in derived class\r\n */\r\n entityFactory(id: string): T {\r\n // Override this method in derived classes to provide entity creation logic\r\n throw new Error(\"Entity factory not implemented.\");\r\n }\r\n\r\n /**\r\n * Removes the entity associated with the specified ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n */\r\n removeById = (id: string) => {\r\n const existing = this.entityLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.entityLookup.delete(id);\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityRemovedObservers.notify(existing);\r\n };\r\n\r\n /**\r\n * Removes the entity associated with the specified AppObject ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n * @deprecated Use removeById instead\r\n */\r\n removeForAppObject = (id: string) => {\r\n this.removeById(id);\r\n };\r\n\r\n /**\r\n * Removes all entities from the repository.\r\n *\r\n * Unsubscribes from all entity change observers and notifies all registered\r\n * removal observers for each entity before clearing the repository.\r\n */\r\n deleteAll = () => {\r\n const entities = Array.from(this.entityLookup.values());\r\n\r\n entities.forEach((entity) => {\r\n entity.removeChangeObserver(this.notifyOnChange);\r\n this.onEntityRemovedObservers.notify(entity);\r\n });\r\n\r\n this.entityLookup.clear();\r\n this.notifyOnChange();\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n */\r\n getById = (id: string): T | undefined => {\r\n return this.entityLookup.get(id);\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n * @deprecated Use getById instead\r\n */\r\n getForAppObject = (appObjectID: string): T | undefined => {\r\n return this.getById(appObjectID);\r\n };\r\n\r\n /**\r\n * Gets all entities in the repository.\r\n *\r\n * @returns {T[]} An array of all entities\r\n */\r\n getAll = (): T[] => {\r\n return Array.from(this.entityLookup.values());\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"AppObjectEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAC3C,4CAAgD;AAEhD,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,mBAEX,SAAQ,iCAAe;IAFzB;;QAGU,iBAAY,GAAG,IAAI,GAAG,EAAa,CAAC;QAEpC,2BAAsB,GAAG,IAAI,uBAAY,EAAK,CAAC;QACvD;;;;WAIG;QACH,2BAAsB,GAAG,CAAC,QAAkC,EAAE,EAAE;YAC9D,IAAI,CAAC,sBAAsB,CAAC,G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AAC,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC;IA9IC;;;;;;;OAOG;IACH,GAAG,CAAC,MAAS;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAW;QAChB,MAAM,OAAO,GAAG,EAAE,IAAI,IAAA,4BAAgB,GAAE,CAAC;QACzC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACH,aAAa,CAAC,SAAoB;QAChC,2EAA2E;QAC3E,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CA4FF;AAhND,kDAgNC","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { generateUniqueID } from \"../Utilities\";\r\nimport { AppObject } from \"./AppObject\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * A repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class provides a centralized way to store, retrieve, and manage\r\n * entities that are associated with specific AppObjects. It implements the observer\r\n * pattern to notify listeners when entities are added or removed.\r\n *\r\n * Derived classes should override the `entityFactory` method to provide custom\r\n * entity creation logic for the `create` method.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntity\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a custom repository with entity factory\r\n * class PlayerRepo extends AppObjectEntityRepo<PlayerEntity> {\r\n * entityFactory(id: string): PlayerEntity {\r\n * const appObject = makeAppObject(id, this.appObjects);\r\n * return new PlayerEntity(appObject);\r\n * }\r\n * }\r\n *\r\n * const playerRepo = new PlayerRepo(repoAppObject);\r\n *\r\n * // Create a new player with auto-generated ID\r\n * const player = playerRepo.create();\r\n *\r\n * // Create a new player with specific ID\r\n * const specificPlayer = playerRepo.create(\"player1\");\r\n *\r\n * // Get a player by its ID\r\n * const retrievedPlayer = playerRepo.getById(\"player1\");\r\n * ```\r\n */\r\nexport class AppObjectEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntity {\r\n private entityLookup = new Map<string, T>();\r\n\r\n private onEntityAddedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is added to the repository.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added\r\n */\r\n addEntityAddedObserver = (observer: (addedEntity: T) => void) => {\r\n this.onEntityAddedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity addition notifications.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityAddedObserver = (observer: (addedEntity: T) => void): void => {\r\n this.onEntityAddedObservers.remove(observer);\r\n };\r\n\r\n private onEntityRemovedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is removed from the repository.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed\r\n */\r\n addEntityRemovedObserver = (observer: (removedEntity: T) => void) => {\r\n this.onEntityRemovedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity removal notifications.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityRemovedObserver = (\r\n observer: (removedEntity: T) => void\r\n ): void => {\r\n this.onEntityRemovedObservers.remove(observer);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given ID, false otherwise\r\n */\r\n has = (id: string): boolean => {\r\n return this.entityLookup.has(id);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise\r\n * @deprecated Use has instead\r\n */\r\n hasForAppObject = (appObjectID: string): boolean => {\r\n return this.has(appObjectID);\r\n };\r\n\r\n /**\r\n * Adds an entity to the repository.\r\n *\r\n * If an entity with the same AppObject ID already exists, it is replaced.\r\n * Notifies all registered observers after the entity is added.\r\n *\r\n * @param {T} entity - The entity to add\r\n */\r\n add(entity: T) {\r\n const existing = this.entityLookup.get(entity.appObject.id);\r\n if (existing) {\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n }\r\n\r\n this.entityLookup.set(entity.appObject.id, entity);\r\n entity.addChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityAddedObservers.notify(entity);\r\n }\r\n\r\n /**\r\n * Creates a new entity with the specified or auto-generated ID and adds it to the repository.\r\n *\r\n * This method uses the `entityFactory` method to create the entity instance.\r\n * If no ID is provided, a unique ID is generated automatically.\r\n *\r\n * @param {string} [id] - Optional ID for the entity. If not provided, a unique ID is generated.\r\n * @returns {T} The newly created entity\r\n */\r\n create(id?: string): T {\r\n const idToUse = id ?? generateUniqueID();\r\n const ao = this.appObjects.getOrCreate(idToUse);\r\n const entity = this.entityFactory(ao);\r\n this.add(entity);\r\n return entity;\r\n }\r\n\r\n /**\r\n * Factory method for creating entity instances.\r\n *\r\n * This method must be overridden in derived classes to provide custom entity creation logic.\r\n * It is called by the `create` method to instantiate new entities.\r\n *\r\n * @param {string} id - The ID to use for the new entity\r\n * @returns {T} A new entity instance\r\n * @throws {Error} If not overridden in derived class\r\n */\r\n entityFactory(appObject: AppObject): T {\r\n // Override this method in derived classes to provide entity creation logic\r\n throw new Error(\"Entity factory not implemented.\");\r\n }\r\n\r\n /**\r\n * Removes the entity associated with the specified ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n */\r\n removeById = (id: string) => {\r\n const existing = this.entityLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.entityLookup.delete(id);\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityRemovedObservers.notify(existing);\r\n };\r\n\r\n /**\r\n * Removes the entity associated with the specified AppObject ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n * @deprecated Use removeById instead\r\n */\r\n removeForAppObject = (id: string) => {\r\n this.removeById(id);\r\n };\r\n\r\n /**\r\n * Removes all entities from the repository.\r\n *\r\n * Unsubscribes from all entity change observers and notifies all registered\r\n * removal observers for each entity before clearing the repository.\r\n */\r\n deleteAll = () => {\r\n const entities = Array.from(this.entityLookup.values());\r\n\r\n entities.forEach((entity) => {\r\n entity.removeChangeObserver(this.notifyOnChange);\r\n this.onEntityRemovedObservers.notify(entity);\r\n });\r\n\r\n this.entityLookup.clear();\r\n this.notifyOnChange();\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n */\r\n getById = (id: string): T | undefined => {\r\n return this.entityLookup.get(id);\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n * @deprecated Use getById instead\r\n */\r\n getForAppObject = (appObjectID: string): T | undefined => {\r\n return this.getById(appObjectID);\r\n };\r\n\r\n /**\r\n * Gets all entities in the repository.\r\n *\r\n * @returns {T[]} An array of all entities\r\n */\r\n getAll = (): T[] => {\r\n return Array.from(this.entityLookup.values());\r\n };\r\n\r\n /**\r\n * Gets an entity by ID, or creates it if it doesn't exist.\r\n *\r\n * @param {string} id - The ID of the entity to get or create\r\n * @returns {T} The existing or newly created entity\r\n */\r\n getOrCreate = (id: string): T => {\r\n const existing = this.getById(id);\r\n if (existing) {\r\n return existing;\r\n }\r\n return this.create(id);\r\n };\r\n}\r\n"]}
|
|
@@ -77,12 +77,11 @@ function makeExampleRepo(appObject) {
|
|
|
77
77
|
class ExampleRepoImp extends ExampleRepo {
|
|
78
78
|
/**
|
|
79
79
|
* Factory implementation for creating ExampleEntity instances
|
|
80
|
-
* @param
|
|
80
|
+
* @param appObject The AppObject for the entity
|
|
81
81
|
* @returns A newly created ExampleEntity
|
|
82
82
|
*/
|
|
83
|
-
entityFactory(
|
|
84
|
-
|
|
85
|
-
return (0, ExampleEntity_1.makeExampleEntity)(ao);
|
|
83
|
+
entityFactory(appObject) {
|
|
84
|
+
return (0, ExampleEntity_1.makeExampleEntity)(appObject);
|
|
86
85
|
}
|
|
87
86
|
/**
|
|
88
87
|
* Deletes an ExampleEntity from the repository by its AppObject ID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AA6DH,0CAEC;AA7DD,+CAAgF;AAChF,mDAAmE;AAKnE;;;GAGG;AACH,MAAsB,WAAY,SAAQ,+BAAkC;IAO1E;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB;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,CAAC,EAAE,CAAC,EAAE,YAAY,CAAc,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAoB;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAc,WAAW,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;;AAzCH,kCA0CC;AAzCC,gDAAgD;AAChC,gBAAI,GAAG,iBAAiB,CAAC;AA0C3C;;;;GAIG;AACH,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,WAAW;IACtC;;;;OAIG;IACH,aAAa,CAAC,SAAoB;QAChC,OAAO,IAAA,iCAAiB,EAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,EAAU;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n *\r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n *\r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n *\r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport { AppObject, AppObjectEntityRepo, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (appObject: AppObject) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Factory implementation for creating ExampleEntity instances\r\n * @param appObject The AppObject for the entity\r\n * @returns A newly created ExampleEntity\r\n */\r\n entityFactory(appObject: AppObject): ExampleEntity {\r\n return makeExampleEntity(appObject);\r\n }\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getById(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeById(id);\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
|
|
@@ -162,6 +162,19 @@ export class AppObjectEntityRepo extends AppObjectEntity {
|
|
|
162
162
|
this.getAll = () => {
|
|
163
163
|
return Array.from(this.entityLookup.values());
|
|
164
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* Gets an entity by ID, or creates it if it doesn't exist.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} id - The ID of the entity to get or create
|
|
169
|
+
* @returns {T} The existing or newly created entity
|
|
170
|
+
*/
|
|
171
|
+
this.getOrCreate = (id) => {
|
|
172
|
+
const existing = this.getById(id);
|
|
173
|
+
if (existing) {
|
|
174
|
+
return existing;
|
|
175
|
+
}
|
|
176
|
+
return this.create(id);
|
|
177
|
+
};
|
|
165
178
|
}
|
|
166
179
|
/**
|
|
167
180
|
* Adds an entity to the repository.
|
|
@@ -192,7 +205,8 @@ export class AppObjectEntityRepo extends AppObjectEntity {
|
|
|
192
205
|
*/
|
|
193
206
|
create(id) {
|
|
194
207
|
const idToUse = id ?? generateUniqueID();
|
|
195
|
-
const
|
|
208
|
+
const ao = this.appObjects.getOrCreate(idToUse);
|
|
209
|
+
const entity = this.entityFactory(ao);
|
|
196
210
|
this.add(entity);
|
|
197
211
|
return entity;
|
|
198
212
|
}
|
|
@@ -206,7 +220,7 @@ export class AppObjectEntityRepo extends AppObjectEntity {
|
|
|
206
220
|
* @returns {T} A new entity instance
|
|
207
221
|
* @throws {Error} If not overridden in derived class
|
|
208
222
|
*/
|
|
209
|
-
entityFactory(
|
|
223
|
+
entityFactory(appObject) {
|
|
210
224
|
// Override this method in derived classes to provide entity creation logic
|
|
211
225
|
throw new Error("Entity factory not implemented.");
|
|
212
226
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,mBAEX,SAAQ,eAAe;IAFzB;;QAGU,iBAAY,GAAG,IAAI,GAAG,EAAa,CAAC;QAEpC,2BAAsB,GAAG,IAAI,YAAY,EAAK,CAAC;QACvD;;;;WAIG;QACH,2BAAsB,GAAG,CAAC,QAAkC,EAAE,EAAE;YAC9D,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC;QAEF;;;;WAIG;QACH,8BAAyB,GAAG,CAAC,QAAkC,EAAQ,EAAE;YACvE,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEM,6BAAwB,GAAG,IAAI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,EAAE,CAAC;QACtB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAW;QAChB,MAAM,OAAO,GAAG,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAU;QACtB,2EAA2E;QAC3E,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CA8EF","sourcesContent":["import { ObserverList } from \"../Entities\";\r\nimport { generateUniqueID } from \"../Utilities\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * A repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class provides a centralized way to store, retrieve, and manage\r\n * entities that are associated with specific AppObjects. It implements the observer\r\n * pattern to notify listeners when entities are added or removed.\r\n *\r\n * Derived classes should override the `entityFactory` method to provide custom\r\n * entity creation logic for the `create` method.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntity\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a custom repository with entity factory\r\n * class PlayerRepo extends AppObjectEntityRepo<PlayerEntity> {\r\n * entityFactory(id: string): PlayerEntity {\r\n * const appObject = makeAppObject(id, this.appObjects);\r\n * return new PlayerEntity(appObject);\r\n * }\r\n * }\r\n *\r\n * const playerRepo = new PlayerRepo(repoAppObject);\r\n *\r\n * // Create a new player with auto-generated ID\r\n * const player = playerRepo.create();\r\n *\r\n * // Create a new player with specific ID\r\n * const specificPlayer = playerRepo.create(\"player1\");\r\n *\r\n * // Get a player by its ID\r\n * const retrievedPlayer = playerRepo.getById(\"player1\");\r\n * ```\r\n */\r\nexport class AppObjectEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntity {\r\n private entityLookup = new Map<string, T>();\r\n\r\n private onEntityAddedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is added to the repository.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added\r\n */\r\n addEntityAddedObserver = (observer: (addedEntity: T) => void) => {\r\n this.onEntityAddedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity addition notifications.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityAddedObserver = (observer: (addedEntity: T) => void): void => {\r\n this.onEntityAddedObservers.remove(observer);\r\n };\r\n\r\n private onEntityRemovedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is removed from the repository.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed\r\n */\r\n addEntityRemovedObserver = (observer: (removedEntity: T) => void) => {\r\n this.onEntityRemovedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity removal notifications.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityRemovedObserver = (\r\n observer: (removedEntity: T) => void\r\n ): void => {\r\n this.onEntityRemovedObservers.remove(observer);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given ID, false otherwise\r\n */\r\n has = (id: string): boolean => {\r\n return this.entityLookup.has(id);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise\r\n * @deprecated Use has instead\r\n */\r\n hasForAppObject = (appObjectID: string): boolean => {\r\n return this.has(appObjectID);\r\n };\r\n\r\n /**\r\n * Adds an entity to the repository.\r\n *\r\n * If an entity with the same AppObject ID already exists, it is replaced.\r\n * Notifies all registered observers after the entity is added.\r\n *\r\n * @param {T} entity - The entity to add\r\n */\r\n add(entity: T) {\r\n const existing = this.entityLookup.get(entity.appObject.id);\r\n if (existing) {\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n }\r\n\r\n this.entityLookup.set(entity.appObject.id, entity);\r\n entity.addChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityAddedObservers.notify(entity);\r\n }\r\n\r\n /**\r\n * Creates a new entity with the specified or auto-generated ID and adds it to the repository.\r\n *\r\n * This method uses the `entityFactory` method to create the entity instance.\r\n * If no ID is provided, a unique ID is generated automatically.\r\n *\r\n * @param {string} [id] - Optional ID for the entity. If not provided, a unique ID is generated.\r\n * @returns {T} The newly created entity\r\n */\r\n create(id?: string): T {\r\n const idToUse = id ?? generateUniqueID();\r\n const entity = this.entityFactory(idToUse);\r\n this.add(entity);\r\n return entity;\r\n }\r\n\r\n /**\r\n * Factory method for creating entity instances.\r\n *\r\n * This method must be overridden in derived classes to provide custom entity creation logic.\r\n * It is called by the `create` method to instantiate new entities.\r\n *\r\n * @param {string} id - The ID to use for the new entity\r\n * @returns {T} A new entity instance\r\n * @throws {Error} If not overridden in derived class\r\n */\r\n entityFactory(id: string): T {\r\n // Override this method in derived classes to provide entity creation logic\r\n throw new Error(\"Entity factory not implemented.\");\r\n }\r\n\r\n /**\r\n * Removes the entity associated with the specified ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n */\r\n removeById = (id: string) => {\r\n const existing = this.entityLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.entityLookup.delete(id);\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityRemovedObservers.notify(existing);\r\n };\r\n\r\n /**\r\n * Removes the entity associated with the specified AppObject ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n * @deprecated Use removeById instead\r\n */\r\n removeForAppObject = (id: string) => {\r\n this.removeById(id);\r\n };\r\n\r\n /**\r\n * Removes all entities from the repository.\r\n *\r\n * Unsubscribes from all entity change observers and notifies all registered\r\n * removal observers for each entity before clearing the repository.\r\n */\r\n deleteAll = () => {\r\n const entities = Array.from(this.entityLookup.values());\r\n\r\n entities.forEach((entity) => {\r\n entity.removeChangeObserver(this.notifyOnChange);\r\n this.onEntityRemovedObservers.notify(entity);\r\n });\r\n\r\n this.entityLookup.clear();\r\n this.notifyOnChange();\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n */\r\n getById = (id: string): T | undefined => {\r\n return this.entityLookup.get(id);\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n * @deprecated Use getById instead\r\n */\r\n getForAppObject = (appObjectID: string): T | undefined => {\r\n return this.getById(appObjectID);\r\n };\r\n\r\n /**\r\n * Gets all entities in the repository.\r\n *\r\n * @returns {T[]} An array of all entities\r\n */\r\n getAll = (): T[] => {\r\n return Array.from(this.entityLookup.values());\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"AppObjectEntityRepo.js","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,mBAEX,SAAQ,eAAe;IAFzB;;QAGU,iBAAY,GAAG,I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{ generateUniqueID } from \"../Utilities\";\r\nimport { AppObject } from \"./AppObject\";\r\nimport { AppObjectEntity } from \"./AppObjectEntity\";\r\n\r\n/**\r\n * A repository for managing collections of AppObjectEntity instances.\r\n *\r\n * This generic class provides a centralized way to store, retrieve, and manage\r\n * entities that are associated with specific AppObjects. It implements the observer\r\n * pattern to notify listeners when entities are added or removed.\r\n *\r\n * Derived classes should override the `entityFactory` method to provide custom\r\n * entity creation logic for the `create` method.\r\n *\r\n * @template T - The type of entities managed by this repository, must extend AppObjectEntity\r\n * @extends AppObjectEntity\r\n *\r\n * @example\r\n * ```typescript\r\n * // Create a custom repository with entity factory\r\n * class PlayerRepo extends AppObjectEntityRepo<PlayerEntity> {\r\n * entityFactory(id: string): PlayerEntity {\r\n * const appObject = makeAppObject(id, this.appObjects);\r\n * return new PlayerEntity(appObject);\r\n * }\r\n * }\r\n *\r\n * const playerRepo = new PlayerRepo(repoAppObject);\r\n *\r\n * // Create a new player with auto-generated ID\r\n * const player = playerRepo.create();\r\n *\r\n * // Create a new player with specific ID\r\n * const specificPlayer = playerRepo.create(\"player1\");\r\n *\r\n * // Get a player by its ID\r\n * const retrievedPlayer = playerRepo.getById(\"player1\");\r\n * ```\r\n */\r\nexport class AppObjectEntityRepo<\r\n T extends AppObjectEntity,\r\n> extends AppObjectEntity {\r\n private entityLookup = new Map<string, T>();\r\n\r\n private onEntityAddedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is added to the repository.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to invoke when an entity is added\r\n */\r\n addEntityAddedObserver = (observer: (addedEntity: T) => void) => {\r\n this.onEntityAddedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity addition notifications.\r\n *\r\n * @param {(addedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityAddedObserver = (observer: (addedEntity: T) => void): void => {\r\n this.onEntityAddedObservers.remove(observer);\r\n };\r\n\r\n private onEntityRemovedObservers = new ObserverList<T>();\r\n /**\r\n * Registers an observer to be notified when an entity is removed from the repository.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to invoke when an entity is removed\r\n */\r\n addEntityRemovedObserver = (observer: (removedEntity: T) => void) => {\r\n this.onEntityRemovedObservers.add(observer);\r\n };\r\n\r\n /**\r\n * Removes an observer previously registered for entity removal notifications.\r\n *\r\n * @param {(removedEntity: T) => void} observer - The callback function to remove\r\n */\r\n removeEntityRemovedObserver = (\r\n observer: (removedEntity: T) => void\r\n ): void => {\r\n this.onEntityRemovedObservers.remove(observer);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given ID, false otherwise\r\n */\r\n has = (id: string): boolean => {\r\n return this.entityLookup.has(id);\r\n };\r\n\r\n /**\r\n * Checks if an entity exists for the given AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {boolean} True if an entity exists for the given AppObject ID, false otherwise\r\n * @deprecated Use has instead\r\n */\r\n hasForAppObject = (appObjectID: string): boolean => {\r\n return this.has(appObjectID);\r\n };\r\n\r\n /**\r\n * Adds an entity to the repository.\r\n *\r\n * If an entity with the same AppObject ID already exists, it is replaced.\r\n * Notifies all registered observers after the entity is added.\r\n *\r\n * @param {T} entity - The entity to add\r\n */\r\n add(entity: T) {\r\n const existing = this.entityLookup.get(entity.appObject.id);\r\n if (existing) {\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n }\r\n\r\n this.entityLookup.set(entity.appObject.id, entity);\r\n entity.addChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityAddedObservers.notify(entity);\r\n }\r\n\r\n /**\r\n * Creates a new entity with the specified or auto-generated ID and adds it to the repository.\r\n *\r\n * This method uses the `entityFactory` method to create the entity instance.\r\n * If no ID is provided, a unique ID is generated automatically.\r\n *\r\n * @param {string} [id] - Optional ID for the entity. If not provided, a unique ID is generated.\r\n * @returns {T} The newly created entity\r\n */\r\n create(id?: string): T {\r\n const idToUse = id ?? generateUniqueID();\r\n const ao = this.appObjects.getOrCreate(idToUse);\r\n const entity = this.entityFactory(ao);\r\n this.add(entity);\r\n return entity;\r\n }\r\n\r\n /**\r\n * Factory method for creating entity instances.\r\n *\r\n * This method must be overridden in derived classes to provide custom entity creation logic.\r\n * It is called by the `create` method to instantiate new entities.\r\n *\r\n * @param {string} id - The ID to use for the new entity\r\n * @returns {T} A new entity instance\r\n * @throws {Error} If not overridden in derived class\r\n */\r\n entityFactory(appObject: AppObject): T {\r\n // Override this method in derived classes to provide entity creation logic\r\n throw new Error(\"Entity factory not implemented.\");\r\n }\r\n\r\n /**\r\n * Removes the entity associated with the specified ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n */\r\n removeById = (id: string) => {\r\n const existing = this.entityLookup.get(id);\r\n if (!existing) return;\r\n\r\n this.entityLookup.delete(id);\r\n existing.removeChangeObserver(this.notifyOnChange);\r\n this.notifyOnChange();\r\n this.onEntityRemovedObservers.notify(existing);\r\n };\r\n\r\n /**\r\n * Removes the entity associated with the specified AppObject ID.\r\n *\r\n * Notifies all registered observers after the entity is removed.\r\n *\r\n * @param {string} id - The ID of the AppObject whose entity should be removed\r\n * @deprecated Use removeById instead\r\n */\r\n removeForAppObject = (id: string) => {\r\n this.removeById(id);\r\n };\r\n\r\n /**\r\n * Removes all entities from the repository.\r\n *\r\n * Unsubscribes from all entity change observers and notifies all registered\r\n * removal observers for each entity before clearing the repository.\r\n */\r\n deleteAll = () => {\r\n const entities = Array.from(this.entityLookup.values());\r\n\r\n entities.forEach((entity) => {\r\n entity.removeChangeObserver(this.notifyOnChange);\r\n this.onEntityRemovedObservers.notify(entity);\r\n });\r\n\r\n this.entityLookup.clear();\r\n this.notifyOnChange();\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified ID.\r\n *\r\n * @param {string} id - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n */\r\n getById = (id: string): T | undefined => {\r\n return this.entityLookup.get(id);\r\n };\r\n\r\n /**\r\n * Gets the entity associated with the specified AppObject ID.\r\n *\r\n * @param {string} appObjectID - The ID of the AppObject\r\n * @returns {T | undefined} The entity if found, undefined otherwise\r\n * @deprecated Use getById instead\r\n */\r\n getForAppObject = (appObjectID: string): T | undefined => {\r\n return this.getById(appObjectID);\r\n };\r\n\r\n /**\r\n * Gets all entities in the repository.\r\n *\r\n * @returns {T[]} An array of all entities\r\n */\r\n getAll = (): T[] => {\r\n return Array.from(this.entityLookup.values());\r\n };\r\n\r\n /**\r\n * Gets an entity by ID, or creates it if it doesn't exist.\r\n *\r\n * @param {string} id - The ID of the entity to get or create\r\n * @returns {T} The existing or newly created entity\r\n */\r\n getOrCreate = (id: string): T => {\r\n const existing = this.getById(id);\r\n if (existing) {\r\n return existing;\r\n }\r\n return this.create(id);\r\n };\r\n}\r\n"]}
|
|
@@ -72,12 +72,11 @@ export function makeExampleRepo(appObject) {
|
|
|
72
72
|
class ExampleRepoImp extends ExampleRepo {
|
|
73
73
|
/**
|
|
74
74
|
* Factory implementation for creating ExampleEntity instances
|
|
75
|
-
* @param
|
|
75
|
+
* @param appObject The AppObject for the entity
|
|
76
76
|
* @returns A newly created ExampleEntity
|
|
77
77
|
*/
|
|
78
|
-
entityFactory(
|
|
79
|
-
|
|
80
|
-
return makeExampleEntity(ao);
|
|
78
|
+
entityFactory(appObject) {
|
|
79
|
+
return makeExampleEntity(appObject);
|
|
81
80
|
}
|
|
82
81
|
/**
|
|
83
82
|
* Deletes an ExampleEntity from the repository by its AppObject ID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleRepo.js","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAa,mBAAmB,EAAiB,MAAM,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C;CACF","sourcesContent":["/**\r\n * ExampleRepo.ts\r\n *\r\n * This file demonstrates how to implement a repository to manage collections of entities.\r\n * Repositories are responsible for creating, retrieving, and deleting entities.\r\n *\r\n * Key concepts:\r\n * - Repositories extend AppObjectEntityRepo<T> where T is the entity type\r\n * - They provide methods to create and delete entities\r\n * - They manage collections of entities and provide access to them\r\n * - They can use custom entity factories to create specialized entities\r\n *\r\n * Usage pattern:\r\n * 1. Get or create a repository using getById, get, or addIfMissing\r\n * 2. Use the repository to create new entities\r\n * 3. Access entities through the repository's getters\r\n * 4. Delete entities through the repository when they're no longer needed\r\n */\r\n\r\nimport { AppObject, AppObjectEntityRepo, AppObjectRepo } from \"../../AppObject\";\r\nimport { ExampleEntity, makeExampleEntity } from \"./ExampleEntity\";\r\n\r\n/** Type definition for a factory function that creates ExampleEntity instances */\r\nexport type ExampleEntityFactory = (appObject: AppObject) => ExampleEntity;\r\n\r\n/**\r\n * ExampleRepo manages a collection of ExampleEntity instances.\r\n * Abstract class provides the interface and static helper methods.\r\n */\r\nexport abstract class ExampleRepo extends AppObjectEntityRepo<ExampleEntity> {\r\n /** Unique type identifier for this component */\r\n static readonly type = \"ExampleRepoType\";\r\n\r\n /** Deletes an entity by its AppObject ID */\r\n abstract deleteExampleEntity(id: string): void;\r\n\r\n /**\r\n * Retrieves an ExampleRepo component from an AppObject\r\n * @param appObj The AppObject to get the component from\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static get(appObj: AppObject): ExampleRepo | undefined {\r\n return appObj.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Retrieves an ExampleRepo by its parent AppObject's ID\r\n * @param id The ID of the parent AppObject\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The ExampleRepo component or undefined if not found\r\n */\r\n static getById(\r\n id: string,\r\n appObjects: AppObjectRepo\r\n ): ExampleRepo | undefined {\r\n return appObjects.get(id)?.getComponent<ExampleRepo>(this.type);\r\n }\r\n\r\n /**\r\n * Ensures an ExampleRepo exists on the AppObject, creating one if needed\r\n * @param appObject The AppObject to check/add the component to\r\n * @returns The existing or newly created ExampleRepo\r\n */\r\n static addIfMissing(appObject: AppObject): ExampleRepo {\r\n const existing = appObject.getComponent<ExampleRepo>(ExampleRepo.type);\r\n if (existing) {\r\n return existing;\r\n } else {\r\n return makeExampleRepo(appObject);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new ExampleRepo\r\n * @param appObject The AppObject to attach the repo to\r\n * @returns A new ExampleRepo instance\r\n */\r\nexport function makeExampleRepo(appObject: AppObject): ExampleRepo {\r\n return new ExampleRepoImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of ExampleRepo\r\n * This private class handles the actual implementation details\r\n */\r\nclass ExampleRepoImp extends ExampleRepo {\r\n /**\r\n * Factory implementation for creating ExampleEntity instances\r\n * @param appObject The AppObject for the entity\r\n * @returns A newly created ExampleEntity\r\n */\r\n entityFactory(appObject: AppObject): ExampleEntity {\r\n return makeExampleEntity(appObject);\r\n }\r\n\r\n /**\r\n * Deletes an ExampleEntity from the repository by its AppObject ID\r\n * @param id The ID of the entity's AppObject\r\n */\r\n deleteExampleEntity(id: string): void {\r\n const entity = this.getById(id);\r\n if (!entity) return;\r\n\r\n entity.appObject.dispose();\r\n this.removeById(id);\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, ExampleRepo.type);\r\n }\r\n}\r\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AppObject } from "./AppObject";
|
|
1
2
|
import { AppObjectEntity } from "./AppObjectEntity";
|
|
2
3
|
/**
|
|
3
4
|
* A repository for managing collections of AppObjectEntity instances.
|
|
@@ -106,7 +107,7 @@ export declare class AppObjectEntityRepo<T extends AppObjectEntity> extends AppO
|
|
|
106
107
|
* @returns {T} A new entity instance
|
|
107
108
|
* @throws {Error} If not overridden in derived class
|
|
108
109
|
*/
|
|
109
|
-
entityFactory(
|
|
110
|
+
entityFactory(appObject: AppObject): T;
|
|
110
111
|
/**
|
|
111
112
|
* Removes the entity associated with the specified ID.
|
|
112
113
|
*
|
|
@@ -152,5 +153,12 @@ export declare class AppObjectEntityRepo<T extends AppObjectEntity> extends AppO
|
|
|
152
153
|
* @returns {T[]} An array of all entities
|
|
153
154
|
*/
|
|
154
155
|
getAll: () => T[];
|
|
156
|
+
/**
|
|
157
|
+
* Gets an entity by ID, or creates it if it doesn't exist.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} id - The ID of the entity to get or create
|
|
160
|
+
* @returns {T} The existing or newly created entity
|
|
161
|
+
*/
|
|
162
|
+
getOrCreate: (id: string) => T;
|
|
155
163
|
}
|
|
156
164
|
//# sourceMappingURL=AppObjectEntityRepo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppObjectEntityRepo.d.ts","sourceRoot":"","sources":["../../../src/AppObject/AppObjectEntityRepo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,mBAAmB,CAC9B,CAAC,SAAS,eAAe,CACzB,SAAQ,eAAe;IACvB,OAAO,CAAC,YAAY,CAAwB;IAE5C,OAAO,CAAC,sBAAsB,CAAyB;IACvD;;;;OAIG;IACH,sBAAsB,GAAI,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,UAE1D;IAEF;;;;OAIG;IACH,yBAAyB,GAAI,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,KAAG,IAAI,CAEpE;IAEF,OAAO,CAAC,wBAAwB,CAAyB;IACzD;;;;OAIG;IACH,wBAAwB,GAAI,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,IAAI,UAE9D;IAEF;;;;OAIG;IACH,2BAA2B,GACzB,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,IAAI,KACnC,IAAI,CAEL;IAEF;;;;;OAKG;IACH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MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC;IAQtB;;;;;;;;;OASG;IACH,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,CAAC;IAKtC;;;;;;OAMG;IACH,UAAU,GAAI,IAAI,MAAM,UAQtB;IAEF;;;;;;;OAOG;IACH,kBAAkB,GAAI,IAAI,MAAM,UAE9B;IAEF;;;;;OAKG;IACH,SAAS,aAUP;IAEF;;;;;OAKG;IACH,OAAO,GAAI,IAAI,MAAM,KAAG,CAAC,GAAG,SAAS,CAEnC;IAEF;;;;;;OAMG;IACH,eAAe,GAAI,aAAa,MAAM,KAAG,CAAC,GAAG,SAAS,CAEpD;IAEF;;;;OAIG;IACH,MAAM,QAAO,CAAC,EAAE,CAEd;IAEF;;;;;OAKG;IACH,WAAW,GAAI,IAAI,MAAM,KAAG,CAAC,CAM3B;CACH"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { AppObject, AppObjectEntityRepo, AppObjectRepo } from "../../AppObject";
|
|
20
20
|
import { ExampleEntity } from "./ExampleEntity";
|
|
21
21
|
/** Type definition for a factory function that creates ExampleEntity instances */
|
|
22
|
-
export type ExampleEntityFactory = (
|
|
22
|
+
export type ExampleEntityFactory = (appObject: AppObject) => ExampleEntity;
|
|
23
23
|
/**
|
|
24
24
|
* ExampleRepo manages a collection of ExampleEntity instances.
|
|
25
25
|
* Abstract class provides the interface and static helper methods.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleRepo.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AAEnE,kFAAkF;AAClF,MAAM,MAAM,oBAAoB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"ExampleRepo.d.ts","sourceRoot":"","sources":["../../../../src/ExampleFeature/Entities/ExampleRepo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AAEnE,kFAAkF;AAClF,MAAM,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,aAAa,CAAC;AAE3E;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IAC1E,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,IAAI,qBAAqB;IAEzC,4CAA4C;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAE9C;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS;IAItD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CACZ,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,GACxB,WAAW,GAAG,SAAS;IAI1B;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;CAQvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAEjE"}
|