chore: local workflow proxying methods to pass context (#6263)
What: - When calling a module's method inside a Local Workflow the MedusaContext is passed as the last argument to the method if not provided - Add `requestId` to req - A couple of fixes on Remote Joiner and the data fetcher for internal services Why: - The context used to initialize the workflow has to be shared with all modules. properties like transactionId will be used to emit events and requestId to trace logs for example.
This commit is contained in:
1 parent
a2bf6756ac
commit
45134e4d11
40 files changed
+576
-170
No files matched your search
@@ -54,6 +54,11 @@ import {
|
||||
MedusaError,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { ProductEventData, ProductEvents } from "../types/services/product"
|
||||
import {
|
||||
ProductCategoryEventData,
|
||||
ProductCategoryEvents,
|
||||
} from "../types/services/product-category"
|
||||
import {
|
||||
CreateProductOptionValueDTO,
|
||||
UpdateProductOptionValueDTO,
|
||||
@@ -63,11 +68,6 @@ import {
|
||||
joinerConfig,
|
||||
LinkableKeys,
|
||||
} from "./../joiner-config"
|
||||
import {
|
||||
ProductCategoryEventData,
|
||||
ProductCategoryEvents,
|
||||
} from "../types/services/product-category"
|
||||
import { ProductEventData, ProductEvents } from "../types/services/product"
|
||||
|
||||
type InjectedDependencies = {
|
||||
baseRepository: DAL.RepositoryService
|
||||
@@ -897,7 +897,7 @@ export default class ProductModuleService<
|
||||
@InjectManager("baseRepository_")
|
||||
async create(
|
||||
data: ProductTypes.CreateProductDTO[],
|
||||
sharedContext?: Context
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<ProductTypes.ProductDTO[]> {
|
||||
const products = await this.create_(data, sharedContext)
|
||||
const createdProducts = await this.baseRepository_.serialize<
|
||||
@@ -1319,7 +1319,7 @@ export default class ProductModuleService<
|
||||
>(
|
||||
productIds: string[],
|
||||
{ returnLinkableKeys }: SoftDeleteReturn<TReturnableLinkableKeys> = {},
|
||||
sharedContext: Context = {}
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
|
||||
const [products, cascadedEntitiesMap] = await this.softDelete_(
|
||||
productIds,
|
||||
@@ -1369,7 +1369,7 @@ export default class ProductModuleService<
|
||||
>(
|
||||
productIds: string[],
|
||||
{ returnLinkableKeys }: RestoreReturn<TReturnableLinkableKeys> = {},
|
||||
sharedContext: Context = {}
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
|
||||
const [_, cascadedEntitiesMap] = await this.restore_(
|
||||
productIds,
|
||||
|
||||
Reference in new issue
Block a user