use std::collections::HashMap;
use crate::{
analyze::{
conjunction::Variable,
pipeline::{Pipeline, Reducer},
},
concept::{ValueType, type_::Type},
};
pub mod conjunction;
pub mod pipeline;
#[derive(Debug, Clone)]
pub struct AnalyzedQuery {
pub source: String,
pub query: Pipeline,
pub preamble: Vec<Function>,
pub fetch: Option<Fetch>,
}
#[derive(Debug, Clone)]
pub struct Function {
pub argument_variables: Vec<Variable>,
pub return_operation: ReturnOperation,
pub body: Pipeline,
pub argument_annotations: Vec<VariableAnnotations>,
pub return_annotations: Vec<VariableAnnotations>,
}
#[derive(Debug, Clone)]
pub enum ReturnOperation {
Stream {
variables: Vec<Variable>,
},
Single {
selector: String,
variables: Vec<Variable>,
},
Check {},
Reduce {
reducers: Vec<Reducer>,
},
}
#[derive(Debug, Clone)]
pub enum Fetch {
List(Box<Fetch>),
Leaf(FetchLeaf),
Object(HashMap<String, Fetch>),
}
#[derive(Debug, Clone)]
pub struct FetchLeaf {
pub annotations: Vec<ValueType>,
}
#[derive(Debug, Clone)]
pub struct VariableAnnotations {
#[allow(dead_code, reason = "TODO: Make pub when we know this is correct")]
pub(crate) is_optional: bool,
pub types: TypeAnnotations,
}
#[derive(Debug, Clone)]
pub enum TypeAnnotations {
Instance(Vec<Type>),
Type(Vec<Type>),
Value(ValueType),
}