//! The Playground DSL.
//!
//! The DSL is the simplified, beginner-friendly command surface
//! described in ADR-0003. This module owns its grammar
//! (`parser`), its abstract syntax tree (`command`), and the
//! user-facing type vocabulary (`types`).
//!
//! Raw SQL handling for advanced mode is intentionally *not* in
//! this module — that path uses `sqlparser-rs` and lives
//! elsewhere when it lands.

pub mod action;
pub mod command;
pub mod grammar;
pub mod parser;
pub mod shortid;
pub mod sql_functions;
pub mod types;
pub mod value;
pub mod walker;

pub use action::ReferentialAction;
pub use command::{
    AlterTableAction, AppCommand, ChangeColumnMode, ColumnSpec, Command, CompareOp, CopyScope,
    Expr, IndexSelector, MessagesValue, ModeValue, Operand, Predicate, RelationshipSelector,
    RowFilter, ShowListKind, SqlForeignKey,
};
pub use parser::{ParseError, parse_command};
pub use types::Type;
pub use value::Value;

/// Prefix every echoed DSL command carries in the output
/// panel — i.e. `[simple] running: <input>` reads as
/// `[simple]` (tag) + `running: ` (this constant) + the
/// user's input.
///
/// The catalog template `dsl.running` is contracted to equal
/// `format!("{ECHO_PREFIX}{{input}}")`. The constant lives
/// in code because the echo-line renderer (ADR-0022 §5)
/// peels this prefix off and re-tokenises the rest for
/// highlighting; a unit test (`echo_prefix_matches_catalog_template`)
/// pins the binding.
pub const ECHO_PREFIX: &str = "running: ";

#[cfg(test)]
mod tests {
    use super::ECHO_PREFIX;

    #[test]
    fn echo_prefix_matches_catalog_template() {
        // The catalog template `dsl.running` must produce
        // `<ECHO_PREFIX><input>` so the echo-line renderer can
        // peel the prefix and re-tokenise the rest. A
        // translator changing the prefix breaks this test.
        let rendered = crate::t!("dsl.running", input = "");
        assert_eq!(rendered, ECHO_PREFIX);
    }
}
