fix(modules-sdk): create workflow returning step transformer (#6102)
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
||||
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
|
||||
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import { OrchestrationUtils } from "@medusajs/utils"
|
||||
import { EOL } from "os"
|
||||
import { ulid } from "ulid"
|
||||
import { MedusaWorkflow } from "../medusa-workflow"
|
||||
@@ -129,33 +128,11 @@ export const exportWorkflow = <TData = unknown, TResult = unknown>(
|
||||
throw new Error(errorMessage)
|
||||
}
|
||||
|
||||
let result: any = undefined
|
||||
|
||||
const resFrom =
|
||||
resultFrom?.__type === OrchestrationUtils.SymbolWorkflowStep
|
||||
? resultFrom.__step__
|
||||
: resultFrom
|
||||
|
||||
if (resFrom) {
|
||||
if (Array.isArray(resFrom)) {
|
||||
result = resFrom.map((from) => {
|
||||
const res = transaction.getContext().invoke?.[from]
|
||||
return res?.__type === OrchestrationUtils.SymbolWorkflowWorkflowData
|
||||
? res.output
|
||||
: res
|
||||
})
|
||||
} else {
|
||||
const res = transaction.getContext().invoke?.[resFrom]
|
||||
result =
|
||||
res?.__type === OrchestrationUtils.SymbolWorkflowWorkflowData
|
||||
? res.output
|
||||
: res
|
||||
}
|
||||
|
||||
const ret = result || resFrom
|
||||
result = options?.wrappedInput
|
||||
? await resolveValue(ret, transaction.getContext())
|
||||
: ret
|
||||
let result
|
||||
if (options?.wrappedInput) {
|
||||
result = await resolveValue(resultFrom, transaction.getContext())
|
||||
} else {
|
||||
result = transaction.getContext().invoke?.[resultFrom]
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user