use crate::pipeline::NodeDefinition;
pub mod ai;
pub mod auth;
pub mod browser;
pub mod crypto;
pub mod fs;
pub mod function;
pub mod geo;
pub mod http;
pub mod input;
pub mod javascript;
pub mod kv;
pub mod logic;
pub mod mail;
pub mod mapserver;
pub mod postgres;
pub mod sekejap;
pub mod sqlite;
pub mod table;
pub mod trigger;
pub mod typescript;
pub mod web;
pub mod ws;
pub const ANSWERING_KINDS: [&str; 2] = [web::response::NODE_KIND, auth::oauth_approve::NODE_KIND];
pub fn answering_kind(kind: &str) -> bool {
ANSWERING_KINDS.contains(&kind)
}
fn family_definitions() -> Vec<NodeDefinition> {
let mut items = Vec::new();
items.extend(ai::definitions());
items.extend(auth::definitions());
items.extend(browser::definitions());
items.extend(crypto::definitions());
items.extend(fs::definitions());
items.extend(function::definitions());
items.extend(geo::definitions());
items.extend(http::definitions());
items.extend(input::definitions());
items.extend(javascript::definitions());
items.extend(kv::definitions());
items.extend(logic::definitions());
items.extend(mail::definitions());
items.extend(mapserver::definitions());
items.extend(postgres::definitions());
items.extend(sekejap::definitions());
items.extend(sqlite::definitions());
items.extend(table::definitions());
items.extend(trigger::definitions());
items.extend(typescript::definitions());
items.extend(web::definitions());
items.extend(ws::definitions());
items
}
pub fn builtin_node_definitions() -> Vec<NodeDefinition> {
let mut items = family_definitions();
let common_flags = crate::pipeline::model::engine_common_dsl_flags();
let common_fields = crate::pipeline::model::engine_common_fields();
for def in &mut items {
for flag in &common_flags {
if !def
.dsl_flags
.iter()
.any(|f| f.config_key == flag.config_key || f.flag == flag.flag)
{
def.dsl_flags.push(flag.clone());
}
}
for field in &common_fields {
if !def.fields.iter().any(|f| f.name == field.name) {
def.fields.push(field.clone());
}
}
}
for def in &mut items {
if !def.ui_category.is_empty() {
continue;
}
let (cat, label) = ui_category_for_kind(&def.kind);
def.ui_category = cat.to_string();
def.ui_category_label = label.to_string();
}
items.sort_by(|a, b| a.kind.cmp(&b.kind));
items
}
fn ui_category_for_kind(kind: &str) -> (&'static str, &'static str) {
if kind.starts_with("trigger.") {
return ("trigger", "");
}
if kind.starts_with(input::KIND_PREFIX) {
return ("input", "");
}
if kind.starts_with("sekejap.") {
return ("data.sekejap", "Sekejap");
}
if kind.starts_with("sqlite.") {
return ("data.sqlite", "SQLite");
}
if kind.starts_with("postgres.") {
return ("data.postgres", "Postgres");
}
if kind.starts_with("kv.") {
return ("data.kv", "KV Store");
}
if kind.starts_with("table.") {
return ("data.table", "Table");
}
if kind.starts_with("geo.") {
return ("data.geo", "Geo");
}
if kind.starts_with("mapserver.") {
return ("data.mapserver", "MapServer");
}
if kind.starts_with("ai.") {
return ("logic.ai", "AI");
}
if kind.starts_with("logic.") || kind.starts_with("function.") || kind.starts_with("javascript.") || kind.starts_with("typescript.") {
return ("logic", "");
}
if kind.starts_with("browser.") {
return ("web.browser", "Browser");
}
if kind.starts_with("ws.") {
return ("web.websocket", "WebSocket");
}
if kind.starts_with("http.") || kind.starts_with("web.") {
return ("web", "");
}
if kind.starts_with("mail.") {
return ("communication.mail", "Mail");
}
if kind.starts_with("auth.") || kind.starts_with("crypto.") {
return ("security", "");
}
if kind.starts_with("fs.") {
return ("files.fs", "File System");
}
if kind.starts_with(crate::contracts::kinds::INSTALLED_NODE_KIND_PREFIX) {
return ("installed", "Installed");
}
("other", "")
}