@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.
Files changed (97) hide show
  1. package/README.md +17 -5
  2. package/index.js +177 -112
  3. package/package.json +19 -5
  4. package/templates/common/app/titan.d.ts +87 -0
  5. package/templates/extension/node_modules/.bin/esbuild +16 -0
  6. package/templates/extension/node_modules/.bin/esbuild.cmd +17 -0
  7. package/templates/extension/node_modules/.bin/esbuild.ps1 +28 -0
  8. package/templates/extension/node_modules/.bin/titanpl-sdk +16 -0
  9. package/templates/extension/node_modules/.bin/titanpl-sdk.cmd +17 -0
  10. package/templates/extension/node_modules/.bin/titanpl-sdk.ps1 +28 -0
  11. package/templates/extension/node_modules/.package-lock.json +111 -0
  12. package/templates/extension/node_modules/@esbuild/win32-x64/README.md +3 -0
  13. package/templates/extension/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
  14. package/templates/extension/node_modules/@esbuild/win32-x64/package.json +20 -0
  15. package/templates/extension/node_modules/@titanpl/core/LICENSE +15 -0
  16. package/templates/extension/node_modules/@titanpl/core/README.md +127 -0
  17. package/templates/extension/node_modules/@titanpl/core/globals.d.ts +17 -0
  18. package/templates/extension/node_modules/@titanpl/core/index.js +250 -0
  19. package/templates/extension/node_modules/@titanpl/core/native/target/release/titan_core.dll +0 -0
  20. package/templates/extension/node_modules/@titanpl/core/package.json +41 -0
  21. package/templates/extension/node_modules/@titanpl/core/titan.json +115 -0
  22. package/templates/extension/node_modules/chokidar/LICENSE +21 -0
  23. package/templates/extension/node_modules/chokidar/README.md +305 -0
  24. package/templates/extension/node_modules/chokidar/handler.d.ts +90 -0
  25. package/templates/extension/node_modules/chokidar/handler.js +632 -0
  26. package/templates/extension/node_modules/chokidar/index.d.ts +217 -0
  27. package/templates/extension/node_modules/chokidar/index.js +822 -0
  28. package/templates/extension/node_modules/chokidar/package.json +63 -0
  29. package/templates/extension/node_modules/esbuild/LICENSE.md +21 -0
  30. package/templates/extension/node_modules/esbuild/README.md +3 -0
  31. package/templates/extension/node_modules/esbuild/bin/esbuild +223 -0
  32. package/templates/extension/node_modules/esbuild/install.js +289 -0
  33. package/templates/extension/node_modules/esbuild/lib/main.d.ts +716 -0
  34. package/templates/extension/node_modules/esbuild/lib/main.js +2242 -0
  35. package/templates/extension/node_modules/esbuild/package.json +49 -0
  36. package/templates/extension/node_modules/readdirp/LICENSE +21 -0
  37. package/templates/extension/node_modules/readdirp/README.md +120 -0
  38. package/templates/extension/node_modules/readdirp/index.d.ts +108 -0
  39. package/templates/extension/node_modules/readdirp/index.js +272 -0
  40. package/templates/extension/node_modules/readdirp/package.json +66 -0
  41. package/templates/extension/node_modules/titanpl-sdk/LICENSE +15 -0
  42. package/templates/extension/node_modules/titanpl-sdk/README.md +109 -0
  43. package/templates/extension/node_modules/titanpl-sdk/assets/titanpl-sdk.png +0 -0
  44. package/templates/extension/node_modules/titanpl-sdk/bin/run.js +251 -0
  45. package/templates/extension/node_modules/titanpl-sdk/index.d.ts +46 -0
  46. package/templates/extension/node_modules/titanpl-sdk/index.js +5 -0
  47. package/templates/extension/node_modules/titanpl-sdk/package.json +33 -0
  48. package/templates/{rust-js → extension/node_modules/titanpl-sdk/templates}/Dockerfile +4 -17
  49. package/templates/extension/node_modules/titanpl-sdk/templates/app/actions/hello.js +5 -0
  50. package/templates/extension/node_modules/titanpl-sdk/templates/app/app.js +10 -0
  51. package/templates/extension/node_modules/titanpl-sdk/templates/jsconfig.json +19 -0
  52. package/templates/extension/node_modules/titanpl-sdk/templates/server/Cargo.lock +2839 -0
  53. package/templates/extension/node_modules/titanpl-sdk/templates/server/Cargo.toml +27 -0
  54. package/templates/extension/node_modules/titanpl-sdk/templates/server/src/action_management.rs +131 -0
  55. package/templates/extension/node_modules/titanpl-sdk/templates/server/src/errors.rs +10 -0
  56. package/templates/extension/node_modules/titanpl-sdk/templates/server/src/extensions.rs +640 -0
  57. package/templates/extension/node_modules/titanpl-sdk/templates/server/src/main.rs +345 -0
  58. package/templates/extension/node_modules/titanpl-sdk/templates/server/src/utils.rs +33 -0
  59. package/templates/extension/node_modules/titanpl-sdk/templates/titan/bundle.js +65 -0
  60. package/templates/extension/node_modules/titanpl-sdk/templates/titan/dev.js +113 -0
  61. package/templates/extension/node_modules/titanpl-sdk/templates/titan/titan.js +98 -0
  62. package/templates/extension/package-lock.json +522 -0
  63. package/templates/extension/package.json +4 -3
  64. package/templates/rust-ts/app/actions/hello.ts +1 -1
  65. package/templates/rust-ts/titan/runtime.d.ts +1 -0
  66. package/templates/rust-ts/titan/runtime.js +1 -0
  67. package/templates/rust-ts/titan/titan.d.ts +117 -117
  68. package/templates/rust-ts/titan/titan.js +1 -1
  69. package/templates/ts/app/actions/hello.ts +1 -1
  70. package/templates/ts/titan/builder.js +121 -121
  71. package/templates/ts/titan/runtime.d.ts +1 -0
  72. package/templates/ts/titan/runtime.js +1 -1
  73. package/templates/ts/titan/titan.d.ts +117 -117
  74. package/templates/ts/titan/titan.js +1 -1
  75. package/titanpl-sdk/node_modules/.package-lock.json +17 -0
  76. package/titanpl-sdk/node_modules/@titanpl/core/LICENSE +15 -0
  77. package/titanpl-sdk/node_modules/@titanpl/core/README.md +127 -0
  78. package/titanpl-sdk/node_modules/@titanpl/core/globals.d.ts +17 -0
  79. package/titanpl-sdk/node_modules/@titanpl/core/index.js +250 -0
  80. package/titanpl-sdk/node_modules/@titanpl/core/native/target/release/titan_core.dll +0 -0
  81. package/titanpl-sdk/node_modules/@titanpl/core/package.json +41 -0
  82. package/titanpl-sdk/node_modules/@titanpl/core/titan.json +115 -0
  83. package/titanpl-sdk/package-lock.json +28 -0
  84. package/titanpl-sdk/package.json +6 -3
  85. package/templates/rust-js/_gitignore +0 -38
  86. package/templates/rust-js/app/titan.d.ts +0 -101
  87. package/templates/rust-ts/Dockerfile +0 -66
  88. package/templates/rust-ts/_dockerignore +0 -3
  89. package/templates/rust-ts/_gitignore +0 -38
  90. package/templates/ts/Dockerfile +0 -40
  91. package/templates/ts/_dockerignore +0 -3
  92. package/templates/ts/_gitignore +0 -38
  93. /package/templates/{js → common}/Dockerfile +0 -0
  94. /package/templates/{js → common}/_dockerignore +0 -0
  95. /package/templates/{js → common}/_gitignore +0 -0
  96. /package/templates/{rust-js/_dockerignore → extension/node_modules/titanpl-sdk/templates/.dockerignore} +0 -0
  97. /package/templates/{js → extension/node_modules/titanpl-sdk/templates}/app/titan.d.ts +0 -0
@@ -1,117 +1,117 @@
1
-
2
- // -- Module Definitions (for imports from "titan") --
3
-
4
- export interface RouteHandler {
5
- reply(value: any): void;
6
- action(name: string): void;
7
- }
8
-
9
- export interface TitanBuilder {
10
- get(route: string): RouteHandler;
11
- post(route: string): RouteHandler;
12
- log(module: string, msg: string): void;
13
- start(port?: number, msg?: string): Promise<void>;
14
- }
15
-
16
- // The default export from titan.js is the Builder
17
- declare const builder: TitanBuilder;
18
- export default builder;
19
-
20
- /**
21
- * Define a Titan Action with type inference.
22
- */
23
- export declare function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
24
-
25
-
26
- // -- Global Definitions (Runtime Environment) --
27
-
28
- declare global {
29
- /**
30
- * The Titan Request Object passed to actions.
31
- */
32
- interface TitanRequest {
33
- body: any;
34
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
35
- path: string;
36
- headers: {
37
- host?: string;
38
- "content-type"?: string;
39
- "user-agent"?: string;
40
- authorization?: string;
41
- [key: string]: string | undefined;
42
- };
43
- params: Record<string, string>;
44
- query: Record<string, string>;
45
- }
46
-
47
- interface DbConnection {
48
- /**
49
- * Execute a SQL query.
50
- * @param sql The SQL query string.
51
- * @param params (Optional) Parameters for the query ($1, $2, etc).
52
- */
53
- query(sql: string, params?: any[]): any[];
54
- }
55
-
56
- /**
57
- * Global defineAction (available without import in runtime, though imports are preferred in TS)
58
- */
59
- function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
60
-
61
- /**
62
- * Global Request Object
63
- * Available automatically in actions.
64
- */
65
- var req: TitanRequest;
66
-
67
- /**
68
- * Titan Runtime Utilities
69
- * (Available globally in the runtime, e.g. inside actions)
70
- */
71
- const t: {
72
- /**
73
- * Log messages to the server console with Titan formatting.
74
- */
75
- log(...args: any[]): void;
76
-
77
- /**
78
- * Read a file contents as string.
79
- * @param path Relative path to the file from project root.
80
- */
81
- read(path: string): string;
82
-
83
- fetch(url: string, options?: {
84
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
85
- headers?: Record<string, string>;
86
- body?: string | object;
87
- }): {
88
- ok: boolean;
89
- status?: number;
90
- body?: string;
91
- error?: string;
92
- };
93
-
94
- jwt: {
95
- sign(
96
- payload: object,
97
- secret: string,
98
- options?: { expiresIn?: string | number }
99
- ): string;
100
- verify(token: string, secret: string): any;
101
- };
102
-
103
- password: {
104
- hash(password: string): string;
105
- verify(password: string, hash: string): boolean;
106
- };
107
-
108
- db: {
109
- connect(url: string): DbConnection;
110
- };
111
-
112
- /**
113
- * Titan Validator (Zod-compatible)
114
- */
115
- valid: any;
116
- };
117
- }
1
+
2
+ // -- Module Definitions (for imports from "titan") --
3
+
4
+ export interface RouteHandler {
5
+ reply(value: any): void;
6
+ action(name: string): void;
7
+ }
8
+
9
+ export interface TitanBuilder {
10
+ get(route: string): RouteHandler;
11
+ post(route: string): RouteHandler;
12
+ log(module: string, msg: string): void;
13
+ start(port?: number, msg?: string): Promise<void>;
14
+ }
15
+
16
+ // The default export from titan.js is the Builder
17
+ declare const builder: TitanBuilder;
18
+ export default builder;
19
+
20
+ /**
21
+ * Define a Titan Action with type inference.
22
+ */
23
+ export declare function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
24
+
25
+
26
+ // -- Global Definitions (Runtime Environment) --
27
+
28
+ declare global {
29
+ /**
30
+ * The Titan Request Object passed to actions.
31
+ */
32
+ interface TitanRequest {
33
+ body: any;
34
+ method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
35
+ path: string;
36
+ headers: {
37
+ host?: string;
38
+ "content-type"?: string;
39
+ "user-agent"?: string;
40
+ authorization?: string;
41
+ [key: string]: string | undefined;
42
+ };
43
+ params: Record<string, string>;
44
+ query: Record<string, string>;
45
+ }
46
+
47
+ interface DbConnection {
48
+ /**
49
+ * Execute a SQL query.
50
+ * @param sql The SQL query string.
51
+ * @param params (Optional) Parameters for the query ($1, $2, etc).
52
+ */
53
+ query(sql: string, params?: any[]): any[];
54
+ }
55
+
56
+ /**
57
+ * Global defineAction (available without import in runtime, though imports are preferred in TS)
58
+ */
59
+ function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
60
+
61
+ /**
62
+ * Global Request Object
63
+ * Available automatically in actions.
64
+ */
65
+ var req: TitanRequest;
66
+
67
+ /**
68
+ * Titan Runtime Utilities
69
+ * (Available globally in the runtime, e.g. inside actions)
70
+ */
71
+ const t: {
72
+ /**
73
+ * Log messages to the server console with Titan formatting.
74
+ */
75
+ log(...args: any[]): void;
76
+
77
+ /**
78
+ * Read a file contents as string.
79
+ * @param path Relative path to the file from project root.
80
+ */
81
+ read(path: string): string;
82
+
83
+ fetch(url: string, options?: {
84
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
85
+ headers?: Record<string, string>;
86
+ body?: string | object;
87
+ }): {
88
+ ok: boolean;
89
+ status?: number;
90
+ body?: string;
91
+ error?: string;
92
+ };
93
+
94
+ jwt: {
95
+ sign(
96
+ payload: object,
97
+ secret: string,
98
+ options?: { expiresIn?: string | number }
99
+ ): string;
100
+ verify(token: string, secret: string): any;
101
+ };
102
+
103
+ password: {
104
+ hash(password: string): string;
105
+ verify(password: string, hash: string): boolean;
106
+ };
107
+
108
+ db: {
109
+ connect(url: string): DbConnection;
110
+ };
111
+
112
+ /**
113
+ * Titan Validator (Zod-compatible)
114
+ */
115
+ valid: any;
116
+ };
117
+ }
@@ -2,7 +2,7 @@ import { bundle } from "./bundle.js";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
 
5
- export const defineAction = (handler) => handler;
5
+ export * from "./runtime.js";
6
6
 
7
7
  const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
8
8
  const green = (t) => `\x1b[32m${t}\x1b[0m`;
@@ -2,7 +2,7 @@ interface HelloResponse {
2
2
  message: string;
3
3
  }
4
4
 
5
- import { defineAction } from "../../titan/titan";
5
+ import { defineAction } from "../../titan/runtime";
6
6
 
7
7
  export const hello = defineAction((req): HelloResponse => {
8
8
  return {
@@ -1,121 +1,121 @@
1
- import { bundle } from "./bundle.js";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
6
- const green = (t) => `\x1b[32m${t}\x1b[0m`;
7
-
8
- const routes = {};
9
- const dynamicRoutes = {};
10
- const actionMap = {};
11
-
12
- function addRoute(method, route) {
13
- const key = `${method.toUpperCase()}:${route}`;
14
-
15
-
16
- return {
17
- reply(value) {
18
- routes[key] = {
19
- type: typeof value === "object" ? "json" : "text",
20
- value
21
- };
22
- },
23
-
24
- action(name) {
25
- if (route.includes(":")) {
26
- if (!dynamicRoutes[method]) dynamicRoutes[method] = [];
27
- dynamicRoutes[method].push({
28
- method: method.toUpperCase(),
29
- pattern: route,
30
- action: name
31
- });
32
- } else {
33
- routes[key] = {
34
- type: "action",
35
- value: name
36
- };
37
- actionMap[key] = name;
38
- }
39
- }
40
- };
41
- }
42
-
43
- /**
44
- * @typedef {Object} RouteHandler
45
- * @property {(value: any) => void} reply - Send a direct response
46
- * @property {(name: string) => void} action - Bind to a server-side action
47
- */
48
-
49
- /**
50
- * Titan App Builder
51
- */
52
- const t = {
53
- /**
54
- * Define a GET route
55
- * @param {string} route
56
- * @returns {RouteHandler}
57
- */
58
- get(route) {
59
- return addRoute("GET", route);
60
- },
61
-
62
- /**
63
- * Define a POST route
64
- * @param {string} route
65
- * @returns {RouteHandler}
66
- */
67
- post(route) {
68
- return addRoute("POST", route);
69
- },
70
-
71
- log(module, msg) {
72
- console.log(`[\x1b[35m${module}\x1b[0m] ${msg}`);
73
- },
74
-
75
- /**
76
- * Start the Titan Server
77
- * @param {number} [port=3000]
78
- * @param {string} [msg=""]
79
- */
80
- async start(port = 3000, msg = "") {
81
- try {
82
- console.log(cyan("[Titan] Preparing runtime..."));
83
- await bundle();
84
-
85
- const base = path.join(process.cwd(), "server");
86
- if (!fs.existsSync(base)) {
87
- fs.mkdirSync(base, { recursive: true });
88
- }
89
-
90
- const routesPath = path.join(base, "routes.json");
91
- const actionMapPath = path.join(base, "action_map.json");
92
-
93
- fs.writeFileSync(
94
- routesPath,
95
- JSON.stringify(
96
- {
97
- __config: { port },
98
- routes,
99
- __dynamic_routes: Object.values(dynamicRoutes).flat()
100
- },
101
- null,
102
- 2
103
- )
104
- );
105
-
106
- fs.writeFileSync(
107
- actionMapPath,
108
- JSON.stringify(actionMap, null, 2)
109
- );
110
-
111
- console.log(green("✔ Titan metadata written successfully"));
112
- if (msg) console.log(cyan(msg));
113
-
114
- } catch (e) {
115
- console.error(`\x1b[31m[Titan] Build Error: ${e.message}\x1b[0m`);
116
- process.exit(1);
117
- }
118
- }
119
- };
120
-
121
- export default t;
1
+ import { bundle } from "./bundle.js";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
6
+ const green = (t) => `\x1b[32m${t}\x1b[0m`;
7
+
8
+ const routes = {};
9
+ const dynamicRoutes = {};
10
+ const actionMap = {};
11
+
12
+ function addRoute(method, route) {
13
+ const key = `${method.toUpperCase()}:${route}`;
14
+
15
+
16
+ return {
17
+ reply(value) {
18
+ routes[key] = {
19
+ type: typeof value === "object" ? "json" : "text",
20
+ value
21
+ };
22
+ },
23
+
24
+ action(name) {
25
+ if (route.includes(":")) {
26
+ if (!dynamicRoutes[method]) dynamicRoutes[method] = [];
27
+ dynamicRoutes[method].push({
28
+ method: method.toUpperCase(),
29
+ pattern: route,
30
+ action: name
31
+ });
32
+ } else {
33
+ routes[key] = {
34
+ type: "action",
35
+ value: name
36
+ };
37
+ actionMap[key] = name;
38
+ }
39
+ }
40
+ };
41
+ }
42
+
43
+ /**
44
+ * @typedef {Object} RouteHandler
45
+ * @property {(value: any) => void} reply - Send a direct response
46
+ * @property {(name: string) => void} action - Bind to a server-side action
47
+ */
48
+
49
+ /**
50
+ * Titan App Builder
51
+ */
52
+ const t = {
53
+ /**
54
+ * Define a GET route
55
+ * @param {string} route
56
+ * @returns {RouteHandler}
57
+ */
58
+ get(route) {
59
+ return addRoute("GET", route);
60
+ },
61
+
62
+ /**
63
+ * Define a POST route
64
+ * @param {string} route
65
+ * @returns {RouteHandler}
66
+ */
67
+ post(route) {
68
+ return addRoute("POST", route);
69
+ },
70
+
71
+ log(module, msg) {
72
+ console.log(`[\x1b[35m${module}\x1b[0m] ${msg}`);
73
+ },
74
+
75
+ /**
76
+ * Start the Titan Server
77
+ * @param {number} [port=3000]
78
+ * @param {string} [msg=""]
79
+ */
80
+ async start(port = 3000, msg = "") {
81
+ try {
82
+ console.log(cyan("[Titan] Preparing runtime..."));
83
+ await bundle();
84
+
85
+ const base = path.join(process.cwd(), "server");
86
+ if (!fs.existsSync(base)) {
87
+ fs.mkdirSync(base, { recursive: true });
88
+ }
89
+
90
+ const routesPath = path.join(base, "routes.json");
91
+ const actionMapPath = path.join(base, "action_map.json");
92
+
93
+ fs.writeFileSync(
94
+ routesPath,
95
+ JSON.stringify(
96
+ {
97
+ __config: { port },
98
+ routes,
99
+ __dynamic_routes: Object.values(dynamicRoutes).flat()
100
+ },
101
+ null,
102
+ 2
103
+ )
104
+ );
105
+
106
+ fs.writeFileSync(
107
+ actionMapPath,
108
+ JSON.stringify(actionMap, null, 2)
109
+ );
110
+
111
+ console.log(green("✔ Titan metadata written successfully"));
112
+ if (msg) console.log(cyan(msg));
113
+
114
+ } catch (e) {
115
+ console.error(`\x1b[31m[Titan] Build Error: ${e.message}\x1b[0m`);
116
+ process.exit(1);
117
+ }
118
+ }
119
+ };
120
+
121
+ export default t;
@@ -0,0 +1 @@
1
+ export declare function defineAction<Req = any, Res = any>(handler: (req: Req) => Res): (req: Req) => Res;
@@ -1 +1 @@
1
- export const defineAction = (handler) => handler;
1
+ export const defineAction = (handler) => handler;