fix(medusa): Bulk create variant + pass transaction to the inventory service context methods (#3835)
* fix(medusa): Bulk create variant and pass transaction where needed * Create fair-penguins-stare.md * fix unit tests * event * transaction orchestration * revert options * Prevent isolated module to use the given transaction if any in the exposed service * Use enum * remove changeset to re do it * Create thick-ants-tickle.md * update event bus local * remove changeset to re do it * Create thick-kings-wonder.md * remove changeset to re do it * Create slimy-bees-eat.md * Update packages/utils/src/event-bus/index.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> --------- Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
Philip Korsholm
parent
366b12fcea
commit
af710f1b48
@@ -1,7 +1,8 @@
|
||||
import { SharedContext } from "@medusajs/types"
|
||||
|
||||
export function InjectEntityManager(
|
||||
managerProperty = "manager_"
|
||||
shouldForceTransaction: (target: any) => boolean = () => false,
|
||||
managerProperty: string = "manager_"
|
||||
): MethodDecorator {
|
||||
return function (
|
||||
target: any,
|
||||
@@ -18,9 +19,10 @@ export function InjectEntityManager(
|
||||
|
||||
const argIndex = target.MedusaContextIndex_[propertyKey]
|
||||
descriptor.value = async function (...args: any[]) {
|
||||
const shouldForceTransactionRes = shouldForceTransaction(target)
|
||||
const context: SharedContext = args[argIndex] ?? {}
|
||||
|
||||
if (context?.transactionManager) {
|
||||
if (!shouldForceTransactionRes && context?.transactionManager) {
|
||||
return await originalMethod.apply(this, args)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user