Skip to content

Commit 6016a0d

Browse files
vinassefrancheeffect-bot
authored andcommitted
Add workflow type utils (#5490)
1 parent d2140c1 commit 6016a0d

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
@@ -25,6 +25,41 @@ import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.js"
2525
*/
2626
export const TypeId: unique symbol = Symbol.for("@effect/workflow/Workflow")
2727

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

0 commit comments

Comments
 (0)