From ffb0c7b4cdbc83b61f70c881001a69de6ec8ae99 Mon Sep 17 00:00:00 2001 From: "Carlos R. L. Rodrigues" <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:39:27 +0000 Subject: [PATCH] feat(workflows-sdk): get name method (#5714) --- .changeset/real-ears-eat.md | 5 +++++ .../src/utils/composer/create-workflow.ts | 20 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .changeset/real-ears-eat.md diff --git a/.changeset/real-ears-eat.md b/.changeset/real-ears-eat.md new file mode 100644 index 0000000000000..cb640f7182845 --- /dev/null +++ b/.changeset/real-ears-eat.md @@ -0,0 +1,5 @@ +--- +"@medusajs/workflows-sdk": patch +--- + +Expose getName method to the workflow diff --git a/packages/workflows-sdk/src/utils/composer/create-workflow.ts b/packages/workflows-sdk/src/utils/composer/create-workflow.ts index 199d7ff183053..d44a47f629e87 100644 --- a/packages/workflows-sdk/src/utils/composer/create-workflow.ts +++ b/packages/workflows-sdk/src/utils/composer/create-workflow.ts @@ -4,19 +4,19 @@ import { WorkflowManager, } from "@medusajs/orchestration" import { LoadedModule, MedusaContainer } from "@medusajs/types" -import { exportWorkflow, FlowRunOptions, WorkflowResult } from "../../helper" +import { FlowRunOptions, WorkflowResult, exportWorkflow } from "../../helper" import { - CreateWorkflowComposerContext, - WorkflowData, - WorkflowDataProperties, -} from "./type" -import { - resolveValue, SymbolInputReference, SymbolMedusaWorkflowComposerContext, SymbolWorkflowStep, + resolveValue, } from "./helpers" import { proxify } from "./helpers/proxy" +import { + CreateWorkflowComposerContext, + WorkflowData, + WorkflowDataProperties, +} from "./type" global[SymbolMedusaWorkflowComposerContext] = null @@ -81,7 +81,9 @@ type ReturnWorkflow> = { > > } -} & THooks +} & THooks & { + getName: () => string + } /** * This function creates a workflow with the provided name and a constructor function. @@ -259,5 +261,7 @@ export function createWorkflow< } } + mainFlow.getName = () => name + return mainFlow as ReturnWorkflow }