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