Skip to main content

shape_runtime/plugins/data_source/
schema.rs

1//! Schema type definitions for plugin data sources
2//!
3//! This module contains the Rust-friendly representations of query and output schemas
4//! used for LSP autocomplete, validation, and runtime schema discovery.
5
6use serde_json::Value;
7use shape_abi_v1::ParamType;
8
9/// Rust-friendly representation of a query parameter
10#[derive(Debug, Clone)]
11pub struct ParsedQueryParam {
12    /// Parameter name
13    pub name: String,
14    /// Human-readable description
15    pub description: String,
16    /// Parameter type
17    pub param_type: ParamType,
18    /// Is this parameter required?
19    pub required: bool,
20    /// Default value (if any)
21    pub default_value: Option<Value>,
22    /// Allowed values (for enum-like params)
23    pub allowed_values: Option<Vec<Value>>,
24    /// Nested schema (for Object type)
25    pub nested_schema: Option<Box<ParsedQuerySchema>>,
26}
27
28/// Rust-friendly representation of a query schema
29#[derive(Debug, Clone)]
30pub struct ParsedQuerySchema {
31    /// Parameter definitions
32    pub params: Vec<ParsedQueryParam>,
33    /// Example query for documentation
34    pub example_query: Option<Value>,
35}
36
37/// Rust-friendly representation of an output field
38#[derive(Debug, Clone)]
39pub struct ParsedOutputField {
40    /// Field name
41    pub name: String,
42    /// Field type
43    pub field_type: ParamType,
44    /// Human-readable description
45    pub description: String,
46}
47
48/// Rust-friendly representation of an output schema
49#[derive(Debug, Clone)]
50pub struct ParsedOutputSchema {
51    /// Field definitions
52    pub fields: Vec<ParsedOutputField>,
53}