feat(): improve module typings in medusa config (#14478)

* feat(events): Allow priority configuration

* feat(events): Allow priority configuration

* wip

* wip

* wip

* fix typings

* Create cold-lamps-search.md

* implement priority config usage

* comment out #1

* fixes

* fixes
This commit is contained in:
Adrien de Peretti
2026-01-14 18:39:57 +01:00
committed by GitHub
parent cbc9f3d059
commit 1347698876
21 changed files with 593 additions and 65 deletions

View File

@@ -0,0 +1,10 @@
---
"@medusajs/event-bus-redis": patch
"@medusajs/draft-order": patch
"@medusajs/framework": patch
"@medusajs/types": patch
"@medusajs/utils": patch
---
Feat/enable event configuration in medusa config
enables event priority configuration through the Medusa config, allowing users to configure event processing options (like priority) for specific events at the module level.

View File

@@ -27,7 +27,10 @@
"./telemetry": "./dist/telemetry/index.js",
"./feature-flags": "./dist/feature-flags/index.js",
"./utils": "./dist/utils/index.js",
"./types": "./dist/types/index.js",
"./types": {
"types": "./dist/types/index.d.ts",
"default": "./dist/types/index.js"
},
"./build-tools": "./dist/build-tools/index.js",
"./orchestration": "./dist/orchestration/index.js",
"./workflows-sdk": "./dist/workflows-sdk/index.js",

View File

@@ -1 +1,8 @@
import "@medusajs/utils"
export * from "@medusajs/types"
import type { ModuleOptions as ModuleOptionsType } from "@medusajs/types"
// Re-declare ModuleOptions to enable augmentation from @medusajs/framework/types
// EventBusEventsOptions is exported via "export *" and gets augmentations from @medusajs/utils
export interface ModuleOptions extends ModuleOptionsType {}

View File

@@ -1,3 +1,5 @@
import "@medusajs/types"
import "@medusajs/utils"
import "../types/container"
export * from "@medusajs/utils"

View File

@@ -1139,32 +1139,30 @@ type ExternalModuleDeclarationOverride = ExternalModuleDeclaration & {
disable?: boolean
}
/**
* Generates a union of typed module configs for all known modules in the ModuleOptions registry.
* This enables automatic type inference when using registered module resolve strings.
*/
type KnownModuleConfigs = {
[K in keyof ModuleOptions]: Partial<
Omit<InternalModuleDeclaration, "options"> & {
type ModuleConfigForResolve<R extends string> = R extends keyof ModuleOptions
? {
resolve: R
key?: string
disable?: boolean
resolve: K
options?: ModuleOptions[K]
}
>
}[keyof ModuleOptions]
options?: ModuleOptions[R]
} & Partial<Omit<InternalModuleDeclaration, "options" | "resolve">>
: {
resolve?: string
key?: string
disable?: boolean
options?: object
} & Partial<Omit<InternalModuleDeclaration, "options" | "resolve">>
/**
* Generates a union of typed module configs for all known modules in the ModuleOptions registry.
* This distributes over all keys in ModuleOptions to create specific config types for each.
*/
type KnownModuleConfigs = ModuleConfigForResolve<keyof ModuleOptions & string>
/**
* Generic module config for modules not registered in ModuleOptions.
*/
type GenericModuleConfig = Partial<
Omit<InternalModuleDeclaration, "options"> & {
key?: string
disable?: boolean
resolve?: string
options?: Record<string, unknown>
}
>
type GenericModuleConfig = ModuleConfigForResolve<string & {}>
/**
* Modules accepted by the defineConfig function.
@@ -1177,20 +1175,36 @@ export type InputConfigModules = (
)[]
/**
* The configuration accepted by the "defineConfig" helper
* Base configuration type without modules
*/
export type InputConfig = Partial<
type InputConfigBase = Partial<
Omit<ConfigModule, "admin" | "modules"> & {
admin?: Partial<ConfigModule["admin"]>
modules:
| InputConfigModules
/**
* @deprecated use the array instead
*/
| ConfigModule["modules"]
}
>
/**
* Configuration with array-based modules (recommended)
*/
export type InputConfigWithArrayModules = InputConfigBase & {
modules?: InputConfigModules
}
/**
* Configuration with object-based modules (deprecated)
* @deprecated Use array-based modules instead
*/
export type InputConfigWithObjectModules = InputConfigBase & {
modules?: ConfigModule["modules"]
}
/**
* The configuration accepted by the "defineConfig" helper
*/
export type InputConfig =
| InputConfigWithArrayModules
| InputConfigWithObjectModules
type PluginAdminDetails = {
type: "local" | "package"
resolve: string

View File

@@ -1,5 +1,27 @@
import { Context } from "../shared-context"
// TODO: Comment temporarely and we will re enable it in the near future #14478
// /**
// * Configuration options for individual events.
// */
// export interface EventOptions {
// /**
// * Priority level for the event processing.
// * Lower numbers indicate higher priority.
// */
// priority?: number
// }
// /**
// * Registry for event bus events options types.
// * Events will be added to this registry to serve as a global configuration for all events
// * as part of the event bus module service module options.
// *
// * Modules augment this interface using declaration merging to register their event configurations.
// * Custom events can be added via declaration merging in your project.
// */
// export interface EventBusEventsOptions {}
export type Subscriber<TData = unknown> = (data: Event<TData>) => Promise<void>
export type SubscriberContext = {

View File

@@ -3,6 +3,8 @@ import {
ConfigModule,
InputConfig,
InputConfigModules,
InputConfigWithArrayModules,
InputConfigWithObjectModules,
InternalModuleDeclaration,
MedusaCloudOptions,
} from "@medusajs/types"
@@ -43,6 +45,15 @@ export const DEFAULT_STORE_RESTRICTED_FIELDS = [
* make an application work seamlessly, but still provide you the ability
* to override configuration as needed.
*/
export function defineConfig(
config?: InputConfigWithArrayModules
): ConfigModule
/**
* @deprecated Use array-based modules configuration instead
*/
export function defineConfig(
config?: InputConfigWithObjectModules
): ConfigModule
export function defineConfig(config: InputConfig = {}): ConfigModule {
const options = {
isCloud: process.env.EXECUTION_CONTEXT === MEDUSA_CLOUD_EXECUTION_CONTEXT,

View File

@@ -1,3 +1,6 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
/**
* @category Cart
* @customNamespace Cart
@@ -63,7 +66,7 @@ export const CartWorkflowEvents = {
* ```
*/
CUSTOMER_TRANSFERRED: "cart.customer_transferred",
}
} as const
/**
* @category Customer
@@ -103,7 +106,7 @@ export const CustomerWorkflowEvents = {
* ```
*/
DELETED: "customer.deleted",
}
} as const
/**
* @category Order
@@ -259,7 +262,7 @@ export const OrderWorkflowEvents = {
* ```
*/
TRANSFER_REQUESTED: "order.transfer_requested",
}
} as const
/**
* @category Order Edit
@@ -308,7 +311,7 @@ export const OrderEditWorkflowEvents = {
* ```
*/
CANCELED: "order-edit.canceled",
}
} as const
/**
* @category User
@@ -348,7 +351,7 @@ export const UserWorkflowEvents = {
* ```
*/
DELETED: "user.deleted",
}
} as const
/**
* @category Auth
@@ -370,7 +373,7 @@ export const AuthWorkflowEvents = {
* ```
*/
PASSWORD_RESET: "auth.password_reset",
}
} as const
/**
* @category Sales Channel
@@ -410,7 +413,7 @@ export const SalesChannelWorkflowEvents = {
* ```
*/
DELETED: "sales-channel.deleted",
}
} as const
/**
* @category Product Category
@@ -450,7 +453,7 @@ export const ProductCategoryWorkflowEvents = {
* ```
*/
DELETED: "product-category.deleted",
}
} as const
/**
* @category Product Collection
@@ -490,7 +493,7 @@ export const ProductCollectionWorkflowEvents = {
* ```
*/
DELETED: "product-collection.deleted",
}
} as const
/**
* @category Product Variant
@@ -530,7 +533,7 @@ export const ProductVariantWorkflowEvents = {
* ```
*/
DELETED: "product-variant.deleted",
}
} as const
/**
* @category Product
@@ -570,7 +573,7 @@ export const ProductWorkflowEvents = {
* ```
*/
DELETED: "product.deleted",
}
} as const
/**
* @category Product Type
@@ -610,7 +613,7 @@ export const ProductTypeWorkflowEvents = {
* ```
*/
DELETED: "product-type.deleted",
}
} as const
/**
* @category Product Tag
@@ -650,7 +653,7 @@ export const ProductTagWorkflowEvents = {
* ```
*/
DELETED: "product-tag.deleted",
}
} as const
/**
* @category Product Option
@@ -690,7 +693,7 @@ export const ProductOptionWorkflowEvents = {
* ```
*/
DELETED: "product-option.deleted",
}
} as const
/**
* @category Invite
@@ -744,7 +747,7 @@ export const InviteWorkflowEvents = {
* ```
*/
RESENT: "invite.resent",
}
} as const
/**
* @category Region
@@ -784,7 +787,7 @@ export const RegionWorkflowEvents = {
* ```
*/
DELETED: "region.deleted",
}
} as const
/**
* @category Fulfillment
@@ -814,7 +817,7 @@ export const FulfillmentWorkflowEvents = {
* ```
*/
DELIVERY_CREATED: "delivery.created",
}
} as const
/**
* @category Shipping Option Type
@@ -860,7 +863,7 @@ export const ShippingOptionTypeWorkflowEvents = {
* ```
*/
DELETED: "shipping-option-type.deleted",
}
} as const
/**
* @category Shipping Option
@@ -906,7 +909,7 @@ export const ShippingOptionWorkflowEvents = {
* ```
*/
DELETED: "shipping-option.deleted",
}
} as const
/**
* @category Payment
@@ -935,7 +938,7 @@ export const PaymentEvents = {
* ```
*/
REFUNDED: "payment.refunded",
}
} as const
/**
* @category Translation
@@ -981,4 +984,122 @@ export const TranslationWorkflowEvents = {
* ```
*/
DELETED: "translation.deleted",
}
} as const
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Cart events
// [CartWorkflowEvents.CREATED]?: EventOptions
// [CartWorkflowEvents.UPDATED]?: EventOptions
// [CartWorkflowEvents.CUSTOMER_UPDATED]?: EventOptions
// [CartWorkflowEvents.REGION_UPDATED]?: EventOptions
// [CartWorkflowEvents.CUSTOMER_TRANSFERRED]?: EventOptions
// // Customer events
// [CustomerWorkflowEvents.CREATED]?: EventOptions
// [CustomerWorkflowEvents.UPDATED]?: EventOptions
// [CustomerWorkflowEvents.DELETED]?: EventOptions
// // Order events
// [OrderWorkflowEvents.UPDATED]?: EventOptions
// [OrderWorkflowEvents.PLACED]?: EventOptions
// [OrderWorkflowEvents.CANCELED]?: EventOptions
// [OrderWorkflowEvents.COMPLETED]?: EventOptions
// [OrderWorkflowEvents.ARCHIVED]?: EventOptions
// [OrderWorkflowEvents.FULFILLMENT_CREATED]?: EventOptions
// [OrderWorkflowEvents.FULFILLMENT_CANCELED]?: EventOptions
// [OrderWorkflowEvents.RETURN_REQUESTED]?: EventOptions
// [OrderWorkflowEvents.RETURN_RECEIVED]?: EventOptions
// [OrderWorkflowEvents.CLAIM_CREATED]?: EventOptions
// [OrderWorkflowEvents.EXCHANGE_CREATED]?: EventOptions
// [OrderWorkflowEvents.TRANSFER_REQUESTED]?: EventOptions
// // Order Edit events
// [OrderEditWorkflowEvents.REQUESTED]?: EventOptions
// [OrderEditWorkflowEvents.CONFIRMED]?: EventOptions
// [OrderEditWorkflowEvents.CANCELED]?: EventOptions
// // User events
// [UserWorkflowEvents.CREATED]?: EventOptions
// [UserWorkflowEvents.UPDATED]?: EventOptions
// [UserWorkflowEvents.DELETED]?: EventOptions
// // Auth events
// [AuthWorkflowEvents.PASSWORD_RESET]?: EventOptions
// // Sales Channel events
// [SalesChannelWorkflowEvents.CREATED]?: EventOptions
// [SalesChannelWorkflowEvents.UPDATED]?: EventOptions
// [SalesChannelWorkflowEvents.DELETED]?: EventOptions
// // Product Category events
// [ProductCategoryWorkflowEvents.CREATED]?: EventOptions
// [ProductCategoryWorkflowEvents.UPDATED]?: EventOptions
// [ProductCategoryWorkflowEvents.DELETED]?: EventOptions
// // Product Collection events
// [ProductCollectionWorkflowEvents.CREATED]?: EventOptions
// [ProductCollectionWorkflowEvents.UPDATED]?: EventOptions
// [ProductCollectionWorkflowEvents.DELETED]?: EventOptions
// // Product Variant events
// [ProductVariantWorkflowEvents.CREATED]?: EventOptions
// [ProductVariantWorkflowEvents.UPDATED]?: EventOptions
// [ProductVariantWorkflowEvents.DELETED]?: EventOptions
// // Product events
// [ProductWorkflowEvents.CREATED]?: EventOptions
// [ProductWorkflowEvents.UPDATED]?: EventOptions
// [ProductWorkflowEvents.DELETED]?: EventOptions
// // Product Type events
// [ProductTypeWorkflowEvents.CREATED]?: EventOptions
// [ProductTypeWorkflowEvents.UPDATED]?: EventOptions
// [ProductTypeWorkflowEvents.DELETED]?: EventOptions
// // Product Tag events
// [ProductTagWorkflowEvents.CREATED]?: EventOptions
// [ProductTagWorkflowEvents.UPDATED]?: EventOptions
// [ProductTagWorkflowEvents.DELETED]?: EventOptions
// // Product Option events
// [ProductOptionWorkflowEvents.CREATED]?: EventOptions
// [ProductOptionWorkflowEvents.UPDATED]?: EventOptions
// [ProductOptionWorkflowEvents.DELETED]?: EventOptions
// // Invite events
// [InviteWorkflowEvents.ACCEPTED]?: EventOptions
// [InviteWorkflowEvents.CREATED]?: EventOptions
// [InviteWorkflowEvents.DELETED]?: EventOptions
// [InviteWorkflowEvents.RESENT]?: EventOptions
// // Region events
// [RegionWorkflowEvents.CREATED]?: EventOptions
// [RegionWorkflowEvents.UPDATED]?: EventOptions
// [RegionWorkflowEvents.DELETED]?: EventOptions
// // Fulfillment events
// [FulfillmentWorkflowEvents.SHIPMENT_CREATED]?: EventOptions
// [FulfillmentWorkflowEvents.DELIVERY_CREATED]?: EventOptions
// // Shipping Option Type events
// [ShippingOptionTypeWorkflowEvents.CREATED]?: EventOptions
// [ShippingOptionTypeWorkflowEvents.UPDATED]?: EventOptions
// [ShippingOptionTypeWorkflowEvents.DELETED]?: EventOptions
// // Shipping Option events
// [ShippingOptionWorkflowEvents.CREATED]?: EventOptions
// [ShippingOptionWorkflowEvents.UPDATED]?: EventOptions
// [ShippingOptionWorkflowEvents.DELETED]?: EventOptions
// // Payment events
// [PaymentEvents.CAPTURED]?: EventOptions
// [PaymentEvents.REFUNDED]?: EventOptions
// // Translation events
// [TranslationWorkflowEvents.CREATED]?: EventOptions
// [TranslationWorkflowEvents.UPDATED]?: EventOptions
// [TranslationWorkflowEvents.DELETED]?: EventOptions
// }
// }

View File

@@ -2,30 +2,42 @@ import { KebabCase, SnakeCase } from "@medusajs/types"
import { camelToSnakeCase, kebabCase, lowerCaseFirst } from "../common"
import { CommonEvents } from "./common-events"
type ReturnType<TNames extends string[]> = {
type ReturnType<TNames extends string[], TPrefix extends string = ""> = {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_CREATED`]: `${KebabCase<K & string>}.created`
>}_CREATED`]: TPrefix extends ""
? `${KebabCase<K & string>}.created`
: `${TPrefix}.${KebabCase<K & string>}.created`
} & {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_UPDATED`]: `${KebabCase<K & string>}.updated`
>}_UPDATED`]: TPrefix extends ""
? `${KebabCase<K & string>}.updated`
: `${TPrefix}.${KebabCase<K & string>}.updated`
} & {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_DELETED`]: `${KebabCase<K & string>}.deleted`
>}_DELETED`]: TPrefix extends ""
? `${KebabCase<K & string>}.deleted`
: `${TPrefix}.${KebabCase<K & string>}.deleted`
} & {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_RESTORED`]: `${KebabCase<K & string>}.restored`
>}_RESTORED`]: TPrefix extends ""
? `${KebabCase<K & string>}.restored`
: `${TPrefix}.${KebabCase<K & string>}.restored`
} & {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_ATTACHED`]: `${KebabCase<K & string>}.attached`
>}_ATTACHED`]: TPrefix extends ""
? `${KebabCase<K & string>}.attached`
: `${TPrefix}.${KebabCase<K & string>}.attached`
} & {
[K in TNames[number] as `${Uppercase<
SnakeCase<K & string>
>}_DETACHED`]: `${KebabCase<K & string>}.detached`
>}_DETACHED`]: TPrefix extends ""
? `${KebabCase<K & string>}.detached`
: `${TPrefix}.${KebabCase<K & string>}.detached`
}
/**
@@ -64,10 +76,10 @@ export function buildModuleResourceEventName({
* @param names
* @param prefix
*/
export function buildEventNamesFromEntityName<TNames extends string[]>(
names: TNames,
prefix?: string
): ReturnType<TNames> {
export function buildEventNamesFromEntityName<
TNames extends string[],
TPrefix extends string = ""
>(names: TNames, prefix?: TPrefix): ReturnType<TNames, TPrefix> {
const events = {}
for (let i = 0; i < names.length; i++) {
@@ -85,7 +97,7 @@ export function buildEventNamesFromEntityName<TNames extends string[]>(
}
}
return events as ReturnType<TNames>
return events as ReturnType<TNames, TPrefix>
}
export const EventPriority = {

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -37,4 +39,101 @@ export const FulfillmentEvents = {
* @deprecated use `FulfillmentWorkflowEvents.DELIVERY_CREATED` instead
*/
DELIVERY_CREATED: "delivery.created",
}
} as const
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Fulfillment Set events
// [FulfillmentEvents.FULFILLMENT_SET_CREATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_SET_UPDATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_SET_DELETED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_SET_RESTORED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_SET_ATTACHED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_SET_DETACHED]?: EventOptions
// // Service Zone events
// [FulfillmentEvents.SERVICE_ZONE_CREATED]?: EventOptions
// [FulfillmentEvents.SERVICE_ZONE_UPDATED]?: EventOptions
// [FulfillmentEvents.SERVICE_ZONE_DELETED]?: EventOptions
// [FulfillmentEvents.SERVICE_ZONE_RESTORED]?: EventOptions
// [FulfillmentEvents.SERVICE_ZONE_ATTACHED]?: EventOptions
// [FulfillmentEvents.SERVICE_ZONE_DETACHED]?: EventOptions
// // Geo Zone events
// [FulfillmentEvents.GEO_ZONE_CREATED]?: EventOptions
// [FulfillmentEvents.GEO_ZONE_UPDATED]?: EventOptions
// [FulfillmentEvents.GEO_ZONE_DELETED]?: EventOptions
// [FulfillmentEvents.GEO_ZONE_RESTORED]?: EventOptions
// [FulfillmentEvents.GEO_ZONE_ATTACHED]?: EventOptions
// [FulfillmentEvents.GEO_ZONE_DETACHED]?: EventOptions
// // Shipping Option events
// [FulfillmentEvents.SHIPPING_OPTION_CREATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_UPDATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_DELETED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RESTORED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_ATTACHED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_DETACHED]?: EventOptions
// // Shipping Option Type events
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_CREATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_UPDATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_DELETED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_RESTORED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_ATTACHED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_TYPE_DETACHED]?: EventOptions
// // Shipping Profile events
// [FulfillmentEvents.SHIPPING_PROFILE_CREATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_PROFILE_UPDATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_PROFILE_DELETED]?: EventOptions
// [FulfillmentEvents.SHIPPING_PROFILE_RESTORED]?: EventOptions
// [FulfillmentEvents.SHIPPING_PROFILE_ATTACHED]?: EventOptions
// [FulfillmentEvents.SHIPPING_PROFILE_DETACHED]?: EventOptions
// // Shipping Option Rule events
// [FulfillmentEvents.SHIPPING_OPTION_RULE_CREATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RULE_UPDATED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RULE_DELETED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RULE_RESTORED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RULE_ATTACHED]?: EventOptions
// [FulfillmentEvents.SHIPPING_OPTION_RULE_DETACHED]?: EventOptions
// // Fulfillment events
// [FulfillmentEvents.FULFILLMENT_CREATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_UPDATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_DELETED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_RESTORED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ATTACHED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_DETACHED]?: EventOptions
// // Fulfillment Address events
// [FulfillmentEvents.FULFILLMENT_ADDRESS_CREATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ADDRESS_UPDATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ADDRESS_DELETED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ADDRESS_RESTORED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ADDRESS_ATTACHED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ADDRESS_DETACHED]?: EventOptions
// // Fulfillment Item events
// [FulfillmentEvents.FULFILLMENT_ITEM_CREATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ITEM_UPDATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ITEM_DELETED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ITEM_RESTORED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ITEM_ATTACHED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_ITEM_DETACHED]?: EventOptions
// // Fulfillment Label events
// [FulfillmentEvents.FULFILLMENT_LABEL_CREATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_LABEL_UPDATED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_LABEL_DELETED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_LABEL_RESTORED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_LABEL_ATTACHED]?: EventOptions
// [FulfillmentEvents.FULFILLMENT_LABEL_DETACHED]?: EventOptions
// // Deprecated events
// [FulfillmentEvents.SHIPMENT_CREATED]?: EventOptions
// [FulfillmentEvents.DELIVERY_CREATED]?: EventOptions
// }
// }

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -11,3 +13,32 @@ export const InventoryEvents = buildEventNamesFromEntityName(
eventBaseNames,
Modules.INVENTORY
)
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Inventory Item events
// [InventoryEvents.INVENTORY_ITEM_CREATED]?: EventOptions
// [InventoryEvents.INVENTORY_ITEM_UPDATED]?: EventOptions
// [InventoryEvents.INVENTORY_ITEM_DELETED]?: EventOptions
// [InventoryEvents.INVENTORY_ITEM_RESTORED]?: EventOptions
// [InventoryEvents.INVENTORY_ITEM_ATTACHED]?: EventOptions
// [InventoryEvents.INVENTORY_ITEM_DETACHED]?: EventOptions
// // Reservation Item events
// [InventoryEvents.RESERVATION_ITEM_CREATED]?: EventOptions
// [InventoryEvents.RESERVATION_ITEM_UPDATED]?: EventOptions
// [InventoryEvents.RESERVATION_ITEM_DELETED]?: EventOptions
// [InventoryEvents.RESERVATION_ITEM_RESTORED]?: EventOptions
// [InventoryEvents.RESERVATION_ITEM_ATTACHED]?: EventOptions
// [InventoryEvents.RESERVATION_ITEM_DETACHED]?: EventOptions
// // Inventory Level events
// [InventoryEvents.INVENTORY_LEVEL_CREATED]?: EventOptions
// [InventoryEvents.INVENTORY_LEVEL_UPDATED]?: EventOptions
// [InventoryEvents.INVENTORY_LEVEL_DELETED]?: EventOptions
// [InventoryEvents.INVENTORY_LEVEL_RESTORED]?: EventOptions
// [InventoryEvents.INVENTORY_LEVEL_ATTACHED]?: EventOptions
// [InventoryEvents.INVENTORY_LEVEL_DETACHED]?: EventOptions
// }
// }

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -7,3 +9,16 @@ export const NotificationEvents = buildEventNamesFromEntityName(
eventBaseNames,
Modules.NOTIFICATION
)
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Notification events
// [NotificationEvents.NOTIFICATION_CREATED]?: EventOptions
// [NotificationEvents.NOTIFICATION_UPDATED]?: EventOptions
// [NotificationEvents.NOTIFICATION_DELETED]?: EventOptions
// [NotificationEvents.NOTIFICATION_RESTORED]?: EventOptions
// [NotificationEvents.NOTIFICATION_ATTACHED]?: EventOptions
// [NotificationEvents.NOTIFICATION_DETACHED]?: EventOptions
// }
// }

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -13,3 +15,48 @@ export const PricingEvents = buildEventNamesFromEntityName(
eventBaseNames,
Modules.PRICING
)
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Price List Rule events
// [PricingEvents.PRICE_LIST_RULE_CREATED]?: EventOptions
// [PricingEvents.PRICE_LIST_RULE_UPDATED]?: EventOptions
// [PricingEvents.PRICE_LIST_RULE_DELETED]?: EventOptions
// [PricingEvents.PRICE_LIST_RULE_RESTORED]?: EventOptions
// [PricingEvents.PRICE_LIST_RULE_ATTACHED]?: EventOptions
// [PricingEvents.PRICE_LIST_RULE_DETACHED]?: EventOptions
// // Price List events
// [PricingEvents.PRICE_LIST_CREATED]?: EventOptions
// [PricingEvents.PRICE_LIST_UPDATED]?: EventOptions
// [PricingEvents.PRICE_LIST_DELETED]?: EventOptions
// [PricingEvents.PRICE_LIST_RESTORED]?: EventOptions
// [PricingEvents.PRICE_LIST_ATTACHED]?: EventOptions
// [PricingEvents.PRICE_LIST_DETACHED]?: EventOptions
// // Price Rule events
// [PricingEvents.PRICE_RULE_CREATED]?: EventOptions
// [PricingEvents.PRICE_RULE_UPDATED]?: EventOptions
// [PricingEvents.PRICE_RULE_DELETED]?: EventOptions
// [PricingEvents.PRICE_RULE_RESTORED]?: EventOptions
// [PricingEvents.PRICE_RULE_ATTACHED]?: EventOptions
// [PricingEvents.PRICE_RULE_DETACHED]?: EventOptions
// // Price Set events
// [PricingEvents.PRICE_SET_CREATED]?: EventOptions
// [PricingEvents.PRICE_SET_UPDATED]?: EventOptions
// [PricingEvents.PRICE_SET_DELETED]?: EventOptions
// [PricingEvents.PRICE_SET_RESTORED]?: EventOptions
// [PricingEvents.PRICE_SET_ATTACHED]?: EventOptions
// [PricingEvents.PRICE_SET_DETACHED]?: EventOptions
// // Price events
// [PricingEvents.PRICE_CREATED]?: EventOptions
// [PricingEvents.PRICE_UPDATED]?: EventOptions
// [PricingEvents.PRICE_DELETED]?: EventOptions
// [PricingEvents.PRICE_RESTORED]?: EventOptions
// [PricingEvents.PRICE_ATTACHED]?: EventOptions
// [PricingEvents.PRICE_DETACHED]?: EventOptions
// }
// }

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -27,3 +29,80 @@ export const ProductEvents = buildEventNamesFromEntityName(
eventBaseNames,
Modules.PRODUCT
)
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // Product events
// [ProductEvents.PRODUCT_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_DETACHED]?: EventOptions
// // Product Variant events
// [ProductEvents.PRODUCT_VARIANT_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_VARIANT_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_VARIANT_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_VARIANT_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_VARIANT_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_VARIANT_DETACHED]?: EventOptions
// // Product Option events
// [ProductEvents.PRODUCT_OPTION_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_DETACHED]?: EventOptions
// // Product Option Value events
// [ProductEvents.PRODUCT_OPTION_VALUE_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_VALUE_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_VALUE_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_VALUE_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_VALUE_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_OPTION_VALUE_DETACHED]?: EventOptions
// // Product Type events
// [ProductEvents.PRODUCT_TYPE_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_TYPE_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_TYPE_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_TYPE_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_TYPE_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_TYPE_DETACHED]?: EventOptions
// // Product Tag events
// [ProductEvents.PRODUCT_TAG_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_TAG_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_TAG_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_TAG_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_TAG_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_TAG_DETACHED]?: EventOptions
// // Product Category events
// [ProductEvents.PRODUCT_CATEGORY_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_CATEGORY_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_CATEGORY_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_CATEGORY_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_CATEGORY_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_CATEGORY_DETACHED]?: EventOptions
// // Product Collection events
// [ProductEvents.PRODUCT_COLLECTION_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_COLLECTION_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_COLLECTION_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_COLLECTION_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_COLLECTION_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_COLLECTION_DETACHED]?: EventOptions
// // Product Image events
// [ProductEvents.PRODUCT_IMAGE_CREATED]?: EventOptions
// [ProductEvents.PRODUCT_IMAGE_UPDATED]?: EventOptions
// [ProductEvents.PRODUCT_IMAGE_DELETED]?: EventOptions
// [ProductEvents.PRODUCT_IMAGE_RESTORED]?: EventOptions
// [ProductEvents.PRODUCT_IMAGE_ATTACHED]?: EventOptions
// [ProductEvents.PRODUCT_IMAGE_DETACHED]?: EventOptions
// }
// }

View File

@@ -1,3 +1,5 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import { EventOptions } from "@medusajs/types"
import { buildEventNamesFromEntityName } from "../event-bus"
import { Modules } from "../modules-sdk"
@@ -6,4 +8,28 @@ const eventBaseNames: ["user", "invite"] = ["user", "invite"]
export const UserEvents = {
...buildEventNamesFromEntityName(eventBaseNames, Modules.USER),
INVITE_TOKEN_GENERATED: `${Modules.USER}.user.invite.token_generated`,
}
} as const
// TODO: Comment temporarely and we will re enable it in the near future #14478
// declare module "@medusajs/types" {
// export interface EventBusEventsOptions {
// // User events
// [UserEvents.USER_CREATED]?: EventOptions
// [UserEvents.USER_UPDATED]?: EventOptions
// [UserEvents.USER_DELETED]?: EventOptions
// [UserEvents.USER_RESTORED]?: EventOptions
// [UserEvents.USER_ATTACHED]?: EventOptions
// [UserEvents.USER_DETACHED]?: EventOptions
// // Invite events
// [UserEvents.INVITE_CREATED]?: EventOptions
// [UserEvents.INVITE_UPDATED]?: EventOptions
// [UserEvents.INVITE_DELETED]?: EventOptions
// [UserEvents.INVITE_RESTORED]?: EventOptions
// [UserEvents.INVITE_ATTACHED]?: EventOptions
// [UserEvents.INVITE_DETACHED]?: EventOptions
// // Custom events
// [UserEvents.INVITE_TOKEN_GENERATED]?: EventOptions
// }
// }

View File

@@ -23,7 +23,9 @@
"author": "Medusa",
"license": "MIT",
"devDependencies": {
"@medusajs/framework": "2.12.5"
"@medusajs/framework": "2.12.5",
"@medusajs/types": "2.12.5",
"@medusajs/utils": "2.12.5"
},
"scripts": {
"watch": "yarn run -T tsc --build --watch",

View File

@@ -1,5 +1,7 @@
import {
Event,
// TODO: Comment temporarely and we will re enable it in the near future #14478
// EventBusEventsOptions,
InternalModuleDeclaration,
Logger,
Message,
@@ -53,6 +55,8 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
protected readonly queueOptions_: Omit<QueueOptions, "connection">
protected readonly workerOptions_: Omit<WorkerOptions, "connection">
protected readonly jobOptions_: EmitOptions
// TODO: Comment temporarely and we will re enable it in the near future #14478
// private readonly eventOptions_: EventBusEventsOptions
protected queue_: Queue
protected bullWorker_: Worker
@@ -79,6 +83,11 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
this.queueOptions_ = eventBusRedisQueueOptions ?? {}
this.workerOptions_ = eventBusRedisWorkerOptions ?? {}
this.jobOptions_ = eventBusRedisJobOptions ?? {}
// TODO: Comment temporarely and we will re enable it in the near future #14478
// this.eventOptions_ =
// _moduleOptions.eventOptions ??
// _moduleDeclaration.options?.eventOptions ??
// {}
this.queue_ = new Queue(this.queueName_, {
prefix: `${this.constructor.name}`,
@@ -153,6 +162,11 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
...eventData.options,
}
// TODO: Comment temporarely and we will re enable it in the near future #14478
// finalOptions.priority =
// eventData.options?.priority ??
// this.eventOptions_[eventData.name]?.priority
if (
finalOptions.priority != undefined &&
(finalOptions.priority < 1 ||

View File

@@ -1,3 +1,10 @@
// TODO: Comment temporarely and we will re enable it in the near future #14478
// import type { EventBusEventsOptions } from "@medusajs/types"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import type { ModuleOptions } from "@medusajs/types"
import {
BulkJobOptions,
Job,
@@ -68,6 +75,8 @@ export type EventBusRedisModuleOptions = {
* @see https://api.docs.bullmq.io/interfaces/BaseJobOptions.html
*/
jobOptions?: EmitOptions
// eventOptions?: EventBusEventsOptions
}
declare module "@medusajs/types" {

View File

@@ -0,0 +1 @@
// noop for typeRoots in compiler options

View File

@@ -0,0 +1 @@
// noop, for compiler options

View File

@@ -3575,6 +3575,8 @@ __metadata:
resolution: "@medusajs/event-bus-redis@workspace:packages/modules/event-bus-redis"
dependencies:
"@medusajs/framework": 2.12.5
"@medusajs/types": 2.12.5
"@medusajs/utils": 2.12.5
bullmq: 5.13.0
ioredis: ^5.4.1
peerDependencies: