titanpl-sdk 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Development SDK for Titan Planet. Provides TypeScript type definitions for the global 't' runtime object and a 'lite' test-harness runtime for building and verifying extensions.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -8,6 +8,7 @@ use serde_json::Value;
8
8
  #[derive(Debug, Deserialize, Clone)]
9
9
  pub struct RouteVal {
10
10
  pub r#type: String,
11
+ #[serde(alias = "target")]
11
12
  pub value: Value,
12
13
  }
13
14
 
@@ -33,30 +34,36 @@ pub fn resolve_actions_dir() -> PathBuf {
33
34
  return PathBuf::from("/app/actions");
34
35
  }
35
36
 
36
- // Try to walk up from the executing binary to discover `<...>/server/actions`
37
+ // Try to walk up from the executing binary to discover `<...>/server/src/actions`
37
38
  if let Ok(exe) = std::env::current_exe() {
38
39
  if let Some(parent) = exe.parent() {
39
40
  if let Some(target_dir) = parent.parent() {
40
41
  if let Some(server_dir) = target_dir.parent() {
41
- let candidate = server_dir.join("actions");
42
+ let candidate = server_dir.join("src").join("actions");
42
43
  if candidate.exists() {
43
44
  return candidate;
44
45
  }
46
+ let candidate2 = server_dir.join("actions");
47
+ if candidate2.exists() {
48
+ return candidate2;
49
+ }
45
50
  }
46
51
  }
47
52
  }
48
53
  }
49
54
 
50
- // Fall back to local ./actions
51
- PathBuf::from("./actions")
55
+ // Fall back to local ./src/actions
56
+ PathBuf::from("./src/actions")
52
57
  }
53
58
 
54
59
  /// Try to find the directory that contains compiled action bundles.
55
60
  pub fn find_actions_dir(project_root: &PathBuf) -> Option<PathBuf> {
56
61
  let candidates = [
62
+ project_root.join("server").join("src").join("actions"),
63
+ project_root.join("server").join("actions"),
57
64
  project_root.join("app").join("actions"),
58
65
  project_root.join("actions"),
59
- project_root.join("server").join("actions"),
66
+
60
67
  project_root.join("..").join("server").join("actions"),
61
68
  PathBuf::from("/app").join("actions"),
62
69
  PathBuf::from("actions"),
@@ -138,17 +145,16 @@ pub fn match_dynamic_route(
138
145
  pub fn scan_actions(root: &PathBuf) -> HashMap<String, PathBuf> {
139
146
  let mut map = HashMap::new();
140
147
 
141
- // Locate actions dir
142
- let actions_dir = resolve_actions_dir();
143
- let dir = if actions_dir.exists() {
144
- actions_dir
145
- } else {
146
- match find_actions_dir(root) {
147
- Some(d) => d,
148
- None => return map,
148
+ // Locate actions dir - Priority: project root relative paths
149
+ let dir = match find_actions_dir(root) {
150
+ Some(d) => d,
151
+ None => {
152
+ let ad = resolve_actions_dir();
153
+ if ad.exists() { ad } else { return map; }
149
154
  }
150
155
  };
151
156
 
157
+ // Scanning actions
152
158
  if let Ok(entries) = std::fs::read_dir(dir) {
153
159
  for entry in entries.flatten() {
154
160
  let path = entry.path();
@@ -162,9 +168,10 @@ pub fn scan_actions(root: &PathBuf) -> HashMap<String, PathBuf> {
162
168
  let file_stem = path.file_stem().and_then(|s| s.to_str()).unwrap_or("");
163
169
  if file_stem.is_empty() { continue; }
164
170
 
171
+ // Found action
165
172
  map.insert(file_stem.to_string(), path);
166
173
  }
167
174
  }
168
175
 
169
176
  map
170
- }
177
+ }