@vvlad1973/telegram-bot-client 1.3.0 → 2.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.
Files changed (66) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/README.md +300 -273
  3. package/dist/agents/LongPollingManager.d.ts +5 -6
  4. package/dist/agents/LongPollingManager.js +48 -46
  5. package/dist/agents/LongPollingManager.js.map +1 -1
  6. package/dist/agents/types/polling-manager.types.d.ts +4 -4
  7. package/dist/agents/workers/WorkerClientFactory.js +3 -3
  8. package/dist/agents/workers/WorkerClientFactory.js.map +1 -1
  9. package/dist/agents/workers/long-polling-worker-test.js +2 -1
  10. package/dist/agents/workers/long-polling-worker-test.js.map +1 -1
  11. package/dist/api/BaseTelegramApi.generated.js +481 -0
  12. package/dist/api/BaseTelegramApi.generated.js.map +1 -1
  13. package/dist/client/TelegramBotClient.d.ts +15 -4
  14. package/dist/client/TelegramBotClient.js +17 -4
  15. package/dist/client/TelegramBotClient.js.map +1 -1
  16. package/dist/client/index.d.ts +1 -1
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client/managers/PollingIntegrationManager.d.ts +160 -0
  19. package/dist/client/managers/PollingIntegrationManager.js +274 -0
  20. package/dist/client/managers/PollingIntegrationManager.js.map +1 -0
  21. package/dist/client/managers/RouteConfigManager.d.ts +186 -0
  22. package/dist/client/managers/RouteConfigManager.js +395 -0
  23. package/dist/client/managers/RouteConfigManager.js.map +1 -0
  24. package/dist/client/managers/RouteLifecycleManager.d.ts +146 -0
  25. package/dist/client/managers/RouteLifecycleManager.js +402 -0
  26. package/dist/client/managers/RouteLifecycleManager.js.map +1 -0
  27. package/dist/client/managers/index.d.ts +11 -0
  28. package/dist/client/managers/index.js +10 -0
  29. package/dist/client/managers/index.js.map +1 -0
  30. package/dist/helpers/index.d.ts +1 -0
  31. package/dist/helpers/index.js +2 -0
  32. package/dist/helpers/index.js.map +1 -1
  33. package/dist/helpers/logger-helpers.d.ts +2 -5
  34. package/dist/helpers/logger-helpers.js +2 -10
  35. package/dist/helpers/logger-helpers.js.map +1 -1
  36. package/dist/helpers/logging-decorators.d.ts +43 -0
  37. package/dist/helpers/logging-decorators.js +156 -0
  38. package/dist/helpers/logging-decorators.js.map +1 -0
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.js +1 -3
  41. package/dist/index.js.map +1 -1
  42. package/dist/queue/InMemoryQueueProvider.d.ts +2 -2
  43. package/dist/queue/InMemoryQueueProvider.js +2 -2
  44. package/dist/queue/InMemoryQueueProvider.js.map +1 -1
  45. package/dist/transport/TelegramHttpClient.d.ts +2 -2
  46. package/dist/transport/TelegramHttpClient.js +2 -2
  47. package/dist/transport/TelegramHttpClient.js.map +1 -1
  48. package/dist/transport/TelegramHttpTransport.d.ts +2 -2
  49. package/dist/transport/TelegramHttpTransport.js +3 -4
  50. package/dist/transport/TelegramHttpTransport.js.map +1 -1
  51. package/dist/transport/TelegramTransport.d.ts +2 -2
  52. package/dist/transport/TelegramTransport.js +23 -7
  53. package/dist/transport/TelegramTransport.js.map +1 -1
  54. package/dist/transport/TokensManager.d.ts +2 -2
  55. package/dist/transport/TokensManager.js +6 -6
  56. package/dist/transport/TokensManager.js.map +1 -1
  57. package/dist/transport/index.d.ts +0 -1
  58. package/dist/transport/index.js +1 -3
  59. package/dist/transport/index.js.map +1 -1
  60. package/dist/types/logger.types.d.ts +3 -9
  61. package/dist/types/route.types.d.ts +110 -0
  62. package/dist/types/route.types.js +19 -0
  63. package/dist/types/route.types.js.map +1 -0
  64. package/dist/types/transport.types.d.ts +3 -1
  65. package/package.json +1 -1
  66. package/test_output.txt +256 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Route Lifecycle Manager
3
+ * Manages route initialization, activation, deactivation, and hot reload
4
+ *
5
+ * @module client/managers/RouteLifecycleManager
6
+ */
7
+ import type { RouteConfigManager } from './RouteConfigManager.js';
8
+ import type { BaseTelegramApi } from '../../api/BaseTelegramApi.generated.js';
9
+ import type { RouteStatus, RouteMode } from '../../types/route.types.js';
10
+ import type { ILogger, LoggerOptions, ILoggerAware } from '../../types/logger.types.js';
11
+ /**
12
+ * Configuration options for RouteLifecycleManager
13
+ */
14
+ export interface RouteLifecycleManagerOptions extends LoggerOptions {
15
+ /** Route configuration manager */
16
+ configManager: RouteConfigManager;
17
+ /** API client for webhook and bot info operations */
18
+ apiClient: BaseTelegramApi;
19
+ /**
20
+ * Base URL for webhooks (optional)
21
+ * Combined with route's webhook.path to form full webhook URL
22
+ * Example: 'https://example.com/webhooks'
23
+ */
24
+ webhookBaseUrl?: string;
25
+ }
26
+ /**
27
+ * Route Lifecycle Manager
28
+ * Manages route initialization, activation, deactivation, and mode switching
29
+ *
30
+ * Responsibilities:
31
+ * - Initialize routes (getMe, store bot info)
32
+ * - Activate routes (set webhooks, prepare for polling)
33
+ * - Deactivate routes (delete webhooks, stop polling)
34
+ * - Switch between modes (webhook ↔ longPolling ↔ inactive)
35
+ * - Hot reload routes (apply configuration changes)
36
+ * - Manage route status
37
+ */
38
+ export declare class RouteLifecycleManager implements ILoggerAware {
39
+ private readonly configManager;
40
+ private readonly apiClient;
41
+ private readonly webhookBaseUrl?;
42
+ /** Logger instance - mutable to support LoggerBinder.bind() */
43
+ logger?: ILogger;
44
+ /**
45
+ * Create a new RouteLifecycleManager instance
46
+ * @param options - Configuration options
47
+ */
48
+ constructor(options: RouteLifecycleManagerOptions);
49
+ /**
50
+ * Initialize a route
51
+ * Calls getMe to fetch bot info and stores it in route config
52
+ *
53
+ * @param routeId - Route identifier (uses default if not specified)
54
+ * @throws {Error} If route not found or initialization fails
55
+ */
56
+ initRoute(routeId?: string): Promise<void>;
57
+ /**
58
+ * Initialize all routes
59
+ * Calls initRoute for each configured route
60
+ */
61
+ initAllRoutes(): Promise<void>;
62
+ /**
63
+ * Activate a route in specified mode
64
+ * For webhook mode: calls setWebhook
65
+ * For longPolling mode: prepares route status
66
+ * For inactive mode: does nothing
67
+ *
68
+ * @param routeId - Route identifier
69
+ * @param mode - Mode to activate (uses route's configured mode if not specified)
70
+ * @throws {Error} If route not found or activation fails
71
+ */
72
+ activateRoute(routeId: string, mode?: RouteMode): Promise<void>;
73
+ /**
74
+ * Resolve webhook URL from route configuration
75
+ * Priority: webhook.url > webhook.path + webhookBaseUrl
76
+ *
77
+ * @param routeId - Route identifier
78
+ * @param webhook - Webhook configuration
79
+ * @returns Resolved webhook URL
80
+ * @throws {Error} If URL cannot be resolved
81
+ */
82
+ private resolveWebhookUrl;
83
+ /**
84
+ * Activate webhook mode for a route
85
+ * Calls setWebhook with route's webhook configuration
86
+ *
87
+ * @param routeId - Route identifier
88
+ * @param route - Route configuration
89
+ */
90
+ private activateWebhook;
91
+ /**
92
+ * Activate long polling mode for a route
93
+ * Deletes webhook and prepares status for polling
94
+ *
95
+ * @param routeId - Route identifier
96
+ * @param route - Route configuration
97
+ */
98
+ private activateLongPolling;
99
+ /**
100
+ * Deactivate a route
101
+ * For webhook mode: deletes webhook
102
+ * For longPolling mode: marks as inactive (actual polling stop handled by PollingIntegrationManager)
103
+ *
104
+ * @param routeId - Route identifier
105
+ * @throws {Error} If route not found or deactivation fails
106
+ */
107
+ deactivateRoute(routeId: string): Promise<void>;
108
+ /**
109
+ * Switch route to a different mode
110
+ * Deactivates current mode and activates new mode
111
+ *
112
+ * @param routeId - Route identifier
113
+ * @param newMode - New mode to activate
114
+ * @throws {Error} If route not found or mode switch fails
115
+ */
116
+ switchMode(routeId: string, newMode: RouteMode): Promise<void>;
117
+ /**
118
+ * Get route status
119
+ *
120
+ * @param routeId - Route identifier
121
+ * @returns Route status or undefined
122
+ */
123
+ getStatus(routeId: string): RouteStatus | undefined;
124
+ /**
125
+ * Set route status
126
+ * Use with caution - normally status is managed internally
127
+ *
128
+ * @param routeId - Route identifier
129
+ * @param status - Route status
130
+ */
131
+ setStatus(routeId: string, status: RouteStatus): void;
132
+ /**
133
+ * Hot reload a route
134
+ * Applies configuration changes without full restart
135
+ * If route is active, deactivates and reactivates it
136
+ *
137
+ * @param routeId - Route identifier
138
+ * @throws {Error} If route not found or reload fails
139
+ */
140
+ reloadRoute(routeId: string): Promise<void>;
141
+ /**
142
+ * Hot reload all routes
143
+ * Applies configuration changes to all routes
144
+ */
145
+ reloadAllRoutes(): Promise<void>;
146
+ }
@@ -0,0 +1,402 @@
1
+ /**
2
+ * Route Lifecycle Manager
3
+ * Manages route initialization, activation, deactivation, and hot reload
4
+ *
5
+ * @module client/managers/RouteLifecycleManager
6
+ */
7
+ 'use strict';
8
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ };
14
+ import { RouteMode as RouteModeEnum } from '../../types/route.types.js';
15
+ import { initializeLogger } from '../../helpers/logger-helpers.js';
16
+ import { LogMethod } from '../../helpers/logging-decorators.js';
17
+ /**
18
+ * Route Lifecycle Manager
19
+ * Manages route initialization, activation, deactivation, and mode switching
20
+ *
21
+ * Responsibilities:
22
+ * - Initialize routes (getMe, store bot info)
23
+ * - Activate routes (set webhooks, prepare for polling)
24
+ * - Deactivate routes (delete webhooks, stop polling)
25
+ * - Switch between modes (webhook ↔ longPolling ↔ inactive)
26
+ * - Hot reload routes (apply configuration changes)
27
+ * - Manage route status
28
+ */
29
+ export class RouteLifecycleManager {
30
+ configManager;
31
+ apiClient;
32
+ webhookBaseUrl;
33
+ /** Logger instance - mutable to support LoggerBinder.bind() */
34
+ logger;
35
+ /**
36
+ * Create a new RouteLifecycleManager instance
37
+ * @param options - Configuration options
38
+ */
39
+ constructor(options) {
40
+ this.configManager = options.configManager;
41
+ this.apiClient = options.apiClient;
42
+ this.webhookBaseUrl = options.webhookBaseUrl;
43
+ this.logger = initializeLogger(this, options.logger);
44
+ this.logger?.info?.('RouteLifecycleManager initialized');
45
+ }
46
+ /**
47
+ * Initialize a route
48
+ * Calls getMe to fetch bot info and stores it in route config
49
+ *
50
+ * @param routeId - Route identifier (uses default if not specified)
51
+ * @throws {Error} If route not found or initialization fails
52
+ */
53
+ async initRoute(routeId) {
54
+ const id = routeId || this.configManager.getDefaultRouteId();
55
+ if (!id) {
56
+ throw new Error('No route specified and no default route set');
57
+ }
58
+ const route = this.configManager.getRoute(id);
59
+ if (!route) {
60
+ throw new Error(`Route not found: ${id}`);
61
+ }
62
+ this.logger?.info?.(`Initializing route: ${id}`);
63
+ try {
64
+ // Call getMe to get bot information
65
+ const response = await this.apiClient.getMe({}, { routeId: id });
66
+ if (!response.ok) {
67
+ const errorMsg = 'description' in response ? response.description : 'Unknown error';
68
+ throw new Error(`getMe failed for route ${id}: ${errorMsg}`);
69
+ }
70
+ // Type narrowing: response is GetMeOkResponse here
71
+ // Note: GetMeResponseSuccess is incorrectly typed as Success<string> instead of Success<User>
72
+ // Using type assertion until API types are regenerated
73
+ const botInfo = ('result' in response ? response.result : undefined);
74
+ if (!botInfo) {
75
+ throw new Error(`Unexpected response structure from getMe for route ${id}`);
76
+ }
77
+ // Store bot info in route config
78
+ route.botInfo = botInfo;
79
+ // Initialize status if not present
80
+ if (!route.status) {
81
+ route.status = {
82
+ mode: route.mode || RouteModeEnum.Inactive,
83
+ active: false,
84
+ };
85
+ }
86
+ // Store updated bot info in status
87
+ route.status.botInfo = botInfo;
88
+ this.logger?.info?.(`Route ${id} initialized (@${botInfo.username || 'unknown'})`);
89
+ }
90
+ catch (error) {
91
+ const err = error instanceof Error ? error : new Error(String(error));
92
+ this.logger?.error?.({ routeId: id, err }, 'Failed to initialize route');
93
+ throw err;
94
+ }
95
+ }
96
+ /**
97
+ * Initialize all routes
98
+ * Calls initRoute for each configured route
99
+ */
100
+ async initAllRoutes() {
101
+ const routeIds = this.configManager.getRouteIds();
102
+ this.logger?.info?.(`Initializing ${routeIds.length} route(s)`);
103
+ const results = await Promise.allSettled(routeIds.map((id) => this.initRoute(id)));
104
+ // Log failures
105
+ results.forEach((result, index) => {
106
+ if (result.status === 'rejected') {
107
+ this.logger?.error?.({ routeId: routeIds[index], err: result.reason }, 'Failed to initialize route');
108
+ }
109
+ });
110
+ const successCount = results.filter((r) => r.status === 'fulfilled').length;
111
+ this.logger?.info?.(`Routes initialized: ${successCount}/${routeIds.length} successful`);
112
+ }
113
+ /**
114
+ * Activate a route in specified mode
115
+ * For webhook mode: calls setWebhook
116
+ * For longPolling mode: prepares route status
117
+ * For inactive mode: does nothing
118
+ *
119
+ * @param routeId - Route identifier
120
+ * @param mode - Mode to activate (uses route's configured mode if not specified)
121
+ * @throws {Error} If route not found or activation fails
122
+ */
123
+ async activateRoute(routeId, mode) {
124
+ const route = this.configManager.getRoute(routeId);
125
+ if (!route) {
126
+ throw new Error(`Route not found: ${routeId}`);
127
+ }
128
+ const targetMode = mode || route.mode || RouteModeEnum.Inactive;
129
+ this.logger?.info?.(`Activating route ${routeId} in ${targetMode} mode`);
130
+ // Initialize status if not present
131
+ if (!route.status) {
132
+ route.status = {
133
+ mode: targetMode,
134
+ active: false,
135
+ };
136
+ }
137
+ try {
138
+ switch (targetMode) {
139
+ case RouteModeEnum.Webhook:
140
+ await this.activateWebhook(routeId, route);
141
+ break;
142
+ case RouteModeEnum.LongPolling:
143
+ await this.activateLongPolling(routeId, route);
144
+ break;
145
+ case RouteModeEnum.Inactive:
146
+ // Deactivate instead
147
+ await this.deactivateRoute(routeId);
148
+ return;
149
+ }
150
+ route.status.mode = targetMode;
151
+ route.status.active = true;
152
+ this.logger?.info?.(`Route ${routeId} activated in ${targetMode} mode`);
153
+ }
154
+ catch (error) {
155
+ const err = error instanceof Error ? error : new Error(String(error));
156
+ this.logger?.error?.({ routeId, err }, 'Failed to activate route');
157
+ throw err;
158
+ }
159
+ }
160
+ /**
161
+ * Resolve webhook URL from route configuration
162
+ * Priority: webhook.url > webhook.path + webhookBaseUrl
163
+ *
164
+ * @param routeId - Route identifier
165
+ * @param webhook - Webhook configuration
166
+ * @returns Resolved webhook URL
167
+ * @throws {Error} If URL cannot be resolved
168
+ */
169
+ resolveWebhookUrl(routeId, webhook) {
170
+ // Full URL has priority
171
+ if (webhook.url) {
172
+ return webhook.url;
173
+ }
174
+ // Combine path with webhookBaseUrl
175
+ if (webhook.path) {
176
+ if (!this.webhookBaseUrl) {
177
+ throw new Error(`Cannot resolve webhook URL for route ${routeId}: webhook.path is set but webhookBaseUrl is not configured in TelegramBotClient`);
178
+ }
179
+ // Ensure proper URL formation
180
+ const baseUrl = this.webhookBaseUrl.endsWith('/')
181
+ ? this.webhookBaseUrl.slice(0, -1)
182
+ : this.webhookBaseUrl;
183
+ const path = webhook.path.startsWith('/')
184
+ ? webhook.path
185
+ : '/' + webhook.path;
186
+ return baseUrl + path;
187
+ }
188
+ throw new Error(`Cannot resolve webhook URL for route ${routeId}: neither webhook.url nor webhook.path is specified`);
189
+ }
190
+ /**
191
+ * Activate webhook mode for a route
192
+ * Calls setWebhook with route's webhook configuration
193
+ *
194
+ * @param routeId - Route identifier
195
+ * @param route - Route configuration
196
+ */
197
+ async activateWebhook(routeId, route) {
198
+ if (!route.webhook) {
199
+ throw new Error(`Webhook configuration not found for route: ${routeId}`);
200
+ }
201
+ // Resolve webhook URL
202
+ const webhookUrl = this.resolveWebhookUrl(routeId, route.webhook);
203
+ this.logger?.debug?.({ routeId, webhookUrl }, 'Setting webhook for route');
204
+ // Build params, omitting undefined values
205
+ const params = {
206
+ url: webhookUrl,
207
+ };
208
+ if (route.webhook.secretToken !== undefined)
209
+ params.secret_token = route.webhook.secretToken;
210
+ if (route.webhook.maxConnections !== undefined)
211
+ params.max_connections = route.webhook.maxConnections;
212
+ if (route.webhook.allowedUpdates !== undefined)
213
+ params.allowed_updates = route.webhook.allowedUpdates;
214
+ if (route.webhook.dropPendingUpdates !== undefined)
215
+ params.drop_pending_updates = route.webhook.dropPendingUpdates;
216
+ if (route.webhook.ipAddress !== undefined)
217
+ params.ip_address = route.webhook.ipAddress;
218
+ if (route.webhook.certificate !== undefined)
219
+ params.certificate = route.webhook.certificate;
220
+ // Type assertion needed because params is Record<string, unknown>
221
+ const response = await this.apiClient.setWebhook(params, { routeId });
222
+ if (!response.ok) {
223
+ const errorMsg = 'description' in response ? response.description : 'Unknown error';
224
+ throw new Error(`setWebhook failed for route ${routeId}: ${errorMsg}`);
225
+ }
226
+ // Fetch webhook info to verify
227
+ const infoResponse = await this.apiClient.getWebhookInfo({}, { routeId });
228
+ if (infoResponse.ok && 'result' in infoResponse) {
229
+ if (route.status) {
230
+ route.status.webhookInfo = infoResponse.result;
231
+ }
232
+ }
233
+ }
234
+ /**
235
+ * Activate long polling mode for a route
236
+ * Deletes webhook and prepares status for polling
237
+ *
238
+ * @param routeId - Route identifier
239
+ * @param route - Route configuration
240
+ */
241
+ async activateLongPolling(routeId, route) {
242
+ this.logger?.debug?.({ routeId }, 'Preparing long polling for route');
243
+ // Delete webhook to enable long polling
244
+ const response = await this.apiClient.deleteWebhook({ drop_pending_updates: false }, { routeId });
245
+ if (!response.ok) {
246
+ const errorMsg = 'description' in response ? response.description : 'Unknown error';
247
+ throw new Error(`deleteWebhook failed for route ${routeId}: ${errorMsg}`);
248
+ }
249
+ // Clear webhook info from status
250
+ if (route.status) {
251
+ route.status.webhookInfo = undefined;
252
+ }
253
+ }
254
+ /**
255
+ * Deactivate a route
256
+ * For webhook mode: deletes webhook
257
+ * For longPolling mode: marks as inactive (actual polling stop handled by PollingIntegrationManager)
258
+ *
259
+ * @param routeId - Route identifier
260
+ * @throws {Error} If route not found or deactivation fails
261
+ */
262
+ async deactivateRoute(routeId) {
263
+ const route = this.configManager.getRoute(routeId);
264
+ if (!route) {
265
+ throw new Error(`Route not found: ${routeId}`);
266
+ }
267
+ if (!route.status || !route.status.active) {
268
+ this.logger?.debug?.({ routeId }, 'Route is already inactive');
269
+ return;
270
+ }
271
+ this.logger?.info?.(`Deactivating route: ${routeId}`);
272
+ try {
273
+ // If in webhook mode, delete webhook
274
+ if (route.status.mode === RouteModeEnum.Webhook) {
275
+ const response = await this.apiClient.deleteWebhook({ drop_pending_updates: false }, { routeId });
276
+ if (!response.ok) {
277
+ const errorMsg = 'description' in response ? response.description : 'Unknown error';
278
+ this.logger?.warn?.({ routeId, description: errorMsg }, 'deleteWebhook failed');
279
+ }
280
+ }
281
+ route.status.active = false;
282
+ route.status.mode = RouteModeEnum.Inactive;
283
+ this.logger?.info?.(`Route ${routeId} deactivated`);
284
+ }
285
+ catch (error) {
286
+ const err = error instanceof Error ? error : new Error(String(error));
287
+ this.logger?.error?.({ routeId, err }, 'Failed to deactivate route');
288
+ throw err;
289
+ }
290
+ }
291
+ /**
292
+ * Switch route to a different mode
293
+ * Deactivates current mode and activates new mode
294
+ *
295
+ * @param routeId - Route identifier
296
+ * @param newMode - New mode to activate
297
+ * @throws {Error} If route not found or mode switch fails
298
+ */
299
+ async switchMode(routeId, newMode) {
300
+ const route = this.configManager.getRoute(routeId);
301
+ if (!route) {
302
+ throw new Error(`Route not found: ${routeId}`);
303
+ }
304
+ const currentMode = route.status?.mode || RouteModeEnum.Inactive;
305
+ if (currentMode === newMode) {
306
+ this.logger?.debug?.({ routeId, mode: newMode }, 'Route is already in specified mode');
307
+ return;
308
+ }
309
+ this.logger?.info?.(`Switching route ${routeId} from ${currentMode} to ${newMode}`);
310
+ // Deactivate current mode
311
+ if (route.status?.active) {
312
+ await this.deactivateRoute(routeId);
313
+ }
314
+ // Update route mode config
315
+ route.mode = newMode;
316
+ // Activate new mode
317
+ await this.activateRoute(routeId, newMode);
318
+ }
319
+ /**
320
+ * Get route status
321
+ *
322
+ * @param routeId - Route identifier
323
+ * @returns Route status or undefined
324
+ */
325
+ getStatus(routeId) {
326
+ const route = this.configManager.getRoute(routeId);
327
+ return route?.status;
328
+ }
329
+ /**
330
+ * Set route status
331
+ * Use with caution - normally status is managed internally
332
+ *
333
+ * @param routeId - Route identifier
334
+ * @param status - Route status
335
+ */
336
+ setStatus(routeId, status) {
337
+ const route = this.configManager.getRoute(routeId);
338
+ if (!route) {
339
+ throw new Error(`Route not found: ${routeId}`);
340
+ }
341
+ route.status = status;
342
+ }
343
+ /**
344
+ * Hot reload a route
345
+ * Applies configuration changes without full restart
346
+ * If route is active, deactivates and reactivates it
347
+ *
348
+ * @param routeId - Route identifier
349
+ * @throws {Error} If route not found or reload fails
350
+ */
351
+ async reloadRoute(routeId) {
352
+ const route = this.configManager.getRoute(routeId);
353
+ if (!route) {
354
+ throw new Error(`Route not found: ${routeId}`);
355
+ }
356
+ this.logger?.info?.(`Reloading route: ${routeId}`);
357
+ const wasActive = route.status?.active || false;
358
+ const currentMode = route.status?.mode;
359
+ try {
360
+ // Deactivate if active
361
+ if (wasActive) {
362
+ await this.deactivateRoute(routeId);
363
+ }
364
+ // Re-initialize to refresh bot info
365
+ await this.initRoute(routeId);
366
+ // Reactivate if was active
367
+ if (wasActive && currentMode) {
368
+ await this.activateRoute(routeId, currentMode);
369
+ }
370
+ this.logger?.info?.(`Route ${routeId} reloaded successfully`);
371
+ }
372
+ catch (error) {
373
+ const err = error instanceof Error ? error : new Error(String(error));
374
+ this.logger?.error?.({ routeId, err }, 'Failed to reload route');
375
+ throw err;
376
+ }
377
+ }
378
+ /**
379
+ * Hot reload all routes
380
+ * Applies configuration changes to all routes
381
+ */
382
+ async reloadAllRoutes() {
383
+ const routeIds = this.configManager.getRouteIds();
384
+ this.logger?.info?.(`Reloading ${routeIds.length} route(s)`);
385
+ const results = await Promise.allSettled(routeIds.map((id) => this.reloadRoute(id)));
386
+ // Log failures
387
+ results.forEach((result, index) => {
388
+ if (result.status === 'rejected') {
389
+ this.logger?.error?.({ routeId: routeIds[index], err: result.reason }, 'Failed to reload route');
390
+ }
391
+ });
392
+ const successCount = results.filter((r) => r.status === 'fulfilled').length;
393
+ this.logger?.info?.(`Routes reloaded: ${successCount}/${routeIds.length} successful`);
394
+ }
395
+ }
396
+ __decorate([
397
+ LogMethod({ level: 'debug', logParams: true, logReturn: false })
398
+ ], RouteLifecycleManager.prototype, "activateRoute", null);
399
+ __decorate([
400
+ LogMethod({ level: 'debug', logParams: true, logReturn: false })
401
+ ], RouteLifecycleManager.prototype, "deactivateRoute", null);
402
+ //# sourceMappingURL=RouteLifecycleManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteLifecycleManager.js","sourceRoot":"","sources":["../../../src/client/managers/RouteLifecycleManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,CAAC;;;;;;;AAOb,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAoBhE;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAqB;IACf,aAAa,CAAqB;IAClC,SAAS,CAAkB;IAC3B,cAAc,CAAU;IAEzC,+DAA+D;IACxD,MAAM,CAAW;IAExB;;;OAGG;IACH,YAAY,OAAqC;QAC/C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAErD,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,mCAAmC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,CAAC,OAAgB;QAC9B,MAAM,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,CAA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AW,CAAC,EAAE,CAAC,CAAC,CAC3C,CAAC;QAEF,eAAe;QACf,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAChC,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACjC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC;YACnG,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;QAC5E,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,oBAAoB,YAAY,IAAI,QAAQ,CAAC,MAAM,aAAa,CAAC,CAAC;IACxF,CAAC;CACF;AAxUO;IADL,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;0DA4ChE;AA2HK;IADL,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4DAqChE"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Route managers for composition-based architecture
3
+ *
4
+ * @module client/managers
5
+ */
6
+ export { RouteConfigManager } from './RouteConfigManager.js';
7
+ export type { RouteConfigManagerOptions } from './RouteConfigManager.js';
8
+ export { RouteLifecycleManager } from './RouteLifecycleManager.js';
9
+ export type { RouteLifecycleManagerOptions } from './RouteLifecycleManager.js';
10
+ export { PollingIntegrationManager } from './PollingIntegrationManager.js';
11
+ export type { PollingIntegrationManagerOptions } from './PollingIntegrationManager.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Route managers for composition-based architecture
3
+ *
4
+ * @module client/managers
5
+ */
6
+ 'use strict';
7
+ export { RouteConfigManager } from './RouteConfigManager.js';
8
+ export { RouteLifecycleManager } from './RouteLifecycleManager.js';
9
+ export { PollingIntegrationManager } from './PollingIntegrationManager.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/managers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -6,3 +6,4 @@ export { UpdateType, MessageType, SERVICE_MESSAGE_TYPES, parseCommand, getMessag
6
6
  export { DiceEmoji, DiceTypes, MediaType, MediaTypes, ParseMode, ChatType, type DiceEmoji as DiceEmojiType, type MediaType as MediaTypeEnum, type ParseMode as ParseModeType, type ChatType as ChatTypeEnum } from './constants.js';
7
7
  export { formatUserUrl, formatUserMention, type UserLike, type MentionParseMode } from './user-helpers.js';
8
8
  export { getFileUrl, getTelegramFileBuffer, getTelegramFileStream, downloadFileBuffer, downloadFileStream, getFileBuffer, getFileStream } from './file-helpers.js';
9
+ export { LogMethod, LogEntry, type LogMethodOptions } from './logging-decorators.js';
@@ -10,4 +10,6 @@ export { DiceEmoji, DiceTypes, MediaType, MediaTypes, ParseMode, ChatType } from
10
10
  export { formatUserUrl, formatUserMention } from './user-helpers.js';
11
11
  // File helpers
12
12
  export { getFileUrl, getTelegramFileBuffer, getTelegramFileStream, downloadFileBuffer, downloadFileStream, getFileBuffer, getFileStream } from './file-helpers.js';
13
+ // Logging decorators
14
+ export { LogMethod, LogEntry } from './logging-decorators.js';
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iBAAiB;AACjB,OAAO,EACL,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAE7B,YAAY;AACZ,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAExB,eAAe;AACf,OAAO,EACL,aAAa,EACb,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAE3B,eAAe;AACf,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iBAAiB;AACjB,OAAO,EACL,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAE7B,YAAY;AACZ,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAExB,eAAe;AACf,OAAO,EACL,aAAa,EACb,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAE3B,eAAe;AACf,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,qBAAqB;AACrB,OAAO,EACL,SAAS,EACT,QAAQ,EAET,MAAM,yBAAyB,CAAC"}
@@ -3,20 +3,17 @@
3
3
  * @description Helper functions for logger integration
4
4
  */
5
5
  import type { ILogger } from '../types/logger.types.js';
6
- import type { LoggerBinder } from '@vvlad1973/logger-tree';
7
6
  /**
8
7
  * Initialize logger for a component
9
- * Supports both LoggerBinder.bind() and direct logger instance
8
+ * Only supports direct logger instance (not LoggerBinder - use binder.bind() externally instead)
10
9
  *
11
10
  * @param target - Target component to bind logger to
12
- * @param loggerPath - Path for the logger (e.g., 'TelegramHttpClient')
13
- * @param loggerBinder - Optional LoggerBinder instance
14
11
  * @param logger - Optional logger instance
15
12
  * @returns Logger instance or undefined
16
13
  */
17
14
  export declare function initializeLogger(target: {
18
15
  logger?: ILogger;
19
- }, loggerPath: string, loggerBinder?: LoggerBinder, logger?: ILogger): ILogger | undefined;
16
+ }, logger?: ILogger): ILogger | undefined;
20
17
  /**
21
18
  * Safe context wrapper for logger calls
22
19
  * Handles undefined/null/primitive values by wrapping them in an object
@@ -5,26 +5,18 @@
5
5
  'use strict';
6
6
  /**
7
7
  * Initialize logger for a component
8
- * Supports both LoggerBinder.bind() and direct logger instance
8
+ * Only supports direct logger instance (not LoggerBinder - use binder.bind() externally instead)
9
9
  *
10
10
  * @param target - Target component to bind logger to
11
- * @param loggerPath - Path for the logger (e.g., 'TelegramHttpClient')
12
- * @param loggerBinder - Optional LoggerBinder instance
13
11
  * @param logger - Optional logger instance
14
12
  * @returns Logger instance or undefined
15
13
  */
16
- export function initializeLogger(target, loggerPath, loggerBinder, logger) {
14
+ export function initializeLogger(target, logger) {
17
15
  // If logger is provided directly, use it
18
16
  if (logger) {
19
17
  target.logger = logger;
20
18
  return logger;
21
19
  }
22
- // If loggerBinder is provided, use it to bind logger
23
- if (loggerBinder) {
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- loggerBinder.bind(loggerPath, target);
26
- return target.logger;
27
- }
28
20
  // No logger available
29
21
  return undefined;
30
22
  }