Refactor Rhai integration with context-based execution and type registry
Major Changes:
- Moved Rhai support from rhai_support/ to rhai/ module
- Implemented context-based execution with signatory access control
- Added TypeRegistry for dynamic type registration and object creation
- Refactored engine to use context (Vec<String>) instead of instance
- Removed old runner binary (moved to runner_rust crate)
Rhai Module:
- engine.rs: Core Rhai engine with context-based get_context()
- functions.rs: Rhai function bindings (create_note, create_event, etc.)
- mod.rs: Module exports and organization
Store Improvements:
- TypeRegistry for registering object types and creators
- Generic store uses type registry for dynamic object creation
- Improved error handling and type safety
Documentation:
- RHAI_REFACTOR_COMPLETE.md: Refactoring details
- SIGNATORY_ACCESS_CONTROL.md: Context-based access control
- TYPE_REGISTRY_DESIGN.md: Type registry architecture
- REFACTORING_COMPLETE.md: Overall refactoring summary
- TESTS_COMPLETE.md: Testing documentation
Build Status: ✅ Compiles successfully with minor warnings
This commit is contained in:
@@ -2,7 +2,6 @@ use crate::store::BaseData;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
#[cfg(feature = "rhai-support")]
|
||||
pub mod rhai;
|
||||
|
||||
/// Event status
|
||||
|
||||
@@ -34,8 +34,15 @@ impl CustomType for Event {
|
||||
pub fn register_event_api(engine: &mut Engine) {
|
||||
engine.build_type::<Event>();
|
||||
|
||||
// Register builder-style constructor
|
||||
engine.register_fn("event", |ns: String, title: String| Event::new(ns, title));
|
||||
// Register builder-style constructor (namespace only, like note())
|
||||
engine.register_fn("event", |ns: String| Event::new(ns, String::new()));
|
||||
|
||||
// Register title as a chainable method
|
||||
engine.register_fn("title", |mut event: Event, title: String| {
|
||||
event.title = title;
|
||||
event.base_data.update_modified();
|
||||
event
|
||||
});
|
||||
|
||||
// Register chainable methods that return Self
|
||||
engine.register_fn("description", |mut event: Event, desc: String| {
|
||||
|
||||
@@ -2,7 +2,6 @@ use crate::store::BaseData;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[cfg(feature = "rhai-support")]
|
||||
pub mod rhai;
|
||||
|
||||
/// A simple note object
|
||||
|
||||
Reference in New Issue
Block a user