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:
Carlos R. L. Rodrigues
2024-02-01 13:37:26 +00:00
committed by GitHub
parent a2bf6756ac
commit 45134e4d11
40 changed files with 576 additions and 170 deletions
@@ -939,7 +939,7 @@ export default class PromotionModuleService<
>(
ids: string | string[],
{ returnLinkableKeys }: SoftDeleteReturn<TReturnableLinkableKeys> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
const idsToDelete = Array.isArray(ids) ? ids : [ids]
let [_, cascadedEntitiesMap] = await this.softDelete_(
@@ -975,7 +975,7 @@ export default class PromotionModuleService<
>(
ids: string | string[],
{ returnLinkableKeys }: RestoreReturn<TReturnableLinkableKeys> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
const idsToRestore = Array.isArray(ids) ? ids : [ids]
const [_, cascadedEntitiesMap] = await this.restore_(
@@ -1376,7 +1376,7 @@ export default class PromotionModuleService<
async softDeleteCampaigns<TReturnableLinkableKeys extends string>(
ids: string | string[],
{ returnLinkableKeys }: SoftDeleteReturn<TReturnableLinkableKeys> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
const idsToDelete = Array.isArray(ids) ? ids : [ids]
let [_, cascadedEntitiesMap] = await this.softDeleteCampaigns_(
@@ -1412,7 +1412,7 @@ export default class PromotionModuleService<
>(
ids: string | string[],
{ returnLinkableKeys }: RestoreReturn<TReturnableLinkableKeys> = {},
sharedContext: Context = {}
@MedusaContext() sharedContext: Context = {}
): Promise<Record<Lowercase<keyof typeof LinkableKeys>, string[]> | void> {
const idsToRestore = Array.isArray(ids) ? ids : [ids]
const [_, cascadedEntitiesMap] = await this.restoreCampaigns_(