feature: share execution context with hook handlers (#8501)

This commit is contained in:
Harminder Virk authored and GitHub committed 2024-08-08 17:18:07 +05:30
1 parent f831deaf74
commit 9cd66bc842
2 files changed
+5 -2

No files matched your search

@@ -30,8 +30,9 @@ const workflow = createWorkflow(
}
)
workflow.hooks.something((input) => {
workflow.hooks.something((input, context) => {
console.log("input>", input)
console.log("context>", context)
})
workflow.run().then((res) => {
@@ -32,7 +32,9 @@ export type HookHandler = (...args: any[]) => void | Promise<void>
type ConvertHooksToFunctions<THooks extends any[]> = {
[K in keyof THooks]: THooks[K] extends Hook<infer Name, infer Input>
? {
[Fn in Name]: (callback: (input: Input) => any) => void
[Fn in Name]: (
callback: (input: Input, context: StepExecutionContext) => any
) => void
}
: never
}[number]