Skip to content

Commit 79a612d

Browse files
vinassefrancheeffect-bot
authored andcommitted
Add workflow type utils (#5490)
1 parent 52d5963 commit 79a612d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.changeset/afraid-phones-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/workflow": patch
3+
---
4+
5+
Add Workflow type utils

packages/workflow/src/Workflow.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,41 @@ import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.js"
2626
*/
2727
export const TypeId: unique symbol = Symbol.for("@effect/workflow/Workflow")
2828

29+
/**
30+
* @since 1.0.0
31+
*/
32+
export declare namespace Workflow {
33+
/**
34+
* Extracts the type of the Payload of a `Workflow`.
35+
*
36+
* @since 1.0.0
37+
* @category Type-level Utils
38+
*/
39+
export type Payload<W extends Workflow<any, any, any, any>> = W extends Workflow<any, infer Payload, any, any>
40+
? Payload["Type"]
41+
: never
42+
43+
/**
44+
* Extracts the type of the Success of a `Workflow`.
45+
*
46+
* @since 1.0.0
47+
* @category Type-level Utils
48+
*/
49+
export type Success<W extends Workflow<any, any, any, any>> = W extends Workflow<any, any, infer Success, any>
50+
? Success["Type"]
51+
: never
52+
53+
/**
54+
* Extracts the type of the Error of a `Workflow`.
55+
*
56+
* @since 1.0.0
57+
* @category Type-level Utils
58+
*/
59+
export type Error<W extends Workflow<any, any, any, any>> = W extends Workflow<any, any, any, infer Error>
60+
? Error["Type"]
61+
: never
62+
}
63+
2964
/**
3065
* @since 1.0.0
3166
* @category Symbols

0 commit comments

Comments
 (0)