@ezetgalaxy/titan 26.9.1 → 26.9.3
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/README.md +17 -5
- package/index.js +177 -112
- package/package.json +19 -5
- package/templates/common/app/titan.d.ts +87 -0
- package/templates/extension/node_modules/.bin/esbuild +16 -0
- package/templates/extension/node_modules/.bin/esbuild.cmd +17 -0
- package/templates/extension/node_modules/.bin/esbuild.ps1 +28 -0
- package/templates/extension/node_modules/.bin/titanpl-sdk +16 -0
- package/templates/extension/node_modules/.bin/titanpl-sdk.cmd +17 -0
- package/templates/extension/node_modules/.bin/titanpl-sdk.ps1 +28 -0
- package/templates/extension/node_modules/.package-lock.json +111 -0
- package/templates/extension/node_modules/@esbuild/win32-x64/README.md +3 -0
- package/templates/extension/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
- package/templates/extension/node_modules/@esbuild/win32-x64/package.json +20 -0
- package/templates/extension/node_modules/@titanpl/core/LICENSE +15 -0
- package/templates/extension/node_modules/@titanpl/core/README.md +127 -0
- package/templates/extension/node_modules/@titanpl/core/globals.d.ts +17 -0
- package/templates/extension/node_modules/@titanpl/core/index.js +250 -0
- package/templates/extension/node_modules/@titanpl/core/native/target/release/titan_core.dll +0 -0
- package/templates/extension/node_modules/@titanpl/core/package.json +41 -0
- package/templates/extension/node_modules/@titanpl/core/titan.json +115 -0
- package/templates/extension/node_modules/chokidar/LICENSE +21 -0
- package/templates/extension/node_modules/chokidar/README.md +305 -0
- package/templates/extension/node_modules/chokidar/handler.d.ts +90 -0
- package/templates/extension/node_modules/chokidar/handler.js +632 -0
- package/templates/extension/node_modules/chokidar/index.d.ts +217 -0
- package/templates/extension/node_modules/chokidar/index.js +822 -0
- package/templates/extension/node_modules/chokidar/package.json +63 -0
- package/templates/extension/node_modules/esbuild/LICENSE.md +21 -0
- package/templates/extension/node_modules/esbuild/README.md +3 -0
- package/templates/extension/node_modules/esbuild/bin/esbuild +223 -0
- package/templates/extension/node_modules/esbuild/install.js +289 -0
- package/templates/extension/node_modules/esbuild/lib/main.d.ts +716 -0
- package/templates/extension/node_modules/esbuild/lib/main.js +2242 -0
- package/templates/extension/node_modules/esbuild/package.json +49 -0
- package/templates/extension/node_modules/readdirp/LICENSE +21 -0
- package/templates/extension/node_modules/readdirp/README.md +120 -0
- package/templates/extension/node_modules/readdirp/index.d.ts +108 -0
- package/templates/extension/node_modules/readdirp/index.js +272 -0
- package/templates/extension/node_modules/readdirp/package.json +66 -0
- package/templates/extension/node_modules/titanpl-sdk/LICENSE +15 -0
- package/templates/extension/node_modules/titanpl-sdk/README.md +109 -0
- package/templates/extension/node_modules/titanpl-sdk/assets/titanpl-sdk.png +0 -0
- package/templates/extension/node_modules/titanpl-sdk/bin/run.js +251 -0
- package/templates/extension/node_modules/titanpl-sdk/index.d.ts +46 -0
- package/templates/extension/node_modules/titanpl-sdk/index.js +5 -0
- package/templates/extension/node_modules/titanpl-sdk/package.json +33 -0
- package/templates/{rust-js → extension/node_modules/titanpl-sdk/templates}/Dockerfile +4 -17
- package/templates/extension/node_modules/titanpl-sdk/templates/app/actions/hello.js +5 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/app/app.js +10 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/jsconfig.json +19 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/Cargo.lock +2839 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/Cargo.toml +27 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/src/action_management.rs +131 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/src/errors.rs +10 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/src/extensions.rs +640 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/src/main.rs +345 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/server/src/utils.rs +33 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/titan/bundle.js +65 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/titan/dev.js +113 -0
- package/templates/extension/node_modules/titanpl-sdk/templates/titan/titan.js +98 -0
- package/templates/extension/package-lock.json +522 -0
- package/templates/extension/package.json +4 -3
- package/templates/rust-ts/app/actions/hello.ts +1 -1
- package/templates/rust-ts/titan/runtime.d.ts +1 -0
- package/templates/rust-ts/titan/runtime.js +1 -0
- package/templates/rust-ts/titan/titan.d.ts +117 -117
- package/templates/rust-ts/titan/titan.js +1 -1
- package/templates/ts/app/actions/hello.ts +1 -1
- package/templates/ts/titan/builder.js +121 -121
- package/templates/ts/titan/runtime.d.ts +1 -0
- package/templates/ts/titan/runtime.js +1 -1
- package/templates/ts/titan/titan.d.ts +117 -117
- package/templates/ts/titan/titan.js +1 -1
- package/titanpl-sdk/node_modules/.package-lock.json +17 -0
- package/titanpl-sdk/node_modules/@titanpl/core/LICENSE +15 -0
- package/titanpl-sdk/node_modules/@titanpl/core/README.md +127 -0
- package/titanpl-sdk/node_modules/@titanpl/core/globals.d.ts +17 -0
- package/titanpl-sdk/node_modules/@titanpl/core/index.js +250 -0
- package/titanpl-sdk/node_modules/@titanpl/core/native/target/release/titan_core.dll +0 -0
- package/titanpl-sdk/node_modules/@titanpl/core/package.json +41 -0
- package/titanpl-sdk/node_modules/@titanpl/core/titan.json +115 -0
- package/titanpl-sdk/package-lock.json +28 -0
- package/titanpl-sdk/package.json +6 -3
- package/templates/rust-js/_gitignore +0 -38
- package/templates/rust-js/app/titan.d.ts +0 -101
- package/templates/rust-ts/Dockerfile +0 -66
- package/templates/rust-ts/_dockerignore +0 -3
- package/templates/rust-ts/_gitignore +0 -38
- package/templates/ts/Dockerfile +0 -40
- package/templates/ts/_dockerignore +0 -3
- package/templates/ts/_gitignore +0 -38
- /package/templates/{js → common}/Dockerfile +0 -0
- /package/templates/{js → common}/_dockerignore +0 -0
- /package/templates/{js → common}/_gitignore +0 -0
- /package/templates/{rust-js/_dockerignore → extension/node_modules/titanpl-sdk/templates/.dockerignore} +0 -0
- /package/templates/{js → extension/node_modules/titanpl-sdk/templates}/app/titan.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
[package]
|
|
3
|
+
name = "titan-server"
|
|
4
|
+
version = "0.1.0"
|
|
5
|
+
edition = "2024"
|
|
6
|
+
|
|
7
|
+
[dependencies]
|
|
8
|
+
axum = "0.8.7"
|
|
9
|
+
dotenv = "0.15.0"
|
|
10
|
+
reqwest = { version = "0.12.24", features = ["json", "rustls-tls", "gzip", "brotli", "blocking"] }
|
|
11
|
+
serde = { version = "1.0.228", features = ["derive"] }
|
|
12
|
+
serde_json = "1.0.145"
|
|
13
|
+
thiserror = "2.0.17"
|
|
14
|
+
tokio = { version = "1.48.0", features = ["rt-multi-thread", "macros", "process"] }
|
|
15
|
+
tower-http = { version = "0.6.7", features = ["cors"] }
|
|
16
|
+
tracing = "0.1.43"
|
|
17
|
+
tracing-subscriber = "0.3.22"
|
|
18
|
+
anyhow = "1"
|
|
19
|
+
v8 = "0.106.0"
|
|
20
|
+
dotenvy = "0.15"
|
|
21
|
+
base64 = "0.21"
|
|
22
|
+
regex = "1.10"
|
|
23
|
+
bcrypt = "0.15"
|
|
24
|
+
jsonwebtoken = "9"
|
|
25
|
+
postgres = { version = "0.19", features = ["with-serde_json-1"] }
|
|
26
|
+
libloading = "0.8"
|
|
27
|
+
walkdir = "2"
|
package/templates/extension/node_modules/titanpl-sdk/templates/server/src/action_management.rs
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
use std::collections::HashMap;
|
|
2
|
+
use std::env;
|
|
3
|
+
use std::path::{Path, PathBuf};
|
|
4
|
+
use serde::Deserialize;
|
|
5
|
+
use serde_json::Value;
|
|
6
|
+
|
|
7
|
+
/// Route configuration (loaded from routes.json)
|
|
8
|
+
#[derive(Debug, Deserialize, Clone)]
|
|
9
|
+
pub struct RouteVal {
|
|
10
|
+
pub r#type: String,
|
|
11
|
+
pub value: Value,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[derive(Debug, Deserialize, Clone)]
|
|
15
|
+
pub struct DynamicRoute {
|
|
16
|
+
pub method: String,
|
|
17
|
+
pub pattern: String,
|
|
18
|
+
pub action: String,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// -------------------------
|
|
22
|
+
// ACTION DIRECTORY RESOLUTION
|
|
23
|
+
// -------------------------
|
|
24
|
+
|
|
25
|
+
pub fn resolve_actions_dir() -> PathBuf {
|
|
26
|
+
// Respect explicit override first
|
|
27
|
+
if let Ok(override_dir) = env::var("TITAN_ACTIONS_DIR") {
|
|
28
|
+
return PathBuf::from(override_dir);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Production container layout
|
|
32
|
+
if Path::new("/app/actions").exists() {
|
|
33
|
+
return PathBuf::from("/app/actions");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Try to walk up from the executing binary to discover `<...>/server/actions`
|
|
37
|
+
if let Ok(exe) = std::env::current_exe() {
|
|
38
|
+
if let Some(parent) = exe.parent() {
|
|
39
|
+
if let Some(target_dir) = parent.parent() {
|
|
40
|
+
if let Some(server_dir) = target_dir.parent() {
|
|
41
|
+
let candidate = server_dir.join("actions");
|
|
42
|
+
if candidate.exists() {
|
|
43
|
+
return candidate;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Fall back to local ./actions
|
|
51
|
+
PathBuf::from("./actions")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Try to find the directory that contains compiled action bundles.
|
|
55
|
+
pub fn find_actions_dir(project_root: &PathBuf) -> Option<PathBuf> {
|
|
56
|
+
let candidates = [
|
|
57
|
+
project_root.join("server").join("actions"),
|
|
58
|
+
project_root.join("actions"),
|
|
59
|
+
project_root.join("..").join("server").join("actions"),
|
|
60
|
+
PathBuf::from("/app").join("actions"),
|
|
61
|
+
PathBuf::from("actions"),
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
for p in &candidates {
|
|
65
|
+
if p.exists() && p.is_dir() {
|
|
66
|
+
return Some(p.clone());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
None
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Dynamic Matcher (Core Logic)
|
|
74
|
+
|
|
75
|
+
pub fn match_dynamic_route(
|
|
76
|
+
method: &str,
|
|
77
|
+
path: &str,
|
|
78
|
+
routes: &[DynamicRoute],
|
|
79
|
+
) -> Option<(String, HashMap<String, String>)> {
|
|
80
|
+
let path_segments: Vec<&str> =
|
|
81
|
+
path.trim_matches('/').split('/').collect();
|
|
82
|
+
|
|
83
|
+
for route in routes {
|
|
84
|
+
if route.method != method {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let pattern_segments: Vec<&str> =
|
|
89
|
+
route.pattern.trim_matches('/').split('/').collect();
|
|
90
|
+
|
|
91
|
+
if pattern_segments.len() != path_segments.len() {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let mut params = HashMap::new();
|
|
96
|
+
let mut matched = true;
|
|
97
|
+
|
|
98
|
+
for (pat, val) in pattern_segments.iter().zip(path_segments.iter()) {
|
|
99
|
+
if pat.starts_with(':') {
|
|
100
|
+
let inner = &pat[1..];
|
|
101
|
+
|
|
102
|
+
let (name, ty) = inner
|
|
103
|
+
.split_once('<')
|
|
104
|
+
.map(|(n, t)| (n, t.trim_end_matches('>')))
|
|
105
|
+
.unwrap_or((inner, "string"));
|
|
106
|
+
|
|
107
|
+
let valid = match ty {
|
|
108
|
+
"number" => val.parse::<i64>().is_ok(),
|
|
109
|
+
"string" => true,
|
|
110
|
+
_ => false,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
if !valid {
|
|
114
|
+
matched = false;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
params.insert(name.to_string(), (*val).to_string());
|
|
119
|
+
} else if pat != val {
|
|
120
|
+
matched = false;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if matched {
|
|
126
|
+
return Some((route.action.clone(), params));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
None
|
|
131
|
+
}
|