shape_runtime/metadata/
builtin_types.rs1use std::sync::OnceLock;
8
9use super::types::TypeInfo;
10
11static BUILTIN_TYPES: OnceLock<Vec<TypeInfo>> = OnceLock::new();
12
13pub fn builtin_types() -> Vec<TypeInfo> {
15 BUILTIN_TYPES
16 .get_or_init(|| {
17 let stdlib_path = crate::stdlib_metadata::default_stdlib_path();
18 let metadata = crate::stdlib_metadata::StdlibMetadata::load(&stdlib_path)
19 .unwrap_or_else(|_| crate::stdlib_metadata::StdlibMetadata::empty());
20 if !metadata.intrinsic_types.is_empty() {
21 metadata.intrinsic_types
22 } else {
23 fallback_builtin_types()
24 }
25 })
26 .clone()
27}
28
29fn fallback_builtin_types() -> Vec<TypeInfo> {
30 vec![
31 TypeInfo {
32 name: "Number".to_string(),
33 description: "Numeric type (integer or floating-point)".to_string(),
34 },
35 TypeInfo {
36 name: "String".to_string(),
37 description: "String type".to_string(),
38 },
39 TypeInfo {
40 name: "Boolean".to_string(),
41 description: "Boolean type (true or false)".to_string(),
42 },
43 TypeInfo {
44 name: "Vec".to_string(),
45 description: "Vec type".to_string(),
46 },
47 TypeInfo {
48 name: "Mat".to_string(),
49 description: "Dense numeric matrix type".to_string(),
50 },
51 TypeInfo {
52 name: "Object".to_string(),
53 description: "Object type".to_string(),
54 },
55 TypeInfo {
56 name: "Table".to_string(),
57 description: "Typed table container for row-oriented and relational operations"
58 .to_string(),
59 },
60 TypeInfo {
61 name: "Row".to_string(),
62 description: "Generic data row with timestamp and arbitrary fields".to_string(),
63 },
64 TypeInfo {
65 name: "Pattern".to_string(),
66 description: "Pattern type".to_string(),
67 },
68 TypeInfo {
69 name: "Signal".to_string(),
70 description: "Generic action signal type".to_string(),
71 },
72 TypeInfo {
73 name: "DateTime".to_string(),
74 description: "Date/time value".to_string(),
75 },
76 TypeInfo {
77 name: "Result".to_string(),
78 description: "Result type - Ok(value) or Err(AnyError)".to_string(),
79 },
80 TypeInfo {
81 name: "Option".to_string(),
82 description: "Option type - Some(value) or None".to_string(),
83 },
84 TypeInfo {
85 name: "AnyError".to_string(),
86 description: "Universal runtime error type used by Result<T>".to_string(),
87 },
88 ]
89}