===== Helper Functions =====
(name string, fn func(input any) (any, error))
| 247 | // ===== Helper Functions ===== |
| 248 | |
| 249 | func SimpleFunction(name string, fn func(input any) (any, error)) *FunctionStep { |
| 250 | return NewFunctionStep(name, func(ctx context.Context, stepInput *StepInput) (*StepOutput, error) { |
| 251 | input := stepInput.Input |
| 252 | if input == nil && stepInput.PreviousStepContent != nil { |
| 253 | input = stepInput.PreviousStepContent |
| 254 | } |
| 255 | |
| 256 | output, err := fn(input) |
| 257 | if err != nil { |
| 258 | return nil, err |
| 259 | } |
| 260 | |
| 261 | return &StepOutput{ |
| 262 | Content: output, |
| 263 | Metadata: make(map[string]any), |
| 264 | }, nil |
| 265 | }) |
| 266 | } |
| 267 | |
| 268 | func TransformFunction(name string, transform func(input any) any) *FunctionStep { |
| 269 | return SimpleFunction(name, func(input any) (any, error) { |
no test coverage detected