titanpl-sdk 2.0.0 → 2.0.2

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/bin/run.js CHANGED
@@ -198,24 +198,24 @@ await import("${name}");
198
198
  // Extension test harness for: ${name}
199
199
  const ext = t["${name}"];
200
200
 
201
- console.log("---------------------------------------------------");
202
- console.log("Testing Extension: ${name}");
203
- console.log("---------------------------------------------------");
201
+ t.log("---------------------------------------------------");
202
+ t.log("Testing Extension: ${name}");
203
+ t.log("---------------------------------------------------");
204
204
 
205
205
  if (!ext) {
206
206
  console.log("ERROR: Extension '${name}' not found in global 't'.");
207
207
  } else {
208
- console.log("✓ Extension loaded successfully!");
209
- console.log("✓ Available methods:", Object.keys(ext).join(", "));
208
+ t.log("✓ Extension loaded successfully!");
209
+ t.log("✓ Available methods:", Object.keys(ext).join(", "));
210
210
 
211
211
  // Try 'hello' if it exists
212
212
  if (typeof ext.hello === 'function') {
213
213
  console.log("\\nTesting ext.hello('Titan')...");
214
214
  try {
215
215
  const res = ext.hello("Titan");
216
- console.log("✓ Result:", res);
216
+ t.log("✓ Result:", res);
217
217
  } catch(e) {
218
- console.log("✗ Error:", e.message);
218
+ t.log("✗ Error:", e.message);
219
219
  }
220
220
  }
221
221
 
@@ -224,25 +224,25 @@ if (!ext) {
224
224
  console.log("\\nTesting ext.calc(10, 20)...");
225
225
  try {
226
226
  const res = ext.calc(10, 20);
227
- console.log("✓ Result:", res);
227
+ t.log("✓ Result:", res);
228
228
  } catch(e) {
229
- console.log("✗ Error:", e.message);
229
+ t.log("✗ Error:", e.message);
230
230
  }
231
231
  }
232
232
  }
233
233
 
234
- console.log("---------------------------------------------------");
235
- console.log("✓ Test complete!");
236
- console.log("\\n📍 Routes:");
237
- console.log(" GET http://localhost:3000/ → Test harness info");
238
- console.log(" GET http://localhost:3000/test → Extension test results (JSON)");
239
- console.log("---------------------------------------------------\\n");
234
+ t.log("---------------------------------------------------");
235
+ t.log("✓ Test complete!");
236
+ t.log("\\n📍 Routes:");
237
+ t.log(" GET http://localhost:3000/ → Test harness info");
238
+ t.log(" GET http://localhost:3000/test → Extension test results (JSON)");
239
+ t.log("---------------------------------------------------\\n");
240
240
 
241
241
  // Create routes
242
242
  t.get("/test").action("test");
243
243
  t.get("/").reply("🚀 Extension Test Harness for ${name}\\n\\nVisit /test to see extension test results");
244
244
 
245
- await t.start(3000, "Titan Extension Test Running!");
245
+ await t.start(3000, "Titan Extension Test Running!", 10, 16);
246
246
  `;
247
247
  fs.writeFileSync(appJsPath, testScript);
248
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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
+ }