titanpl 7.0.0-beta → 7.0.0
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 +2 -6
- package/packages/cli/package.json +4 -4
- package/packages/core-source/LICENSE +15 -0
- package/packages/core-source/README.md +128 -0
- package/packages/core-source/V8_SERIALIZATION.md +125 -0
- package/packages/core-source/configure.js +50 -0
- package/packages/core-source/globals.d.ts +2238 -0
- package/packages/core-source/index.d.ts +515 -0
- package/packages/core-source/index.js +639 -0
- package/packages/core-source/jsconfig.json +12 -0
- package/packages/core-source/mkctx.config.json +7 -0
- package/packages/core-source/native/Cargo.lock +1559 -0
- package/packages/core-source/native/Cargo.toml +30 -0
- package/packages/core-source/native/src/crypto_impl.rs +139 -0
- package/packages/core-source/native/src/lib.rs +702 -0
- package/packages/core-source/native/src/storage_impl.rs +73 -0
- package/packages/core-source/native/src/v8_impl.rs +93 -0
- package/packages/core-source/package-lock.json +1464 -0
- package/packages/core-source/package.json +53 -0
- package/packages/core-source/tests/buffer.test.js +78 -0
- package/packages/core-source/tests/cookies.test.js +117 -0
- package/packages/core-source/tests/crypto.test.js +142 -0
- package/packages/core-source/tests/fs.test.js +176 -0
- package/packages/core-source/tests/ls.test.js +149 -0
- package/packages/core-source/tests/net.test.js +84 -0
- package/packages/core-source/tests/os.test.js +81 -0
- package/packages/core-source/tests/path.test.js +102 -0
- package/packages/core-source/tests/response.test.js +146 -0
- package/packages/core-source/tests/session.test.js +110 -0
- package/packages/core-source/tests/setup.js +325 -0
- package/packages/core-source/tests/time.test.js +57 -0
- package/packages/core-source/tests/url.test.js +82 -0
- package/packages/core-source/titan-ext.d.ts +2 -0
- package/packages/core-source/titan.json +9 -0
- package/packages/core-source/vitest.config.js +8 -0
- package/packages/engine-darwin-arm64/package.json +1 -1
- package/packages/engine-linux-x64/package.json +1 -1
- package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
- package/packages/engine-win32-x64/package.json +1 -1
- package/packages/native/index.d.ts +16 -1
- package/packages/native/index.js +6 -0
- package/packages/native/package.json +2 -2
- package/packages/native/t.native.d.ts +77 -0
- package/packages/packet/index.js +94 -102
- package/packages/packet/package.json +1 -1
- package/packages/route/package.json +1 -1
- package/packages/sdk/package.json +1 -1
- package/templates/common/_tanfig.json +4 -2
- package/templates/extension/package.json +2 -2
- package/templates/js/package.json +8 -8
- package/templates/rust-js/package.json +5 -5
- package/templates/rust-ts/package.json +5 -5
- package/templates/ts/package.json +8 -8
- package/packages/packet/node_modules/typescript/LICENSE.txt +0 -55
- package/packages/packet/node_modules/typescript/README.md +0 -50
- package/packages/packet/node_modules/typescript/SECURITY.md +0 -41
- package/packages/packet/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/packages/packet/node_modules/typescript/bin/tsc +0 -2
- package/packages/packet/node_modules/typescript/bin/tsserver +0 -2
- package/packages/packet/node_modules/typescript/lib/_tsc.js +0 -133818
- package/packages/packet/node_modules/typescript/lib/_tsserver.js +0 -659
- package/packages/packet/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/packages/packet/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/lib.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
- package/packages/packet/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
- package/packages/packet/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
- package/packages/packet/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
- package/packages/packet/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
- package/packages/packet/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
- package/packages/packet/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
- package/packages/packet/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
- package/packages/packet/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/packages/packet/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
- package/packages/packet/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
- package/packages/packet/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
- package/packages/packet/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
- package/packages/packet/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
- package/packages/packet/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
- package/packages/packet/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
- package/packages/packet/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
- package/packages/packet/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
- package/packages/packet/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
- package/packages/packet/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
- package/packages/packet/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
- package/packages/packet/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
- package/packages/packet/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
- package/packages/packet/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
- package/packages/packet/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
- package/packages/packet/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
- package/packages/packet/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
- package/packages/packet/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
- package/packages/packet/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
- package/packages/packet/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
- package/packages/packet/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
- package/packages/packet/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
- package/packages/packet/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
- package/packages/packet/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
- package/packages/packet/node_modules/typescript/lib/lib.es6.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
- package/packages/packet/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
- package/packages/packet/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
- package/packages/packet/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
- package/packages/packet/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
- package/packages/packet/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
- package/packages/packet/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
- package/packages/packet/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
- package/packages/packet/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tsc.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserver.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/packages/packet/node_modules/typescript/lib/typesMap.json +0 -497
- package/packages/packet/node_modules/typescript/lib/typescript.d.ts +0 -11437
- package/packages/packet/node_modules/typescript/lib/typescript.js +0 -200276
- package/packages/packet/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/packages/packet/node_modules/typescript/lib/watchGuard.js +0 -53
- package/packages/packet/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/package.json +0 -120
|
@@ -0,0 +1,2238 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// @titanpl/core — Global Type Declarations
|
|
3
|
+
// The official Core Standard Library for Titan Planet
|
|
4
|
+
// Version: 2.x
|
|
5
|
+
// Repository: https://github.com/ezet-galaxy/-titanpl-core
|
|
6
|
+
// =============================================================================
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Native Rust Bindings (Internal)
|
|
10
|
+
// These are low-level bindings used internally by the JS implementation
|
|
11
|
+
// =============================================================================
|
|
12
|
+
declare var fs_read_file: any;
|
|
13
|
+
declare var fs_write_file: any;
|
|
14
|
+
declare var fs_readdir: any;
|
|
15
|
+
declare var fs_mkdir: any;
|
|
16
|
+
declare var fs_exists: any;
|
|
17
|
+
declare var fs_stat: any;
|
|
18
|
+
declare var fs_remove: any;
|
|
19
|
+
declare var path_cwd: any;
|
|
20
|
+
declare var crypto_hash: any;
|
|
21
|
+
declare var crypto_random_bytes: any;
|
|
22
|
+
declare var crypto_uuid: any;
|
|
23
|
+
declare var os_info: any;
|
|
24
|
+
declare var net_resolve: any;
|
|
25
|
+
declare var net_ip: any;
|
|
26
|
+
declare var proc_info: any;
|
|
27
|
+
declare var proc_run: any;
|
|
28
|
+
declare var proc_kill: any;
|
|
29
|
+
declare var proc_list: any;
|
|
30
|
+
declare var time_sleep: any;
|
|
31
|
+
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// Global Declarations
|
|
34
|
+
// Uses `declare global` for proper declaration merging with TitanRuntimeUtils
|
|
35
|
+
// =============================================================================
|
|
36
|
+
declare global {
|
|
37
|
+
// =========================================================================
|
|
38
|
+
// TitanCore Namespace
|
|
39
|
+
// Contains all type definitions for the core standard library modules
|
|
40
|
+
// =========================================================================
|
|
41
|
+
namespace TitanCore {
|
|
42
|
+
// =====================================================================
|
|
43
|
+
// Core Interface — Unified Access Point
|
|
44
|
+
// =====================================================================
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* # Core Module
|
|
48
|
+
*
|
|
49
|
+
* Unified access point to all `@titanpl/core` standard library APIs.
|
|
50
|
+
* Access via `t.core` for namespaced organization.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```js
|
|
54
|
+
* // Destructure what you need
|
|
55
|
+
* const { fs, crypto, os } = t.core;
|
|
56
|
+
*
|
|
57
|
+
* // Read config and generate secure ID
|
|
58
|
+
* const config = JSON.parse(fs.readFile("./config.json"));
|
|
59
|
+
* const requestId = crypto.uuid();
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core
|
|
63
|
+
*/
|
|
64
|
+
interface Core {
|
|
65
|
+
/** File System operations */
|
|
66
|
+
fs: FileSystem;
|
|
67
|
+
/** Path manipulation utilities */
|
|
68
|
+
path: Path;
|
|
69
|
+
/** Cryptographic functions */
|
|
70
|
+
crypto: Crypto;
|
|
71
|
+
/** Operating System information */
|
|
72
|
+
os: OS;
|
|
73
|
+
/** Network utilities */
|
|
74
|
+
net: Net;
|
|
75
|
+
/** Process management */
|
|
76
|
+
proc: Process;
|
|
77
|
+
/** Time utilities */
|
|
78
|
+
time: Time;
|
|
79
|
+
/** URL parsing and formatting */
|
|
80
|
+
url: URLModule;
|
|
81
|
+
/** Binary data encoding/decoding */
|
|
82
|
+
buffer: BufferModule;
|
|
83
|
+
/** Key-value local storage */
|
|
84
|
+
ls: LocalStorage;
|
|
85
|
+
/** Session state management */
|
|
86
|
+
session: Session;
|
|
87
|
+
/** HTTP cookie utilities */
|
|
88
|
+
cookies: Cookies;
|
|
89
|
+
/** HTTP response builder */
|
|
90
|
+
response: ResponseModule;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// =====================================================================
|
|
94
|
+
// File System Module
|
|
95
|
+
// =====================================================================
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* # File System API
|
|
99
|
+
*
|
|
100
|
+
* Native file operations backed by Rust. All methods are **synchronous**
|
|
101
|
+
* for maximum performance in the Titan runtime — no `drift()` needed.
|
|
102
|
+
*
|
|
103
|
+
* **Performance:** Native Rust I/O with zero-copy where possible.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```js
|
|
107
|
+
* // Read and parse JSON config
|
|
108
|
+
* const raw = t.fs.readFile("./config.json");
|
|
109
|
+
* const config = JSON.parse(raw);
|
|
110
|
+
*
|
|
111
|
+
* // Write data to file
|
|
112
|
+
* t.fs.writeFile("./output.json", JSON.stringify(data, null, 2));
|
|
113
|
+
*
|
|
114
|
+
* // Check existence before operations
|
|
115
|
+
* if (t.fs.exists("./cache")) {
|
|
116
|
+
* const files = t.fs.readdir("./cache");
|
|
117
|
+
* t.log("Cache files:", files);
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* // Get file metadata
|
|
121
|
+
* const stats = t.fs.stat("./data.db");
|
|
122
|
+
* t.log(`Size: ${stats.size} bytes, Modified: ${stats.modified}`);
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#fs-file-system
|
|
126
|
+
*/
|
|
127
|
+
interface FileSystem {
|
|
128
|
+
/**
|
|
129
|
+
* Read the entire contents of a file as a UTF-8 string.
|
|
130
|
+
*
|
|
131
|
+
* @param path - Absolute or relative path to the file
|
|
132
|
+
* @returns File contents as UTF-8 string
|
|
133
|
+
* @throws If the file does not exist or cannot be read
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```js
|
|
137
|
+
* const content = t.fs.readFile("./data/users.json");
|
|
138
|
+
* const users = JSON.parse(content);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
readFile(path: string): string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Write string content to a file, creating or overwriting it.
|
|
145
|
+
*
|
|
146
|
+
* Parent directories are **not** created automatically —
|
|
147
|
+
* use `mkdir()` first if needed.
|
|
148
|
+
*
|
|
149
|
+
* @param path - Target file path
|
|
150
|
+
* @param content - String content to write (UTF-8 encoded)
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* const data = { users: [], timestamp: Date.now() };
|
|
155
|
+
* t.fs.writeFile("./output.json", JSON.stringify(data, null, 2));
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
writeFile(path: string, content: string): void;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* List all entries (files and directories) in a directory.
|
|
162
|
+
*
|
|
163
|
+
* @param path - Directory path to list
|
|
164
|
+
* @returns Array of entry names (not full paths)
|
|
165
|
+
* @throws If the directory does not exist
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```js
|
|
169
|
+
* const entries = t.fs.readdir("./uploads");
|
|
170
|
+
* // → ["image1.png", "document.pdf", "archive"]
|
|
171
|
+
*
|
|
172
|
+
* // Filter by extension
|
|
173
|
+
* const images = entries.filter(f => f.endsWith(".png"));
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
readdir(path: string): string[];
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Create a directory and all parent directories (recursive).
|
|
180
|
+
*
|
|
181
|
+
* No error if the directory already exists.
|
|
182
|
+
*
|
|
183
|
+
* @param path - Directory path to create
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```js
|
|
187
|
+
* // Creates ./data/cache/temp and all parents
|
|
188
|
+
* t.fs.mkdir("./data/cache/temp");
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
mkdir(path: string): void;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Check if a file or directory exists at the given path.
|
|
195
|
+
*
|
|
196
|
+
* @param path - Path to check
|
|
197
|
+
* @returns `true` if path exists, `false` otherwise
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```js
|
|
201
|
+
* if (!t.fs.exists("./config.json")) {
|
|
202
|
+
* t.fs.writeFile("./config.json", "{}");
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
exists(path: string): boolean;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get metadata/statistics about a file or directory.
|
|
210
|
+
*
|
|
211
|
+
* @param path - Path to stat
|
|
212
|
+
* @returns Statistics object with size, type, and modification time
|
|
213
|
+
* @throws If the path does not exist
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```js
|
|
217
|
+
* const stats = t.fs.stat("./database.db");
|
|
218
|
+
*
|
|
219
|
+
* if (stats.isFile) {
|
|
220
|
+
* t.log(`Database size: ${stats.size} bytes`);
|
|
221
|
+
* t.log(`Last modified: ${new Date(stats.modified)}`);
|
|
222
|
+
* }
|
|
223
|
+
*
|
|
224
|
+
* if (stats.isDir) {
|
|
225
|
+
* t.log("Path is a directory");
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
stat(path: string): Stats;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Remove a file or directory (recursive for directories).
|
|
233
|
+
*
|
|
234
|
+
* **⚠️ Destructive operation** — cannot be undone.
|
|
235
|
+
*
|
|
236
|
+
* @param path - Path to remove
|
|
237
|
+
* @throws If the path does not exist
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```js
|
|
241
|
+
* // Remove a single file
|
|
242
|
+
* t.fs.remove("./temp.txt");
|
|
243
|
+
*
|
|
244
|
+
* // Remove directory and all contents
|
|
245
|
+
* t.fs.remove("./cache");
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
remove(path: string): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* File or directory statistics returned by `fs.stat()`.
|
|
253
|
+
*/
|
|
254
|
+
interface Stats {
|
|
255
|
+
/** File size in bytes (0 for directories) */
|
|
256
|
+
size: number;
|
|
257
|
+
/** `true` if the path is a regular file */
|
|
258
|
+
isFile: boolean;
|
|
259
|
+
/** `true` if the path is a directory */
|
|
260
|
+
isDir: boolean;
|
|
261
|
+
/** Last modification time as Unix timestamp in milliseconds */
|
|
262
|
+
modified: number;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// =====================================================================
|
|
266
|
+
// Path Module
|
|
267
|
+
// =====================================================================
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* # Path API
|
|
271
|
+
*
|
|
272
|
+
* Cross-platform path manipulation utilities.
|
|
273
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
274
|
+
*
|
|
275
|
+
* Uses the appropriate path separator for the current OS
|
|
276
|
+
* (`/` on Unix, `\` on Windows).
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```js
|
|
280
|
+
* // Build paths safely
|
|
281
|
+
* const configPath = t.path.join("app", "config", "settings.json");
|
|
282
|
+
* // Unix: "app/config/settings.json"
|
|
283
|
+
* // Windows: "app\\config\\settings.json"
|
|
284
|
+
*
|
|
285
|
+
* // Get absolute path
|
|
286
|
+
* const absolute = t.path.resolve("./data", "users.db");
|
|
287
|
+
* // → "/home/app/data/users.db"
|
|
288
|
+
*
|
|
289
|
+
* // Extract path components
|
|
290
|
+
* const file = "/var/log/app/error.log";
|
|
291
|
+
* t.path.dirname(file); // → "/var/log/app"
|
|
292
|
+
* t.path.basename(file); // → "error.log"
|
|
293
|
+
* t.path.extname(file); // → ".log"
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#path-path-manipulation
|
|
297
|
+
*/
|
|
298
|
+
interface Path {
|
|
299
|
+
/**
|
|
300
|
+
* Join multiple path segments into a single normalized path.
|
|
301
|
+
*
|
|
302
|
+
* Handles redundant separators and normalizes `.` and `..` segments.
|
|
303
|
+
*
|
|
304
|
+
* @param args - Two or more path segments to join
|
|
305
|
+
* @returns Joined and normalized path string
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```js
|
|
309
|
+
* t.path.join("app", "actions", "user.js");
|
|
310
|
+
* // → "app/actions/user.js"
|
|
311
|
+
*
|
|
312
|
+
* t.path.join("/var", "log", "..", "data");
|
|
313
|
+
* // → "/var/data"
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
join(...args: string[]): string;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Resolve path segments to an absolute path.
|
|
320
|
+
*
|
|
321
|
+
* Processes from right to left, prepending each segment until
|
|
322
|
+
* an absolute path is formed. If no absolute path is reached,
|
|
323
|
+
* the current working directory is prepended.
|
|
324
|
+
*
|
|
325
|
+
* @param args - Path segments to resolve
|
|
326
|
+
* @returns Absolute path string
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```js
|
|
330
|
+
* // From current working directory
|
|
331
|
+
* t.path.resolve("./config.json");
|
|
332
|
+
* // → "/home/app/config.json"
|
|
333
|
+
*
|
|
334
|
+
* // Absolute path takes precedence
|
|
335
|
+
* t.path.resolve("/etc", "passwd");
|
|
336
|
+
* // → "/etc/passwd"
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
resolve(...args: string[]): string;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Get the file extension including the leading dot.
|
|
343
|
+
*
|
|
344
|
+
* @param path - File path
|
|
345
|
+
* @returns Extension (e.g., `".json"`, `".tar.gz"`) or empty string
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```js
|
|
349
|
+
* t.path.extname("photo.png"); // → ".png"
|
|
350
|
+
* t.path.extname("archive.tar.gz"); // → ".gz"
|
|
351
|
+
* t.path.extname("Makefile"); // → ""
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
extname(path: string): string;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Get the directory portion of a path.
|
|
358
|
+
*
|
|
359
|
+
* @param path - File or directory path
|
|
360
|
+
* @returns Parent directory path
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```js
|
|
364
|
+
* t.path.dirname("/var/log/app.log");
|
|
365
|
+
* // → "/var/log"
|
|
366
|
+
*
|
|
367
|
+
* t.path.dirname("app/config.json");
|
|
368
|
+
* // → "app"
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
dirname(path: string): string;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Get the last segment (filename or directory name) of a path.
|
|
375
|
+
*
|
|
376
|
+
* @param path - Path to extract from
|
|
377
|
+
* @returns Final path segment
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```js
|
|
381
|
+
* t.path.basename("/var/log/app.log");
|
|
382
|
+
* // → "app.log"
|
|
383
|
+
*
|
|
384
|
+
* t.path.basename("/var/log/");
|
|
385
|
+
* // → "log"
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
basename(path: string): string;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// =====================================================================
|
|
392
|
+
// Crypto Module
|
|
393
|
+
// =====================================================================
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* # Cryptography API
|
|
397
|
+
*
|
|
398
|
+
* Cryptographic utilities powered by native Rust implementations.
|
|
399
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
400
|
+
*
|
|
401
|
+
* **Security:** Uses constant-time comparisons where appropriate
|
|
402
|
+
* to prevent timing attacks.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```js
|
|
406
|
+
* // Generate secure identifiers
|
|
407
|
+
* const id = t.crypto.uuid();
|
|
408
|
+
* const token = t.crypto.randomBytes(32);
|
|
409
|
+
*
|
|
410
|
+
* // Hash data
|
|
411
|
+
* const hash = t.crypto.hash("sha256", "password123");
|
|
412
|
+
*
|
|
413
|
+
* // Secure comparison (timing-attack safe)
|
|
414
|
+
* const isValid = t.crypto.compare(storedHash, computedHash);
|
|
415
|
+
*
|
|
416
|
+
* // Base64 encoding
|
|
417
|
+
* const encoded = t.crypto.base64.encode("Hello World");
|
|
418
|
+
* const decoded = t.crypto.base64.decode(encoded);
|
|
419
|
+
*
|
|
420
|
+
* // HMAC for webhook signatures
|
|
421
|
+
* const signature = t.crypto.hashKeyed(
|
|
422
|
+
* "hmac-sha256",
|
|
423
|
+
* process.env.WEBHOOK_SECRET,
|
|
424
|
+
* JSON.stringify(payload)
|
|
425
|
+
* );
|
|
426
|
+
*
|
|
427
|
+
* // Encryption/Decryption
|
|
428
|
+
* const encrypted = t.crypto.encrypt("aes-256-gcm", key, "secret data");
|
|
429
|
+
* const decrypted = t.crypto.decrypt("aes-256-gcm", key, encrypted);
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
432
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#crypto-cryptography
|
|
433
|
+
*/
|
|
434
|
+
interface Crypto {
|
|
435
|
+
/**
|
|
436
|
+
* Compute a cryptographic hash of the input data.
|
|
437
|
+
*
|
|
438
|
+
* @param algorithm - Hash algorithm: `"sha256"`, `"sha512"`, or `"md5"`
|
|
439
|
+
* @param data - String data to hash
|
|
440
|
+
* @returns Hex-encoded hash string
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```js
|
|
444
|
+
* const hash = t.crypto.hash("sha256", "hello world");
|
|
445
|
+
* // → "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
|
|
446
|
+
*
|
|
447
|
+
* // MD5 (not recommended for security, but useful for checksums)
|
|
448
|
+
* const checksum = t.crypto.hash("md5", fileContent);
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
hash(algorithm: 'sha256' | 'sha512' | 'md5', data: string): string;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Generate cryptographically secure random bytes.
|
|
455
|
+
*
|
|
456
|
+
* @param size - Number of random bytes to generate
|
|
457
|
+
* @returns Hex-encoded string (length = size × 2)
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```js
|
|
461
|
+
* // Generate a 256-bit (32-byte) random token
|
|
462
|
+
* const token = t.crypto.randomBytes(32);
|
|
463
|
+
* // → "a1b2c3d4e5f6..." (64 hex characters)
|
|
464
|
+
*
|
|
465
|
+
* // Generate a short verification code
|
|
466
|
+
* const code = t.crypto.randomBytes(4);
|
|
467
|
+
* // → "f7a3b2c1" (8 hex characters)
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
randomBytes(size: number): string;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Generate a random UUID v4.
|
|
474
|
+
*
|
|
475
|
+
* @returns UUID string in standard format
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```js
|
|
479
|
+
* const id = t.crypto.uuid();
|
|
480
|
+
* // → "550e8400-e29b-41d4-a716-446655440000"
|
|
481
|
+
*
|
|
482
|
+
* // Use as database primary key
|
|
483
|
+
* const user = { id: t.crypto.uuid(), name: "Alice" };
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
uuid(): string;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Base64 encoding/decoding utilities.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```js
|
|
493
|
+
* // Encode string to Base64
|
|
494
|
+
* const encoded = t.crypto.base64.encode("Hello World");
|
|
495
|
+
* // → "SGVsbG8gV29ybGQ="
|
|
496
|
+
*
|
|
497
|
+
* // Decode Base64 to string
|
|
498
|
+
* const decoded = t.crypto.base64.decode(encoded);
|
|
499
|
+
* // → "Hello World"
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
base64: {
|
|
503
|
+
/**
|
|
504
|
+
* Encode a string to Base64.
|
|
505
|
+
* @param str - String to encode
|
|
506
|
+
* @returns Base64-encoded string
|
|
507
|
+
*/
|
|
508
|
+
encode(str: string): string;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Decode a Base64 string.
|
|
512
|
+
* @param str - Base64-encoded string
|
|
513
|
+
* @returns Decoded string
|
|
514
|
+
*/
|
|
515
|
+
decode(str: string): string;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Perform a constant-time string comparison.
|
|
520
|
+
*
|
|
521
|
+
* **Security:** Prevents timing attacks by ensuring comparison
|
|
522
|
+
* takes the same time regardless of where strings differ.
|
|
523
|
+
* Always use this for comparing hashes, tokens, or secrets.
|
|
524
|
+
*
|
|
525
|
+
* @param hash - First string (typically the expected/stored value)
|
|
526
|
+
* @param target - Second string (typically the user-provided value)
|
|
527
|
+
* @returns `true` if strings are identical, `false` otherwise
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```js
|
|
531
|
+
* // Verify a password hash
|
|
532
|
+
* const storedHash = getUserHash(email);
|
|
533
|
+
* const computedHash = t.crypto.hash("sha256", password + salt);
|
|
534
|
+
*
|
|
535
|
+
* if (t.crypto.compare(storedHash, computedHash)) {
|
|
536
|
+
* return { success: true };
|
|
537
|
+
* }
|
|
538
|
+
*
|
|
539
|
+
* // Verify webhook signature
|
|
540
|
+
* const expected = t.crypto.hashKeyed("hmac-sha256", secret, body);
|
|
541
|
+
* const provided = req.headers["x-signature"];
|
|
542
|
+
*
|
|
543
|
+
* if (!t.crypto.compare(expected, provided)) {
|
|
544
|
+
* return t.response.json({ error: "Invalid signature" }, 401);
|
|
545
|
+
* }
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
compare(hash: string, target: string): boolean;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Encrypt plaintext using AES-256-GCM.
|
|
552
|
+
*
|
|
553
|
+
* @param algorithm - Encryption algorithm (use `"aes-256-gcm"`)
|
|
554
|
+
* @param key - 32-byte encryption key
|
|
555
|
+
* @param plaintext - Data to encrypt
|
|
556
|
+
* @returns Base64-encoded ciphertext (includes IV and auth tag)
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```js
|
|
560
|
+
* const key = process.env.ENCRYPTION_KEY; // 32-byte key
|
|
561
|
+
* const encrypted = t.crypto.encrypt("aes-256-gcm", key, "sensitive data");
|
|
562
|
+
* // Store encrypted value safely
|
|
563
|
+
* ```
|
|
564
|
+
*/
|
|
565
|
+
encrypt(algorithm: string, key: string, plaintext: string): string;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Decrypt ciphertext encrypted with AES-256-GCM.
|
|
569
|
+
*
|
|
570
|
+
* @param algorithm - Decryption algorithm (use `"aes-256-gcm"`)
|
|
571
|
+
* @param key - Same 32-byte key used for encryption
|
|
572
|
+
* @param ciphertext - Base64-encoded ciphertext from `encrypt()`
|
|
573
|
+
* @returns Original plaintext string
|
|
574
|
+
* @throws If decryption fails (wrong key, corrupted data, etc.)
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```js
|
|
578
|
+
* const key = process.env.ENCRYPTION_KEY;
|
|
579
|
+
* const decrypted = t.crypto.decrypt("aes-256-gcm", key, encrypted);
|
|
580
|
+
* // → "sensitive data"
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
decrypt(algorithm: string, key: string, ciphertext: string): string;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Compute an HMAC (Hash-based Message Authentication Code).
|
|
587
|
+
*
|
|
588
|
+
* Used for message authentication and webhook signature verification.
|
|
589
|
+
*
|
|
590
|
+
* @param algorithm - HMAC algorithm: `"hmac-sha256"` or `"hmac-sha512"`
|
|
591
|
+
* @param key - Secret key for the HMAC
|
|
592
|
+
* @param message - Message to authenticate
|
|
593
|
+
* @returns Hex-encoded HMAC string
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```js
|
|
597
|
+
* // Sign outgoing webhook
|
|
598
|
+
* const payload = JSON.stringify({ event: "user.created", data: user });
|
|
599
|
+
* const signature = t.crypto.hashKeyed("hmac-sha256", webhookSecret, payload);
|
|
600
|
+
*
|
|
601
|
+
* drift(t.fetch(webhookUrl, {
|
|
602
|
+
* method: "POST",
|
|
603
|
+
* headers: {
|
|
604
|
+
* "Content-Type": "application/json",
|
|
605
|
+
* "X-Signature": signature
|
|
606
|
+
* },
|
|
607
|
+
* body: payload
|
|
608
|
+
* }));
|
|
609
|
+
*
|
|
610
|
+
* // Verify incoming webhook
|
|
611
|
+
* export function webhook(req) {
|
|
612
|
+
* const expected = t.crypto.hashKeyed(
|
|
613
|
+
* "hmac-sha256",
|
|
614
|
+
* process.env.WEBHOOK_SECRET,
|
|
615
|
+
* JSON.stringify(req.body)
|
|
616
|
+
* );
|
|
617
|
+
*
|
|
618
|
+
* if (!t.crypto.compare(expected, req.headers["x-signature"])) {
|
|
619
|
+
* return t.response.json({ error: "Invalid signature" }, 401);
|
|
620
|
+
* }
|
|
621
|
+
*
|
|
622
|
+
* // Process verified webhook...
|
|
623
|
+
* }
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
hashKeyed(algorithm: 'hmac-sha256' | 'hmac-sha512', key: string, message: string): string;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// =====================================================================
|
|
630
|
+
// OS Module
|
|
631
|
+
// =====================================================================
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* # Operating System API
|
|
635
|
+
*
|
|
636
|
+
* Retrieve system information about the host machine.
|
|
637
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* ```js
|
|
641
|
+
* export function systemInfo(req) {
|
|
642
|
+
* return {
|
|
643
|
+
* platform: t.os.platform(), // "linux", "darwin", "windows"
|
|
644
|
+
* cpus: t.os.cpus(), // 8
|
|
645
|
+
* totalMemory: t.os.totalMemory(), // 17179869184 (16 GB)
|
|
646
|
+
* freeMemory: t.os.freeMemory(), // 8589934592 (8 GB)
|
|
647
|
+
* tmpdir: t.os.tmpdir() // "/tmp"
|
|
648
|
+
* };
|
|
649
|
+
* }
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#os-operating-system
|
|
653
|
+
*/
|
|
654
|
+
interface OS {
|
|
655
|
+
/**
|
|
656
|
+
* Get the operating system platform identifier.
|
|
657
|
+
*
|
|
658
|
+
* @returns Platform string: `"linux"`, `"darwin"` (macOS), or `"windows"`
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```js
|
|
662
|
+
* const platform = t.os.platform();
|
|
663
|
+
*
|
|
664
|
+
* if (platform === "windows") {
|
|
665
|
+
* // Windows-specific logic
|
|
666
|
+
* }
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
platform(): string;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Get the number of logical CPU cores.
|
|
673
|
+
*
|
|
674
|
+
* @returns Number of CPU cores available
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```js
|
|
678
|
+
* const workers = Math.max(1, t.os.cpus() - 1);
|
|
679
|
+
* t.log(`Starting ${workers} worker threads`);
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
cpus(): number;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Get the total system memory in bytes.
|
|
686
|
+
*
|
|
687
|
+
* @returns Total memory in bytes
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```js
|
|
691
|
+
* const totalGB = t.os.totalMemory() / (1024 ** 3);
|
|
692
|
+
* t.log(`Total RAM: ${totalGB.toFixed(2)} GB`);
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
totalMemory(): number;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Get the currently available (free) system memory in bytes.
|
|
699
|
+
*
|
|
700
|
+
* @returns Free memory in bytes
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```js
|
|
704
|
+
* const freeGB = t.os.freeMemory() / (1024 ** 3);
|
|
705
|
+
* const totalGB = t.os.totalMemory() / (1024 ** 3);
|
|
706
|
+
* const usedPercent = ((1 - freeGB / totalGB) * 100).toFixed(1);
|
|
707
|
+
*
|
|
708
|
+
* t.log(`Memory usage: ${usedPercent}%`);
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
freeMemory(): number;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Get the path to the system's temporary directory.
|
|
715
|
+
*
|
|
716
|
+
* @returns Temporary directory path
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```js
|
|
720
|
+
* const tempFile = t.path.join(t.os.tmpdir(), "upload-" + t.crypto.uuid());
|
|
721
|
+
* t.fs.writeFile(tempFile, data);
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
tmpdir(): string;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// =====================================================================
|
|
728
|
+
// Network Module
|
|
729
|
+
// =====================================================================
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* # Network API
|
|
733
|
+
*
|
|
734
|
+
* Network utilities for DNS resolution and IP lookup.
|
|
735
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```js
|
|
739
|
+
* // Resolve domain to IP addresses
|
|
740
|
+
* const ips = t.net.resolveDNS("google.com");
|
|
741
|
+
* t.log("Google IPs:", ips);
|
|
742
|
+
*
|
|
743
|
+
* // Get local IP
|
|
744
|
+
* const localIp = t.net.ip();
|
|
745
|
+
* t.log("Server IP:", localIp);
|
|
746
|
+
* ```
|
|
747
|
+
*
|
|
748
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#net-network
|
|
749
|
+
*/
|
|
750
|
+
interface Net {
|
|
751
|
+
/**
|
|
752
|
+
* Resolve a hostname to its IP addresses via DNS lookup.
|
|
753
|
+
*
|
|
754
|
+
* @param hostname - Domain name to resolve (e.g., `"example.com"`)
|
|
755
|
+
* @returns Array of IP address strings
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```js
|
|
759
|
+
* const ips = t.net.resolveDNS("github.com");
|
|
760
|
+
* // → ["140.82.114.3", "140.82.114.4"]
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
resolveDNS(hostname: string): string[];
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Get the local IP address of the server.
|
|
767
|
+
*
|
|
768
|
+
* @returns Local IP address string
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```js
|
|
772
|
+
* const serverIp = t.net.ip();
|
|
773
|
+
* // → "192.168.1.100"
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
ip(): string;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Check if a host is reachable.
|
|
780
|
+
*
|
|
781
|
+
* **Note:** Implementation may be limited on some platforms.
|
|
782
|
+
*
|
|
783
|
+
* @param host - Hostname or IP address to ping
|
|
784
|
+
* @returns `true` if host responds, `false` otherwise
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```js
|
|
788
|
+
* const isReachable = t.net.ping("8.8.8.8");
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
ping(host: string): boolean;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// =====================================================================
|
|
795
|
+
// Process Module
|
|
796
|
+
// =====================================================================
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* # Process API
|
|
800
|
+
*
|
|
801
|
+
* Runtime process information and subprocess management.
|
|
802
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```js
|
|
806
|
+
* export function processInfo(req) {
|
|
807
|
+
* return {
|
|
808
|
+
* pid: t.proc.pid(),
|
|
809
|
+
* uptime: t.proc.uptime(),
|
|
810
|
+
* memory: t.proc.memory()
|
|
811
|
+
* };
|
|
812
|
+
* }
|
|
813
|
+
*
|
|
814
|
+
* // Spawn a subprocess
|
|
815
|
+
* const result = t.proc.run("ls", ["-la"], "./data");
|
|
816
|
+
* t.log("Spawned process:", result.pid);
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#proc-process
|
|
820
|
+
*/
|
|
821
|
+
interface Process {
|
|
822
|
+
/**
|
|
823
|
+
* Get the process ID of the Titan server.
|
|
824
|
+
*
|
|
825
|
+
* @returns Numeric process ID
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```js
|
|
829
|
+
* const pid = t.proc.pid();
|
|
830
|
+
* t.log(`Server running as PID ${pid}`);
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
pid(): number;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Get the server uptime in seconds.
|
|
837
|
+
*
|
|
838
|
+
* @returns Uptime in seconds since server start
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* ```js
|
|
842
|
+
* const uptime = t.proc.uptime();
|
|
843
|
+
* const hours = Math.floor(uptime / 3600);
|
|
844
|
+
* const minutes = Math.floor((uptime % 3600) / 60);
|
|
845
|
+
* t.log(`Uptime: ${hours}h ${minutes}m`);
|
|
846
|
+
* ```
|
|
847
|
+
*/
|
|
848
|
+
uptime(): number;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Get memory usage statistics for the server process.
|
|
852
|
+
*
|
|
853
|
+
* @returns Object with memory metrics (rss, heapTotal, heapUsed, etc.)
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```js
|
|
857
|
+
* const mem = t.proc.memory();
|
|
858
|
+
* t.log(`RSS: ${(mem.rss / 1024 / 1024).toFixed(2)} MB`);
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
861
|
+
memory(): Record<string, any>;
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Spawn a subprocess.
|
|
865
|
+
*
|
|
866
|
+
* @param command - Executable to run
|
|
867
|
+
* @param args - Command-line arguments
|
|
868
|
+
* @param cwd - Working directory (optional)
|
|
869
|
+
* @returns Object with spawn result: `{ ok, pid, cwd }`
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* ```js
|
|
873
|
+
* // Run a shell command
|
|
874
|
+
* const result = t.proc.run("node", ["script.js", "--verbose"], "./scripts");
|
|
875
|
+
*
|
|
876
|
+
* if (result.ok) {
|
|
877
|
+
* t.log(`Spawned process ${result.pid} in ${result.cwd}`);
|
|
878
|
+
* }
|
|
879
|
+
* ```
|
|
880
|
+
*/
|
|
881
|
+
run(command: string, args: string[], cwd?: string): {
|
|
882
|
+
/** Whether the process was spawned successfully */
|
|
883
|
+
ok: boolean;
|
|
884
|
+
/** Process ID of the spawned process */
|
|
885
|
+
pid: number;
|
|
886
|
+
/** Working directory of the process */
|
|
887
|
+
cwd: string;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Kill a process by PID.
|
|
892
|
+
*
|
|
893
|
+
* @param pid - Process ID to terminate
|
|
894
|
+
* @returns `true` if the signal was sent successfully
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```js
|
|
898
|
+
* const killed = t.proc.kill(12345);
|
|
899
|
+
* t.log(killed ? "Process terminated" : "Failed to kill process");
|
|
900
|
+
* ```
|
|
901
|
+
*/
|
|
902
|
+
kill(pid: number): boolean;
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* List running processes.
|
|
906
|
+
*
|
|
907
|
+
* @returns Array of process information objects
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```js
|
|
911
|
+
* const processes = t.proc.list();
|
|
912
|
+
* processes.forEach(p => {
|
|
913
|
+
* t.log(`${p.pid}: ${p.name} (${p.cmd})`);
|
|
914
|
+
* });
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
list(): Array<{
|
|
918
|
+
/** Process ID */
|
|
919
|
+
pid: number;
|
|
920
|
+
/** Process name */
|
|
921
|
+
name: string;
|
|
922
|
+
/** Command line */
|
|
923
|
+
cmd: string;
|
|
924
|
+
/** CPU usage percentage (may be undefined) */
|
|
925
|
+
cpu?: number;
|
|
926
|
+
/** Memory usage in bytes (may be undefined) */
|
|
927
|
+
memory?: number;
|
|
928
|
+
}>;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// =====================================================================
|
|
932
|
+
// Time Module
|
|
933
|
+
// =====================================================================
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* # Time API
|
|
937
|
+
*
|
|
938
|
+
* Time utilities including sleep, timestamps, and high-resolution clock.
|
|
939
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* ```js
|
|
943
|
+
* // Measure execution time
|
|
944
|
+
* const start = t.time.now();
|
|
945
|
+
* // ... perform operations ...
|
|
946
|
+
* const elapsed = t.time.now() - start;
|
|
947
|
+
* t.log(`Operation took ${elapsed}ms`);
|
|
948
|
+
*
|
|
949
|
+
* // Get ISO timestamp for logging
|
|
950
|
+
* const timestamp = t.time.timestamp();
|
|
951
|
+
* // → "2026-01-15T12:30:45.123Z"
|
|
952
|
+
*
|
|
953
|
+
* // Rate limiting with sleep
|
|
954
|
+
* t.time.sleep(100); // Pause for 100ms
|
|
955
|
+
* ```
|
|
956
|
+
*
|
|
957
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#time-time
|
|
958
|
+
*/
|
|
959
|
+
interface Time {
|
|
960
|
+
/**
|
|
961
|
+
* Pause execution for the specified duration.
|
|
962
|
+
*
|
|
963
|
+
* **Note:** This is a blocking sleep — use sparingly.
|
|
964
|
+
* For non-blocking delays in async contexts, consider
|
|
965
|
+
* `drift(t.time.sleep(ms))` if supported.
|
|
966
|
+
*
|
|
967
|
+
* @param ms - Duration to sleep in milliseconds
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* ```js
|
|
971
|
+
* // Simple rate limiting
|
|
972
|
+
* t.time.sleep(100);
|
|
973
|
+
*
|
|
974
|
+
* // Retry with backoff
|
|
975
|
+
* for (let i = 0; i < 3; i++) {
|
|
976
|
+
* const result = tryOperation();
|
|
977
|
+
* if (result.ok) break;
|
|
978
|
+
* t.time.sleep(1000 * Math.pow(2, i)); // 1s, 2s, 4s
|
|
979
|
+
* }
|
|
980
|
+
* ```
|
|
981
|
+
*/
|
|
982
|
+
sleep(ms: number): void;
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Get the current time as a high-resolution millisecond timestamp.
|
|
986
|
+
*
|
|
987
|
+
* @returns Numeric timestamp in milliseconds (similar to `Date.now()`)
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* ```js
|
|
991
|
+
* const start = t.time.now();
|
|
992
|
+
* performExpensiveOperation();
|
|
993
|
+
* const duration = t.time.now() - start;
|
|
994
|
+
* t.log(`Completed in ${duration}ms`);
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
now(): number;
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Get the current time as an ISO 8601 formatted string.
|
|
1001
|
+
*
|
|
1002
|
+
* @returns ISO timestamp string (e.g., `"2026-01-15T12:30:45.123Z"`)
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```js
|
|
1006
|
+
* const log = {
|
|
1007
|
+
* timestamp: t.time.timestamp(),
|
|
1008
|
+
* level: "info",
|
|
1009
|
+
* message: "Server started"
|
|
1010
|
+
* };
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
timestamp(): string;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// =====================================================================
|
|
1017
|
+
// URL Module
|
|
1018
|
+
// =====================================================================
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* # URL API
|
|
1022
|
+
*
|
|
1023
|
+
* URL parsing, formatting, and query string manipulation.
|
|
1024
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
* ```js
|
|
1028
|
+
* // Parse a URL
|
|
1029
|
+
* const parsed = t.url.parse("https://api.example.com:8080/users?page=2&limit=10#section");
|
|
1030
|
+
* // → { protocol: "https:", hostname: "api.example.com", port: "8080", ... }
|
|
1031
|
+
*
|
|
1032
|
+
* // Build a URL
|
|
1033
|
+
* const url = t.url.format({
|
|
1034
|
+
* protocol: "https:",
|
|
1035
|
+
* hostname: "api.example.com",
|
|
1036
|
+
* pathname: "/v2/users"
|
|
1037
|
+
* });
|
|
1038
|
+
* // → "https://api.example.com/v2/users"
|
|
1039
|
+
*
|
|
1040
|
+
* // Work with query strings
|
|
1041
|
+
* const params = new t.url.SearchParams({ page: "1", limit: "20" });
|
|
1042
|
+
* params.set("sort", "name");
|
|
1043
|
+
* const queryString = params.toString();
|
|
1044
|
+
* // → "page=1&limit=20&sort=name"
|
|
1045
|
+
* ```
|
|
1046
|
+
*
|
|
1047
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#url-url
|
|
1048
|
+
*/
|
|
1049
|
+
interface URLModule {
|
|
1050
|
+
/**
|
|
1051
|
+
* Parse a URL string into its component parts.
|
|
1052
|
+
*
|
|
1053
|
+
* @param url - URL string to parse
|
|
1054
|
+
* @returns Parsed URL object with protocol, hostname, port, etc.
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```js
|
|
1058
|
+
* const url = t.url.parse("https://user:pass@example.com:8080/path?q=1#hash");
|
|
1059
|
+
* // → {
|
|
1060
|
+
* // protocol: "https:",
|
|
1061
|
+
* // hostname: "example.com",
|
|
1062
|
+
* // port: "8080",
|
|
1063
|
+
* // pathname: "/path",
|
|
1064
|
+
* // search: "?q=1",
|
|
1065
|
+
* // hash: "#hash"
|
|
1066
|
+
* // }
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
parse(url: string): UrlObject;
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Format a URL object back into a URL string.
|
|
1073
|
+
*
|
|
1074
|
+
* @param urlObj - URL object with components
|
|
1075
|
+
* @returns Formatted URL string
|
|
1076
|
+
*
|
|
1077
|
+
* @example
|
|
1078
|
+
* ```js
|
|
1079
|
+
* const url = t.url.format({
|
|
1080
|
+
* protocol: "https:",
|
|
1081
|
+
* hostname: "api.example.com",
|
|
1082
|
+
* pathname: "/users",
|
|
1083
|
+
* search: "?active=true"
|
|
1084
|
+
* });
|
|
1085
|
+
* // → "https://api.example.com/users?active=true"
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
format(urlObj: any): string;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* URLSearchParams constructor for query string manipulation.
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```js
|
|
1095
|
+
* // From string
|
|
1096
|
+
* const params = new t.url.SearchParams("page=1&limit=20");
|
|
1097
|
+
*
|
|
1098
|
+
* // From object
|
|
1099
|
+
* const params = new t.url.SearchParams({ page: "1", limit: "20" });
|
|
1100
|
+
*
|
|
1101
|
+
* params.get("page"); // → "1"
|
|
1102
|
+
* params.set("sort", "name");
|
|
1103
|
+
* params.has("limit"); // → true
|
|
1104
|
+
* params.delete("limit");
|
|
1105
|
+
* params.toString(); // → "page=1&sort=name"
|
|
1106
|
+
* ```
|
|
1107
|
+
*/
|
|
1108
|
+
SearchParams: typeof TitanURLSearchParams;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Parsed URL components returned by `url.parse()`.
|
|
1113
|
+
*/
|
|
1114
|
+
interface UrlObject {
|
|
1115
|
+
/** Protocol with colon (e.g., `"https:"`) */
|
|
1116
|
+
protocol: string;
|
|
1117
|
+
/** Hostname without port (e.g., `"example.com"`) */
|
|
1118
|
+
hostname: string;
|
|
1119
|
+
/** Port number as string (e.g., `"8080"`) or empty */
|
|
1120
|
+
port: string;
|
|
1121
|
+
/** Path portion (e.g., `"/api/users"`) */
|
|
1122
|
+
pathname: string;
|
|
1123
|
+
/** Query string with `?` (e.g., `"?page=1"`) or empty */
|
|
1124
|
+
search: string;
|
|
1125
|
+
/** Fragment with `#` (e.g., `"#section"`) or empty */
|
|
1126
|
+
hash: string;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* URLSearchParams for query string parsing and manipulation.
|
|
1131
|
+
*
|
|
1132
|
+
* Similar to the Web API `URLSearchParams`.
|
|
1133
|
+
*/
|
|
1134
|
+
class TitanURLSearchParams {
|
|
1135
|
+
/**
|
|
1136
|
+
* Create a new URLSearchParams instance.
|
|
1137
|
+
*
|
|
1138
|
+
* @param init - Initial value: query string or key-value object
|
|
1139
|
+
*/
|
|
1140
|
+
constructor(init?: string | Record<string, string>);
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* Get the value of a query parameter.
|
|
1144
|
+
*
|
|
1145
|
+
* @param key - Parameter name
|
|
1146
|
+
* @returns Parameter value or `null` if not found
|
|
1147
|
+
*/
|
|
1148
|
+
get(key: string): string | null;
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Set a query parameter (creates or updates).
|
|
1152
|
+
*
|
|
1153
|
+
* @param key - Parameter name
|
|
1154
|
+
* @param value - Parameter value
|
|
1155
|
+
*/
|
|
1156
|
+
set(key: string, value: string): void;
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Check if a parameter exists.
|
|
1160
|
+
*
|
|
1161
|
+
* @param key - Parameter name
|
|
1162
|
+
* @returns `true` if the parameter exists
|
|
1163
|
+
*/
|
|
1164
|
+
has(key: string): boolean;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Delete a query parameter.
|
|
1168
|
+
*
|
|
1169
|
+
* @param key - Parameter name to remove
|
|
1170
|
+
*/
|
|
1171
|
+
delete(key: string): void;
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Convert to a URL-encoded query string (without leading `?`).
|
|
1175
|
+
*
|
|
1176
|
+
* @returns Query string (e.g., `"page=1&limit=20"`)
|
|
1177
|
+
*/
|
|
1178
|
+
toString(): string;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Get all key-value pairs as an array of tuples.
|
|
1182
|
+
*
|
|
1183
|
+
* @returns Array of `[key, value]` tuples
|
|
1184
|
+
*/
|
|
1185
|
+
entries(): [string, string][];
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Get all parameter names.
|
|
1189
|
+
*
|
|
1190
|
+
* @returns Array of keys
|
|
1191
|
+
*/
|
|
1192
|
+
keys(): string[];
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Get all parameter values.
|
|
1196
|
+
*
|
|
1197
|
+
* @returns Array of values
|
|
1198
|
+
*/
|
|
1199
|
+
values(): string[];
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
// =====================================================================
|
|
1203
|
+
// Buffer Module
|
|
1204
|
+
// =====================================================================
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* # Buffer API
|
|
1208
|
+
*
|
|
1209
|
+
* Binary data encoding and decoding utilities.
|
|
1210
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
1211
|
+
*
|
|
1212
|
+
* Supports conversions between strings, `Uint8Array`, Base64, and Hex.
|
|
1213
|
+
*
|
|
1214
|
+
* @example
|
|
1215
|
+
* ```js
|
|
1216
|
+
* // Base64 encode/decode
|
|
1217
|
+
* const encoded = t.buffer.toBase64("Hello, World!");
|
|
1218
|
+
* // → "SGVsbG8sIFdvcmxkIQ=="
|
|
1219
|
+
*
|
|
1220
|
+
* const bytes = t.buffer.fromBase64(encoded);
|
|
1221
|
+
* const decoded = t.buffer.toUtf8(bytes);
|
|
1222
|
+
* // → "Hello, World!"
|
|
1223
|
+
*
|
|
1224
|
+
* // Hex encode/decode
|
|
1225
|
+
* const hex = t.buffer.toHex("Hello");
|
|
1226
|
+
* // → "48656c6c6f"
|
|
1227
|
+
*
|
|
1228
|
+
* const original = t.buffer.toUtf8(t.buffer.fromHex(hex));
|
|
1229
|
+
* // → "Hello"
|
|
1230
|
+
* ```
|
|
1231
|
+
*
|
|
1232
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#buffer-buffer-utilities
|
|
1233
|
+
*/
|
|
1234
|
+
interface BufferModule {
|
|
1235
|
+
/**
|
|
1236
|
+
* Decode a Base64-encoded string to bytes.
|
|
1237
|
+
*
|
|
1238
|
+
* @param str - Base64-encoded string
|
|
1239
|
+
* @returns Decoded byte array
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```js
|
|
1243
|
+
* const bytes = t.buffer.fromBase64("SGVsbG8=");
|
|
1244
|
+
* const text = t.buffer.toUtf8(bytes);
|
|
1245
|
+
* // → "Hello"
|
|
1246
|
+
* ```
|
|
1247
|
+
*/
|
|
1248
|
+
fromBase64(str: string): Uint8Array;
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Encode bytes or a string to Base64.
|
|
1252
|
+
*
|
|
1253
|
+
* @param bytes - `Uint8Array` or plain string to encode
|
|
1254
|
+
* @returns Base64-encoded string
|
|
1255
|
+
*
|
|
1256
|
+
* @example
|
|
1257
|
+
* ```js
|
|
1258
|
+
* const b64 = t.buffer.toBase64("Hello, World!");
|
|
1259
|
+
* // → "SGVsbG8sIFdvcmxkIQ=="
|
|
1260
|
+
* ```
|
|
1261
|
+
*/
|
|
1262
|
+
toBase64(bytes: Uint8Array | string): string;
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Decode a hex-encoded string to bytes.
|
|
1266
|
+
*
|
|
1267
|
+
* @param str - Hex-encoded string (e.g., `"48656c6c6f"`)
|
|
1268
|
+
* @returns Decoded byte array
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* ```js
|
|
1272
|
+
* const bytes = t.buffer.fromHex("48656c6c6f");
|
|
1273
|
+
* const text = t.buffer.toUtf8(bytes);
|
|
1274
|
+
* // → "Hello"
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
fromHex(str: string): Uint8Array;
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Encode bytes or a string to hexadecimal.
|
|
1281
|
+
*
|
|
1282
|
+
* @param bytes - `Uint8Array` or plain string to encode
|
|
1283
|
+
* @returns Hex-encoded string
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```js
|
|
1287
|
+
* const hex = t.buffer.toHex("Hello");
|
|
1288
|
+
* // → "48656c6c6f"
|
|
1289
|
+
* ```
|
|
1290
|
+
*/
|
|
1291
|
+
toHex(bytes: Uint8Array | string): string;
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Encode a UTF-8 string to bytes.
|
|
1295
|
+
*
|
|
1296
|
+
* @param str - String to encode
|
|
1297
|
+
* @returns UTF-8 encoded byte array
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```js
|
|
1301
|
+
* const bytes = t.buffer.fromUtf8("Hello");
|
|
1302
|
+
* // → Uint8Array [72, 101, 108, 108, 111]
|
|
1303
|
+
* ```
|
|
1304
|
+
*/
|
|
1305
|
+
fromUtf8(str: string): Uint8Array;
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Decode bytes to a UTF-8 string.
|
|
1309
|
+
*
|
|
1310
|
+
* @param bytes - Byte array to decode
|
|
1311
|
+
* @returns UTF-8 decoded string
|
|
1312
|
+
*
|
|
1313
|
+
* @example
|
|
1314
|
+
* ```js
|
|
1315
|
+
* const bytes = new Uint8Array([72, 101, 108, 108, 111]);
|
|
1316
|
+
* const text = t.buffer.toUtf8(bytes);
|
|
1317
|
+
* // → "Hello"
|
|
1318
|
+
* ```
|
|
1319
|
+
*/
|
|
1320
|
+
toUtf8(bytes: Uint8Array): string;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// =====================================================================
|
|
1324
|
+
// Local Storage Module
|
|
1325
|
+
// =====================================================================
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* # Local Storage API
|
|
1329
|
+
*
|
|
1330
|
+
* High-performance in-memory key-value store backed by native Rust
|
|
1331
|
+
* `RwLock<HashMap>`. Data persists across requests but is **volatile**
|
|
1332
|
+
* (lost on server restart).
|
|
1333
|
+
*
|
|
1334
|
+
* **Performance Benchmarks (10,000 operations):**
|
|
1335
|
+
* - 📖 Read: ~156,250 ops/sec (0.0064ms avg)
|
|
1336
|
+
* - ✍️ Write: ~89,286 ops/sec (0.0112ms avg)
|
|
1337
|
+
* - 🔄 Mixed: ~125,000 ops/sec (0.008ms avg)
|
|
1338
|
+
*
|
|
1339
|
+
* **Characteristics:**
|
|
1340
|
+
* - ⚡ ~1000x faster than file-based storage
|
|
1341
|
+
* - 💾 In-memory only (not persistent across restarts)
|
|
1342
|
+
* - 🔒 Thread-safe with RwLock (multiple readers, single writer)
|
|
1343
|
+
* - 📦 Supports V8 Serialization for complex objects (Map, Set, Date, etc.)
|
|
1344
|
+
*
|
|
1345
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
1346
|
+
*
|
|
1347
|
+
* @example
|
|
1348
|
+
* ```js
|
|
1349
|
+
* // Basic string storage
|
|
1350
|
+
* t.ls.set("user:123", JSON.stringify({ name: "Alice", role: "admin" }));
|
|
1351
|
+
* const userData = JSON.parse(t.ls.get("user:123") || "{}");
|
|
1352
|
+
*
|
|
1353
|
+
* // Complex object storage (preserves Map, Set, Date, etc.)
|
|
1354
|
+
* const data = {
|
|
1355
|
+
* users: new Map([["alice", { role: "admin" }]]),
|
|
1356
|
+
* tags: new Set(["active", "verified"]),
|
|
1357
|
+
* created: new Date()
|
|
1358
|
+
* };
|
|
1359
|
+
* t.ls.setObject("complex:data", data);
|
|
1360
|
+
* const restored = t.ls.getObject("complex:data");
|
|
1361
|
+
* // restored.users instanceof Map → true
|
|
1362
|
+
*
|
|
1363
|
+
* // List and cleanup
|
|
1364
|
+
* const allKeys = t.ls.keys();
|
|
1365
|
+
* t.ls.remove("user:123");
|
|
1366
|
+
* t.ls.clear(); // Remove all data
|
|
1367
|
+
* ```
|
|
1368
|
+
*
|
|
1369
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#ls--localstorage-persistent-storage
|
|
1370
|
+
*/
|
|
1371
|
+
interface LocalStorage {
|
|
1372
|
+
/**
|
|
1373
|
+
* Get a string value by key.
|
|
1374
|
+
*
|
|
1375
|
+
* @param key - Storage key
|
|
1376
|
+
* @returns Stored string value, or `null` if not found
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```js
|
|
1380
|
+
* const value = t.ls.get("config:theme");
|
|
1381
|
+
* // → "dark" or null
|
|
1382
|
+
* ```
|
|
1383
|
+
*/
|
|
1384
|
+
get(key: string): string | null;
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Store a string value under a key.
|
|
1388
|
+
*
|
|
1389
|
+
* @param key - Storage key
|
|
1390
|
+
* @param value - String value to store
|
|
1391
|
+
*
|
|
1392
|
+
* @example
|
|
1393
|
+
* ```js
|
|
1394
|
+
* t.ls.set("config:theme", "dark");
|
|
1395
|
+
* t.ls.set("user:123", JSON.stringify({ name: "Alice" }));
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
set(key: string, value: string): void;
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Remove a key from storage.
|
|
1402
|
+
*
|
|
1403
|
+
* @param key - Key to remove (no error if key doesn't exist)
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```js
|
|
1407
|
+
* t.ls.remove("session:expired");
|
|
1408
|
+
* ```
|
|
1409
|
+
*/
|
|
1410
|
+
remove(key: string): void;
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Clear all keys and values from storage.
|
|
1414
|
+
*
|
|
1415
|
+
* **⚠️ Destructive operation** — removes everything.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* ```js
|
|
1419
|
+
* t.ls.clear();
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
clear(): void;
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* Get a list of all stored keys.
|
|
1426
|
+
*
|
|
1427
|
+
* @returns Array of all key names
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```js
|
|
1431
|
+
* const keys = t.ls.keys();
|
|
1432
|
+
* // → ["user:123", "config:theme", "cache:data"]
|
|
1433
|
+
*
|
|
1434
|
+
* // Filter keys by prefix
|
|
1435
|
+
* const userKeys = keys.filter(k => k.startsWith("user:"));
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
keys(): string[];
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Store a complex JavaScript object using V8 serialization.
|
|
1442
|
+
*
|
|
1443
|
+
* **Advantages over JSON.stringify:**
|
|
1444
|
+
* - ✅ Preserves `Map`, `Set`, `Date`, `RegExp`, `BigInt`
|
|
1445
|
+
* - ✅ Handles circular references
|
|
1446
|
+
* - ✅ ~50x faster than JSON for large objects
|
|
1447
|
+
*
|
|
1448
|
+
* @param key - Storage key
|
|
1449
|
+
* @param value - Any JavaScript value to store
|
|
1450
|
+
*
|
|
1451
|
+
* @example
|
|
1452
|
+
* ```js
|
|
1453
|
+
* const session = {
|
|
1454
|
+
* user: { id: 1, name: "Alice" },
|
|
1455
|
+
* permissions: new Set(["read", "write"]),
|
|
1456
|
+
* metadata: new Map([["loginTime", new Date()]]),
|
|
1457
|
+
* count: BigInt(9007199254740993)
|
|
1458
|
+
* };
|
|
1459
|
+
*
|
|
1460
|
+
* t.ls.setObject("session:abc", session);
|
|
1461
|
+
* ```
|
|
1462
|
+
*/
|
|
1463
|
+
setObject(key: string, value: any): void;
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Retrieve and deserialize a complex JavaScript object.
|
|
1467
|
+
*
|
|
1468
|
+
* @typeParam T - Expected return type
|
|
1469
|
+
* @param key - Storage key
|
|
1470
|
+
* @returns Deserialized object, or `null` if not found or invalid
|
|
1471
|
+
*
|
|
1472
|
+
* @example
|
|
1473
|
+
* ```js
|
|
1474
|
+
* const session = t.ls.getObject("session:abc");
|
|
1475
|
+
*
|
|
1476
|
+
* if (session) {
|
|
1477
|
+
* session.permissions instanceof Set; // → true
|
|
1478
|
+
* session.metadata instanceof Map; // → true
|
|
1479
|
+
* session.metadata.get("loginTime") instanceof Date; // → true
|
|
1480
|
+
* }
|
|
1481
|
+
* ```
|
|
1482
|
+
*/
|
|
1483
|
+
getObject<T = any>(key: string): T | null;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* Serialize a JavaScript value to V8 binary format.
|
|
1487
|
+
*
|
|
1488
|
+
* Useful for manual serialization before storing or transmitting.
|
|
1489
|
+
*
|
|
1490
|
+
* @param value - Value to serialize
|
|
1491
|
+
* @returns Binary representation as `Uint8Array`
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```js
|
|
1495
|
+
* const data = { map: new Map([["a", 1]]) };
|
|
1496
|
+
* const bytes = t.ls.serialize(data);
|
|
1497
|
+
* // bytes can be stored, sent over network, etc.
|
|
1498
|
+
* ```
|
|
1499
|
+
*/
|
|
1500
|
+
serialize(value: any): Uint8Array;
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Deserialize V8 binary format back to a JavaScript value.
|
|
1504
|
+
*
|
|
1505
|
+
* @param bytes - Binary data to deserialize
|
|
1506
|
+
* @returns Original JavaScript value
|
|
1507
|
+
*
|
|
1508
|
+
* @example
|
|
1509
|
+
* ```js
|
|
1510
|
+
* const data = t.ls.deserialize(bytes);
|
|
1511
|
+
* // data.map instanceof Map → true
|
|
1512
|
+
* ```
|
|
1513
|
+
*/
|
|
1514
|
+
deserialize(bytes: Uint8Array): any;
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Register a custom class for serialization/hydration support.
|
|
1518
|
+
*
|
|
1519
|
+
* @param ClassRef - Constructor function of the class
|
|
1520
|
+
* @param hydrateFn - Optional custom hydration function
|
|
1521
|
+
* @param typeName - Optional type name override
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```js
|
|
1525
|
+
* class User {
|
|
1526
|
+
* constructor(name, email) {
|
|
1527
|
+
* this.name = name;
|
|
1528
|
+
* this.email = email;
|
|
1529
|
+
* }
|
|
1530
|
+
* }
|
|
1531
|
+
*
|
|
1532
|
+
* t.ls.register(User, (data) => new User(data.name, data.email));
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
register(ClassRef: Function, hydrateFn?: Function, typeName?: string): void;
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Hydrate a custom object from serialized data.
|
|
1539
|
+
*
|
|
1540
|
+
* @param typeName - Registered type name
|
|
1541
|
+
* @param data - Plain object data
|
|
1542
|
+
* @returns Hydrated class instance
|
|
1543
|
+
*
|
|
1544
|
+
* @example
|
|
1545
|
+
* ```js
|
|
1546
|
+
* const user = t.ls.hydrate("User", { name: "Alice", email: "alice@example.com" });
|
|
1547
|
+
* // user instanceof User → true
|
|
1548
|
+
* ```
|
|
1549
|
+
*/
|
|
1550
|
+
hydrate(typeName: string, data: object): any;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// =====================================================================
|
|
1554
|
+
// Session Module
|
|
1555
|
+
// =====================================================================
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* # Session API
|
|
1559
|
+
*
|
|
1560
|
+
* High-performance server-side session state management.
|
|
1561
|
+
* Uses composite keys (`{sessionId}:{key}`) for isolation.
|
|
1562
|
+
*
|
|
1563
|
+
* **Implementation:** Native Rust `RwLock<HashMap>`
|
|
1564
|
+
* **Performance:** Same as LocalStorage (~89K-156K ops/sec)
|
|
1565
|
+
*
|
|
1566
|
+
* **Characteristics:**
|
|
1567
|
+
* - 🔐 Session-scoped (isolated per session ID)
|
|
1568
|
+
* - ⚡ Sub-millisecond operations
|
|
1569
|
+
* - 💾 In-memory only (not persistent across restarts)
|
|
1570
|
+
*
|
|
1571
|
+
* All methods are **synchronous** — no `drift()` needed.
|
|
1572
|
+
*
|
|
1573
|
+
* @example
|
|
1574
|
+
* ```js
|
|
1575
|
+
* // Get session ID from cookie or header
|
|
1576
|
+
* const sessionId = t.cookies.get(req, "session_id") || t.crypto.uuid();
|
|
1577
|
+
*
|
|
1578
|
+
* // Store shopping cart
|
|
1579
|
+
* t.session.set(sessionId, "cart", JSON.stringify([
|
|
1580
|
+
* { productId: 1, quantity: 2 },
|
|
1581
|
+
* { productId: 5, quantity: 1 }
|
|
1582
|
+
* ]));
|
|
1583
|
+
*
|
|
1584
|
+
* // Retrieve cart
|
|
1585
|
+
* const cart = JSON.parse(t.session.get(sessionId, "cart") || "[]");
|
|
1586
|
+
*
|
|
1587
|
+
* // Store user authentication state
|
|
1588
|
+
* t.session.set(sessionId, "userId", "123");
|
|
1589
|
+
* t.session.set(sessionId, "role", "admin");
|
|
1590
|
+
*
|
|
1591
|
+
* // Logout: clear entire session
|
|
1592
|
+
* t.session.clear(sessionId);
|
|
1593
|
+
* ```
|
|
1594
|
+
*
|
|
1595
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#session-server-side-sessions
|
|
1596
|
+
*/
|
|
1597
|
+
interface Session {
|
|
1598
|
+
/**
|
|
1599
|
+
* Get a value from a session.
|
|
1600
|
+
*
|
|
1601
|
+
* @param sessionId - Unique session identifier
|
|
1602
|
+
* @param key - Key within the session
|
|
1603
|
+
* @returns Stored value, or `null` if not found
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```js
|
|
1607
|
+
* const userId = t.session.get(sessionId, "userId");
|
|
1608
|
+
* if (!userId) {
|
|
1609
|
+
* return t.response.json({ error: "Not authenticated" }, 401);
|
|
1610
|
+
* }
|
|
1611
|
+
* ```
|
|
1612
|
+
*/
|
|
1613
|
+
get(sessionId: string, key: string): string | null;
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* Store a value in a session.
|
|
1617
|
+
*
|
|
1618
|
+
* @param sessionId - Unique session identifier
|
|
1619
|
+
* @param key - Key within the session
|
|
1620
|
+
* @param value - Value to store
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```js
|
|
1624
|
+
* t.session.set(sessionId, "lastActivity", t.time.timestamp());
|
|
1625
|
+
* t.session.set(sessionId, "preferences", JSON.stringify({ theme: "dark" }));
|
|
1626
|
+
* ```
|
|
1627
|
+
*/
|
|
1628
|
+
set(sessionId: string, key: string, value: string): void;
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Delete a single key from a session.
|
|
1632
|
+
*
|
|
1633
|
+
* @param sessionId - Unique session identifier
|
|
1634
|
+
* @param key - Key to delete
|
|
1635
|
+
*
|
|
1636
|
+
* @example
|
|
1637
|
+
* ```js
|
|
1638
|
+
* t.session.delete(sessionId, "tempData");
|
|
1639
|
+
* ```
|
|
1640
|
+
*/
|
|
1641
|
+
delete(sessionId: string, key: string): void;
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Clear an entire session (remove all data for this session ID).
|
|
1645
|
+
*
|
|
1646
|
+
* Useful for logout functionality.
|
|
1647
|
+
*
|
|
1648
|
+
* @param sessionId - Unique session identifier
|
|
1649
|
+
*
|
|
1650
|
+
* @example
|
|
1651
|
+
* ```js
|
|
1652
|
+
* export function logout(req) {
|
|
1653
|
+
* const sessionId = t.cookies.get(req, "session_id");
|
|
1654
|
+
* if (sessionId) {
|
|
1655
|
+
* t.session.clear(sessionId);
|
|
1656
|
+
* t.cookies.delete(req, "session_id");
|
|
1657
|
+
* }
|
|
1658
|
+
* return t.response.redirect("/login");
|
|
1659
|
+
* }
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
clear(sessionId: string): void;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// =====================================================================
|
|
1666
|
+
// Cookies Module
|
|
1667
|
+
// =====================================================================
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* # Cookie API
|
|
1671
|
+
*
|
|
1672
|
+
* HTTP cookie parsing and setting utilities.
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```js
|
|
1676
|
+
* export function handleAuth(req) {
|
|
1677
|
+
* // Read a cookie
|
|
1678
|
+
* const token = t.cookies.get(req, "auth_token");
|
|
1679
|
+
*
|
|
1680
|
+
* if (!token) {
|
|
1681
|
+
* // Set a new cookie
|
|
1682
|
+
* const newToken = t.crypto.uuid();
|
|
1683
|
+
* t.cookies.set(req, "auth_token", newToken, {
|
|
1684
|
+
* httpOnly: true,
|
|
1685
|
+
* secure: true,
|
|
1686
|
+
* sameSite: "Strict",
|
|
1687
|
+
* maxAge: 86400 * 7, // 7 days
|
|
1688
|
+
* path: "/"
|
|
1689
|
+
* });
|
|
1690
|
+
* return { token: newToken, isNew: true };
|
|
1691
|
+
* }
|
|
1692
|
+
*
|
|
1693
|
+
* return { token, isNew: false };
|
|
1694
|
+
* }
|
|
1695
|
+
*
|
|
1696
|
+
* export function logout(req) {
|
|
1697
|
+
* t.cookies.delete(req, "auth_token");
|
|
1698
|
+
* return t.response.redirect("/login");
|
|
1699
|
+
* }
|
|
1700
|
+
* ```
|
|
1701
|
+
*
|
|
1702
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#cookies-http-cookies
|
|
1703
|
+
*/
|
|
1704
|
+
interface Cookies {
|
|
1705
|
+
/**
|
|
1706
|
+
* Parse and retrieve a cookie value from the request.
|
|
1707
|
+
*
|
|
1708
|
+
* @param req - Titan request object
|
|
1709
|
+
* @param name - Cookie name
|
|
1710
|
+
* @returns Cookie value, or `null` if not found
|
|
1711
|
+
*
|
|
1712
|
+
* @example
|
|
1713
|
+
* ```js
|
|
1714
|
+
* const sessionId = t.cookies.get(req, "session_id");
|
|
1715
|
+
* const theme = t.cookies.get(req, "theme") || "light";
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1718
|
+
get(req: any, name: string): string | null;
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Set a cookie on the response.
|
|
1722
|
+
*
|
|
1723
|
+
* @param res - Response context (typically the request object in Titan)
|
|
1724
|
+
* @param name - Cookie name
|
|
1725
|
+
* @param value - Cookie value
|
|
1726
|
+
* @param options - Cookie options (httpOnly, secure, sameSite, etc.)
|
|
1727
|
+
*
|
|
1728
|
+
* @example
|
|
1729
|
+
* ```js
|
|
1730
|
+
* // Secure authentication cookie
|
|
1731
|
+
* t.cookies.set(req, "auth_token", token, {
|
|
1732
|
+
* httpOnly: true, // Not accessible via JavaScript
|
|
1733
|
+
* secure: true, // HTTPS only
|
|
1734
|
+
* sameSite: "Strict", // CSRF protection
|
|
1735
|
+
* maxAge: 86400, // 1 day in seconds
|
|
1736
|
+
* path: "/"
|
|
1737
|
+
* });
|
|
1738
|
+
*
|
|
1739
|
+
* // Simple preference cookie
|
|
1740
|
+
* t.cookies.set(req, "theme", "dark", {
|
|
1741
|
+
* maxAge: 86400 * 365 // 1 year
|
|
1742
|
+
* });
|
|
1743
|
+
* ```
|
|
1744
|
+
*/
|
|
1745
|
+
set(res: any, name: string, value: string, options?: CookieOptions): void;
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Delete a cookie by setting its expiration in the past.
|
|
1749
|
+
*
|
|
1750
|
+
* @param res - Response context
|
|
1751
|
+
* @param name - Cookie name to delete
|
|
1752
|
+
*
|
|
1753
|
+
* @example
|
|
1754
|
+
* ```js
|
|
1755
|
+
* t.cookies.delete(req, "auth_token");
|
|
1756
|
+
* t.cookies.delete(req, "session_id");
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
delete(res: any, name: string): void;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* Options for configuring cookies.
|
|
1764
|
+
*/
|
|
1765
|
+
interface CookieOptions {
|
|
1766
|
+
/**
|
|
1767
|
+
* Maximum age in seconds before the cookie expires.
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```js
|
|
1771
|
+
* maxAge: 86400 // 1 day
|
|
1772
|
+
* maxAge: 86400 * 7 // 1 week
|
|
1773
|
+
* maxAge: 86400 * 30 // 30 days
|
|
1774
|
+
* ```
|
|
1775
|
+
*/
|
|
1776
|
+
maxAge?: number;
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* URL path where the cookie is valid.
|
|
1780
|
+
* @default "/"
|
|
1781
|
+
*/
|
|
1782
|
+
path?: string;
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* If `true`, cookie is not accessible via JavaScript (`document.cookie`).
|
|
1786
|
+
* **Recommended for authentication tokens.**
|
|
1787
|
+
*/
|
|
1788
|
+
httpOnly?: boolean;
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* If `true`, cookie is only sent over HTTPS connections.
|
|
1792
|
+
* **Recommended for production.**
|
|
1793
|
+
*/
|
|
1794
|
+
secure?: boolean;
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* SameSite policy for CSRF protection.
|
|
1798
|
+
* - `"Strict"` — Cookie only sent for same-site requests
|
|
1799
|
+
* - `"Lax"` — Cookie sent for same-site + top-level navigation
|
|
1800
|
+
* - `"None"` — Cookie sent for all requests (requires `secure: true`)
|
|
1801
|
+
*/
|
|
1802
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// =====================================================================
|
|
1806
|
+
// Response Module
|
|
1807
|
+
// =====================================================================
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* # Response API
|
|
1811
|
+
*
|
|
1812
|
+
* HTTP response builder for controlled response formatting.
|
|
1813
|
+
* Creates `ResponseObject` instances that the Titan runtime processes.
|
|
1814
|
+
*
|
|
1815
|
+
* @example
|
|
1816
|
+
* ```js
|
|
1817
|
+
* // JSON response
|
|
1818
|
+
* export function getUser(req) {
|
|
1819
|
+
* const user = findUser(req.params.id);
|
|
1820
|
+
* if (!user) {
|
|
1821
|
+
* return t.response.json({ error: "User not found" }, 404);
|
|
1822
|
+
* }
|
|
1823
|
+
* return t.response.json(user);
|
|
1824
|
+
* }
|
|
1825
|
+
*
|
|
1826
|
+
* // HTML response
|
|
1827
|
+
* export function homePage(req) {
|
|
1828
|
+
* const html = t.fs.readFile("./views/home.html");
|
|
1829
|
+
* return t.response.html(html);
|
|
1830
|
+
* }
|
|
1831
|
+
*
|
|
1832
|
+
* // Redirect
|
|
1833
|
+
* export function oldEndpoint(req) {
|
|
1834
|
+
* return t.response.redirect("/api/v2/users");
|
|
1835
|
+
* }
|
|
1836
|
+
*
|
|
1837
|
+
* // Custom response with headers
|
|
1838
|
+
* export function download(req) {
|
|
1839
|
+
* const content = t.fs.readFile("./data/export.csv");
|
|
1840
|
+
* return t.response({
|
|
1841
|
+
* status: 200,
|
|
1842
|
+
* headers: {
|
|
1843
|
+
* "Content-Type": "text/csv",
|
|
1844
|
+
* "Content-Disposition": "attachment; filename=\"export.csv\""
|
|
1845
|
+
* },
|
|
1846
|
+
* body: content
|
|
1847
|
+
* });
|
|
1848
|
+
* }
|
|
1849
|
+
*
|
|
1850
|
+
* // Empty response (204 No Content)
|
|
1851
|
+
* export function deleteUser(req) {
|
|
1852
|
+
* removeUser(req.params.id);
|
|
1853
|
+
* return t.response.empty();
|
|
1854
|
+
* }
|
|
1855
|
+
* ```
|
|
1856
|
+
*
|
|
1857
|
+
* @see https://titan-docs-ez.vercel.app/docs/04-runtime-apis
|
|
1858
|
+
*/
|
|
1859
|
+
interface ResponseModule {
|
|
1860
|
+
/**
|
|
1861
|
+
* Create a fully custom response.
|
|
1862
|
+
*
|
|
1863
|
+
* @param options - Response configuration
|
|
1864
|
+
* @returns ResponseObject for the Titan runtime
|
|
1865
|
+
*
|
|
1866
|
+
* @example
|
|
1867
|
+
* ```js
|
|
1868
|
+
* return t.response({
|
|
1869
|
+
* status: 201,
|
|
1870
|
+
* headers: {
|
|
1871
|
+
* "X-Request-Id": requestId,
|
|
1872
|
+
* "Content-Type": "application/json"
|
|
1873
|
+
* },
|
|
1874
|
+
* body: JSON.stringify({ created: true })
|
|
1875
|
+
* });
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
(options: ResponseOptions): ResponseObject;
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Send a plain text response.
|
|
1882
|
+
*
|
|
1883
|
+
* Automatically sets `Content-Type: text/plain; charset=utf-8`.
|
|
1884
|
+
*
|
|
1885
|
+
* @param content - Text content to send
|
|
1886
|
+
* @param options - Optional response options (status, headers)
|
|
1887
|
+
* @returns ResponseObject
|
|
1888
|
+
*
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```js
|
|
1891
|
+
* return t.response.text("Hello, World!");
|
|
1892
|
+
* return t.response.text("Not Found", { status: 404 });
|
|
1893
|
+
* ```
|
|
1894
|
+
*/
|
|
1895
|
+
text(content: string, options?: ResponseOptions): ResponseObject;
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Send an HTML response.
|
|
1899
|
+
*
|
|
1900
|
+
* Automatically sets `Content-Type: text/html; charset=utf-8`.
|
|
1901
|
+
*
|
|
1902
|
+
* @param content - HTML content to send
|
|
1903
|
+
* @param options - Optional response options (status, headers)
|
|
1904
|
+
* @returns ResponseObject
|
|
1905
|
+
*
|
|
1906
|
+
* @example
|
|
1907
|
+
* ```js
|
|
1908
|
+
* const html = `<!DOCTYPE html>
|
|
1909
|
+
* <html><body><h1>Welcome</h1></body></html>`;
|
|
1910
|
+
* return t.response.html(html);
|
|
1911
|
+
*
|
|
1912
|
+
* // From file
|
|
1913
|
+
* const page = t.fs.readFile("./views/index.html");
|
|
1914
|
+
* return t.response.html(page);
|
|
1915
|
+
* ```
|
|
1916
|
+
*/
|
|
1917
|
+
html(content: string, options?: ResponseOptions): ResponseObject;
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Send a JSON response.
|
|
1921
|
+
*
|
|
1922
|
+
* Automatically sets `Content-Type: application/json` and
|
|
1923
|
+
* serializes the content with `JSON.stringify()`.
|
|
1924
|
+
*
|
|
1925
|
+
* @param content - JavaScript object to serialize as JSON
|
|
1926
|
+
* @param options - Optional response options (status, headers)
|
|
1927
|
+
* @returns ResponseObject
|
|
1928
|
+
*
|
|
1929
|
+
* @example
|
|
1930
|
+
* ```js
|
|
1931
|
+
* // Success response
|
|
1932
|
+
* return t.response.json({ users: [], total: 0 });
|
|
1933
|
+
*
|
|
1934
|
+
* // Error response
|
|
1935
|
+
* return t.response.json({ error: "Invalid input" }, { status: 400 });
|
|
1936
|
+
*
|
|
1937
|
+
* // Created response
|
|
1938
|
+
* return t.response.json({ id: newId, created: true }, { status: 201 });
|
|
1939
|
+
* ```
|
|
1940
|
+
*/
|
|
1941
|
+
json(content: any, options?: ResponseOptions): ResponseObject;
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Create an HTTP redirect response.
|
|
1945
|
+
*
|
|
1946
|
+
* @param url - Target URL to redirect to
|
|
1947
|
+
* @param status - HTTP status code (default: 302 Found)
|
|
1948
|
+
* @returns ResponseObject
|
|
1949
|
+
*
|
|
1950
|
+
* @example
|
|
1951
|
+
* ```js
|
|
1952
|
+
* // Temporary redirect (302)
|
|
1953
|
+
* return t.response.redirect("/login");
|
|
1954
|
+
*
|
|
1955
|
+
* // Permanent redirect (301)
|
|
1956
|
+
* return t.response.redirect("/api/v2/users", 301);
|
|
1957
|
+
*
|
|
1958
|
+
* // External redirect
|
|
1959
|
+
* return t.response.redirect("https://example.com/callback");
|
|
1960
|
+
* ```
|
|
1961
|
+
*/
|
|
1962
|
+
redirect(url: string, status?: number): ResponseObject;
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* Create an empty response (no body).
|
|
1966
|
+
*
|
|
1967
|
+
* Useful for DELETE operations or acknowledgments.
|
|
1968
|
+
*
|
|
1969
|
+
* @param status - HTTP status code (default: 204 No Content)
|
|
1970
|
+
* @returns ResponseObject
|
|
1971
|
+
*
|
|
1972
|
+
* @example
|
|
1973
|
+
* ```js
|
|
1974
|
+
* // After successful deletion
|
|
1975
|
+
* return t.response.empty(); // 204 No Content
|
|
1976
|
+
*
|
|
1977
|
+
* // Accepted for processing
|
|
1978
|
+
* return t.response.empty(202);
|
|
1979
|
+
* ```
|
|
1980
|
+
*/
|
|
1981
|
+
empty(status?: number): ResponseObject;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* Options for constructing a custom response.
|
|
1986
|
+
*/
|
|
1987
|
+
interface ResponseOptions {
|
|
1988
|
+
/**
|
|
1989
|
+
* HTTP status code.
|
|
1990
|
+
* @default 200
|
|
1991
|
+
*
|
|
1992
|
+
* @example
|
|
1993
|
+
* ```js
|
|
1994
|
+
* status: 200 // OK
|
|
1995
|
+
* status: 201 // Created
|
|
1996
|
+
* status: 400 // Bad Request
|
|
1997
|
+
* status: 404 // Not Found
|
|
1998
|
+
* status: 500 // Internal Server Error
|
|
1999
|
+
* ```
|
|
2000
|
+
*/
|
|
2001
|
+
status?: number;
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* Custom HTTP headers as key-value pairs.
|
|
2005
|
+
*
|
|
2006
|
+
* @example
|
|
2007
|
+
* ```js
|
|
2008
|
+
* headers: {
|
|
2009
|
+
* "Content-Type": "application/pdf",
|
|
2010
|
+
* "Content-Disposition": "attachment; filename=\"doc.pdf\"",
|
|
2011
|
+
* "X-Request-Id": requestId
|
|
2012
|
+
* }
|
|
2013
|
+
* ```
|
|
2014
|
+
*/
|
|
2015
|
+
headers?: Record<string, string>;
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* Response body as a string.
|
|
2019
|
+
*
|
|
2020
|
+
* For JSON, use `JSON.stringify(data)`.
|
|
2021
|
+
*/
|
|
2022
|
+
body?: string;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Standardized response object consumed by the Titan runtime.
|
|
2027
|
+
*
|
|
2028
|
+
* Created by `t.response()` and its helper methods.
|
|
2029
|
+
* Do not construct manually — use the Response API.
|
|
2030
|
+
*/
|
|
2031
|
+
interface ResponseObject {
|
|
2032
|
+
/** Internal marker for Titan runtime response detection */
|
|
2033
|
+
_isResponse: true;
|
|
2034
|
+
/** HTTP status code */
|
|
2035
|
+
status: number;
|
|
2036
|
+
/** HTTP headers */
|
|
2037
|
+
headers: Record<string, string>;
|
|
2038
|
+
/** Response body */
|
|
2039
|
+
body: string;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
// =========================================================================
|
|
2044
|
+
// Declaration Merging: Extend TitanRuntimeUtils
|
|
2045
|
+
// This makes t.response, t.core, etc. available automatically when
|
|
2046
|
+
// @titanpl/core is installed
|
|
2047
|
+
// =========================================================================
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Extension of the base Titan runtime utilities.
|
|
2051
|
+
*
|
|
2052
|
+
* When `@titanpl/core` is installed, these properties are automatically
|
|
2053
|
+
* available on the `t` global object.
|
|
2054
|
+
*/
|
|
2055
|
+
interface TitanRuntimeUtils {
|
|
2056
|
+
/**
|
|
2057
|
+
* HTTP Response Builder.
|
|
2058
|
+
*
|
|
2059
|
+
* Create controlled HTTP responses with proper status codes,
|
|
2060
|
+
* headers, and body formatting.
|
|
2061
|
+
*
|
|
2062
|
+
* @see {@link TitanCore.ResponseModule}
|
|
2063
|
+
*/
|
|
2064
|
+
response: TitanCore.ResponseModule;
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Core namespace providing unified access to all APIs.
|
|
2068
|
+
*
|
|
2069
|
+
* @example
|
|
2070
|
+
* ```js
|
|
2071
|
+
* const { fs, crypto, os } = t.core;
|
|
2072
|
+
* ```
|
|
2073
|
+
*
|
|
2074
|
+
* @see {@link TitanCore.Core}
|
|
2075
|
+
*/
|
|
2076
|
+
core: TitanCore.Core;
|
|
2077
|
+
|
|
2078
|
+
/**
|
|
2079
|
+
* File System API — Native file operations.
|
|
2080
|
+
* @see {@link TitanCore.FileSystem}
|
|
2081
|
+
*/
|
|
2082
|
+
fs: TitanCore.FileSystem;
|
|
2083
|
+
|
|
2084
|
+
/**
|
|
2085
|
+
* Path API — Cross-platform path manipulation.
|
|
2086
|
+
* @see {@link TitanCore.Path}
|
|
2087
|
+
*/
|
|
2088
|
+
path: TitanCore.Path;
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Cryptography API — Hashing, encryption, and random generation.
|
|
2092
|
+
* @see {@link TitanCore.Crypto}
|
|
2093
|
+
*/
|
|
2094
|
+
crypto: TitanCore.Crypto;
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* Operating System API — System information.
|
|
2098
|
+
* @see {@link TitanCore.OS}
|
|
2099
|
+
*/
|
|
2100
|
+
os: TitanCore.OS;
|
|
2101
|
+
|
|
2102
|
+
/**
|
|
2103
|
+
* Network API — DNS resolution and IP utilities.
|
|
2104
|
+
* @see {@link TitanCore.Net}
|
|
2105
|
+
*/
|
|
2106
|
+
net: TitanCore.Net;
|
|
2107
|
+
|
|
2108
|
+
/**
|
|
2109
|
+
* Process API — Runtime process information.
|
|
2110
|
+
* @see {@link TitanCore.Process}
|
|
2111
|
+
*/
|
|
2112
|
+
proc: TitanCore.Process;
|
|
2113
|
+
|
|
2114
|
+
/**
|
|
2115
|
+
* Time API — Timestamps, sleep, and timing utilities.
|
|
2116
|
+
* @see {@link TitanCore.Time}
|
|
2117
|
+
*/
|
|
2118
|
+
time: TitanCore.Time;
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* URL API — URL parsing and formatting.
|
|
2122
|
+
* @see {@link TitanCore.URLModule}
|
|
2123
|
+
*/
|
|
2124
|
+
url: TitanCore.URLModule;
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* Buffer API — Binary data encoding/decoding.
|
|
2128
|
+
* @see {@link TitanCore.BufferModule}
|
|
2129
|
+
*/
|
|
2130
|
+
buffer: TitanCore.BufferModule;
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* Local Storage API — High-performance key-value store.
|
|
2134
|
+
* @see {@link TitanCore.LocalStorage}
|
|
2135
|
+
*/
|
|
2136
|
+
ls: TitanCore.LocalStorage;
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* Alias for `t.ls` (Local Storage).
|
|
2140
|
+
* @see {@link TitanCore.LocalStorage}
|
|
2141
|
+
*/
|
|
2142
|
+
localStorage: TitanCore.LocalStorage;
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* Session API — Server-side session management.
|
|
2146
|
+
* @see {@link TitanCore.Session}
|
|
2147
|
+
*/
|
|
2148
|
+
session: TitanCore.Session;
|
|
2149
|
+
|
|
2150
|
+
/**
|
|
2151
|
+
* Cookie API — HTTP cookie utilities.
|
|
2152
|
+
* @see {@link TitanCore.Cookies}
|
|
2153
|
+
*/
|
|
2154
|
+
cookies: TitanCore.Cookies;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
// =========================================================================
|
|
2158
|
+
// Titan Runtime Namespace (Legacy/Alternative Access)
|
|
2159
|
+
// Provides Titan.Runtime interface for alternative access patterns
|
|
2160
|
+
// =========================================================================
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* Titan Runtime namespace for alternative access patterns.
|
|
2164
|
+
*
|
|
2165
|
+
* @example
|
|
2166
|
+
* ```js
|
|
2167
|
+
* // Alternative access via Titan namespace
|
|
2168
|
+
* const core: Titan.Runtime["@titanpl/core"] = t.core;
|
|
2169
|
+
* ```
|
|
2170
|
+
*/
|
|
2171
|
+
namespace Titan {
|
|
2172
|
+
/**
|
|
2173
|
+
* Runtime interface defining all available APIs.
|
|
2174
|
+
*/
|
|
2175
|
+
interface Runtime {
|
|
2176
|
+
/**
|
|
2177
|
+
* # @titanpl/core
|
|
2178
|
+
* The official Core Standard Library for Titan Planet.
|
|
2179
|
+
*
|
|
2180
|
+
* @example
|
|
2181
|
+
* ```js
|
|
2182
|
+
* const { fs, crypto, os } = t.core;
|
|
2183
|
+
* ```
|
|
2184
|
+
*/
|
|
2185
|
+
"@titanpl/core": TitanCore.Core;
|
|
2186
|
+
|
|
2187
|
+
/** Alias for @titanpl/core */
|
|
2188
|
+
"titan-core": TitanCore.Core;
|
|
2189
|
+
|
|
2190
|
+
/** File System - Native file operations backed by Rust. */
|
|
2191
|
+
fs: TitanCore.FileSystem;
|
|
2192
|
+
|
|
2193
|
+
/** Path manipulation utilities. */
|
|
2194
|
+
path: TitanCore.Path;
|
|
2195
|
+
|
|
2196
|
+
/** Cryptographic utilities using native Rust implementations. */
|
|
2197
|
+
crypto: TitanCore.Crypto;
|
|
2198
|
+
|
|
2199
|
+
/** Operating System - Deep system introspection. */
|
|
2200
|
+
os: TitanCore.OS;
|
|
2201
|
+
|
|
2202
|
+
/** Network - Low-level networking and DNS utilities. */
|
|
2203
|
+
net: TitanCore.Net;
|
|
2204
|
+
|
|
2205
|
+
/** Process - Runtime execution control and monitoring. */
|
|
2206
|
+
proc: TitanCore.Process;
|
|
2207
|
+
|
|
2208
|
+
/** Time - High-resolution timing and scheduling. */
|
|
2209
|
+
time: TitanCore.Time;
|
|
2210
|
+
|
|
2211
|
+
/** URL - Robust URL parsing and construction. */
|
|
2212
|
+
url: TitanCore.URLModule;
|
|
2213
|
+
|
|
2214
|
+
/** Buffer - High-performance binary data handling. */
|
|
2215
|
+
buffer: TitanCore.BufferModule;
|
|
2216
|
+
|
|
2217
|
+
/** Local Storage - High-performance in-memory key-value store. */
|
|
2218
|
+
ls: TitanCore.LocalStorage;
|
|
2219
|
+
|
|
2220
|
+
/** Alias for `t.ls` - Local Storage */
|
|
2221
|
+
localStorage: TitanCore.LocalStorage;
|
|
2222
|
+
|
|
2223
|
+
/** Session - High-performance session management. */
|
|
2224
|
+
session: TitanCore.Session;
|
|
2225
|
+
|
|
2226
|
+
/** Cookie - Standard-compliant HTTP cookie management. */
|
|
2227
|
+
cookies: TitanCore.Cookies;
|
|
2228
|
+
|
|
2229
|
+
/** Response - HTTP Response Builder. */
|
|
2230
|
+
response: TitanCore.ResponseModule;
|
|
2231
|
+
|
|
2232
|
+
/** Core namespace - Unified access to all APIs. */
|
|
2233
|
+
core: TitanCore.Core;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
export {};
|