feat(product, pricing, utils): Transaction issues and reference issues (#5533)
* feat(product, pricing, utils): Transaction issues and reference issues * fixes decorators * cleanup * fix product module upsert * fix missing active manager * increase timeout * revert package.json * WIP * try another node version based on findings with memory issues with jest introduced after 16.11 but fixed in 21 * re add bail * fix variant options * chore: bulk create pricing * chore: workflow bulk * Create big-chefs-dream.md * fix missing update for upserty * Add integration tests for product options upsert * rm unnecessary return * fix product prices workflow issue * cleanup * fix flag * fix model --------- Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com> Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
committed by
GitHub
parent
57c3a24ad3
commit
f88d75b0a7
@@ -16,13 +16,12 @@ export function InjectManager(managerProperty?: string): MethodDecorator {
|
||||
const argIndex = target.MedusaContextIndex_[propertyKey]
|
||||
|
||||
descriptor.value = function (...args: any[]) {
|
||||
const context: SharedContext | Context = args[argIndex] ?? {}
|
||||
const resourceWithManager = (!managerProperty
|
||||
const context: SharedContext | Context = { ...(args[argIndex] ?? {}) }
|
||||
const resourceWithManager = !managerProperty
|
||||
? this
|
||||
: this[managerProperty])
|
||||
: this[managerProperty]
|
||||
|
||||
context.manager =
|
||||
context.manager ?? resourceWithManager.getFreshManager()
|
||||
context.manager = context.manager ?? resourceWithManager.getFreshManager()
|
||||
args[argIndex] = context
|
||||
|
||||
return originalMethod.apply(this, args)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Context, SharedContext } from "@medusajs/types"
|
||||
import { isString } from "../../common"
|
||||
|
||||
export function InjectTransactionManager(
|
||||
shouldForceTransaction: (target: any) => boolean = () => false,
|
||||
shouldForceTransactionOrManagerProperty:
|
||||
| string
|
||||
| ((target: any) => boolean) = () => false,
|
||||
managerProperty?: string
|
||||
): MethodDecorator {
|
||||
return function (
|
||||
@@ -16,6 +19,14 @@ export function InjectTransactionManager(
|
||||
}
|
||||
|
||||
const originalMethod = descriptor.value
|
||||
const shouldForceTransaction = !isString(
|
||||
shouldForceTransactionOrManagerProperty
|
||||
)
|
||||
? shouldForceTransactionOrManagerProperty
|
||||
: () => false
|
||||
managerProperty = isString(shouldForceTransactionOrManagerProperty)
|
||||
? shouldForceTransactionOrManagerProperty
|
||||
: managerProperty
|
||||
|
||||
const argIndex = target.MedusaContextIndex_[propertyKey]
|
||||
descriptor.value = async function (...args: any[]) {
|
||||
@@ -31,7 +42,7 @@ export function InjectTransactionManager(
|
||||
: this[managerProperty]
|
||||
).transaction(
|
||||
async (transactionManager) => {
|
||||
args[argIndex] = args[argIndex] ?? {}
|
||||
args[argIndex] = { ...(args[argIndex] ?? {}) }
|
||||
args[argIndex].transactionManager = transactionManager
|
||||
|
||||
return await originalMethod.apply(this, args)
|
||||
|
||||
Reference in New Issue
Block a user