diff --git a/.gitignore b/.gitignore index 1de5659..a7f3110 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -target \ No newline at end of file +target +logs \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index bb32693..79d0a78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "baobab_actor" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#ce76f0a2f7149a098dc075f70c50fa4dc2347c5a" +source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047" dependencies = [ "anyhow", "async-trait", @@ -392,7 +392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -982,7 +982,7 @@ checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hero_job" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#ce76f0a2f7149a098dc075f70c50fa4dc2347c5a" +source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047" dependencies = [ "chrono", "log", @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "hero_logger" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#0da7b9363c2956e6f17ac78232152c549f1d5e68" +source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#d7a7eae19ec22c8f5250a5ee1cea6affe7810d4f" dependencies = [ "anyhow", "chrono", @@ -1014,7 +1014,7 @@ dependencies = [ [[package]] name = "hero_supervisor" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#ce76f0a2f7149a098dc075f70c50fa4dc2347c5a" +source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047" dependencies = [ "anyhow", "chrono", @@ -3825,7 +3825,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] diff --git a/examples/scripts/heroledger.rhai b/examples/scripts/heroledger.rhai new file mode 100644 index 0000000..3d4c72f --- /dev/null +++ b/examples/scripts/heroledger.rhai @@ -0,0 +1,53 @@ +// heroledger.rhai - Demonstration of HeroLedger models in Rhai + +print("=== HeroLedger Models Demo ==="); + +// Create a new user +print("\n--- Creating User ---"); +let new_user = new_user() + .name("Alice Johnson") + .email("alice@herocode.com") + .pubkey("0x1234567890abcdef") + .status("Active") + .save_user(); + +print("Created user: " + new_user.get_name()); +print("User ID: " + new_user.get_id()); +print("User email: " + new_user.get_email()); +print("User pubkey: " + new_user.get_pubkey()); + +// Create a new group +print("\n--- Creating Group ---"); +let new_group = new_group() + .name("HeroCode Developers") + .description("A group for HeroCode development team members") + .visibility("Public") + .save_group(); + +print("Created group: " + new_group.get_name()); +print("Group ID: " + new_group.get_id()); +print("Group description: " + new_group.get_description()); + +// Create a new account +print("\n--- Creating Account ---"); +let new_account = new_account() + .name("Alice's Main Account") + .description("Primary account for Alice Johnson") + .currency("USD") + .save_account(); + +print("Created account: " + new_account.get_name()); +print("Account ID: " + new_account.get_id()); +print("Account currency: " + new_account.get_currency()); + +// Create a new DNS zone +print("\n--- Creating DNS Zone ---"); +let new_dns_zone = new_dns_zone() + .name("herocode.com") + .description("Main domain for HeroCode") + .save_dns_zone(); + +print("Created DNS zone: " + new_dns_zone.get_name()); +print("DNS zone ID: " + new_dns_zone.get_id()); + +print("\n=== Demo Complete ==="); diff --git a/src/engine.rs b/src/engine.rs index 1f895a4..602b178 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1,42 +1,4 @@ -//! # Rhailib Domain-Specific Language (DSL) Engine -//! -//! This module provides a comprehensive Domain-Specific Language implementation for the Rhai -//! scripting engine, exposing business domain models and operations through a fluent, -//! chainable API. -//! -//! ## Overview -//! -//! The DSL is organized into business domain modules, each providing Rhai-compatible -//! functions for creating, manipulating, and persisting domain entities. All operations -//! include proper authorization checks and type safety. -//! -//! ## Available Domains -//! -//! - **Business Operations** (`biz`): Companies, products, sales, shareholders -//! - **Financial Models** (`finance`): Accounts, assets, marketplace operations -//! - **Content Management** (`library`): Collections, images, PDFs, books, slideshows -//! - **Workflow Management** (`flow`): Flows, steps, signature requirements -//! - **Community Management** (`circle`): Circles, themes, membership -//! - **Contact Management** (`contact`): Contact information and relationships -//! - **Access Control** (`access`): Security and permissions -//! - **Time Management** (`calendar`): Calendar and scheduling -//! - **Core Utilities** (`core`): Comments and fundamental operations -//! - **Generic Objects** (`object`): Generic object manipulation -//! -//! ## Usage Example -//! -//! ```rust -//! use rhai::Engine; -//! use crate::engine::register_dsl_modules; -//! -//! let mut engine = Engine::new(); -//! register_dsl_modules(&mut engine); -//! -//! // Now the engine can execute scripts like: -//! // let company = new_company().name("Acme Corp").email("contact@acme.com"); -//! // let saved = save_company(company); -//! ``` - +use heromodels::models::heroledger::rhai::register_heroledger_rhai_modules; use rhai::Engine; use rhailib_dsl; use std::sync::{Arc, OnceLock}; @@ -161,6 +123,8 @@ pub fn register_dsl_modules(engine: &mut Engine) { // Register basic object functionality directly register_object_functions(engine); + heromodels::heroledger::rhai::register_heroledger_rhai_modules(&mut engine); + println!("Rhailib Domain Specific Language modules registered successfully."); }