@realvare/baileys 1.0.0 → 1.0.1

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.
@@ -1,70 +1,10 @@
1
1
  /**
2
- * Configurazione performance per ottimizzazioni LID/JID
2
+ * Utility per logging condizionale
3
3
  */
4
- export interface CacheConfig {
5
- ttl: number;
6
- maxSize: number;
7
- cleanupInterval: number;
8
- }
9
-
10
- export interface PerformanceSettings {
11
- enableCache: boolean;
12
- enableLogging: boolean;
13
- enableMetrics: boolean;
14
- batchSize: number;
15
- maxRetries: number;
16
- retryDelay: number;
17
- retryBackoffMultiplier: number;
18
- maxRetryDelay: number;
19
- maxMsgRetryCount: number;
20
- memoryThreshold: number;
21
- // Anti-ban specific settings
22
- markOnlineOnConnect?: boolean;
23
- syncFullHistory?: boolean;
24
- keepAliveIntervalMs?: number;
25
- }
26
-
27
- export interface DebugSettings {
28
- enableLidLogging: boolean;
29
- enablePerformanceLogging: boolean;
30
- enableErrorLogging: boolean;
31
- logLevel: 'error' | 'warn' | 'info' | 'debug';
32
- }
33
-
34
- export interface PerformanceConfigInterface {
35
- cache: {
36
- lidCache: CacheConfig;
37
- jidCache: CacheConfig;
38
- lidToJidCache: CacheConfig;
39
- groupMetadataCache: CacheConfig;
40
- };
41
- performance: PerformanceSettings;
42
- debug: DebugSettings;
43
- }
44
-
45
- export declare class PerformanceConfig implements PerformanceConfigInterface {
46
- cache: {
47
- lidCache: CacheConfig;
48
- jidCache: CacheConfig;
49
- lidToJidCache: CacheConfig;
50
- groupMetadataCache: CacheConfig;
51
- };
52
- performance: PerformanceSettings;
53
- debug: DebugSettings;
54
-
55
- updateCacheConfig(cacheType: string, config: Partial<CacheConfig>): void;
56
- updatePerformanceConfig(config: Partial<PerformanceSettings>): void;
57
- updateDebugConfig(config: Partial<DebugSettings>): void;
58
- shouldLog(level: string): boolean;
59
- }
60
-
61
4
  export declare class Logger {
62
5
  static error(message: string, ...args: any[]): void;
63
6
  static warn(message: string, ...args: any[]): void;
64
7
  static info(message: string, ...args: any[]): void;
65
8
  static debug(message: string, ...args: any[]): void;
66
9
  static performance(message: string, ...args: any[]): void;
67
- }
68
-
69
- export declare const getPerformanceConfig: () => PerformanceConfig;
70
- export declare const setPerformanceConfig: (config: Partial<PerformanceConfigInterface> | PerformanceConfig) => void;
10
+ }
@@ -1,183 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerformanceConfig = exports.setPerformanceConfig = exports.getPerformanceConfig = void 0;
4
-
5
- /**
6
- * Configurazione performance per ottimizzazioni LID/JID
7
- */
8
- class PerformanceConfig {
9
- constructor() {
10
- this.cache = {
11
- lidCache: {
12
- ttl: 3 * 60 * 1000, // 3 minutes
13
- maxSize: 1000,
14
- cleanupInterval: 1 * 60 * 1000 // 1 minute
15
- },
16
- jidCache: {
17
- ttl: 3 * 60 * 1000, // 3 minutes
18
- maxSize: 1000,
19
- cleanupInterval: 1 * 60 * 1000 // 1 minute
20
- },
21
- lidToJidCache: {
22
- ttl: 3 * 60 * 1000, // 3 minutes
23
- maxSize: 500,
24
- cleanupInterval: 2 * 60 * 1000 // 2 minutes
25
- },
26
- groupMetadataCache: {
27
- ttl: 5 * 60 * 1000, // 5 minutes
28
- maxSize: 250,
29
- cleanupInterval: 3 * 60 * 1000 // 3 minutes
30
- }
31
- };
32
-
33
- this.performance = {
34
- enableCache: true,
35
- enableLogging: false,
36
- enableMetrics: false,
37
- batchSize: 50,
38
- maxRetries: 3, // Reduced from 5
39
- retryDelay: 2000, // Reduced from 5000
40
- retryBackoffMultiplier: 1.5,
41
- maxRetryDelay: 30000, // Reduced from 60000
42
- maxMsgRetryCount: 2, // Reduced from 3
43
- memoryThreshold: 0.7,
44
- markOnlineOnConnect: false,
45
- syncFullHistory: false,
46
- keepAliveIntervalMs: 30000,
47
- enableNativeLidCache: true,
48
- enableLidLogging: process.env.DEBUG_LID === 'true',
49
- logLevel: process.env.LOG_LEVEL || 'debug',
50
- // Performance optimizations
51
- enableMessageBatching: true,
52
- messageBatchSize: 10,
53
- messageBatchTimeout: 100,
54
- enableParallelProcessing: true,
55
- maxConcurrentMessages: 5,
56
- enableFastAck: true,
57
- reduceSyncValidation: true
58
- };
59
-
60
- this.debug = {
61
- enableLidLogging: process.env.DEBUG_LID === 'true',
62
- enablePerformanceLogging: process.env.DEBUG_PERFORMANCE === 'true',
63
- enableErrorLogging: true,
64
- logLevel: process.env.LOG_LEVEL || 'debug'
65
- };
66
-
67
- this.security = {
68
- messageDelay: {
69
- min: 1000,
70
- max: 5000
71
- },
72
- antiBan: {
73
- enabled: true,
74
- maxConsecutiveErrors: 5,
75
- cooldownPeriod: 15000
76
- }
77
- };
78
- }
79
-
80
-
81
- /**
82
- * Aggiorna configurazione cache
83
- */
84
- updateCacheConfig(cacheType, config) {
85
- if (this.cache[cacheType]) {
86
- this.cache[cacheType] = { ...this.cache[cacheType], ...config };
87
- }
88
- }
89
-
90
- /**
91
- * Aggiorna configurazione performance
92
- */
93
- updatePerformanceConfig(config) {
94
- this.performance = { ...this.performance, ...config };
95
- }
96
-
97
- /**
98
- * Aggiorna configurazione debug
99
- */
100
- updateDebugConfig(config) {
101
- this.debug = { ...this.debug, ...config };
102
- }
103
-
104
- /**
105
- * Verifica se il logging è abilitato per un livello specifico
106
- */
107
- shouldLog(level) {
108
- const levels = ['error', 'warn', 'info', 'debug'];
109
- const currentLevelIndex = levels.indexOf(this.debug.logLevel);
110
- const requestedLevelIndex = levels.indexOf(level);
111
- return requestedLevelIndex <= currentLevelIndex;
112
- }
113
- }
114
-
115
- // Istanza globale della configurazione
116
- let globalConfig = new PerformanceConfig();
117
-
118
- /**
119
- * Ottieni la configurazione performance globale
120
- */
121
- const getPerformanceConfig = () => globalConfig;
122
- exports.getPerformanceConfig = getPerformanceConfig;
123
-
124
- /**
125
- * Imposta una nuova configurazione performance
126
- */
127
- const setPerformanceConfig = (config) => {
128
- if (config instanceof PerformanceConfig) {
129
- globalConfig = config;
130
- } else {
131
- // Merge con configurazione esistente
132
- if (config.cache) {
133
- Object.keys(config.cache).forEach(key => {
134
- globalConfig.updateCacheConfig(key, config.cache[key]);
135
- });
136
- }
137
- if (config.performance) {
138
- globalConfig.updatePerformanceConfig(config.performance);
139
- }
140
- if (config.debug) {
141
- globalConfig.updateDebugConfig(config.debug);
142
- }
143
- }
144
- };
145
- exports.setPerformanceConfig = setPerformanceConfig;
146
3
 
147
4
  /**
148
5
  * Utility per logging condizionale
149
6
  */
150
7
  class Logger {
151
8
  static error(message, ...args) {
152
- if (globalConfig.shouldLog('error')) {
153
- console.error(`[LID/JID Error] ${message}`, ...args);
154
- }
9
+ console.error(`[LID/JID Error] ${message}`, ...args);
155
10
  }
156
11
 
157
12
  static warn(message, ...args) {
158
- if (globalConfig.shouldLog('warn')) {
159
- console.warn(`[LID/JID Warning] ${message}`, ...args);
160
- }
13
+ console.warn(`[LID/JID Warning] ${message}`, ...args);
161
14
  }
162
15
 
163
16
  static info(message, ...args) {
164
- if (globalConfig.shouldLog('info')) {
165
- console.info(`[LID/JID Info] ${message}`, ...args);
166
- }
17
+ console.info(`[LID/JID Info] ${message}`, ...args);
167
18
  }
168
19
 
169
20
  static debug(message, ...args) {
170
- if (globalConfig.shouldLog('debug')) {
171
- console.debug(`[LID/JID Debug] ${message}`, ...args);
172
- }
21
+ console.debug(`[LID/JID Debug] ${message}`, ...args);
173
22
  }
174
23
 
175
24
  static performance(message, ...args) {
176
- if (globalConfig.debug.enablePerformanceLogging) {
177
- console.log(`[LID/JID Performance] ${message}`, ...args);
178
- }
25
+ console.log(`[LID/JID Performance] ${message}`, ...args);
179
26
  }
180
27
  }
181
28
 
182
- exports.Logger = Logger;
183
- exports.PerformanceConfig = PerformanceConfig;
29
+ exports.Logger = Logger;
@@ -113,8 +113,8 @@ class SimpleLRU {
113
113
  }
114
114
  }
115
115
 
116
- const DEFAULT_LID_CACHE_TTL = 5 * 60 * 1000; // 5 minuti
117
- const DEFAULT_LID_CACHE_MAX = 2000;
116
+ const DEFAULT_LID_CACHE_TTL = 30 * 60 * 1000; // 30 minuti — i mapping LID→JID cambiano raramente
117
+ const DEFAULT_LID_CACHE_MAX = 5000;
118
118
  const lidToJidCache = new SimpleLRU(DEFAULT_LID_CACHE_MAX, DEFAULT_LID_CACHE_TTL);
119
119
 
120
120
  // Shared bidirectional LID phone JID cache (module-level singleton)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realvare/baileys",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Whatsapp api by Sam - Based",
5
5
  "keywords": [
6
6
  "baileys",