chore(workflows-sdk): Update hook functions type (#9117)
RESOLVES FRMW-2703 **What** Update types to reflect both invoke and compensate function for hooks
This commit is contained in:
1 parent
9cf0df53b5
commit
f0c470cb08
1 file changed
+4
-2
@@ -10,6 +10,7 @@ import {
|
|||||||
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
|
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
|
||||||
import { ExportedWorkflow } from "../../helper"
|
import { ExportedWorkflow } from "../../helper"
|
||||||
import { Hook } from "./create-hook"
|
import { Hook } from "./create-hook"
|
||||||
|
import { CompensateFn, InvokeFn } from "./create-step"
|
||||||
|
|
||||||
export type StepFunctionResult<TOutput extends unknown | unknown[] = unknown> =
|
export type StepFunctionResult<TOutput extends unknown | unknown[] = unknown> =
|
||||||
(this: CreateWorkflowComposerContext) => WorkflowData<TOutput>
|
(this: CreateWorkflowComposerContext) => WorkflowData<TOutput>
|
||||||
@@ -32,8 +33,9 @@ export type HookHandler = (...args: any[]) => void | Promise<void>
|
|||||||
type ConvertHooksToFunctions<THooks extends any[]> = {
|
type ConvertHooksToFunctions<THooks extends any[]> = {
|
||||||
[K in keyof THooks]: THooks[K] extends Hook<infer Name, infer Input>
|
[K in keyof THooks]: THooks[K] extends Hook<infer Name, infer Input>
|
||||||
? {
|
? {
|
||||||
[Fn in Name]: (
|
[Fn in Name]: <TOutput, TCompensateInput>(
|
||||||
callback: (input: Input, context: StepExecutionContext) => any
|
invoke: InvokeFn<Input, TOutput, TCompensateInput>,
|
||||||
|
compensate?: CompensateFn<TCompensateInput>
|
||||||
) => void
|
) => void
|
||||||
}
|
}
|
||||||
: never
|
: never
|
||||||
|
|||||||
Reference in new issue
Block a user