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 authored and GitHub committed 2024-02-01 13:37:26 +00:00
1 parent a2bf6756ac
commit 45134e4d11
40 files changed
+576 -170

No files matched your search

@@ -7,7 +7,6 @@ import {
FindConfig,
InternalModuleDeclaration,
ModuleJoinerConfig,
MoneyAmountDTO,
PriceSetDTO,
PricingContext,
PricingFilters,
@@ -56,14 +55,14 @@ import {
PriceSetService,
RuleTypeService,
} from "@services"
import { ServiceTypes } from "@types"
import { validatePriceListDates } from "@utils"
import { CreatePriceListRuleValueDTO } from "src/types/services"
import {
LinkableKeys,
entityNameToLinkableKeysMap,
joinerConfig,
} from "../joiner-config"
import { validatePriceListDates } from "@utils"
import { ServiceTypes } from "@types"
import { CreatePriceListRuleValueDTO } from "src/types/services"
type InjectedDependencies = {
baseRepository: DAL.RepositoryService
pricingRepository: PricingRepositoryService
@@ -639,8 +638,8 @@ export default class PricingModuleService<
// Price set money amounts
let maCursor = 0
const priceSetMoneyAmountsBulkData: unknown[] =
input.flatMap(({ priceSetId, prices }) =>
const priceSetMoneyAmountsBulkData: unknown[] = input.flatMap(
({ priceSetId, prices }) =>
prices.map(() => {
const ma = createdMoneyAmounts[maCursor]
const numberOfRules = Object.entries(
@@ -654,7 +653,7 @@ export default class PricingModuleService<
rules_count: numberOfRules,
}
})
)
)
const createdPriceSetMoneyAmounts =
await this.priceSetMoneyAmountService_.create(
priceSetMoneyAmountsBulkData as ServiceTypes.CreatePriceSetMoneyAmountDTO[],
@@ -1638,7 +1637,6 @@ export default class PricingModuleService<
validatePriceListDates(updatePriceListData)
if (typeof rules === "object") {
updatePriceListData.rules_count = Object.keys(rules).length
}