@ezetgalaxy/titan 26.8.3 → 26.9.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.
Files changed (106) hide show
  1. package/README.md +76 -17
  2. package/index.js +118 -29
  3. package/package.json +1 -2
  4. package/templates/extension/README.md +104 -104
  5. package/templates/extension/index.js +27 -27
  6. package/templates/extension/jsconfig.json +12 -12
  7. package/templates/extension/native/Cargo.toml +9 -9
  8. package/templates/extension/native/src/lib.rs +5 -5
  9. package/templates/extension/package.json +20 -20
  10. package/templates/extension/titan.json +17 -17
  11. package/templates/js/Dockerfile +66 -66
  12. package/templates/js/_dockerignore +3 -3
  13. package/templates/js/_gitignore +1 -0
  14. package/templates/js/app/actions/hello.js +5 -5
  15. package/templates/js/app/titan.d.ts +87 -87
  16. package/templates/js/jsconfig.json +18 -18
  17. package/templates/js/server/src/action_management.rs +131 -131
  18. package/templates/js/server/src/errors.rs +10 -10
  19. package/templates/js/server/src/extensions.rs +989 -989
  20. package/templates/js/server/src/utils.rs +33 -33
  21. package/templates/js/titan/bundle.js +78 -78
  22. package/templates/js/titan/dev.js +9 -1
  23. package/templates/js/titan/titan.js +122 -122
  24. package/templates/{rust → rust-js}/Dockerfile +66 -66
  25. package/templates/{rust → rust-js}/_dockerignore +3 -3
  26. package/templates/{rust → rust-js}/_gitignore +1 -0
  27. package/templates/{rust → rust-js}/app/actions/hello.js +5 -5
  28. package/templates/{rust → rust-js}/app/actions/rust_hello.rs +14 -14
  29. package/templates/{rust → rust-js}/app/titan.d.ts +101 -101
  30. package/templates/{rust → rust-js}/jsconfig.json +18 -18
  31. package/templates/{rust → rust-js}/package.json +1 -1
  32. package/templates/{rust → rust-js}/server/src/action_management.rs +131 -131
  33. package/templates/{rust → rust-js}/server/src/errors.rs +10 -10
  34. package/templates/{rust → rust-js}/server/src/extensions.rs +989 -989
  35. package/templates/{rust → rust-js}/server/src/utils.rs +33 -33
  36. package/templates/{rust → rust-js}/titan/dev.js +9 -1
  37. package/templates/rust-ts/Dockerfile +66 -0
  38. package/templates/rust-ts/_dockerignore +3 -0
  39. package/templates/rust-ts/_gitignore +38 -0
  40. package/templates/rust-ts/app/actions/hello.ts +11 -0
  41. package/templates/rust-ts/app/actions/rust_hello.rs +14 -0
  42. package/templates/rust-ts/app/app.ts +11 -0
  43. package/templates/rust-ts/package.json +14 -0
  44. package/templates/rust-ts/server/Cargo.lock +2869 -0
  45. package/templates/rust-ts/server/Cargo.toml +39 -0
  46. package/templates/rust-ts/server/src/action_management.rs +131 -0
  47. package/templates/rust-ts/server/src/errors.rs +51 -0
  48. package/templates/rust-ts/server/src/extensions.rs +989 -0
  49. package/templates/rust-ts/server/src/main.rs +468 -0
  50. package/templates/rust-ts/server/src/utils.rs +33 -0
  51. package/templates/rust-ts/titan/bundle.js +163 -0
  52. package/templates/rust-ts/titan/dev.js +402 -0
  53. package/templates/rust-ts/titan/titan.d.ts +117 -0
  54. package/templates/rust-ts/titan/titan.js +122 -0
  55. package/templates/rust-ts/tsconfig.json +21 -0
  56. package/templates/ts/Dockerfile +40 -0
  57. package/templates/ts/_dockerignore +3 -0
  58. package/templates/ts/_gitignore +38 -0
  59. package/templates/ts/app/actions/hello.ts +11 -0
  60. package/templates/ts/app/app.ts +10 -0
  61. package/templates/ts/package.json +26 -0
  62. package/templates/ts/server/Cargo.lock +2869 -0
  63. package/templates/ts/server/Cargo.toml +27 -0
  64. package/templates/ts/server/src/action_management.rs +131 -0
  65. package/templates/ts/server/src/errors.rs +51 -0
  66. package/templates/ts/server/src/extensions.rs +989 -0
  67. package/templates/ts/server/src/main.rs +437 -0
  68. package/templates/ts/server/src/utils.rs +33 -0
  69. package/templates/ts/titan/builder.js +121 -0
  70. package/templates/ts/titan/bundle.js +76 -0
  71. package/templates/ts/titan/dev.js +402 -0
  72. package/templates/ts/titan/runtime.js +1 -0
  73. package/templates/ts/titan/titan.d.ts +117 -0
  74. package/templates/ts/titan/titan.js +122 -0
  75. package/templates/ts/tsconfig.json +16 -0
  76. package/titanpl-sdk/README.md +109 -109
  77. package/titanpl-sdk/bin/run.js +251 -254
  78. package/titanpl-sdk/index.d.ts +46 -46
  79. package/titanpl-sdk/index.js +5 -5
  80. package/titanpl-sdk/package.json +32 -32
  81. package/titanpl-sdk/templates/.dockerignore +3 -3
  82. package/titanpl-sdk/templates/Dockerfile +53 -53
  83. package/titanpl-sdk/templates/app/actions/hello.js +5 -5
  84. package/titanpl-sdk/templates/app/titan.d.ts +87 -87
  85. package/titanpl-sdk/templates/jsconfig.json +18 -18
  86. package/titanpl-sdk/templates/server/src/action_management.rs +131 -131
  87. package/titanpl-sdk/templates/server/src/errors.rs +10 -10
  88. package/titanpl-sdk/templates/server/src/extensions.rs +640 -640
  89. package/titanpl-sdk/templates/server/src/utils.rs +33 -33
  90. package/titanpl-sdk/templates/titan/bundle.js +65 -65
  91. package/titanpl-sdk/templates/titan/dev.js +113 -113
  92. package/titanpl-sdk/templates/titan/titan.js +98 -98
  93. package/templates/js/server/action_map.json +0 -3
  94. package/templates/js/server/actions/hello.jsbundle +0 -48
  95. package/templates/js/server/routes.json +0 -16
  96. package/templates/rust/server/action_map.json +0 -3
  97. package/templates/rust/server/actions/hello.jsbundle +0 -47
  98. package/templates/rust/server/routes.json +0 -22
  99. package/templates/rust/server/src/actions_rust/mod.rs +0 -19
  100. package/templates/rust/server/src/actions_rust/rust_hello.rs +0 -14
  101. /package/templates/{rust → rust-js}/app/app.js +0 -0
  102. /package/templates/{rust → rust-js}/server/Cargo.lock +0 -0
  103. /package/templates/{rust → rust-js}/server/Cargo.toml +0 -0
  104. /package/templates/{rust → rust-js}/server/src/main.rs +0 -0
  105. /package/templates/{rust → rust-js}/titan/bundle.js +0 -0
  106. /package/templates/{rust → rust-js}/titan/titan.js +0 -0
@@ -1,27 +1,27 @@
1
- /**
2
- * Titan Extension Entry Point
3
- * You can attach methods to the global `t` object here.
4
- */
5
-
6
- // Define your extension Key
7
- const EXT_KEY = "{{name}}";
8
-
9
- t.log(EXT_KEY, "Extension loading...");
10
-
11
- // Preserve any native functions already attached to this key
12
- t[EXT_KEY] = Object.assign(t[EXT_KEY] || {}, {
13
- // Example pure JavaScript function
14
- hello: function (name) {
15
- t.log(EXT_KEY, `Hello ${name} from ${EXT_KEY}!`);
16
- return `Hello ${name}!`;
17
- },
18
-
19
- // Example Wrapper for Native function
20
- calc: function (a, b) {
21
- t.log(EXT_KEY, `Calculating ${a} + ${b} natively...`);
22
- // Assumes the native function 'add' is mapped in titan.json
23
- return t[EXT_KEY].add(a, b);
24
- }
25
- });
26
-
27
- t.log(EXT_KEY, "Extension loaded!");
1
+ /**
2
+ * Titan Extension Entry Point
3
+ * You can attach methods to the global `t` object here.
4
+ */
5
+
6
+ // Define your extension Key
7
+ const EXT_KEY = "{{name}}";
8
+
9
+ t.log(EXT_KEY, "Extension loading...");
10
+
11
+ // Preserve any native functions already attached to this key
12
+ t[EXT_KEY] = Object.assign(t[EXT_KEY] || {}, {
13
+ // Example pure JavaScript function
14
+ hello: function (name) {
15
+ t.log(EXT_KEY, `Hello ${name} from ${EXT_KEY}!`);
16
+ return `Hello ${name}!`;
17
+ },
18
+
19
+ // Example Wrapper for Native function
20
+ calc: function (a, b) {
21
+ t.log(EXT_KEY, `Calculating ${a} + ${b} natively...`);
22
+ // Assumes the native function 'add' is mapped in titan.json
23
+ return t[EXT_KEY].add(a, b);
24
+ }
25
+ });
26
+
27
+ t.log(EXT_KEY, "Extension loaded!");
@@ -1,13 +1,13 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es2021",
5
- "checkJs": false,
6
- "allowJs": true,
7
- "moduleResolution": "node"
8
- },
9
- "include": [
10
- "index.js",
11
- "node_modules/titan-sdk/index.d.ts"
12
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "es2021",
5
+ "checkJs": false,
6
+ "allowJs": true,
7
+ "moduleResolution": "node"
8
+ },
9
+ "include": [
10
+ "index.js",
11
+ "node_modules/titan-sdk/index.d.ts"
12
+ ]
13
13
  }
@@ -1,9 +1,9 @@
1
- [package]
2
- name = "{{native_name}}_native"
3
- version = "0.1.0"
4
- edition = "2024"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [dependencies]
1
+ [package]
2
+ name = "{{native_name}}_native"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+
6
+ [lib]
7
+ crate-type = ["cdylib"]
8
+
9
+ [dependencies]
@@ -1,5 +1,5 @@
1
-
2
- #[unsafe(no_mangle)]
3
- pub extern "C" fn add(a: f64, b: f64) -> f64 {
4
- a + b
5
- }
1
+
2
+ #[unsafe(no_mangle)]
3
+ pub extern "C" fn add(a: f64, b: f64) -> f64 {
4
+ a + b
5
+ }
@@ -1,21 +1,21 @@
1
- {
2
- "name": "{{name}}",
3
- "version": "1.0.0",
4
- "description": "A Titan Planet extension",
5
- "main": "index.js",
6
- "type": "commonjs",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [
11
- "titan planet",
12
- "extension"
13
- ],
14
- "author": "",
15
- "license": "ISC",
16
- "dependencies": {
17
- "titanpl-sdk": "latest",
18
- "chokidar": "^5.0.0",
19
- "esbuild": "^0.27.2"
20
- }
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "1.0.0",
4
+ "description": "A Titan Planet extension",
5
+ "main": "index.js",
6
+ "type": "commonjs",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [
11
+ "titan planet",
12
+ "extension"
13
+ ],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "titanpl-sdk": "latest",
18
+ "chokidar": "^5.0.0",
19
+ "esbuild": "^0.27.2"
20
+ }
21
21
  }
@@ -1,18 +1,18 @@
1
- {
2
- "name": "{{name}}",
3
- "main": "index.js",
4
- "description": "A Titan extension",
5
- "native": {
6
- "path": "native/target/release/{{native_name}}_native.dll",
7
- "functions": {
8
- "add": {
9
- "symbol": "add",
10
- "parameters": [
11
- "f64",
12
- "f64"
13
- ],
14
- "result": "f64"
15
- }
16
- }
17
- }
1
+ {
2
+ "name": "{{name}}",
3
+ "main": "index.js",
4
+ "description": "A Titan extension",
5
+ "native": {
6
+ "path": "native/target/release/{{native_name}}_native.dll",
7
+ "functions": {
8
+ "add": {
9
+ "symbol": "add",
10
+ "parameters": [
11
+ "f64",
12
+ "f64"
13
+ ],
14
+ "result": "f64"
15
+ }
16
+ }
17
+ }
18
18
  }
@@ -1,66 +1,66 @@
1
- # ================================================================
2
- # STAGE 1 — Build Titan (JS → Rust)
3
- # ================================================================
4
- FROM rust:1.91.1 AS builder
5
-
6
- # Install Node for Titan CLI + bundler
7
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
8
- && apt-get install -y nodejs
9
-
10
- # Install Titan CLI (latest)
11
- RUN npm install -g @ezetgalaxy/titan@latest
12
-
13
- WORKDIR /app
14
-
15
- # Copy project files
16
- COPY . .
17
-
18
- # Install JS dependencies (needed for Titan DSL + bundler)
19
- RUN npm install
20
-
21
- SHELL ["/bin/bash", "-c"]
22
-
23
- # Extract Titan extensions into .ext
24
- RUN mkdir -p /app/.ext && \
25
- find /app/node_modules -maxdepth 5 -type f -name "titan.json" -print0 | \
26
- while IFS= read -r -d '' file; do \
27
- pkg_dir="$(dirname "$file")"; \
28
- pkg_name="$(basename "$pkg_dir")"; \
29
- echo "Copying Titan extension: $pkg_name from $pkg_dir"; \
30
- cp -r "$pkg_dir" "/app/.ext/$pkg_name"; \
31
- done && \
32
- echo "Extensions in .ext:" && \
33
- ls -R /app/.ext
34
-
35
- # Build Titan metadata + bundle JS actions
36
- RUN titan build
37
-
38
- # Build Rust binary
39
- RUN cd server && cargo build --release
40
-
41
-
42
-
43
- # ================================================================
44
- # STAGE 2 — Runtime Image (Lightweight)
45
- # ================================================================
46
- FROM debian:stable-slim
47
-
48
- WORKDIR /app
49
-
50
- # Copy Rust binary from builder stage
51
- COPY --from=builder /app/server/target/release/titan-server ./titan-server
52
-
53
- # Copy Titan routing metadata
54
- COPY --from=builder /app/server/routes.json ./routes.json
55
- COPY --from=builder /app/server/action_map.json ./action_map.json
56
-
57
- # Copy Titan JS bundles
58
- RUN mkdir -p /app/actions
59
- COPY --from=builder /app/server/actions /app/actions
60
-
61
- # Copy only Titan extensions
62
- COPY --from=builder /app/.ext ./.ext
63
-
64
- EXPOSE 3000
65
-
66
- CMD ["./titan-server"]
1
+ # ================================================================
2
+ # STAGE 1 — Build Titan (JS → Rust)
3
+ # ================================================================
4
+ FROM rust:1.91.1 AS builder
5
+
6
+ # Install Node for Titan CLI + bundler
7
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
8
+ && apt-get install -y nodejs
9
+
10
+ # Install Titan CLI (latest)
11
+ RUN npm install -g @ezetgalaxy/titan@latest
12
+
13
+ WORKDIR /app
14
+
15
+ # Copy project files
16
+ COPY . .
17
+
18
+ # Install JS dependencies (needed for Titan DSL + bundler)
19
+ RUN npm install
20
+
21
+ SHELL ["/bin/bash", "-c"]
22
+
23
+ # Extract Titan extensions into .ext
24
+ RUN mkdir -p /app/.ext && \
25
+ find /app/node_modules -maxdepth 5 -type f -name "titan.json" -print0 | \
26
+ while IFS= read -r -d '' file; do \
27
+ pkg_dir="$(dirname "$file")"; \
28
+ pkg_name="$(basename "$pkg_dir")"; \
29
+ echo "Copying Titan extension: $pkg_name from $pkg_dir"; \
30
+ cp -r "$pkg_dir" "/app/.ext/$pkg_name"; \
31
+ done && \
32
+ echo "Extensions in .ext:" && \
33
+ ls -R /app/.ext
34
+
35
+ # Build Titan metadata + bundle JS actions
36
+ RUN titan build
37
+
38
+ # Build Rust binary
39
+ RUN cd server && cargo build --release
40
+
41
+
42
+
43
+ # ================================================================
44
+ # STAGE 2 — Runtime Image (Lightweight)
45
+ # ================================================================
46
+ FROM debian:stable-slim
47
+
48
+ WORKDIR /app
49
+
50
+ # Copy Rust binary from builder stage
51
+ COPY --from=builder /app/server/target/release/titan-server ./titan-server
52
+
53
+ # Copy Titan routing metadata
54
+ COPY --from=builder /app/server/routes.json ./routes.json
55
+ COPY --from=builder /app/server/action_map.json ./action_map.json
56
+
57
+ # Copy Titan JS bundles
58
+ RUN mkdir -p /app/actions
59
+ COPY --from=builder /app/server/actions /app/actions
60
+
61
+ # Copy only Titan extensions
62
+ COPY --from=builder /app/.ext ./.ext
63
+
64
+ EXPOSE 3000
65
+
66
+ CMD ["./titan-server"]
@@ -1,3 +1,3 @@
1
- node_modules
2
- npm-debug.log
3
- .git
1
+ node_modules
2
+ npm-debug.log
3
+ .git
@@ -8,6 +8,7 @@ yarn.lock
8
8
 
9
9
  # Titan Runtime (Auto-generated - DO NOT COMMIT)
10
10
  titan/server-bin*
11
+ .titan/
11
12
  .ext/
12
13
  server/routes.json
13
14
  server/action_map.json
@@ -1,5 +1,5 @@
1
- export const hello = (req) => {
2
- return {
3
- message: `Hello from Titan ${req.body.name}`,
4
- };
5
- }
1
+ export const hello = (req) => {
2
+ return {
3
+ message: `Hello from Titan ${req.body.name}`,
4
+ };
5
+ }
@@ -1,87 +1,87 @@
1
- /**
2
- * TITAN TYPE DEFINITIONS
3
- * ----------------------
4
- * These types are globally available in your Titan project.
5
- */
6
-
7
- /**
8
- * The Titan Request Object passed to actions.
9
- */
10
- interface TitanRequest {
11
- body: any;
12
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
13
- path: string;
14
- headers: {
15
- host?: string;
16
- "content-type"?: string;
17
- "user-agent"?: string;
18
- authorization?: string;
19
- [key: string]: string | undefined;
20
- };
21
- params: Record<string, string>;
22
- query: Record<string, string>;
23
- }
24
-
25
- interface DbConnection {
26
- /**
27
- * Execute a SQL query.
28
- * @param sql The SQL query string.
29
- * @param params (Optional) Parameters for the query ($1, $2, etc).
30
- */
31
- query(sql: string, params?: any[]): any[];
32
- }
33
-
34
- /**
35
- * Define a Titan Action with type inference.
36
- * @example
37
- * export const hello = defineAction((req) => {
38
- * return req.headers;
39
- * });
40
- */
41
- declare function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
42
-
43
- /**
44
- * Titan Runtime Utilities
45
- */
46
- declare const t: {
47
- /**
48
- * Log messages to the server console with Titan formatting.
49
- */
50
- log(...args: any[]): void;
51
-
52
- /**
53
- * Read a file contents as string.
54
- * @param path Relative path to the file from project root.
55
- */
56
- read(path: string): string;
57
-
58
- fetch(url: string, options?: {
59
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
60
- headers?: Record<string, string>;
61
- body?: string | object;
62
- }): {
63
- ok: boolean;
64
- status?: number;
65
- body?: string;
66
- error?: string;
67
- };
68
-
69
- jwt: {
70
- sign(
71
- payload: object,
72
- secret: string,
73
- options?: { expiresIn?: string | number }
74
- ): string;
75
- verify(token: string, secret: string): any;
76
- };
77
-
78
- password: {
79
- hash(password: string): string;
80
- verify(password: string, hash: string): boolean;
81
- };
82
-
83
- db: {
84
- connect(url: string): DbConnection;
85
- };
86
- };
87
-
1
+ /**
2
+ * TITAN TYPE DEFINITIONS
3
+ * ----------------------
4
+ * These types are globally available in your Titan project.
5
+ */
6
+
7
+ /**
8
+ * The Titan Request Object passed to actions.
9
+ */
10
+ interface TitanRequest {
11
+ body: any;
12
+ method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
13
+ path: string;
14
+ headers: {
15
+ host?: string;
16
+ "content-type"?: string;
17
+ "user-agent"?: string;
18
+ authorization?: string;
19
+ [key: string]: string | undefined;
20
+ };
21
+ params: Record<string, string>;
22
+ query: Record<string, string>;
23
+ }
24
+
25
+ interface DbConnection {
26
+ /**
27
+ * Execute a SQL query.
28
+ * @param sql The SQL query string.
29
+ * @param params (Optional) Parameters for the query ($1, $2, etc).
30
+ */
31
+ query(sql: string, params?: any[]): any[];
32
+ }
33
+
34
+ /**
35
+ * Define a Titan Action with type inference.
36
+ * @example
37
+ * export const hello = defineAction((req) => {
38
+ * return req.headers;
39
+ * });
40
+ */
41
+ declare function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
42
+
43
+ /**
44
+ * Titan Runtime Utilities
45
+ */
46
+ declare const t: {
47
+ /**
48
+ * Log messages to the server console with Titan formatting.
49
+ */
50
+ log(...args: any[]): void;
51
+
52
+ /**
53
+ * Read a file contents as string.
54
+ * @param path Relative path to the file from project root.
55
+ */
56
+ read(path: string): string;
57
+
58
+ fetch(url: string, options?: {
59
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
60
+ headers?: Record<string, string>;
61
+ body?: string | object;
62
+ }): {
63
+ ok: boolean;
64
+ status?: number;
65
+ body?: string;
66
+ error?: string;
67
+ };
68
+
69
+ jwt: {
70
+ sign(
71
+ payload: object,
72
+ secret: string,
73
+ options?: { expiresIn?: string | number }
74
+ ): string;
75
+ verify(token: string, secret: string): any;
76
+ };
77
+
78
+ password: {
79
+ hash(password: string): string;
80
+ verify(password: string, hash: string): boolean;
81
+ };
82
+
83
+ db: {
84
+ connect(url: string): DbConnection;
85
+ };
86
+ };
87
+
@@ -1,19 +1,19 @@
1
- {
2
- "compilerOptions": {
3
- "module": "esnext",
4
- "target": "esnext",
5
- "checkJs": false,
6
- "noImplicitAny": false,
7
- "allowJs": true,
8
- "moduleResolution": "node",
9
- "baseUrl": ".",
10
- "paths": {
11
- "*": [
12
- "./app/*"
13
- ]
14
- }
15
- },
16
- "include": [
17
- "app/**/*"
18
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "target": "esnext",
5
+ "checkJs": false,
6
+ "noImplicitAny": false,
7
+ "allowJs": true,
8
+ "moduleResolution": "node",
9
+ "baseUrl": ".",
10
+ "paths": {
11
+ "*": [
12
+ "./app/*"
13
+ ]
14
+ }
15
+ },
16
+ "include": [
17
+ "app/**/*"
18
+ ]
19
19
  }