@arcaelas/whatsapp 3.0.2 → 3.1.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.
- package/package.json +1 -1
- package/build/cjs/decorators.d.ts +0 -9
- package/build/cjs/decorators.js +0 -26
- package/build/cjs/decorators.js.map +0 -1
- package/build/cjs/index.d.ts +0 -9
- package/build/cjs/index.js +0 -18
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/lib/bot/decorator.d.ts +0 -77
- package/build/cjs/lib/bot/decorator.js +0 -219
- package/build/cjs/lib/bot/decorator.js.map +0 -1
- package/build/cjs/lib/bot/decorators.d.ts +0 -113
- package/build/cjs/lib/bot/decorators.js +0 -253
- package/build/cjs/lib/bot/decorators.js.map +0 -1
- package/build/cjs/lib/bot/index.d.ts +0 -3
- package/build/cjs/lib/bot/index.js +0 -20
- package/build/cjs/lib/bot/index.js.map +0 -1
- package/build/cjs/lib/chat/index.d.ts +0 -227
- package/build/cjs/lib/chat/index.js +0 -324
- package/build/cjs/lib/chat/index.js.map +0 -1
- package/build/cjs/lib/contact/index.d.ts +0 -203
- package/build/cjs/lib/contact/index.js +0 -226
- package/build/cjs/lib/contact/index.js.map +0 -1
- package/build/cjs/lib/message/index.d.ts +0 -237
- package/build/cjs/lib/message/index.js +0 -685
- package/build/cjs/lib/message/index.js.map +0 -1
- package/build/cjs/lib/store/engine/index.d.ts +0 -34
- package/build/cjs/lib/store/engine/index.js +0 -13
- package/build/cjs/lib/store/engine/index.js.map +0 -1
- package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +0 -56
- package/build/cjs/lib/store/engine/lib/file_system/index.js +0 -160
- package/build/cjs/lib/store/engine/lib/file_system/index.js.map +0 -1
- package/build/cjs/lib/store/engine/lib/redis/index.d.ts +0 -82
- package/build/cjs/lib/store/engine/lib/redis/index.js +0 -132
- package/build/cjs/lib/store/engine/lib/redis/index.js.map +0 -1
- package/build/cjs/lib/store/index.d.ts +0 -22
- package/build/cjs/lib/store/index.js +0 -38
- package/build/cjs/lib/store/index.js.map +0 -1
- package/build/cjs/lib/whatsapp/index.d.ts +0 -179
- package/build/cjs/lib/whatsapp/index.js +0 -754
- package/build/cjs/lib/whatsapp/index.js.map +0 -1
- package/build/cjs/package.json +0 -1
- package/build/esm/decorators.d.ts +0 -9
- package/build/esm/decorators.js +0 -9
- package/build/esm/decorators.js.map +0 -1
- package/build/esm/index.d.ts +0 -9
- package/build/esm/index.js +0 -8
- package/build/esm/index.js.map +0 -1
- package/build/esm/lib/bot/decorator.d.ts +0 -77
- package/build/esm/lib/bot/decorator.js +0 -210
- package/build/esm/lib/bot/decorator.js.map +0 -1
- package/build/esm/lib/bot/decorators.d.ts +0 -113
- package/build/esm/lib/bot/decorators.js +0 -242
- package/build/esm/lib/bot/decorators.js.map +0 -1
- package/build/esm/lib/bot/index.d.ts +0 -3
- package/build/esm/lib/bot/index.js +0 -3
- package/build/esm/lib/bot/index.js.map +0 -1
- package/build/esm/lib/chat/index.d.ts +0 -227
- package/build/esm/lib/chat/index.js +0 -319
- package/build/esm/lib/chat/index.js.map +0 -1
- package/build/esm/lib/contact/index.d.ts +0 -203
- package/build/esm/lib/contact/index.js +0 -221
- package/build/esm/lib/contact/index.js.map +0 -1
- package/build/esm/lib/message/index.d.ts +0 -237
- package/build/esm/lib/message/index.js +0 -673
- package/build/esm/lib/message/index.js.map +0 -1
- package/build/esm/lib/store/engine/index.d.ts +0 -34
- package/build/esm/lib/store/engine/index.js +0 -8
- package/build/esm/lib/store/engine/index.js.map +0 -1
- package/build/esm/lib/store/engine/lib/file_system/index.d.ts +0 -56
- package/build/esm/lib/store/engine/lib/file_system/index.js +0 -156
- package/build/esm/lib/store/engine/lib/file_system/index.js.map +0 -1
- package/build/esm/lib/store/engine/lib/redis/index.d.ts +0 -82
- package/build/esm/lib/store/engine/lib/redis/index.js +0 -128
- package/build/esm/lib/store/engine/lib/redis/index.js.map +0 -1
- package/build/esm/lib/store/index.d.ts +0 -22
- package/build/esm/lib/store/index.js +0 -31
- package/build/esm/lib/store/index.js.map +0 -1
- package/build/esm/lib/whatsapp/index.d.ts +0 -179
- package/build/esm/lib/whatsapp/index.js +0 -714
- package/build/esm/lib/whatsapp/index.js.map +0 -1
- package/build/esm/package.json +0 -1
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file whatsapp/index.ts
|
|
3
|
-
* @description Orquestador principal del cliente WhatsApp v3.
|
|
4
|
-
* Main orchestrator of the WhatsApp v3 client.
|
|
5
|
-
*/
|
|
6
|
-
import { type WASocket } from 'baileys';
|
|
7
|
-
import { chat } from '../../lib/chat/index.js';
|
|
8
|
-
import { contact } from '../../lib/contact/index.js';
|
|
9
|
-
import { message, Message } from '../../lib/message/index.js';
|
|
10
|
-
import { type Engine } from '../../lib/store/index.js';
|
|
11
|
-
/**
|
|
12
|
-
* Opciones del cliente WhatsApp.
|
|
13
|
-
* WhatsApp client options.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Configuración de reconexión automática tras cierres no-loggedOut.
|
|
17
|
-
* - `true` (default): reintenta indefinidamente con 60s de intervalo.
|
|
18
|
-
* - `false`: no reconecta.
|
|
19
|
-
* - `number`: máximo N reintentos con 60s de intervalo.
|
|
20
|
-
* - `{ max, interval }`: control explícito (interval en segundos).
|
|
21
|
-
*
|
|
22
|
-
* Automatic reconnection config for non-loggedOut closes.
|
|
23
|
-
*/
|
|
24
|
-
export type ReconnectOption = boolean | number | {
|
|
25
|
-
max?: number;
|
|
26
|
-
interval?: number;
|
|
27
|
-
};
|
|
28
|
-
export interface IWhatsApp {
|
|
29
|
-
/** Motor de almacenamiento. / Storage engine. */
|
|
30
|
-
engine: Engine;
|
|
31
|
-
/** Teléfono para emparejamiento por PIN. Si falta, se usa QR. / Phone for PIN pairing; QR otherwise. */
|
|
32
|
-
phone?: number | string;
|
|
33
|
-
/**
|
|
34
|
-
* Si al recibir `loggedOut` debe limpiar todo el engine (default: `true`).
|
|
35
|
-
* Si es `false`, solo elimina `/session/creds` y preserva historial.
|
|
36
|
-
*
|
|
37
|
-
* Whether to clear the entire engine on `loggedOut` (default: `true`).
|
|
38
|
-
*/
|
|
39
|
-
autoclean?: boolean;
|
|
40
|
-
/** Reconexión automática tras cierres no-loggedOut. Default: `true`. / Auto-reconnect on non-loggedOut closes. */
|
|
41
|
-
reconnect?: ReconnectOption;
|
|
42
|
-
/** Sincroniza historial completo desde el móvil (default: `false`). / Sync full history from phone. */
|
|
43
|
-
sync?: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Opciones de desconexión.
|
|
47
|
-
* Disconnect options.
|
|
48
|
-
*/
|
|
49
|
-
export interface DisconnectOptions {
|
|
50
|
-
/** No emitir evento de cierre. / Suppress close emission. */
|
|
51
|
-
silent?: boolean;
|
|
52
|
-
/** Vaciar el engine tras cerrar. / Clear the engine after closing. */
|
|
53
|
-
destroy?: boolean;
|
|
54
|
-
}
|
|
55
|
-
type MessageInstance = Message;
|
|
56
|
-
type ChatInstance = InstanceType<ReturnType<typeof chat>>;
|
|
57
|
-
type ContactInstance = InstanceType<ReturnType<typeof contact>>;
|
|
58
|
-
/**
|
|
59
|
-
* Mapa de eventos emitidos por el cliente. Cada listener recibe el artefacto principal seguido
|
|
60
|
-
* de la instancia del cliente como último argumento.
|
|
61
|
-
* Map of events emitted by the client. Each listener receives the primary payload followed by
|
|
62
|
-
* the client instance as the last argument.
|
|
63
|
-
*/
|
|
64
|
-
interface WhatsAppEventMap {
|
|
65
|
-
connected: [WhatsApp];
|
|
66
|
-
disconnected: [WhatsApp];
|
|
67
|
-
'contact:created': [ContactInstance, ChatInstance, WhatsApp];
|
|
68
|
-
'contact:updated': [ContactInstance, ChatInstance, WhatsApp];
|
|
69
|
-
'contact:deleted': [ContactInstance, ChatInstance, WhatsApp];
|
|
70
|
-
'chat:created': [ChatInstance, WhatsApp];
|
|
71
|
-
'chat:deleted': [ChatInstance, WhatsApp];
|
|
72
|
-
'chat:pinned': [ChatInstance, WhatsApp];
|
|
73
|
-
'chat:unpinned': [ChatInstance, WhatsApp];
|
|
74
|
-
'chat:archived': [ChatInstance, WhatsApp];
|
|
75
|
-
'chat:unarchived': [ChatInstance, WhatsApp];
|
|
76
|
-
'chat:muted': [ChatInstance, WhatsApp];
|
|
77
|
-
'chat:unmuted': [ChatInstance, WhatsApp];
|
|
78
|
-
'message:created': [MessageInstance, ChatInstance, WhatsApp];
|
|
79
|
-
'message:updated': [MessageInstance, ChatInstance, WhatsApp];
|
|
80
|
-
'message:deleted': [MessageInstance, ChatInstance, WhatsApp];
|
|
81
|
-
'message:reacted': [MessageInstance, ChatInstance, string, WhatsApp];
|
|
82
|
-
'message:starred': [MessageInstance, ChatInstance, WhatsApp];
|
|
83
|
-
'message:unstarred': [MessageInstance, ChatInstance, WhatsApp];
|
|
84
|
-
'message:forwarded': [MessageInstance, ChatInstance, WhatsApp];
|
|
85
|
-
'message:seen': [MessageInstance, ChatInstance, WhatsApp];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Cliente principal de WhatsApp. No inicia la conexión al instanciar.
|
|
89
|
-
* Main WhatsApp client. Does not connect on instantiation.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* const wa = new WhatsApp({ engine: new FileSystemEngine(__dirname), phone: 584144709840 });
|
|
93
|
-
* wa.on('message:created', (msg) => console.log(msg.caption));
|
|
94
|
-
* await wa.connect((code) => console.log(code));
|
|
95
|
-
*/
|
|
96
|
-
export declare class WhatsApp {
|
|
97
|
-
private readonly _phone?;
|
|
98
|
-
private readonly _event;
|
|
99
|
-
private readonly _autoclean;
|
|
100
|
-
private readonly _reconnect;
|
|
101
|
-
private readonly _sync;
|
|
102
|
-
/** @internal */
|
|
103
|
-
_socket: WASocket | null;
|
|
104
|
-
private _intentional_close;
|
|
105
|
-
private _has_connected;
|
|
106
|
-
private _retry_timer;
|
|
107
|
-
private _retry_count;
|
|
108
|
-
readonly engine: Engine;
|
|
109
|
-
readonly Contact: ReturnType<typeof contact>;
|
|
110
|
-
readonly Chat: ReturnType<typeof chat>;
|
|
111
|
-
readonly Message: ReturnType<typeof message>;
|
|
112
|
-
constructor(options: IWhatsApp);
|
|
113
|
-
/** @internal */
|
|
114
|
-
private _parse_reconnect;
|
|
115
|
-
/**
|
|
116
|
-
* Registra un listener de evento. Retorna función para desuscribirse.
|
|
117
|
-
* Registers an event listener. Returns an unsubscribe function.
|
|
118
|
-
*/
|
|
119
|
-
on<E extends keyof WhatsAppEventMap>(event: E, handler: (...args: WhatsAppEventMap[E]) => void): () => void;
|
|
120
|
-
/**
|
|
121
|
-
* Quita un listener previamente registrado.
|
|
122
|
-
* Removes a previously registered listener.
|
|
123
|
-
*/
|
|
124
|
-
off<E extends keyof WhatsAppEventMap>(event: E, handler: (...args: WhatsAppEventMap[E]) => void): this;
|
|
125
|
-
/**
|
|
126
|
-
* Registra un listener one-shot. Retorna función para desuscribirse antes de que dispare.
|
|
127
|
-
* Registers a one-shot listener. Returns an unsubscribe function.
|
|
128
|
-
*/
|
|
129
|
-
once<E extends keyof WhatsAppEventMap>(event: E, handler: (...args: WhatsAppEventMap[E]) => void): () => void;
|
|
130
|
-
/**
|
|
131
|
-
* @internal
|
|
132
|
-
* Normaliza cualquier identificador (JID, LID, número, etc.) a JID canónico.
|
|
133
|
-
* Uso interno de la librería — no forma parte de la API pública.
|
|
134
|
-
*/
|
|
135
|
-
_resolve_jid(uid: string): Promise<string | null>;
|
|
136
|
-
/**
|
|
137
|
-
* Inicia la conexión. El callback recibe el PIN (string) si se configuró `phone`, o el QR (Buffer PNG) si no.
|
|
138
|
-
* Resuelve cuando la sesión sincroniza; reintenta automáticamente en cierres no-loggedOut.
|
|
139
|
-
*
|
|
140
|
-
* Starts the connection. Callback receives the PIN (string) when `phone` is configured, or the QR (PNG Buffer) otherwise.
|
|
141
|
-
* Resolves once the session is synced; retries on non-loggedOut disconnects.
|
|
142
|
-
*/
|
|
143
|
-
connect(callback: (auth: string | Buffer) => void | Promise<void>): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Cierra la conexión. Con `destroy: true` vacía el engine completo.
|
|
146
|
-
* Closes the connection. With `destroy: true` clears the engine entirely.
|
|
147
|
-
*/
|
|
148
|
-
disconnect(options?: DisconnectOptions): Promise<void>;
|
|
149
|
-
/**
|
|
150
|
-
* Conecta los handlers de eventos de baileys: contactos, chats y mensajes.
|
|
151
|
-
* Wires baileys event handlers: contacts, chats and messages.
|
|
152
|
-
*
|
|
153
|
-
* @internal
|
|
154
|
-
*/
|
|
155
|
-
private _attach_business_handlers;
|
|
156
|
-
/** @internal */
|
|
157
|
-
private _handle_contacts_upsert;
|
|
158
|
-
/** @internal */
|
|
159
|
-
private _handle_contacts_update;
|
|
160
|
-
/** @internal */
|
|
161
|
-
private _handle_lid_mapping;
|
|
162
|
-
/** @internal */
|
|
163
|
-
private _handle_chats_upsert;
|
|
164
|
-
/** @internal */
|
|
165
|
-
private _handle_chats_update;
|
|
166
|
-
/** @internal */
|
|
167
|
-
private _handle_chats_delete;
|
|
168
|
-
/** @internal */
|
|
169
|
-
private _handle_contacts_delete;
|
|
170
|
-
/** @internal */
|
|
171
|
-
private _handle_message_receipt;
|
|
172
|
-
/** @internal */
|
|
173
|
-
private _handle_messages_upsert;
|
|
174
|
-
/** @internal */
|
|
175
|
-
private _handle_messages_update;
|
|
176
|
-
/** @internal */
|
|
177
|
-
private _handle_messages_reaction;
|
|
178
|
-
}
|
|
179
|
-
export default WhatsApp;
|