stasis/ports/outbound/runtime/
workflow_reflection.rs1use serde::{Deserialize, Serialize};
2use std::collections::BTreeMap;
3
4use crate::domain::errors::Result;
5
6#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7pub enum WorkflowExecutableKind {
8 Query,
9 Mutation,
10 Subscription,
11 Iterator,
12}
13
14#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
15pub struct WorkflowExecutableReflection {
16 pub name: String,
17 pub kind: WorkflowExecutableKind,
18 pub description: Option<String>,
19 pub input_type: Option<String>,
20 pub output_type: Option<String>,
21 pub loop_directive_count: usize,
22 pub recursive_directive_count: usize,
23 pub retry_directive_count: usize,
24 pub timeout_directive_count: usize,
25 pub pipeline_count: usize,
26 pub step_count: usize,
27}
28
29#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
30pub struct WorkflowSourceReflection {
31 pub count: usize,
32 pub executables: Vec<WorkflowExecutableReflection>,
33}
34
35#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
36pub struct WorkflowModuleSearchReflection {
37 pub query: String,
38 pub count: usize,
39 pub matches: Vec<WorkflowModuleSearchMatchReflection>,
40}
41
42#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
43pub struct WorkflowModuleSearchMatchReflection {
44 pub module_id: String,
45 pub score: Option<f64>,
46 pub summary: String,
47 pub matching_ops: Vec<String>,
48 pub related_examples: Vec<String>,
49}
50
51#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
52pub struct WorkflowModuleOperationArgReflection {
53 pub name: String,
54 pub ty: String,
55 pub required: bool,
56}
57
58#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
59pub struct WorkflowModuleOperationObjectFieldReflection {
60 pub ty: String,
61 pub required: bool,
62}
63
64#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
65pub struct WorkflowModuleOperationObjectTypeReflection {
66 pub kind: String,
67 pub required: Vec<String>,
68 pub properties: BTreeMap<String, WorkflowModuleOperationObjectFieldReflection>,
69}
70
71#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
72pub struct WorkflowModuleOperationReflection {
73 pub op: String,
74 pub stability: String,
75 pub effect: String,
76 pub args: Vec<WorkflowModuleOperationArgReflection>,
77 pub input_object_type: Option<WorkflowModuleOperationObjectTypeReflection>,
78 pub output_object_type: Option<WorkflowModuleOperationObjectTypeReflection>,
79 pub input_schema_ref: Option<String>,
80 pub output_schema_ref: Option<String>,
81}
82
83#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
84pub struct WorkflowModuleInfoReflection {
85 pub module_id: String,
86 pub version: String,
87 pub entrypoint: String,
88 pub required_capabilities: Vec<String>,
89 pub total_ops: usize,
90 pub exported_ops: Vec<WorkflowModuleOperationReflection>,
91}
92
93#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
94pub struct WorkflowModuleTypesReflection {
95 pub module_id: String,
96 pub total_types: usize,
97 pub types: Vec<WorkflowModuleOperationReflection>,
98}
99
100pub trait WorkflowReflectionPort: Send + Sync {
101 fn reflect_executables_from_source(&self, source: &str) -> Result<WorkflowSourceReflection>;
102 fn modules_search(&self, query: &str) -> Result<WorkflowModuleSearchReflection>;
103 fn module_info(&self, module_id: &str) -> Result<Option<WorkflowModuleInfoReflection>>;
104 fn module_types(&self, module_id: &str) -> Result<Option<WorkflowModuleTypesReflection>>;
105}