jellyflow-runtime 0.1.0

Headless store, rules, schema, profile, and change pipeline for Jellyflow.
Documentation
//! Canonical lookup maps for fast graph queries (XyFlow-style).
//!
//! XyFlow maintains several "lookup maps" alongside its canonical node/edge arrays:
//! - `nodeLookup` (id -> internal node)
//! - `edgeLookup` (id -> edge)
//! - `connectionLookup` (node/handle -> connections)
//!
//! In Jellyflow the serialized document (`core::Graph`) is already map-based, but a first-class,
//! headless-safe lookup surface is still useful for:
//! - consistent adjacency queries (node/port -> incident edges),
//! - avoiding repeated full scans in editor shells,
//! - providing a stable substrate for B-layer tooling and middleware.

mod apply;
mod connections;
mod parents;
mod rebuild;
mod types;

use std::collections::HashMap;

use jellyflow_core::core::{EdgeId, NodeId};

pub use self::types::{
    ConnectionLookupKey, ConnectionSide, EdgeLookupEntry, HandleConnection, NodeLookupEntry,
};

#[derive(Debug, Default)]
pub struct NodeGraphLookups {
    pub(crate) node_lookup: HashMap<NodeId, NodeLookupEntry>,
    pub(crate) edge_lookup: HashMap<EdgeId, EdgeLookupEntry>,
    pub(crate) connection_lookup: HashMap<ConnectionLookupKey, HashMap<EdgeId, HandleConnection>>,
}

impl NodeGraphLookups {
    pub fn node_count(&self) -> usize {
        self.node_lookup.len()
    }

    pub fn edge_count(&self) -> usize {
        self.edge_lookup.len()
    }

    pub fn is_empty(&self) -> bool {
        self.node_lookup.is_empty()
            && self.edge_lookup.is_empty()
            && self.connection_lookup.is_empty()
    }
}