chore(medusa, orchestration, utils, workflows-sdk): add transaction options support and cleanup (#6020)
* chore(medusa, orchestration, utils, workflows-sdk): add transaction options support and cleanup
This commit is contained in:
committed by
GitHub
parent
0c858f7fd4
commit
fbee006e51
@@ -5,6 +5,7 @@ import {
|
||||
DistributedTransaction,
|
||||
DistributedTransactionEvent,
|
||||
DistributedTransactionEvents,
|
||||
TransactionModelOptions,
|
||||
TransactionOrchestrator,
|
||||
TransactionStepsDefinition,
|
||||
} from "../transaction"
|
||||
@@ -24,6 +25,7 @@ export class LocalWorkflow {
|
||||
protected container: MedusaContainer
|
||||
protected workflowId: string
|
||||
protected flow: OrchestratorBuilder
|
||||
protected customOptions: Partial<TransactionModelOptions> = {}
|
||||
protected workflow: WorkflowDefinition
|
||||
protected handlers: Map<string, StepHandler>
|
||||
|
||||
@@ -64,10 +66,21 @@ export class LocalWorkflow {
|
||||
protected commit() {
|
||||
const finalFlow = this.flow.build()
|
||||
|
||||
const globalWorkflow = WorkflowManager.getWorkflow(this.workflowId)
|
||||
const customOptions = {
|
||||
...globalWorkflow?.options,
|
||||
...this.customOptions,
|
||||
}
|
||||
|
||||
this.workflow = {
|
||||
id: this.workflowId,
|
||||
flow_: finalFlow,
|
||||
orchestrator: new TransactionOrchestrator(this.workflowId, finalFlow),
|
||||
orchestrator: new TransactionOrchestrator(
|
||||
this.workflowId,
|
||||
finalFlow,
|
||||
customOptions
|
||||
),
|
||||
options: customOptions,
|
||||
handler: WorkflowManager.buildHandlers(this.handlers),
|
||||
handlers_: this.handlers,
|
||||
}
|
||||
@@ -361,6 +374,11 @@ export class LocalWorkflow {
|
||||
return transaction
|
||||
}
|
||||
|
||||
setOptions(options: Partial<TransactionModelOptions>) {
|
||||
this.customOptions = options
|
||||
return this
|
||||
}
|
||||
|
||||
addAction(
|
||||
action: string,
|
||||
handler: StepHandler,
|
||||
|
||||
Reference in New Issue
Block a user