feat(generator): add multi-mode schema structs for enhanced LLM extraction
Add ModeConditionJson, NormalizeRulesJson, ApiEndpointEnhancedJson, and ModeConfigJson structs to support multi-mode business logic in generated scripts. Enhance SceneInfoJson with modes, default_mode, and mode_switch_field. 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -20,6 +20,66 @@ pub struct ApiEndpointJson {
|
|||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct ModeConditionJson {
|
||||||
|
pub field: String,
|
||||||
|
#[serde(default = "default_equals")]
|
||||||
|
pub operator: String,
|
||||||
|
pub value: serde_json::Value,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_equals() -> String {
|
||||||
|
"equals".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct NormalizeRulesJson {
|
||||||
|
#[serde(rename = "type", default = "default_validate_all")]
|
||||||
|
pub rules_type: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub required_fields: Vec<String>,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
pub filter_null: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_validate_all() -> String {
|
||||||
|
"validate_all_columns".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_true() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct ApiEndpointEnhancedJson {
|
||||||
|
pub name: String,
|
||||||
|
pub url: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub method: String,
|
||||||
|
#[serde(rename = "contentType", default)]
|
||||||
|
pub content_type: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub description: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct ModeConfigJson {
|
||||||
|
pub name: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub label: Option<String>,
|
||||||
|
pub condition: ModeConditionJson,
|
||||||
|
#[serde(rename = "apiEndpoint")]
|
||||||
|
pub api_endpoint: ApiEndpointEnhancedJson,
|
||||||
|
#[serde(rename = "columnDefs", default)]
|
||||||
|
pub column_defs: Vec<(String, String)>,
|
||||||
|
#[serde(rename = "requestTemplate", default)]
|
||||||
|
pub request_template: Option<serde_json::Value>,
|
||||||
|
#[serde(rename = "normalizeRules", default)]
|
||||||
|
pub normalize_rules: Option<NormalizeRulesJson>,
|
||||||
|
#[serde(rename = "responsePath", default)]
|
||||||
|
pub response_path: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct BusinessLogicJson {
|
pub struct BusinessLogicJson {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -52,6 +112,13 @@ pub struct SceneInfoJson {
|
|||||||
pub entry_method: Option<String>,
|
pub entry_method: Option<String>,
|
||||||
#[serde(rename = "businessLogic", default)]
|
#[serde(rename = "businessLogic", default)]
|
||||||
pub business_logic: Option<BusinessLogicJson>,
|
pub business_logic: Option<BusinessLogicJson>,
|
||||||
|
// Multi-mode support (new fields)
|
||||||
|
#[serde(default)]
|
||||||
|
pub modes: Vec<ModeConfigJson>,
|
||||||
|
#[serde(rename = "defaultMode", default)]
|
||||||
|
pub default_mode: Option<String>,
|
||||||
|
#[serde(rename = "modeSwitchField", default)]
|
||||||
|
pub mode_switch_field: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
Reference in New Issue
Block a user