opticore-webapp 1.0.67 → 1.0.68

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/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Server } from 'http';
2
2
  import { TDependency } from 'opticore-dependency-inject';
3
+ import { TFeatureRoutes } from 'opticore-router';
3
4
  import { express } from 'opticore-express';
4
5
  import { LoggerCore } from 'opticore-logger';
5
6
  import { CorsOptions } from 'cors';
6
- import { TFeatureRoutes } from 'opticore-router';
7
7
 
8
8
  interface WebServerConstructorInterface {
9
9
  app: express.Application;
@@ -13,17 +13,33 @@ interface WebServerConstructorInterface {
13
13
  corsOriginOptions?: Partial<CorsOptions>;
14
14
  }
15
15
 
16
- /**
17
- * WebServerCore - Architecture Serveur-Autorité
18
- *
19
- * Le serveur gère strictement ses états :
20
- * - READY : Prêt à recevoir des demandes de hot reload
21
- * - RELOADING : En cours de hot reload
22
- * - BLOCKED : Bloqué par une erreur, refuse les nouveaux reloads
23
- */
16
+ type TServerStatus = "READY" | "RELOADING" | "BLOCKED" | "ERROR" | "STARTING" | "STOPPING";
17
+
18
+ interface IServerStateInfo {
19
+ status: TServerStatus;
20
+ isRunning: boolean;
21
+ host: string;
22
+ port: number;
23
+ language: string;
24
+ watcherEnabled: boolean;
25
+ watcherActive?: boolean;
26
+ routesCount: number;
27
+ dependenciesCount: number;
28
+ startTime?: Date;
29
+ currentTime?: Date;
30
+ uptime?: number;
31
+ memoryUsage?: NodeJS.MemoryUsage;
32
+ uptimeFormatted?: string;
33
+ pid?: any;
34
+ platform?: any;
35
+ nodeVersion?: any;
36
+ cwd?: any;
37
+ }
38
+
24
39
  declare class WebServerCore {
25
40
  private serverUtility;
26
41
  private expressApp;
42
+ private fileWatcher;
27
43
  private readonly localLanguage;
28
44
  private readonly loggerConfig;
29
45
  private readonly routerExpressApp;
@@ -34,50 +50,171 @@ declare class WebServerCore {
34
50
  private currentDependencies;
35
51
  private server;
36
52
  private errorEmitter;
37
- private serverState;
38
- private lastError;
39
- private hotReloadAttempts;
40
- private hotReloadSuccesses;
41
- private hotReloadFailures;
53
+ private isWatcherEnabled;
54
+ private serverStatus;
55
+ private serverStartTime;
42
56
  constructor(paramsConstructor: WebServerConstructorInterface);
43
57
  onStartServer(routers: TFeatureRoutes[], databaseCallback?: (env: any) => void, dependenciesProvider?: TDependency[]): Server | undefined;
44
58
  /**
45
- * ✅✅✅ Configuration de la gestion d'erreurs
59
+ * Error handling configuration
46
60
  */
47
61
  private setupErrorHandling;
62
+ /**
63
+ * Setup server events
64
+ */
48
65
  private setupServerEvents;
49
- private notifyServerReady;
50
- private setupSignalHandlers;
51
- private setupIPCHandlers;
52
66
  /**
53
- * ✅✅✅ HOT RELOAD avec gestion d'état stricte
67
+ * Initialize file watcher
54
68
  */
55
- private performTrueHotReload;
69
+ private initializeFileWatcher;
56
70
  /**
57
- * Nettoie le cache des modules applicatifs
71
+ * Setup watcher events
58
72
  */
59
- private clearApplicationModulesCache;
60
- private reloadConfigurations;
61
- private reloadDependencies;
73
+ private setupWatcherEvents;
62
74
  /**
63
- * ✅✅✅ Notifier le watcher : SUCCÈS
75
+ * Handle file changes detected by watcher
64
76
  */
65
- private notifyWatcherReloadSuccess;
77
+ private handleFileChange;
66
78
  /**
67
- * ✅✅✅ Notifier le watcher : BLOQUÉ PAR ERREUR TRANSFORM
79
+ * Handle hot reload requested by watcher
68
80
  */
69
- private notifyWatcherBlockedByError;
81
+ private handleHotReload;
70
82
  /**
71
- * ✅✅✅ Notifier le watcher : ERREUR GÉNÉRIQUE
83
+ * Handle watcher errors
72
84
  */
73
- private notifyWatcherReloadError;
85
+ private handleWatcherError;
74
86
  /**
75
- * ✅✅✅ Parser les détails d'une TransformError
87
+ * Notify file change without action
88
+ */
89
+ private notifyFileChange;
90
+ /**
91
+ * Reload environment configuration
92
+ */
93
+ private reloadEnvironmentConfig;
94
+ /**
95
+ * Execute hot reload for environment files
96
+ */
97
+ private executeHotReloadEnvironment;
98
+ /**
99
+ * Reload configuration files
100
+ */
101
+ private reloadConfigurationFiles;
102
+ /**
103
+ * Execute hot reload for config files
104
+ */
105
+ private executeHotReloadConfig;
106
+ /**
107
+ * Reload application routes
108
+ */
109
+ private reloadApplicationRoutes;
110
+ /**
111
+ * Execute hot reload for routes
112
+ */
113
+ private executeHotReloadRoutes;
114
+ /**
115
+ * Execute hot reload for dependencies
116
+ */
117
+ private executeHotReloadDependencies;
118
+ /**
119
+ * Notify environment reload
120
+ */
121
+ private notifyEnvironmentReload;
122
+ /**
123
+ * Reload specific route
124
+ */
125
+ private reloadSpecificRoute;
126
+ /**
127
+ * Reload router for specific file
128
+ */
129
+ private reloadRouterForFile;
130
+ /**
131
+ * Reload configurations
132
+ */
133
+ private reloadConfigurations;
134
+ /**
135
+ * Reload dependencies
136
+ */
137
+ private reloadDependencies;
138
+ /**
139
+ * Register routes
76
140
  */
77
- private parseTransformError;
78
141
  private registerRoutes;
142
+ /**
143
+ * Parse transform error
144
+ */
145
+ private parseTransformError;
146
+ /**
147
+ * Display server info
148
+ */
79
149
  private infoWebApp;
150
+ /**
151
+ * Stop file watcher
152
+ */
153
+ private stopFileWatcher;
154
+ /**
155
+ * Shutdown server
156
+ */
80
157
  private shutdown;
158
+ /**
159
+ * Enable/disable watcher
160
+ */
161
+ setWatcherEnabled(enabled: boolean): void;
162
+ /**
163
+ * Get watcher status
164
+ */
165
+ getWatcherStatus(): {
166
+ enabled: boolean;
167
+ active: boolean;
168
+ };
169
+ /**
170
+ * Get server state information
171
+ */
172
+ getServerState(): IServerStateInfo;
173
+ /**
174
+ * Simple method to get just the status
175
+ */
176
+ getServerStatus(): TServerStatus;
177
+ /**
178
+ * Get server statistics for monitoring
179
+ */
180
+ getServerStats(): {
181
+ status: TServerStatus;
182
+ uptime: string;
183
+ memory: {
184
+ rss: string;
185
+ heapTotal: string;
186
+ heapUsed: string;
187
+ external: string;
188
+ };
189
+ performance: {
190
+ cpuUsage: NodeJS.CpuUsage;
191
+ resourceUsage?: NodeJS.ResourceUsage;
192
+ };
193
+ };
194
+ /**
195
+ * Format bytes to human readable string
196
+ */
197
+ private formatBytes;
198
+ /**
199
+ * Format uptime to human readable string
200
+ */
201
+ private formatUptime;
202
+ /**
203
+ * Add watch directories
204
+ */
205
+ addWatchDirectories(directories: string[]): void;
206
+ /**
207
+ * Clear file cache
208
+ */
209
+ clearFileCache(): void;
210
+ /**
211
+ * Force reload configurations
212
+ */
213
+ forceReloadConfig(): void;
214
+ /**
215
+ * Restart watcher
216
+ */
217
+ restartWatcher(): void;
81
218
  }
82
219
 
83
220
  declare const envPath: string;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Server } from 'http';
2
2
  import { TDependency } from 'opticore-dependency-inject';
3
+ import { TFeatureRoutes } from 'opticore-router';
3
4
  import { express } from 'opticore-express';
4
5
  import { LoggerCore } from 'opticore-logger';
5
6
  import { CorsOptions } from 'cors';
6
- import { TFeatureRoutes } from 'opticore-router';
7
7
 
8
8
  interface WebServerConstructorInterface {
9
9
  app: express.Application;
@@ -13,17 +13,33 @@ interface WebServerConstructorInterface {
13
13
  corsOriginOptions?: Partial<CorsOptions>;
14
14
  }
15
15
 
16
- /**
17
- * WebServerCore - Architecture Serveur-Autorité
18
- *
19
- * Le serveur gère strictement ses états :
20
- * - READY : Prêt à recevoir des demandes de hot reload
21
- * - RELOADING : En cours de hot reload
22
- * - BLOCKED : Bloqué par une erreur, refuse les nouveaux reloads
23
- */
16
+ type TServerStatus = "READY" | "RELOADING" | "BLOCKED" | "ERROR" | "STARTING" | "STOPPING";
17
+
18
+ interface IServerStateInfo {
19
+ status: TServerStatus;
20
+ isRunning: boolean;
21
+ host: string;
22
+ port: number;
23
+ language: string;
24
+ watcherEnabled: boolean;
25
+ watcherActive?: boolean;
26
+ routesCount: number;
27
+ dependenciesCount: number;
28
+ startTime?: Date;
29
+ currentTime?: Date;
30
+ uptime?: number;
31
+ memoryUsage?: NodeJS.MemoryUsage;
32
+ uptimeFormatted?: string;
33
+ pid?: any;
34
+ platform?: any;
35
+ nodeVersion?: any;
36
+ cwd?: any;
37
+ }
38
+
24
39
  declare class WebServerCore {
25
40
  private serverUtility;
26
41
  private expressApp;
42
+ private fileWatcher;
27
43
  private readonly localLanguage;
28
44
  private readonly loggerConfig;
29
45
  private readonly routerExpressApp;
@@ -34,50 +50,171 @@ declare class WebServerCore {
34
50
  private currentDependencies;
35
51
  private server;
36
52
  private errorEmitter;
37
- private serverState;
38
- private lastError;
39
- private hotReloadAttempts;
40
- private hotReloadSuccesses;
41
- private hotReloadFailures;
53
+ private isWatcherEnabled;
54
+ private serverStatus;
55
+ private serverStartTime;
42
56
  constructor(paramsConstructor: WebServerConstructorInterface);
43
57
  onStartServer(routers: TFeatureRoutes[], databaseCallback?: (env: any) => void, dependenciesProvider?: TDependency[]): Server | undefined;
44
58
  /**
45
- * ✅✅✅ Configuration de la gestion d'erreurs
59
+ * Error handling configuration
46
60
  */
47
61
  private setupErrorHandling;
62
+ /**
63
+ * Setup server events
64
+ */
48
65
  private setupServerEvents;
49
- private notifyServerReady;
50
- private setupSignalHandlers;
51
- private setupIPCHandlers;
52
66
  /**
53
- * ✅✅✅ HOT RELOAD avec gestion d'état stricte
67
+ * Initialize file watcher
54
68
  */
55
- private performTrueHotReload;
69
+ private initializeFileWatcher;
56
70
  /**
57
- * Nettoie le cache des modules applicatifs
71
+ * Setup watcher events
58
72
  */
59
- private clearApplicationModulesCache;
60
- private reloadConfigurations;
61
- private reloadDependencies;
73
+ private setupWatcherEvents;
62
74
  /**
63
- * ✅✅✅ Notifier le watcher : SUCCÈS
75
+ * Handle file changes detected by watcher
64
76
  */
65
- private notifyWatcherReloadSuccess;
77
+ private handleFileChange;
66
78
  /**
67
- * ✅✅✅ Notifier le watcher : BLOQUÉ PAR ERREUR TRANSFORM
79
+ * Handle hot reload requested by watcher
68
80
  */
69
- private notifyWatcherBlockedByError;
81
+ private handleHotReload;
70
82
  /**
71
- * ✅✅✅ Notifier le watcher : ERREUR GÉNÉRIQUE
83
+ * Handle watcher errors
72
84
  */
73
- private notifyWatcherReloadError;
85
+ private handleWatcherError;
74
86
  /**
75
- * ✅✅✅ Parser les détails d'une TransformError
87
+ * Notify file change without action
88
+ */
89
+ private notifyFileChange;
90
+ /**
91
+ * Reload environment configuration
92
+ */
93
+ private reloadEnvironmentConfig;
94
+ /**
95
+ * Execute hot reload for environment files
96
+ */
97
+ private executeHotReloadEnvironment;
98
+ /**
99
+ * Reload configuration files
100
+ */
101
+ private reloadConfigurationFiles;
102
+ /**
103
+ * Execute hot reload for config files
104
+ */
105
+ private executeHotReloadConfig;
106
+ /**
107
+ * Reload application routes
108
+ */
109
+ private reloadApplicationRoutes;
110
+ /**
111
+ * Execute hot reload for routes
112
+ */
113
+ private executeHotReloadRoutes;
114
+ /**
115
+ * Execute hot reload for dependencies
116
+ */
117
+ private executeHotReloadDependencies;
118
+ /**
119
+ * Notify environment reload
120
+ */
121
+ private notifyEnvironmentReload;
122
+ /**
123
+ * Reload specific route
124
+ */
125
+ private reloadSpecificRoute;
126
+ /**
127
+ * Reload router for specific file
128
+ */
129
+ private reloadRouterForFile;
130
+ /**
131
+ * Reload configurations
132
+ */
133
+ private reloadConfigurations;
134
+ /**
135
+ * Reload dependencies
136
+ */
137
+ private reloadDependencies;
138
+ /**
139
+ * Register routes
76
140
  */
77
- private parseTransformError;
78
141
  private registerRoutes;
142
+ /**
143
+ * Parse transform error
144
+ */
145
+ private parseTransformError;
146
+ /**
147
+ * Display server info
148
+ */
79
149
  private infoWebApp;
150
+ /**
151
+ * Stop file watcher
152
+ */
153
+ private stopFileWatcher;
154
+ /**
155
+ * Shutdown server
156
+ */
80
157
  private shutdown;
158
+ /**
159
+ * Enable/disable watcher
160
+ */
161
+ setWatcherEnabled(enabled: boolean): void;
162
+ /**
163
+ * Get watcher status
164
+ */
165
+ getWatcherStatus(): {
166
+ enabled: boolean;
167
+ active: boolean;
168
+ };
169
+ /**
170
+ * Get server state information
171
+ */
172
+ getServerState(): IServerStateInfo;
173
+ /**
174
+ * Simple method to get just the status
175
+ */
176
+ getServerStatus(): TServerStatus;
177
+ /**
178
+ * Get server statistics for monitoring
179
+ */
180
+ getServerStats(): {
181
+ status: TServerStatus;
182
+ uptime: string;
183
+ memory: {
184
+ rss: string;
185
+ heapTotal: string;
186
+ heapUsed: string;
187
+ external: string;
188
+ };
189
+ performance: {
190
+ cpuUsage: NodeJS.CpuUsage;
191
+ resourceUsage?: NodeJS.ResourceUsage;
192
+ };
193
+ };
194
+ /**
195
+ * Format bytes to human readable string
196
+ */
197
+ private formatBytes;
198
+ /**
199
+ * Format uptime to human readable string
200
+ */
201
+ private formatUptime;
202
+ /**
203
+ * Add watch directories
204
+ */
205
+ addWatchDirectories(directories: string[]): void;
206
+ /**
207
+ * Clear file cache
208
+ */
209
+ clearFileCache(): void;
210
+ /**
211
+ * Force reload configurations
212
+ */
213
+ forceReloadConfig(): void;
214
+ /**
215
+ * Restart watcher
216
+ */
217
+ restartWatcher(): void;
81
218
  }
82
219
 
83
220
  declare const envPath: string;