feat: restructure events payload (#8143)

* refactor: restructure events payload

Breaking change: This PR changes the event payload accepted by the event
listeners

* refactor: fix failing tests and implement feedback

* add integration tests

* fix timeout

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
Harminder Virk
2024-07-16 21:39:16 +05:30
committed by GitHub
parent 5813216c88
commit f579f0b3be
26 changed files with 194 additions and 111 deletions
@@ -873,7 +873,7 @@ export default class ProductModuleService
await this.eventBusModuleService_?.emit<ProductCollectionEventData>(
collections.map(({ id }) => ({
eventName: ProductCollectionEvents.COLLECTION_CREATED,
name: ProductCollectionEvents.COLLECTION_CREATED,
data: { id },
}))
)
@@ -946,7 +946,7 @@ export default class ProductModuleService
if (created.length) {
await this.eventBusModuleService_?.emit<ProductCollectionEventData>(
created.map(({ id }) => ({
eventName: ProductCollectionEvents.COLLECTION_CREATED,
name: ProductCollectionEvents.COLLECTION_CREATED,
data: { id },
}))
)
@@ -955,7 +955,7 @@ export default class ProductModuleService
if (updated.length) {
await this.eventBusModuleService_?.emit<ProductCollectionEventData>(
updated.map(({ id }) => ({
eventName: ProductCollectionEvents.COLLECTION_UPDATED,
name: ProductCollectionEvents.COLLECTION_UPDATED,
data: { id },
}))
)
@@ -1016,7 +1016,7 @@ export default class ProductModuleService
await this.eventBusModuleService_?.emit<ProductCollectionEventData>(
updatedCollections.map(({ id }) => ({
eventName: ProductCollectionEvents.COLLECTION_UPDATED,
name: ProductCollectionEvents.COLLECTION_UPDATED,
data: { id },
}))
)
@@ -1279,7 +1279,7 @@ export default class ProductModuleService
await this.eventBusModuleService_?.emit<ProductEventData>(
createdProducts.map(({ id }) => ({
eventName: ProductEvents.PRODUCT_CREATED,
name: ProductEvents.PRODUCT_CREATED,
data: { id },
}))
)
@@ -1327,7 +1327,7 @@ export default class ProductModuleService
if (created.length) {
await this.eventBusModuleService_?.emit<ProductEventData>(
created.map(({ id }) => ({
eventName: ProductEvents.PRODUCT_CREATED,
name: ProductEvents.PRODUCT_CREATED,
data: { id },
}))
)
@@ -1336,7 +1336,7 @@ export default class ProductModuleService
if (updated.length) {
await this.eventBusModuleService_?.emit<ProductEventData>(
updated.map(({ id }) => ({
eventName: ProductEvents.PRODUCT_UPDATED,
name: ProductEvents.PRODUCT_UPDATED,
data: { id },
}))
)
@@ -1390,7 +1390,7 @@ export default class ProductModuleService
await this.eventBusModuleService_?.emit<ProductEventData>(
updatedProducts.map(({ id }) => ({
eventName: ProductEvents.PRODUCT_UPDATED,
name: ProductEvents.PRODUCT_UPDATED,
data: { id },
}))
)