- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
transform - Workflows API Reference
This documentation provides a reference to the transform
. It belongs to the @medusajs/framework/workflows-sdk
package.
This function transforms the output of other utility functions.
For example, if you're using the value(s) of some step(s) as an input to a later step. As you can't directly manipulate data in the workflow constructor function passed to createWorkflow,
the transform
function provides access to the runtime value of the step(s) output so that you can manipulate them.
Another example is if you're using the runtime value of some step(s) as the output of a workflow.
If you're also retrieving the output of a hook and want to check if its value is set, you must use a workflow to get the runtime value of that hook.
Example#
1import {2 createWorkflow,3 transform,4 WorkflowResponse5} from "@medusajs/framework/workflows-sdk"6import { step1, step2 } from "./steps"7 8type WorkflowInput = {9 name: string10}11 12const myWorkflow = createWorkflow(13 "hello-world",14 (input: WorkflowInput) => {15 const str1 = step1(input)16 const str2 = step2(input)17 18 const message = transform({19 str1,20 str221 }, (input) => `${input.str1}${input.str2}`)22 23 return new WorkflowResponse(message)24})
Type Parameters#
RFinal
objectOptionalParameters#
values
TThe output(s) of other step functions.
func
[Func1<T, RFinal>]The transform function used to perform action on the runtime values of the provided
values
.Returns#
WorkflowData
WorkflowData<RFinal>There's no expected value to be returned by the
transform
function.Was this page helpful?