mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add type guards for outputs
This commit is contained in:
parent
01607c961f
commit
8d8284afaa
33
invokeai/frontend/web/src/services/types/guards.ts
Normal file
33
invokeai/frontend/web/src/services/types/guards.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import {
|
||||||
|
GraphExecutionState,
|
||||||
|
GraphInvocationOutput,
|
||||||
|
ImageOutput,
|
||||||
|
MaskOutput,
|
||||||
|
PromptOutput,
|
||||||
|
IterateInvocationOutput,
|
||||||
|
CollectInvocationOutput,
|
||||||
|
} from 'services/api';
|
||||||
|
|
||||||
|
export const isImageOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is ImageOutput => output.type === 'image';
|
||||||
|
|
||||||
|
export const isMaskOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is MaskOutput => output.type === 'mask';
|
||||||
|
|
||||||
|
export const isPromptOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is PromptOutput => output.type === 'prompt';
|
||||||
|
|
||||||
|
export const isGraphOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is GraphInvocationOutput => output.type === 'graph_output';
|
||||||
|
|
||||||
|
export const isIterateOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is IterateInvocationOutput => output.type === 'iterate_output';
|
||||||
|
|
||||||
|
export const isCollectOutput = (
|
||||||
|
output: GraphExecutionState['results'][string]
|
||||||
|
): output is CollectInvocationOutput => output.type === 'collect_output';
|
Loading…
x
Reference in New Issue
Block a user