xypriss 9.3.71 → 9.4.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.
Files changed (74) hide show
  1. package/dist/cjs/src/file-upload.js +43 -45
  2. package/dist/cjs/src/file-upload.js.map +1 -1
  3. package/dist/cjs/src/index.js +2 -0
  4. package/dist/cjs/src/index.js.map +1 -1
  5. package/dist/cjs/src/middleware/XyPrissMiddlewareAPI.js +0 -51
  6. package/dist/cjs/src/middleware/XyPrissMiddlewareAPI.js.map +1 -1
  7. package/dist/cjs/src/middleware/built-in/BuiltInMiddleware.js +1 -45
  8. package/dist/cjs/src/middleware/built-in/BuiltInMiddleware.js.map +1 -1
  9. package/dist/cjs/src/middleware/built-in/security/RequestSignatureProtector.js +1 -1
  10. package/dist/cjs/src/middleware/built-in/security/RequestSignatureProtector.js.map +1 -1
  11. package/dist/cjs/src/middleware/security-middleware.js +0 -52
  12. package/dist/cjs/src/middleware/security-middleware.js.map +1 -1
  13. package/dist/cjs/src/plugins/PluginManager.js +1 -1
  14. package/dist/cjs/src/quick-start.js +1 -1
  15. package/dist/cjs/src/server/FastServer.js +5 -5
  16. package/dist/cjs/src/server/components/fastapi/FileUploadManager.js +113 -85
  17. package/dist/cjs/src/server/components/fastapi/FileUploadManager.js.map +1 -1
  18. package/dist/cjs/src/server/const/XHSC_SIGNATURE.js +7 -0
  19. package/dist/cjs/src/server/const/XHSC_SIGNATURE.js.map +1 -0
  20. package/dist/cjs/src/server/core/XHSCBridge.js +66 -6
  21. package/dist/cjs/src/server/core/XHSCBridge.js.map +1 -1
  22. package/dist/cjs/src/server/core/XHSCProtocol.js +44 -7
  23. package/dist/cjs/src/server/core/XHSCProtocol.js.map +1 -1
  24. package/dist/cjs/src/server/core/XyprissApp.js +2 -2
  25. package/dist/cjs/src/sys/FSApi.js +232 -36
  26. package/dist/cjs/src/sys/FSApi.js.map +1 -1
  27. package/dist/cjs/src/sys/PathApi.js +63 -0
  28. package/dist/cjs/src/sys/PathApi.js.map +1 -1
  29. package/dist/cjs/src/sys/SysApi.js +26 -43
  30. package/dist/cjs/src/sys/SysApi.js.map +1 -1
  31. package/dist/cjs/src/sys/XyPrissRunner.js +40 -65
  32. package/dist/cjs/src/sys/XyPrissRunner.js.map +1 -1
  33. package/dist/cjs/src/sys.js +0 -15
  34. package/dist/cjs/src/sys.js.map +1 -1
  35. package/dist/cjs/src/utils/getIp.js +164 -0
  36. package/dist/cjs/src/utils/getIp.js.map +1 -0
  37. package/dist/esm/src/file-upload.js +43 -45
  38. package/dist/esm/src/file-upload.js.map +1 -1
  39. package/dist/esm/src/index.js +1 -0
  40. package/dist/esm/src/index.js.map +1 -1
  41. package/dist/esm/src/middleware/XyPrissMiddlewareAPI.js +0 -51
  42. package/dist/esm/src/middleware/XyPrissMiddlewareAPI.js.map +1 -1
  43. package/dist/esm/src/middleware/built-in/BuiltInMiddleware.js +1 -45
  44. package/dist/esm/src/middleware/built-in/BuiltInMiddleware.js.map +1 -1
  45. package/dist/esm/src/middleware/built-in/security/RequestSignatureProtector.js +1 -1
  46. package/dist/esm/src/middleware/built-in/security/RequestSignatureProtector.js.map +1 -1
  47. package/dist/esm/src/middleware/security-middleware.js +0 -52
  48. package/dist/esm/src/middleware/security-middleware.js.map +1 -1
  49. package/dist/esm/src/plugins/PluginManager.js +1 -1
  50. package/dist/esm/src/quick-start.js +1 -1
  51. package/dist/esm/src/server/FastServer.js +5 -5
  52. package/dist/esm/src/server/components/fastapi/FileUploadManager.js +113 -85
  53. package/dist/esm/src/server/components/fastapi/FileUploadManager.js.map +1 -1
  54. package/dist/esm/src/server/const/XHSC_SIGNATURE.js +5 -0
  55. package/dist/esm/src/server/const/XHSC_SIGNATURE.js.map +1 -0
  56. package/dist/esm/src/server/core/XHSCBridge.js +66 -6
  57. package/dist/esm/src/server/core/XHSCBridge.js.map +1 -1
  58. package/dist/esm/src/server/core/XHSCProtocol.js +44 -7
  59. package/dist/esm/src/server/core/XHSCProtocol.js.map +1 -1
  60. package/dist/esm/src/server/core/XyprissApp.js +2 -2
  61. package/dist/esm/src/sys/FSApi.js +232 -36
  62. package/dist/esm/src/sys/FSApi.js.map +1 -1
  63. package/dist/esm/src/sys/PathApi.js +63 -0
  64. package/dist/esm/src/sys/PathApi.js.map +1 -1
  65. package/dist/esm/src/sys/SysApi.js +26 -43
  66. package/dist/esm/src/sys/SysApi.js.map +1 -1
  67. package/dist/esm/src/sys/XyPrissRunner.js +40 -65
  68. package/dist/esm/src/sys/XyPrissRunner.js.map +1 -1
  69. package/dist/esm/src/sys.js +0 -15
  70. package/dist/esm/src/sys.js.map +1 -1
  71. package/dist/esm/src/utils/getIp.js +162 -0
  72. package/dist/esm/src/utils/getIp.js.map +1 -0
  73. package/dist/index.d.ts +345 -104
  74. package/package.json +34 -39
package/dist/index.d.ts CHANGED
@@ -136,8 +136,6 @@ interface FileUploadConfig {
136
136
  allowedExtensions?: string[];
137
137
  /** Upload destination directory */
138
138
  destination?: string;
139
- /** Custom filename function */
140
- filename?: (req: any, file: any, callback: (error: Error | null, filename: string) => void) => void;
141
139
  /** Detailed limits configuration */
142
140
  limits?: {
143
141
  /** Max field name size in bytes */
@@ -155,10 +153,8 @@ interface FileUploadConfig {
155
153
  };
156
154
  /** Preserve full paths instead of just filenames */
157
155
  preservePath?: boolean;
158
- /** Custom file filter function */
159
- fileFilter?: (req: any, file: any, callback: (error: Error | null, acceptFile: boolean) => void) => void;
160
156
  /** Storage type */
161
- storage?: 'disk' | 'memory' | 'custom';
157
+ storage?: "disk" | "memory" | "custom";
162
158
  /** Create parent directories if they don't exist */
163
159
  createParentPath?: boolean;
164
160
  /** Abort request on limit reached */
@@ -173,29 +169,13 @@ interface FileUploadConfig {
173
169
  parseNested?: boolean;
174
170
  /** Enable debug logging */
175
171
  debug?: boolean;
176
- /** Custom multer options */
177
- multerOptions?: {
178
- dest?: string;
179
- storage?: any;
180
- limits?: {
181
- fieldNameSize?: number;
182
- fieldSize?: number;
183
- fields?: number;
184
- fileSize?: number;
185
- files?: number;
186
- headerPairs?: number;
187
- };
188
- preservePath?: boolean;
189
- fileFilter?: (req: any, file: any, callback: (error: Error | null, acceptFile: boolean) => void) => void;
190
- [key: string]: any;
191
- };
192
172
  }
193
173
 
194
174
  /**
195
- * @fileoverview Core type definitions for XyPrissJS Express integration
175
+ * @fileoverview Core type definitions for XyPriss integration
196
176
  *
197
177
  * This module contains fundamental types and utilities used throughout
198
- * the Express integration system.
178
+ * the XyPriss integration system.
199
179
  *
200
180
  * @version 4.5.11
201
181
  * @author XyPrissJS Team
@@ -370,9 +350,9 @@ interface ResponseManipulationConfig {
370
350
  maxDepth?: number;
371
351
  }
372
352
  /**
373
- * Enhanced Express request interface with additional utilities.
353
+ * Enhanced XyPriss request interface with additional utilities.
374
354
  *
375
- * Extends the standard Express Request with caching, security,
355
+ * Extends the standard XyPriss Request with caching, security,
376
356
  * performance, and validation utilities.
377
357
  *
378
358
  * @interface EnhancedRequest
@@ -447,9 +427,9 @@ interface EnhancedRequest extends XyPrisRequest {
447
427
  session?: SessionData;
448
428
  }
449
429
  /**
450
- * Enhanced Express response interface with additional utilities.
430
+ * Enhanced XyPriss response interface with additional utilities.
451
431
  *
452
- * Extends the standard Express Response with caching, security,
432
+ * Extends the standard XyPriss Response with caching, security,
453
433
  * performance, and convenience methods.
454
434
  *
455
435
  * @interface EnhancedResponse
@@ -537,7 +517,7 @@ type RouteHandler$1 = (req: EnhancedRequest, res: EnhancedResponse, next: NextFu
537
517
  type MiddlewareFunction$1 = (req: EnhancedRequest, res: EnhancedResponse, next: NextFunction) => Promise<void> | void;
538
518
 
539
519
  /**
540
- * @fileoverview Cache-related type definitions for XyPrissJS Express integration
520
+ * @fileoverview Cache-related type definitions for XyPriss integration
541
521
  *
542
522
  * This module contains all cache-related types including configuration,
543
523
  * strategies, metrics, and backend implementations.
@@ -1036,7 +1016,7 @@ interface TerminalOnlyConfig {
1036
1016
  }
1037
1017
 
1038
1018
  /**
1039
- * @fileoverview Security-related type definitions for XyPrissJS Express integration
1019
+ * @fileoverview Security-related type definitions for XyPriss integration
1040
1020
  *
1041
1021
  * This module contains all security-related types including authentication,
1042
1022
  * authorization, encryption, and security policies.
@@ -2485,7 +2465,7 @@ interface RouteSecurityConfig {
2485
2465
  }
2486
2466
 
2487
2467
  /**
2488
- * @fileoverview Performance-related type definitions for XyPrissJS Express integration
2468
+ * @fileoverview Performance-related type definitions for XyPriss integration
2489
2469
  *
2490
2470
  * This module contains all performance-related types including monitoring,
2491
2471
  * optimization, metrics, and configuration.
@@ -2575,7 +2555,7 @@ interface AlertConfig {
2575
2555
  }
2576
2556
 
2577
2557
  /**
2578
- * @fileoverview Routing-related type definitions for XyPrissJS Express integration
2558
+ * @fileoverview Routing-related type definitions for XyPriss integration
2579
2559
  *
2580
2560
  * This module contains all routing-related types including route configuration,
2581
2561
  * caching, security, validation, and optimization.
@@ -3010,6 +2990,75 @@ declare class PathApi extends BaseApi {
3010
2990
  * console.log(clean); // -> "/users/john/images"
3011
2991
  */
3012
2992
  $normalize: (p: string) => string;
2993
+ /**
2994
+ * **Check Child Path Relationship**
2995
+ *
2996
+ * Determines if a given `child` path is strictly contained within a `parent` directory.
2997
+ * This is a critical security utility for verifying that file operations remain
2998
+ * within authorized boundaries.
2999
+ *
3000
+ * @param {string} parent - The expected parent directory.
3001
+ * @param {string} child - The path to check.
3002
+ * @returns {boolean} True if child is inside parent.
3003
+ */
3004
+ $isChild: (parent: string, child: string) => boolean;
3005
+ /**
3006
+ * **Secure Path Join**
3007
+ *
3008
+ * Joins path segments and ensures the result is strictly within the `base` path.
3009
+ * If the resulting path attempts to escape via traversal (e.g., `../`), it
3010
+ * throws a security error or returns a safe path.
3011
+ *
3012
+ * @param {string} base - The root/base directory.
3013
+ * @param {...string[]} segments - The segments to join.
3014
+ * @returns {string} The joined, safe path.
3015
+ */
3016
+ $secureJoin: (base: string, ...segments: string[]) => string;
3017
+ /**
3018
+ * **Get Comprehensive Path Metadata**
3019
+ *
3020
+ * Returns a structured object containing directory, base name, extension,
3021
+ * filename without extension, and absolute status - all in a single high-speed call.
3022
+ *
3023
+ * @param {string} p - The path to evaluate.
3024
+ * @returns {object} Metadata object: { dir, base, ext, name, isAbsolute }
3025
+ */
3026
+ $metadata: (p: string) => {
3027
+ dir: string;
3028
+ base: string;
3029
+ ext: string;
3030
+ name: string;
3031
+ isAbsolute: boolean;
3032
+ };
3033
+ /**
3034
+ * **Convert to Namespaced Path**
3035
+ *
3036
+ * Converts the path to a platform-specific namespaced path (e.g., UNC on Windows).
3037
+ * This is essential for handling extremely long paths or network shares natively.
3038
+ *
3039
+ * @param {string} p - The path to convert.
3040
+ * @returns {string} The namespaced path.
3041
+ */
3042
+ $toNamespacedPath: (p: string) => string;
3043
+ /**
3044
+ * **Normalize Separators**
3045
+ *
3046
+ * Standardizes all path separators (`/` or `\`) to the current operating system's
3047
+ * primary separator format.
3048
+ *
3049
+ * @param {string} p - The path to handle.
3050
+ * @returns {string} The path with uniform separators.
3051
+ */
3052
+ $normalizeSeparators: (p: string) => string;
3053
+ /**
3054
+ * **Identify Common Base Directory**
3055
+ *
3056
+ * Analyzes multiple paths and returns the deepest common directory shared by all.
3057
+ *
3058
+ * @param {...string[]} paths - Multiple paths to analyze.
3059
+ * @returns {string} The shared parent directory.
3060
+ */
3061
+ $commonBase: (...paths: string[]) => string;
3013
3062
  }
3014
3063
 
3015
3064
  /**
@@ -3317,31 +3366,27 @@ declare class FSApi extends PathApi {
3317
3366
  bytes?: boolean;
3318
3367
  }) => string;
3319
3368
  /**
3320
- * **Write File Content ($write)**
3369
+ * **Write File ($writeFile)**
3321
3370
  *
3322
- * Writes data to a file. This method replaces the file if it already exists, unless
3323
- * the `append` option is true. It ensures atomic writes where possible to prevent
3324
- * partial file corruption.
3371
+ * Writes flexible data to a file. This method replaces the file if it already exists, unless
3372
+ * the `append` option is true. Supports Buffers, plain objects (auto-JSON), arrays, and primitives.
3373
+ * It ensures atomic writes where possible to prevent partial file corruption.
3325
3374
  *
3326
3375
  * @param {string} p - The destination file path.
3327
- * @param {string} data - The string data to write.
3376
+ * @param {any} data - The data to write.
3328
3377
  * @param {Object} [options] - Write options.
3329
3378
  * @param {boolean} [options.append=false] - If true, adds data to the end of the file instead of overwriting.
3330
3379
  * @returns {void}
3331
3380
  *
3332
3381
  * @example
3333
- * // writing a new file
3334
- * __sys__.$write("notes.txt", "Important meeting at 10 AM");
3335
- *
3336
- * @example
3337
- * // Appending to a log file
3338
- * __sys__.$write("server.log", "[INFO] Startup ok\n", { append: true });
3382
+ * // writing a new file with text
3383
+ * __sys__.$writeFile("notes.txt", "Important meeting at 10 AM");
3339
3384
  *
3340
3385
  * @example
3341
- * // Writing to a nested path that may not exist yet
3342
- * __sys__.$write("data/cache/state.json", JSON.stringify(state));
3386
+ * // Writing a JSON object directly
3387
+ * __sys__.$writeFile("data.json", { user: "admin", active: true });
3343
3388
  */
3344
- $write: (p: string, data: string, options?: {
3389
+ $writeFile: (p: string, data: any, options?: {
3345
3390
  append?: boolean;
3346
3391
  ensureFile?: boolean;
3347
3392
  }) => void;
@@ -3673,19 +3718,6 @@ declare class FSApi extends PathApi {
3673
3718
  * const userConfig = __sys__.$readJsonSafe("user-config.json", { theme: "dark" });
3674
3719
  */
3675
3720
  $readJsonSafe: <T = any>(p: string, defaultValue: T) => T;
3676
- /**
3677
- * **Write String to File ($writeFile)**
3678
- *
3679
- * A clearly named alias for writing string content to a file.
3680
- *
3681
- * @param {string} p - File path.
3682
- * @param {string} data - Content to write.
3683
- *
3684
- * @example
3685
- * // Writing a simple text file
3686
- * __sys__.$writeFile("hello.txt", "Hello World");
3687
- */
3688
- $writeFile: (p: string, data: string) => void;
3689
3721
  /**
3690
3722
  * **Write Object to JSON File ($writeJson)**
3691
3723
  *
@@ -3790,28 +3822,28 @@ declare class FSApi extends PathApi {
3790
3822
  * Appends data to the end of a file.
3791
3823
  *
3792
3824
  * @param {string} p - File path.
3793
- * @param {string} data - Content to append.
3825
+ * @param {any} data - Content to append.
3794
3826
  */
3795
- $append: (p: string, data: string) => void;
3827
+ $append: (p: string, data: any) => void;
3796
3828
  /**
3797
3829
  * **Append Line ($appendLine)**
3798
3830
  *
3799
3831
  * Appends a string followed by a platform-specific newline to a file.
3800
3832
  *
3801
3833
  * @param {string} p - File path.
3802
- * @param {string} line - Line content.
3834
+ * @param {any} line - Line content.
3803
3835
  */
3804
- $appendLine: (p: string, line: string) => void;
3836
+ $appendLine: (p: string, line: any) => void;
3805
3837
  /**
3806
3838
  * **Write If Not Exists ($writeIfNotExists)**
3807
3839
  *
3808
3840
  * Writes to a file only if it does not already exist.
3809
3841
  *
3810
3842
  * @param {string} p - File path.
3811
- * @param {string} data - Content to write.
3843
+ * @param {any} data - Content to write.
3812
3844
  * @returns {boolean} `true` if written, `false` if file already existed.
3813
3845
  */
3814
- $writeIfNotExists: (p: string, data: string) => boolean;
3846
+ $writeIfNotExists: (p: string, data: any) => boolean;
3815
3847
  /**
3816
3848
  * **Ensure Directory ($ensureDir)**
3817
3849
  *
@@ -4158,6 +4190,151 @@ declare class FSApi extends PathApi {
4158
4190
  * @returns {void}
4159
4191
  */
4160
4192
  $wcp(...args: Parameters<typeof this.$watchContentParallel>): void;
4193
+ /**
4194
+ * **Atomic Write ($atomicWrite)**
4195
+ *
4196
+ * Writes data to a temporary file first, and then atomically renames it over the target file.
4197
+ * This guarantees that the target file is never in a partially written or corrupted state,
4198
+ * even if the process crashes or power is lost during the write.
4199
+ *
4200
+ * @param {string} p - The destination file path.
4201
+ * @param {any} data - The data to write.
4202
+ * @param {Object} [options] - Options (e.g., ensureFile).
4203
+ */
4204
+ $atomicWrite: (p: string, data: any, options?: {
4205
+ ensureFile?: boolean;
4206
+ }) => void;
4207
+ /**
4208
+ * **Secure Shred ($shred)**
4209
+ *
4210
+ * Securely deletes a file from disk by overwriting its contents with random cryptographic
4211
+ * noise multiple times before unlinking it, preventing data recovery tools from restoring the file.
4212
+ *
4213
+ * @param {string} p - The file path to shred.
4214
+ * @param {number} [passes=3] - The number of overwrite passes (default: 3).
4215
+ */
4216
+ $shred: (p: string, passes?: number) => void;
4217
+ /**
4218
+ * **Tail File ($tail)**
4219
+ *
4220
+ * Efficiently reads the last `lines` of a file without loading the entire file into memory.
4221
+ * Ideal for grabbing the end of massive log files.
4222
+ *
4223
+ * @param {string} p - The file path.
4224
+ * @param {number} [lines=10] - Number of lines to return from the end of the file.
4225
+ * @returns {string[]} An array of strings representing the last lines.
4226
+ */
4227
+ $tail: (p: string, lines?: number) => string[];
4228
+ /**
4229
+ * **Inline Patch ($patch)**
4230
+ *
4231
+ * Finds and replaces a string or regex directly inside a file. If the file is extremely large,
4232
+ * this implementation buffers it safely rather than causing memory overflows.
4233
+ *
4234
+ * @param {string} p - The file path.
4235
+ * @param {string|RegExp} searchValue - The value to find.
4236
+ * @param {string} replaceValue - The value to replace it with.
4237
+ * @returns {boolean} True if changes were made.
4238
+ */
4239
+ $patch: (p: string, searchValue: string | RegExp, replaceValue: string) => boolean;
4240
+ /**
4241
+ * **Split File ($split)**
4242
+ *
4243
+ * Fractures a large file into smaller sequential pieces based on exact byte chunks.
4244
+ * Useful for breaking up large SQL dumps, logs, or backups for transport.
4245
+ *
4246
+ * @param {string} p - The file to split.
4247
+ * @param {number} bytesPerChunk - Maximum bytes per split chunk.
4248
+ * @param {string} [outDir] - Directory to put the chunks. Defaults to the source file's directory.
4249
+ * @returns {string[]} Array of created chunk file paths.
4250
+ */
4251
+ $split: (p: string, bytesPerChunk: number, outDir?: string) => string[];
4252
+ /**
4253
+ * **Merge Files ($merge)**
4254
+ *
4255
+ * Safely binary-concatenates an array of source files into a single destination file.
4256
+ * Useful for reconnecting files split by `$split`.
4257
+ *
4258
+ * @param {string[]} sourceFiles - Array of file paths to merge in order.
4259
+ * @param {string} destFile - The destination file to create.
4260
+ */
4261
+ $merge: (sourceFiles: string[], destFile: string) => void;
4262
+ /**
4263
+ * **Lock File ($lock) & ($unlock)**
4264
+ *
4265
+ * Provides a rudimentary file lock mechanism by creating an exclusive `.lock` file
4266
+ * alongside the target. Ensures atomic process cross-synchronization for shared file resources.
4267
+ *
4268
+ * @param {string} p - File path to lock.
4269
+ * @returns {boolean} True if the lock was successfully acquired.
4270
+ */
4271
+ $lock: (p: string) => boolean;
4272
+ /**
4273
+ * **Unlock File ($unlock)**
4274
+ *
4275
+ * Releases a previously acquired lock for a file.
4276
+ *
4277
+ * @param {string} p - File path that was locked.
4278
+ */
4279
+ $unlock: (p: string) => void;
4280
+ /**
4281
+ * **Write Secure ($writeSecure)**
4282
+ *
4283
+ * Atomically writes a file with specific Unix permissions. This prevents the
4284
+ * fraction-of-a-second race condition vulnerability of creating a file and then
4285
+ * changing its permissions with $chmod.
4286
+ *
4287
+ * @param {string} p - The destination file path.
4288
+ * @param {any} data - The data to write.
4289
+ * @param {string} mode - Octal permission string (e.g. "0600").
4290
+ */
4291
+ $writeSecure: (p: string, data: any, mode: string) => void;
4292
+ /**
4293
+ * **Encrypt File ($encrypt)**
4294
+ *
4295
+ * Encrypts a file in-place using AES-256-GCM.
4296
+ *
4297
+ * @param {string} p - The file path to encrypt.
4298
+ * @param {string} key - A string key (hashed internally to 256-bit).
4299
+ */
4300
+ $encrypt: (p: string, key: string) => void;
4301
+ /**
4302
+ * **Decrypt File ($decrypt)**
4303
+ *
4304
+ * Decrypts a previously encrypted file in-place using AES-256-GCM.
4305
+ *
4306
+ * @param {string} p - The file path to decrypt.
4307
+ * @param {string} key - The exact string key used for encryption.
4308
+ */
4309
+ $decrypt: (p: string, key: string) => void;
4310
+ /**
4311
+ * **Diff Files ($diffFiles)**
4312
+ *
4313
+ * Quickly compares two files line-by-line using the Go engine and returns the exact mismatches.
4314
+ *
4315
+ * @param {string} fileA - First file path.
4316
+ * @param {string} fileB - Second file path.
4317
+ * @returns {Array<{line: number, file_a: string, file_b: string}>} Array of differing lines.
4318
+ */
4319
+ $diffFiles: (fileA: string, fileB: string) => Array<{
4320
+ line: number;
4321
+ file_a: string;
4322
+ file_b: string;
4323
+ }>;
4324
+ /**
4325
+ * **Top Big Files ($topBigFiles)**
4326
+ *
4327
+ * Scans a directory structure in Go and returns the N largest files, sorted by size.
4328
+ * Perfect for disk space analysis dashboards.
4329
+ *
4330
+ * @param {string} dir - Directory to scan.
4331
+ * @param {number} [limit=50] - Number of top files to return.
4332
+ * @returns {Array<{path: string, size: number}>} Array of file paths and sizes.
4333
+ */
4334
+ $topBigFiles: (dir: string, limit?: number) => Array<{
4335
+ path: string;
4336
+ size: number;
4337
+ }>;
4161
4338
  }
4162
4339
 
4163
4340
  /**
@@ -4215,7 +4392,8 @@ declare class SysApi extends FSApi {
4215
4392
  * const cores = __sys__.$cpu(true) as CpuInfo[];
4216
4393
  * console.log(`Core 0 Speed: ${cores[0].frequency} MHz`);
4217
4394
  */
4218
- $cpu: (cores?: boolean) => CpuUsage | CpuInfo[];
4395
+ $cpu(cores: true): CpuInfo[];
4396
+ $cpu(cores?: false): CpuUsage;
4219
4397
  /**
4220
4398
  * **Get Memory Usage**
4221
4399
  *
@@ -4276,7 +4454,8 @@ declare class SysApi extends FSApi {
4276
4454
  * }
4277
4455
  * });
4278
4456
  */
4279
- $disks: (mount?: string) => DiskInfo[];
4457
+ $disks(mount: string): DiskInfo | undefined;
4458
+ $disks(): DiskInfo[];
4280
4459
  /**
4281
4460
  * **Get Network Interfaces**
4282
4461
  *
@@ -4800,9 +4979,9 @@ declare class XyPrissConst {
4800
4979
  declare const __const__: XyPrissConst;
4801
4980
 
4802
4981
  /**
4803
- * @fileoverview Main export file for XyPrissJS Express integration types
4982
+ * @fileoverview Main export file for XyPriss integration types
4804
4983
  *
4805
- * This file provides a centralized export point for all Express integration
4984
+ * This file provides a centralized export point for all XyPriss integration
4806
4985
  * types, organized into modular categories for better maintainability.
4807
4986
  *
4808
4987
  * @version 4.5.11
@@ -5197,6 +5376,8 @@ interface XyPrisRequest extends IncomingMessage {
5197
5376
  params: Record<string, string>;
5198
5377
  query: Record<string, any>;
5199
5378
  body: any;
5379
+ files?: any[];
5380
+ file?: any;
5200
5381
  path: string;
5201
5382
  originalUrl: string;
5202
5383
  baseUrl: string;
@@ -7139,6 +7320,20 @@ interface ServerOptions$1 {
7139
7320
  idleTimeout?: number;
7140
7321
  };
7141
7322
  };
7323
+ /**
7324
+ * Firewall management plugin configuration.
7325
+ *
7326
+ * Provides automated port management and IP-based access control
7327
+ * via native system firewall managers (ufw, iptables).
7328
+ */
7329
+ firewall?: {
7330
+ /** Enable firewall management plugin */
7331
+ enabled?: boolean;
7332
+ /** Automatically open required ports (80, 443, and server port) */
7333
+ autoOpen?: boolean;
7334
+ /** List of explicitly allowed IPs or CIDR blocks */
7335
+ allowedIPs?: string[];
7336
+ };
7142
7337
  /**
7143
7338
  * Compression plugin configuration.
7144
7339
  *
@@ -7736,14 +7931,14 @@ interface UFApp {
7736
7931
  */
7737
7932
  middleware: () => XyPrissMiddlewareAPI;
7738
7933
  /**
7739
- * Multer instance for file uploads (available when fileUpload.enabled is true)
7934
+ * Internal upload manager instance for file uploads
7740
7935
  */
7741
7936
  upload?: any;
7742
7937
  /**
7743
7938
  * Create single file upload middleware
7744
7939
  *
7745
7940
  * @param fieldname - Name of the form field
7746
- * @returns Multer middleware for single file upload
7941
+ * @returns Middleware for single file upload
7747
7942
  *
7748
7943
  * @example
7749
7944
  * ```typescript
@@ -7759,7 +7954,7 @@ interface UFApp {
7759
7954
  *
7760
7955
  * @param fieldname - Name of the form field
7761
7956
  * @param maxCount - Maximum number of files (optional)
7762
- * @returns Multer middleware for array file upload
7957
+ * @returns Middleware for array file upload
7763
7958
  *
7764
7959
  * @example
7765
7960
  * ```typescript
@@ -7774,7 +7969,7 @@ interface UFApp {
7774
7969
  * Create fields file upload middleware
7775
7970
  *
7776
7971
  * @param fields - Array of field configurations
7777
- * @returns Multer middleware for multiple fields upload
7972
+ * @returns Middleware for multiple fields upload
7778
7973
  *
7779
7974
  * @example
7780
7975
  * ```typescript
@@ -7791,7 +7986,7 @@ interface UFApp {
7791
7986
  /**
7792
7987
  * Create any file upload middleware
7793
7988
  *
7794
- * @returns Multer middleware that accepts any files
7989
+ * @returns Middleware that accepts any files
7795
7990
  *
7796
7991
  * @example
7797
7992
  * ```typescript
@@ -8168,63 +8363,56 @@ declare class FileUploadAPI {
8168
8363
  private manager;
8169
8364
  private logger;
8170
8365
  private initialized;
8171
- constructor();
8366
+ private configOverride?;
8367
+ constructor(config?: FileUploadConfig);
8172
8368
  /**
8173
- * Initialize the file upload API with configuration from Configs
8174
- *
8175
- * This method requires the Configs class to enforce a single source of truth.
8176
- * Configuration is accessed internally from Configs.get('fileUpload').
8177
- *
8178
- * @param configManager - The Configs class (not an instance, the class itself)
8179
- *
8180
- * @example
8181
- * ```typescript
8182
- * import { Configs } from 'xypriss';
8183
- *
8184
- * const upload = new FileUploadAPI();
8185
- * await upload.initialize(Configs);
8186
- * ```
8369
+ * Internal auto-initialization method.
8370
+ * Called lazily by middleware methods if not already initialized.
8371
+ */
8372
+ private autoInitialize;
8373
+ /**
8374
+ * Manually initialize the file upload API (legacy support)
8187
8375
  */
8188
- initialize(configManager: typeof ConfigurationManager): Promise<void>;
8376
+ initialize(configManager?: any): Promise<void>;
8189
8377
  /**
8190
8378
  * Check if the file upload API is enabled
8191
8379
  */
8192
8380
  isEnabled(): boolean;
8193
8381
  /**
8194
- * Handle multer errors and convert them to proper HTTP responses
8382
+ * Handle upload errors and convert them to proper HTTP responses
8195
8383
  */
8196
- private handleMulterError;
8384
+ private handleUploadError;
8197
8385
  /**
8198
8386
  * Create a middleware for uploading a single file
8199
8387
  *
8200
8388
  * @param fieldname - The name of the form field containing the file
8201
- * @returns Express middleware function
8389
+ * @returns Middleware function
8202
8390
  */
8203
- single(fieldname: string): (req: any, res: any, next: any) => any;
8391
+ single(fieldname: string): (req: any, res: any, next: any) => Promise<any>;
8204
8392
  /**
8205
8393
  * Create a middleware for uploading multiple files with the same field name
8206
8394
  *
8207
8395
  * @param fieldname - The name of the form field containing the files
8208
8396
  * @param maxCount - Maximum number of files to accept (optional)
8209
- * @returns Express middleware function
8397
+ * @returns Middleware function
8210
8398
  */
8211
- array(fieldname: string, maxCount?: number): (req: any, res: any, next: any) => any;
8399
+ array(fieldname: string, maxCount?: number): (req: any, res: any, next: any) => Promise<any>;
8212
8400
  /**
8213
8401
  * Create a middleware for uploading multiple files with different field names
8214
8402
  *
8215
8403
  * @param fields - Array of field configurations
8216
- * @returns Express middleware function
8404
+ * @returns Middleware function
8217
8405
  */
8218
8406
  fields(fields: Array<{
8219
8407
  name: string;
8220
8408
  maxCount?: number;
8221
- }>): (req: any, res: any, next: any) => any;
8409
+ }>): (req: any, res: any, next: any) => Promise<any>;
8222
8410
  /**
8223
8411
  * Create a middleware for uploading any files (accepts all files)
8224
8412
  *
8225
- * @returns Express middleware function
8413
+ * @returns Middleware function
8226
8414
  */
8227
- any(): (req: any, res: any, next: any) => any;
8415
+ any(): (req: any, res: any, next: any) => Promise<any>;
8228
8416
  }
8229
8417
 
8230
8418
  declare const Upload: FileUploadAPI;
@@ -8679,7 +8867,7 @@ declare const Plugin: {
8679
8867
  };
8680
8868
 
8681
8869
  /**
8682
- * XyPrissJS Express Quick Start
8870
+ * XyPrissJS Quick Start
8683
8871
  * Pre-configured server instances for rapid development (tests with limited configs)
8684
8872
  */
8685
8873
  /**
@@ -9058,6 +9246,59 @@ declare function mergeWithDefaults<T extends Record<string | symbol, any>>(defau
9058
9246
  /** @internal — tracks visited objects to break circular refs */
9059
9247
  _seen?: WeakSet<object>): T;
9060
9248
 
9249
+ /***************************************************************************
9250
+ * XyPrissJS - Fast And Secure
9251
+ *
9252
+ * @author Nehonix
9253
+ * @license Nehonix OSL (NOSL)
9254
+ *
9255
+ * Copyright (c) 2025 Nehonix. All rights reserved.
9256
+ *
9257
+ * This License governs the use, modification, and distribution of software
9258
+ * provided by NEHONIX under its open source projects.
9259
+ * NEHONIX is committed to fostering collaborative innovation while strictly
9260
+ * protecting its intellectual property rights.
9261
+ * Violation of any term of this License will result in immediate termination of all granted rights
9262
+ * and may subject the violator to legal action.
9263
+ *
9264
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
9265
+ * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
9266
+ * AND NON-INFRINGEMENT.
9267
+ * IN NO EVENT SHALL NEHONIX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
9268
+ * OR CONSEQUENTIAL DAMAGES ARISING FROM THE USE OR INABILITY TO USE THE SOFTWARE,
9269
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
9270
+ *
9271
+ ***************************************************************************** */
9272
+
9273
+ /** Result enriched with metadata for observability / debugging. */
9274
+ interface GetIpResult {
9275
+ /** Resolved IP address (IPv4 or IPv6, normalised). */
9276
+ ip: string;
9277
+ /** Header / source that provided the IP. */
9278
+ source: IpSource;
9279
+ }
9280
+ type IpSource = "cf-connecting-ip" | "true-client-ip" | "x-real-ip" | "x-forwarded-for" | "forwarded" | "x-client-ip" | "x-cluster-client-ip" | "req.ip" | "socket" | "fallback";
9281
+ /**
9282
+ * Robustly extracts the **real** client IP from a request.
9283
+ *
9284
+ * Resolution order (most-specific / trustworthy first):
9285
+ * 1. `CF-Connecting-IP` – Cloudflare; single, authoritative value
9286
+ * 2. `True-Client-IP` – Akamai / Cloudflare enterprise
9287
+ * 3. `X-Real-IP` – Nginx single-proxy setups
9288
+ * 4. `X-Client-IP` – Some load balancers / Apache mod_remoteip
9289
+ * 5. `X-Cluster-Client-IP` – Rackspace, some Nginx configs
9290
+ * 6. `Forwarded` – RFC 7239 standard header
9291
+ * 7. `X-Forwarded-For` – De-facto standard (picks first public IP)
9292
+ * 8. `req.ip` – XyPrisRequest parsed value
9293
+ * 9. `socket.remoteAddress` – Raw TCP socket
9294
+ * 10. `"127.0.0.1"` – Ultimate fallback (never throws)
9295
+ *
9296
+ * @param req - The request object (XyPrisRequest-compatible).
9297
+ * @param enriched - When `true`, returns `{ ip, source }` for observability.
9298
+ */
9299
+ declare function getIp(req: XyPrisRequest): string;
9300
+ declare function getIp(req: XyPrisRequest, enriched: true): GetIpResult;
9301
+
9061
9302
  /***************************************************************************
9062
9303
  * XyPrissJS - Fast And Secure
9063
9304
  *
@@ -9084,10 +9325,10 @@ _seen?: WeakSet<object>): T;
9084
9325
 
9085
9326
  declare global {
9086
9327
  /**
9087
- * @fileoverview Comprehensive server options interface for XyPrissJS Express integration
9328
+ * @fileoverview Comprehensive server options interface for XyPriss integration
9088
9329
  *
9089
9330
  * This interface provides complete configuration options for creating ultra-fast,
9090
- * secure Express servers with advanced features including caching, clustering,
9331
+ * secure servers with advanced features including caching, clustering,
9091
9332
  * performance optimization, and Go integration.
9092
9333
  *
9093
9334
  * @interface ServerOptions
@@ -9139,5 +9380,5 @@ declare global {
9139
9380
  */
9140
9381
  declare function Router(): XyPrissRouter;
9141
9382
 
9142
- export { ConfigurationManager as CM, ConfigurationManager as Configs, FileUploadAPI as FLA, FileUploadAPI, PerformanceMonitor, Plugin, PluginHookIds, Router, SecurityMiddleware, TrustProxy, Upload, XJsonResponseHandler, MultiServerApp as XyPMS, XyPrissRouter, XyPrissSys, __cfg__, __const__, __sys__, createCircularRefDebugger, createOptimalCache, createSafeJsonMiddleware, createServer, initializeFileUpload, mergeWithDefaults, mergeWithDefaults as mwdef, quickServer, safeJsonStringify, sendSafeJson, setupSafeJson, uploadAny, uploadArray, uploadFields, uploadSingle, xems };
9143
- export type { ArchiveOptions, BatchRenameChange, CacheConfig, FileUploadConfig as FiUpConfig, FileUploadConfig, MonitorSnapshot, MultiServerConfig, NetworkStats, NextFunction, PerformanceConfig, PluginCreator, ProcessInfo, ProcessMonitorSnapshot, XyPrisRequest as Request, RequestHandler, XyPrisResponse as Response, RouteConfig, RouteOptions, SecurityConfig, ServerOptions$1 as ServerOptions, TrustProxyValue$1 as TrustProxyValue, UltraFastApp, XemsTypes, XyPrisRequest, XyPrisResponse, XyPrissPlugin, XyPrisRequest as XyPrissRequest, XyPrisResponse as XyPrissResponse };
9383
+ export { ConfigurationManager as CM, ConfigurationManager as Configs, FileUploadAPI as FLA, FileUploadAPI, PerformanceMonitor, Plugin, PluginHookIds, Router, SecurityMiddleware, TrustProxy, Upload, XJsonResponseHandler, MultiServerApp as XyPMS, XyPrissRouter, XyPrissSys, __cfg__, __const__, __sys__, createCircularRefDebugger, createOptimalCache, createSafeJsonMiddleware, createServer, getIp, initializeFileUpload, mergeWithDefaults, mergeWithDefaults as mwdef, quickServer, safeJsonStringify, sendSafeJson, setupSafeJson, uploadAny, uploadArray, uploadFields, uploadSingle, xems };
9384
+ export type { ArchiveOptions, BatchRenameChange, CacheConfig, FileUploadConfig as FiUpConfig, FileUploadConfig, GetIpResult, IpSource, MonitorSnapshot, MultiServerConfig, NetworkStats, NextFunction, PerformanceConfig, PluginCreator, ProcessInfo, ProcessMonitorSnapshot, XyPrisRequest as Request, RequestHandler, XyPrisResponse as Response, RouteConfig, RouteOptions, SecurityConfig, ServerOptions$1 as ServerOptions, TrustProxyValue$1 as TrustProxyValue, UltraFastApp, XemsTypes, XyPrisRequest, XyPrisResponse, XyPrissPlugin, XyPrisRequest as XyPrissRequest, XyPrisResponse as XyPrissResponse };