feat: Add emitEvent step + cleanup (#7643)
* feat: Add emitEvent step + cleanup * fix typo * fix typo
This commit is contained in:
1 parent
3cd2d60daa
commit
2e77a076b8
19 files changed
+178
-117
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
export * from "./steps/create-remote-links"
|
export * from "./steps/create-remote-links"
|
||||||
export * from "./steps/dismiss-remote-links"
|
export * from "./steps/dismiss-remote-links"
|
||||||
export * from "./steps/remove-remote-links"
|
export * from "./steps/remove-remote-links"
|
||||||
|
export * from "./steps/emit-event"
|
||||||
export * from "./steps/use-remote-query"
|
export * from "./steps/use-remote-query"
|
||||||
export * from "./workflows/batch-links"
|
export * from "./workflows/batch-links"
|
||||||
export * from "./workflows/create-links"
|
export * from "./workflows/create-links"
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { composeMessage, ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
import { createStep, StepExecutionContext } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
|
type Input = {
|
||||||
|
eventName: string
|
||||||
|
source: string
|
||||||
|
object: string
|
||||||
|
action?: string
|
||||||
|
options?: Record<string, any>
|
||||||
|
data: (
|
||||||
|
context: StepExecutionContext
|
||||||
|
) => Promise<Record<any, any>> | Record<any, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const emitEventStepId = "emit-event-step"
|
||||||
|
export const emitEventStep = createStep(
|
||||||
|
emitEventStepId,
|
||||||
|
async (input: Input, context) => {
|
||||||
|
if (!input) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const { container } = context
|
||||||
|
|
||||||
|
const eventBus = container.resolve(ModuleRegistrationName.EVENT_BUS)
|
||||||
|
|
||||||
|
const data_ =
|
||||||
|
typeof input.data === "function" ? await input.data(context) : input.data
|
||||||
|
const message = composeMessage(input.eventName, {
|
||||||
|
data: data_,
|
||||||
|
action: input.action ?? "",
|
||||||
|
object: input.object,
|
||||||
|
source: input.source,
|
||||||
|
options: input.options,
|
||||||
|
context,
|
||||||
|
})
|
||||||
|
|
||||||
|
await eventBus.emit([message])
|
||||||
|
},
|
||||||
|
async (data: void) => {}
|
||||||
|
)
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
import { createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
|
export const releaseEventsStepId = "release-events-step"
|
||||||
|
export const releaseEventsStep = createStep(
|
||||||
|
releaseEventsStepId,
|
||||||
|
async (
|
||||||
|
input: void,
|
||||||
|
{
|
||||||
|
container,
|
||||||
|
metadata: {
|
||||||
|
/* eventGroupId */
|
||||||
|
},
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
const eventBus = container.resolve(ModuleRegistrationName.EVENT_BUS)
|
||||||
|
// await eventBus.release
|
||||||
|
},
|
||||||
|
async (data: void) => {}
|
||||||
|
)
|
||||||
@@ -27,7 +27,7 @@ export type EmitData<T = unknown> = {
|
|||||||
|
|
||||||
export type MessageBody<T = unknown> = {
|
export type MessageBody<T = unknown> = {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: string
|
source: string
|
||||||
action: string
|
action: string
|
||||||
object: string
|
object: string
|
||||||
eventGroupId?: string
|
eventGroupId?: string
|
||||||
@@ -44,7 +44,7 @@ export type Message<T = unknown> = {
|
|||||||
export type RawMessageFormat<T = any> = {
|
export type RawMessageFormat<T = any> = {
|
||||||
eventName: string
|
eventName: string
|
||||||
data: T
|
data: T
|
||||||
service: string
|
source: string
|
||||||
object: string
|
object: string
|
||||||
action?: string
|
action?: string
|
||||||
context?: Pick<Context, "eventGroupId">
|
context?: Pick<Context, "eventGroupId">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.created",
|
eventName: "ProductVariant.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -23,7 +23,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "Product.created",
|
eventName: "Product.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "Product",
|
object: "Product",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -35,7 +35,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.created",
|
eventName: "ProductVariant.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -47,7 +47,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductType.detached",
|
eventName: "ProductType.detached",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "detached",
|
action: "detached",
|
||||||
object: "ProductType",
|
object: "ProductType",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -59,7 +59,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.updated",
|
eventName: "ProductVariant.updated",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "updated",
|
action: "updated",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -87,7 +87,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductType.detached",
|
eventName: "ProductType.detached",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "detached",
|
action: "detached",
|
||||||
object: "ProductType",
|
object: "ProductType",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -102,7 +102,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.updated",
|
eventName: "ProductVariant.updated",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "updated",
|
action: "updated",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -117,7 +117,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.created",
|
eventName: "ProductVariant.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -129,7 +129,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "ProductVariant.created",
|
eventName: "ProductVariant.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "ProductVariant",
|
object: "ProductVariant",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
@@ -144,7 +144,7 @@ describe("MessageAggregator", function () {
|
|||||||
eventName: "Product.created",
|
eventName: "Product.created",
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: "ProductService",
|
source: "ProductService",
|
||||||
action: "created",
|
action: "created",
|
||||||
object: "Product",
|
object: "Product",
|
||||||
eventGroupId: "1",
|
eventGroupId: "1",
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ export function composeMessage(
|
|||||||
eventName: string,
|
eventName: string,
|
||||||
{
|
{
|
||||||
data,
|
data,
|
||||||
service,
|
source,
|
||||||
object,
|
object,
|
||||||
action,
|
action,
|
||||||
context = {},
|
context = {},
|
||||||
options,
|
options,
|
||||||
}: {
|
}: {
|
||||||
data: any
|
data: any
|
||||||
service: string
|
source: string
|
||||||
object: string
|
object: string
|
||||||
action?: string
|
action?: string
|
||||||
context?: Context
|
context?: Context
|
||||||
@@ -34,7 +34,7 @@ export function composeMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const metadata: EventBusTypes.MessageBody["metadata"] = {
|
const metadata: EventBusTypes.MessageBody["metadata"] = {
|
||||||
service,
|
source,
|
||||||
object,
|
object,
|
||||||
action: act!,
|
action: act!,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export class MessageAggregator implements IMessageAggregator {
|
|||||||
const composedMessages = messages.map((message) => {
|
const composedMessages = messages.map((message) => {
|
||||||
return composeMessage(message.eventName, {
|
return composeMessage(message.eventName, {
|
||||||
data: message.data,
|
data: message.data,
|
||||||
service: message.service,
|
source: message.source,
|
||||||
object: message.object,
|
object: message.object,
|
||||||
action: message.action,
|
action: message.action,
|
||||||
options,
|
options,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Context, EventBusTypes } from "@medusajs/types"
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const createdFulfillment = eventBuilderFactory({
|
* const createdFulfillment = eventBuilderFactory({
|
||||||
* service: Modules.FULFILLMENT,
|
* source: Modules.FULFILLMENT,
|
||||||
* action: CommonEvents.CREATED,
|
* action: CommonEvents.CREATED,
|
||||||
* object: "fulfillment",
|
* object: "fulfillment",
|
||||||
* eventsEnum: FulfillmentEvents,
|
* eventsEnum: FulfillmentEvents,
|
||||||
@@ -27,13 +27,13 @@ export function eventBuilderFactory({
|
|||||||
action,
|
action,
|
||||||
object,
|
object,
|
||||||
eventsEnum,
|
eventsEnum,
|
||||||
service,
|
source,
|
||||||
}: {
|
}: {
|
||||||
isMainEntity?: boolean
|
isMainEntity?: boolean
|
||||||
action: string
|
action: string
|
||||||
object: string
|
object: string
|
||||||
eventsEnum: Record<string, string>
|
eventsEnum: Record<string, string>
|
||||||
service: string
|
source: string
|
||||||
}) {
|
}) {
|
||||||
return function ({
|
return function ({
|
||||||
data,
|
data,
|
||||||
@@ -51,7 +51,7 @@ export function eventBuilderFactory({
|
|||||||
|
|
||||||
data.forEach((dataItem) => {
|
data.forEach((dataItem) => {
|
||||||
messages.push({
|
messages.push({
|
||||||
service,
|
source,
|
||||||
action,
|
action,
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
data: { id: dataItem.id },
|
data: { id: dataItem.id },
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export function buildExpectedEventMessageShape(options: {
|
|||||||
metadata: {
|
metadata: {
|
||||||
action: options.action,
|
action: options.action,
|
||||||
eventGroupId: options.eventGroupId,
|
eventGroupId: options.eventGroupId,
|
||||||
service: "fulfillment",
|
source: "fulfillment",
|
||||||
object: options.object,
|
object: options.object,
|
||||||
},
|
},
|
||||||
data: options.data,
|
data: options.data,
|
||||||
|
|||||||
@@ -17,154 +17,154 @@ import {
|
|||||||
|
|
||||||
export const eventBuilders = {
|
export const eventBuilders = {
|
||||||
createdFulfillment: eventBuilderFactory({
|
createdFulfillment: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "fulfillment",
|
object: "fulfillment",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedFulfillment: eventBuilderFactory({
|
updatedFulfillment: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "fulfillment",
|
object: "fulfillment",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdFulfillmentAddress: eventBuilderFactory({
|
createdFulfillmentAddress: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "fulfillment_address",
|
object: "fulfillment_address",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdFulfillmentItem: eventBuilderFactory({
|
createdFulfillmentItem: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "fulfillment_item",
|
object: "fulfillment_item",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdFulfillmentLabel: eventBuilderFactory({
|
createdFulfillmentLabel: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "fulfillment_label",
|
object: "fulfillment_label",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedFulfillmentLabel: eventBuilderFactory({
|
updatedFulfillmentLabel: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "fulfillment_label",
|
object: "fulfillment_label",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedFulfillmentLabel: eventBuilderFactory({
|
deletedFulfillmentLabel: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "fulfillment_label",
|
object: "fulfillment_label",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdShippingProfile: eventBuilderFactory({
|
createdShippingProfile: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "shipping_profile",
|
object: "shipping_profile",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdShippingOptionType: eventBuilderFactory({
|
createdShippingOptionType: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "shipping_option_type",
|
object: "shipping_option_type",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedShippingOptionType: eventBuilderFactory({
|
updatedShippingOptionType: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "shipping_option_type",
|
object: "shipping_option_type",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedShippingOptionType: eventBuilderFactory({
|
deletedShippingOptionType: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "shipping_option_type",
|
object: "shipping_option_type",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdShippingOptionRule: eventBuilderFactory({
|
createdShippingOptionRule: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "shipping_option_rule",
|
object: "shipping_option_rule",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedShippingOptionRule: eventBuilderFactory({
|
updatedShippingOptionRule: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "shipping_option_rule",
|
object: "shipping_option_rule",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedShippingOptionRule: eventBuilderFactory({
|
deletedShippingOptionRule: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "shipping_option_rule",
|
object: "shipping_option_rule",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdShippingOption: eventBuilderFactory({
|
createdShippingOption: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "shipping_option",
|
object: "shipping_option",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedShippingOption: eventBuilderFactory({
|
updatedShippingOption: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "shipping_option",
|
object: "shipping_option",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdFulfillmentSet: eventBuilderFactory({
|
createdFulfillmentSet: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "fulfillment_set",
|
object: "fulfillment_set",
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedFulfillmentSet: eventBuilderFactory({
|
updatedFulfillmentSet: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "fulfillment_set",
|
object: "fulfillment_set",
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedFulfillmentSet: eventBuilderFactory({
|
deletedFulfillmentSet: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "fulfillment_set",
|
object: "fulfillment_set",
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdServiceZone: eventBuilderFactory({
|
createdServiceZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "service_zone",
|
object: "service_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedServiceZone: eventBuilderFactory({
|
updatedServiceZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "service_zone",
|
object: "service_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedServiceZone: eventBuilderFactory({
|
deletedServiceZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "service_zone",
|
object: "service_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
createdGeoZone: eventBuilderFactory({
|
createdGeoZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "geo_zone",
|
object: "geo_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
updatedGeoZone: eventBuilderFactory({
|
updatedGeoZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "geo_zone",
|
object: "geo_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
}),
|
}),
|
||||||
deletedGeoZone: eventBuilderFactory({
|
deletedGeoZone: eventBuilderFactory({
|
||||||
service: Modules.FULFILLMENT,
|
source: Modules.FULFILLMENT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "geo_zone",
|
object: "geo_zone",
|
||||||
eventsEnum: FulfillmentEvents,
|
eventsEnum: FulfillmentEvents,
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ import {
|
|||||||
ReservationItemDTO,
|
ReservationItemDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
|
arrayDifference,
|
||||||
CommonEvents,
|
CommonEvents,
|
||||||
EmitEvents,
|
EmitEvents,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
InventoryEvents,
|
InventoryEvents,
|
||||||
|
isDefined,
|
||||||
|
isString,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
arrayDifference,
|
|
||||||
isDefined,
|
|
||||||
isString,
|
|
||||||
partitionArray,
|
partitionArray,
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
@@ -241,7 +241,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
created.map((reservationItem) => ({
|
created.map((reservationItem) => ({
|
||||||
eventName: InventoryEvents.reservation_item_created,
|
eventName: InventoryEvents.reservation_item_created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "reservation-item",
|
object: "reservation-item",
|
||||||
context,
|
context,
|
||||||
@@ -340,7 +340,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
result.map((inventoryItem) => ({
|
result.map((inventoryItem) => ({
|
||||||
eventName: InventoryEvents.created,
|
eventName: InventoryEvents.created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "inventory-item",
|
object: "inventory-item",
|
||||||
context,
|
context,
|
||||||
@@ -393,7 +393,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
created.map((inventoryLevel) => ({
|
created.map((inventoryLevel) => ({
|
||||||
eventName: InventoryEvents.inventory_level_created,
|
eventName: InventoryEvents.inventory_level_created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "inventory-level",
|
object: "inventory-level",
|
||||||
context,
|
context,
|
||||||
@@ -453,7 +453,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
result.map((inventoryItem) => ({
|
result.map((inventoryItem) => ({
|
||||||
eventName: InventoryEvents.updated,
|
eventName: InventoryEvents.updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "inventory-item",
|
object: "inventory-item",
|
||||||
context,
|
context,
|
||||||
@@ -492,7 +492,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
result[0].map((inventoryLevel) => ({
|
result[0].map((inventoryLevel) => ({
|
||||||
eventName: InventoryEvents.inventory_level_deleted,
|
eventName: InventoryEvents.inventory_level_deleted,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "inventory-level",
|
object: "inventory-level",
|
||||||
context,
|
context,
|
||||||
@@ -523,7 +523,7 @@ export default class InventoryModuleService<
|
|||||||
|
|
||||||
context.messageAggregator?.saveRawMessageData({
|
context.messageAggregator?.saveRawMessageData({
|
||||||
eventName: InventoryEvents.inventory_level_deleted,
|
eventName: InventoryEvents.inventory_level_deleted,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "inventory-level",
|
object: "inventory-level",
|
||||||
context,
|
context,
|
||||||
@@ -565,7 +565,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
levels.map((inventoryLevel) => ({
|
levels.map((inventoryLevel) => ({
|
||||||
eventName: InventoryEvents.inventory_level_updated,
|
eventName: InventoryEvents.inventory_level_updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "inventory-level",
|
object: "inventory-level",
|
||||||
context,
|
context,
|
||||||
@@ -648,7 +648,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
result.map((reservationItem) => ({
|
result.map((reservationItem) => ({
|
||||||
eventName: InventoryEvents.inventory_level_updated,
|
eventName: InventoryEvents.inventory_level_updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "reservation-item",
|
object: "reservation-item",
|
||||||
context,
|
context,
|
||||||
@@ -801,7 +801,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
reservations.map((reservationItem) => ({
|
reservations.map((reservationItem) => ({
|
||||||
eventName: InventoryEvents.reservation_item_deleted,
|
eventName: InventoryEvents.reservation_item_deleted,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "reservation-item",
|
object: "reservation-item",
|
||||||
context,
|
context,
|
||||||
@@ -843,7 +843,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
reservations.map((reservationItem) => ({
|
reservations.map((reservationItem) => ({
|
||||||
eventName: InventoryEvents.reservation_item_deleted,
|
eventName: InventoryEvents.reservation_item_deleted,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "reservation-item",
|
object: "reservation-item",
|
||||||
context,
|
context,
|
||||||
@@ -880,7 +880,7 @@ export default class InventoryModuleService<
|
|||||||
context.messageAggregator?.saveRawMessageData(
|
context.messageAggregator?.saveRawMessageData(
|
||||||
reservations.map((reservationItem) => ({
|
reservations.map((reservationItem) => ({
|
||||||
eventName: InventoryEvents.reservation_item_created,
|
eventName: InventoryEvents.reservation_item_created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "reservation-item",
|
object: "reservation-item",
|
||||||
context,
|
context,
|
||||||
@@ -949,7 +949,7 @@ export default class InventoryModuleService<
|
|||||||
|
|
||||||
context.messageAggregator?.saveRawMessageData({
|
context.messageAggregator?.saveRawMessageData({
|
||||||
eventName: InventoryEvents.inventory_level_updated,
|
eventName: InventoryEvents.inventory_level_updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "inventory-level",
|
object: "inventory-level",
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import {
|
|||||||
CommonEvents,
|
CommonEvents,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isDefined,
|
||||||
|
mapObjectTo,
|
||||||
MapToConfig,
|
MapToConfig,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
isDefined,
|
|
||||||
mapObjectTo,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { LinkService } from "@services"
|
import { LinkService } from "@services"
|
||||||
import { shouldForceTransaction } from "../utils"
|
import { shouldForceTransaction } from "../utils"
|
||||||
@@ -210,7 +210,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
|
|||||||
eventName: this.entityName_ + "." + CommonEvents.ATTACHED,
|
eventName: this.entityName_ + "." + CommonEvents.ATTACHED,
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: this.serviceName_,
|
source: this.serviceName_,
|
||||||
action: CommonEvents.ATTACHED,
|
action: CommonEvents.ATTACHED,
|
||||||
object: this.entityName_,
|
object: this.entityName_,
|
||||||
eventGroupId: sharedContext.eventGroupId,
|
eventGroupId: sharedContext.eventGroupId,
|
||||||
@@ -263,7 +263,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
|
|||||||
eventName: this.entityName_ + "." + CommonEvents.DETACHED,
|
eventName: this.entityName_ + "." + CommonEvents.DETACHED,
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: this.serviceName_,
|
source: this.serviceName_,
|
||||||
action: CommonEvents.DETACHED,
|
action: CommonEvents.DETACHED,
|
||||||
object: this.entityName_,
|
object: this.entityName_,
|
||||||
eventGroupId: sharedContext.eventGroupId,
|
eventGroupId: sharedContext.eventGroupId,
|
||||||
@@ -314,7 +314,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
|
|||||||
eventName: this.entityName_ + "." + CommonEvents.DETACHED,
|
eventName: this.entityName_ + "." + CommonEvents.DETACHED,
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: this.serviceName_,
|
source: this.serviceName_,
|
||||||
action: CommonEvents.DETACHED,
|
action: CommonEvents.DETACHED,
|
||||||
object: this.entityName_,
|
object: this.entityName_,
|
||||||
eventGroupId: sharedContext.eventGroupId,
|
eventGroupId: sharedContext.eventGroupId,
|
||||||
@@ -374,7 +374,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
|
|||||||
eventName: this.entityName_ + "." + CommonEvents.ATTACHED,
|
eventName: this.entityName_ + "." + CommonEvents.ATTACHED,
|
||||||
body: {
|
body: {
|
||||||
metadata: {
|
metadata: {
|
||||||
service: this.serviceName_,
|
source: this.serviceName_,
|
||||||
action: CommonEvents.ATTACHED,
|
action: CommonEvents.ATTACHED,
|
||||||
object: this.entityName_,
|
object: this.entityName_,
|
||||||
eventGroupId: sharedContext.eventGroupId,
|
eventGroupId: sharedContext.eventGroupId,
|
||||||
|
|||||||
+6
-6
@@ -508,7 +508,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(events).toHaveLength(4)
|
expect(events).toHaveLength(4)
|
||||||
expect(events[0]).toEqual(
|
expect(events[0]).toEqual(
|
||||||
composeMessage(PricingEvents.price_list_created, {
|
composeMessage(PricingEvents.price_list_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_list",
|
object: "price_list",
|
||||||
data: { id: priceList.id },
|
data: { id: priceList.id },
|
||||||
@@ -516,7 +516,7 @@ moduleIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
expect(events[1]).toEqual(
|
expect(events[1]).toEqual(
|
||||||
composeMessage(PricingEvents.price_list_rule_created, {
|
composeMessage(PricingEvents.price_list_rule_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_list_rule",
|
object: "price_list_rule",
|
||||||
data: { id: priceList.price_list_rules?.[0].id },
|
data: { id: priceList.price_list_rules?.[0].id },
|
||||||
@@ -524,7 +524,7 @@ moduleIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
expect(events[2]).toEqual(
|
expect(events[2]).toEqual(
|
||||||
composeMessage(PricingEvents.price_list_rule_created, {
|
composeMessage(PricingEvents.price_list_rule_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_list_rule",
|
object: "price_list_rule",
|
||||||
data: { id: priceList.price_list_rules?.[1].id },
|
data: { id: priceList.price_list_rules?.[1].id },
|
||||||
@@ -532,7 +532,7 @@ moduleIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
expect(events[3]).toEqual(
|
expect(events[3]).toEqual(
|
||||||
composeMessage(PricingEvents.price_created, {
|
composeMessage(PricingEvents.price_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price",
|
object: "price",
|
||||||
data: { id: priceList.prices![0].id },
|
data: { id: priceList.prices![0].id },
|
||||||
@@ -867,7 +867,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(events).toHaveLength(2)
|
expect(events).toHaveLength(2)
|
||||||
expect(events[0]).toEqual(
|
expect(events[0]).toEqual(
|
||||||
composeMessage(PricingEvents.price_created, {
|
composeMessage(PricingEvents.price_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price",
|
object: "price",
|
||||||
data: { id: priceList.prices![0].id },
|
data: { id: priceList.prices![0].id },
|
||||||
@@ -875,7 +875,7 @@ moduleIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
expect(events[1]).toEqual(
|
expect(events[1]).toEqual(
|
||||||
composeMessage(PricingEvents.price_rule_created, {
|
composeMessage(PricingEvents.price_rule_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_rule",
|
object: "price_rule",
|
||||||
data: { id: priceList.prices![0].price_rules![0].id },
|
data: { id: priceList.prices![0].price_rules![0].id },
|
||||||
|
|||||||
+6
-6
@@ -12,7 +12,7 @@ import {
|
|||||||
} from "medusa-test-utils"
|
} from "medusa-test-utils"
|
||||||
import { PriceSetRuleType } from "../../../../src"
|
import { PriceSetRuleType } from "../../../../src"
|
||||||
import { seedPriceData } from "../../../__fixtures__/seed-price-data"
|
import { seedPriceData } from "../../../__fixtures__/seed-price-data"
|
||||||
import { CommonEvents, PricingEvents, composeMessage } from "@medusajs/utils"
|
import { CommonEvents, composeMessage, PricingEvents } from "@medusajs/utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(events).toHaveLength(3)
|
expect(events).toHaveLength(3)
|
||||||
expect(events[0]).toEqual(
|
expect(events[0]).toEqual(
|
||||||
composeMessage(PricingEvents.price_set_created, {
|
composeMessage(PricingEvents.price_set_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_set",
|
object: "price_set",
|
||||||
data: { id: priceSet.id },
|
data: { id: priceSet.id },
|
||||||
@@ -455,7 +455,7 @@ moduleIntegrationTestRunner({
|
|||||||
|
|
||||||
expect(events[1]).toEqual(
|
expect(events[1]).toEqual(
|
||||||
composeMessage(PricingEvents.price_created, {
|
composeMessage(PricingEvents.price_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price",
|
object: "price",
|
||||||
data: { id: priceSet.prices![0].id },
|
data: { id: priceSet.prices![0].id },
|
||||||
@@ -464,7 +464,7 @@ moduleIntegrationTestRunner({
|
|||||||
|
|
||||||
expect(events[2]).toEqual(
|
expect(events[2]).toEqual(
|
||||||
composeMessage(PricingEvents.price_rule_created, {
|
composeMessage(PricingEvents.price_rule_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_rule",
|
object: "price_rule",
|
||||||
data: {
|
data: {
|
||||||
@@ -694,7 +694,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(events).toHaveLength(2)
|
expect(events).toHaveLength(2)
|
||||||
expect(events[0]).toEqual(
|
expect(events[0]).toEqual(
|
||||||
composeMessage(PricingEvents.price_created, {
|
composeMessage(PricingEvents.price_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price",
|
object: "price",
|
||||||
data: { id: priceSet.prices![1].id },
|
data: { id: priceSet.prices![1].id },
|
||||||
@@ -702,7 +702,7 @@ moduleIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
expect(events[1]).toEqual(
|
expect(events[1]).toEqual(
|
||||||
composeMessage(PricingEvents.price_rule_created, {
|
composeMessage(PricingEvents.price_rule_created, {
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_rule",
|
object: "price_rule",
|
||||||
data: { id: priceSet.prices![1].price_rules[0].id },
|
data: { id: priceSet.prices![1].price_rules[0].id },
|
||||||
|
|||||||
@@ -1,50 +1,49 @@
|
|||||||
import {} from "@models"
|
|
||||||
import {
|
import {
|
||||||
Modules,
|
|
||||||
CommonEvents,
|
CommonEvents,
|
||||||
PricingEvents,
|
|
||||||
eventBuilderFactory,
|
eventBuilderFactory,
|
||||||
|
Modules,
|
||||||
|
PricingEvents,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const eventBuilders = {
|
export const eventBuilders = {
|
||||||
createdPriceSet: eventBuilderFactory({
|
createdPriceSet: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_set",
|
object: "price_set",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
createdPriceSetRuleType: eventBuilderFactory({
|
createdPriceSetRuleType: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_set_rule_type",
|
object: "price_set_rule_type",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
createdPrice: eventBuilderFactory({
|
createdPrice: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price",
|
object: "price",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
createdPriceRule: eventBuilderFactory({
|
createdPriceRule: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_rule",
|
object: "price_rule",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
createdPriceList: eventBuilderFactory({
|
createdPriceList: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_list",
|
object: "price_list",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
createdPriceListRule: eventBuilderFactory({
|
createdPriceListRule: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "price_list_rule",
|
object: "price_list_rule",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
}),
|
}),
|
||||||
attachedPriceListRule: eventBuilderFactory({
|
attachedPriceListRule: eventBuilderFactory({
|
||||||
service: Modules.PRICING,
|
source: Modules.PRICING,
|
||||||
action: CommonEvents.ATTACHED,
|
action: CommonEvents.ATTACHED,
|
||||||
object: "price_list_rule",
|
object: "price_list_rule",
|
||||||
eventsEnum: PricingEvents,
|
eventsEnum: PricingEvents,
|
||||||
|
|||||||
+4
-4
@@ -279,7 +279,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_tag_updated, {
|
composeMessage(ProductEvents.product_tag_updated, {
|
||||||
data: { id: productTag.id },
|
data: { id: productTag.id },
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -321,7 +321,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_tag_created, {
|
composeMessage(ProductEvents.product_tag_created, {
|
||||||
data: { id: productTag[0].id },
|
data: { id: productTag[0].id },
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -375,13 +375,13 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_tag_created, {
|
composeMessage(ProductEvents.product_tag_created, {
|
||||||
data: { id: newTag.id },
|
data: { id: newTag.id },
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
}),
|
}),
|
||||||
composeMessage(ProductEvents.product_tag_updated, {
|
composeMessage(ProductEvents.product_tag_updated, {
|
||||||
data: { id: updatedTag.id },
|
data: { id: updatedTag.id },
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|||||||
+3
-3
@@ -211,7 +211,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_variant_updated, {
|
composeMessage(ProductEvents.product_variant_updated, {
|
||||||
data: { id: variantOne.id },
|
data: { id: variantOne.id },
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -241,7 +241,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_variant_updated, {
|
composeMessage(ProductEvents.product_variant_updated, {
|
||||||
data: { id: variantOne.id },
|
data: { id: variantOne.id },
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -312,7 +312,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
|||||||
composeMessage(ProductEvents.product_variant_created, {
|
composeMessage(ProductEvents.product_variant_created, {
|
||||||
data: { id: variant.id },
|
data: { id: variant.id },
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -7,94 +7,94 @@ import {
|
|||||||
|
|
||||||
export const eventBuilders = {
|
export const eventBuilders = {
|
||||||
createdProduct: eventBuilderFactory({
|
createdProduct: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "product",
|
object: "product",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
}),
|
}),
|
||||||
updatedProduct: eventBuilderFactory({
|
updatedProduct: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "product",
|
object: "product",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
}),
|
}),
|
||||||
deletedProduct: eventBuilderFactory({
|
deletedProduct: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "product",
|
object: "product",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
isMainEntity: true,
|
isMainEntity: true,
|
||||||
}),
|
}),
|
||||||
createdProductVariant: eventBuilderFactory({
|
createdProductVariant: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
updatedProductVariant: eventBuilderFactory({
|
updatedProductVariant: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
deletedProductVariant: eventBuilderFactory({
|
deletedProductVariant: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "product_variant",
|
object: "product_variant",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
createdProductOption: eventBuilderFactory({
|
createdProductOption: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "product_option",
|
object: "product_option",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
updatedProductOption: eventBuilderFactory({
|
updatedProductOption: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "product_option",
|
object: "product_option",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
deletedProductOption: eventBuilderFactory({
|
deletedProductOption: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "product_option",
|
object: "product_option",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
createdProductType: eventBuilderFactory({
|
createdProductType: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "product_type",
|
object: "product_type",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
updatedProductType: eventBuilderFactory({
|
updatedProductType: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "product_type",
|
object: "product_type",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
deletedProductType: eventBuilderFactory({
|
deletedProductType: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "product_type",
|
object: "product_type",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
createdProductTag: eventBuilderFactory({
|
createdProductTag: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
updatedProductTag: eventBuilderFactory({
|
updatedProductTag: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
}),
|
}),
|
||||||
deletedProductTag: eventBuilderFactory({
|
deletedProductTag: eventBuilderFactory({
|
||||||
service: Modules.PRODUCT,
|
source: Modules.PRODUCT,
|
||||||
action: CommonEvents.DELETED,
|
action: CommonEvents.DELETED,
|
||||||
object: "product_tag",
|
object: "product_tag",
|
||||||
eventsEnum: ProductEvents,
|
eventsEnum: ProductEvents,
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
invites.map((invite) => ({
|
invites.map((invite) => ({
|
||||||
eventName: UserEvents.invite_token_generated,
|
eventName: UserEvents.invite_token_generated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: "token_generated",
|
action: "token_generated",
|
||||||
object: "invite",
|
object: "invite",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
@@ -149,7 +149,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
users.map((user) => ({
|
users.map((user) => ({
|
||||||
eventName: UserEvents.created,
|
eventName: UserEvents.created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "user",
|
object: "user",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
@@ -188,7 +188,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
updatedUsers.map((user) => ({
|
updatedUsers.map((user) => ({
|
||||||
eventName: UserEvents.updated,
|
eventName: UserEvents.updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "user",
|
object: "user",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
@@ -227,7 +227,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
invites.map((invite) => ({
|
invites.map((invite) => ({
|
||||||
eventName: UserEvents.invite_created,
|
eventName: UserEvents.invite_created,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.CREATED,
|
action: CommonEvents.CREATED,
|
||||||
object: "invite",
|
object: "invite",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
@@ -238,7 +238,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
invites.map((invite) => ({
|
invites.map((invite) => ({
|
||||||
eventName: UserEvents.invite_token_generated,
|
eventName: UserEvents.invite_token_generated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: "token_generated",
|
action: "token_generated",
|
||||||
object: "invite",
|
object: "invite",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
@@ -296,7 +296,7 @@ export default class UserModuleService<
|
|||||||
sharedContext.messageAggregator?.saveRawMessageData(
|
sharedContext.messageAggregator?.saveRawMessageData(
|
||||||
serializedInvites.map((invite) => ({
|
serializedInvites.map((invite) => ({
|
||||||
eventName: UserEvents.invite_updated,
|
eventName: UserEvents.invite_updated,
|
||||||
service: this.constructor.name,
|
source: this.constructor.name,
|
||||||
action: CommonEvents.UPDATED,
|
action: CommonEvents.UPDATED,
|
||||||
object: "invite",
|
object: "invite",
|
||||||
context: sharedContext,
|
context: sharedContext,
|
||||||
|
|||||||
Reference in new issue
Block a user