@arcaelas/whatsapp 4.4.0 → 5.1.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.
- package/build/cjs/index.d.ts +6 -4
- package/build/cjs/index.js +22 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/bot/decorator.d.ts +2 -0
- package/build/cjs/lib/bot/decorator.js +6 -0
- package/build/cjs/lib/bot/decorator.js.map +1 -1
- package/build/cjs/lib/chat/index.d.ts +340 -204
- package/build/cjs/lib/chat/index.js +225 -213
- package/build/cjs/lib/chat/index.js.map +1 -1
- package/build/cjs/lib/contact/index.d.ts +162 -179
- package/build/cjs/lib/contact/index.js +96 -190
- package/build/cjs/lib/contact/index.js.map +1 -1
- package/build/cjs/lib/internal.d.ts +40 -0
- package/build/cjs/lib/internal.js +39 -0
- package/build/cjs/lib/internal.js.map +1 -0
- package/build/cjs/lib/message/index.d.ts +463 -278
- package/build/cjs/lib/message/index.js +830 -710
- package/build/cjs/lib/message/index.js.map +1 -1
- package/build/cjs/lib/status/index.d.ts +60 -70
- package/build/cjs/lib/status/index.js +106 -111
- package/build/cjs/lib/status/index.js.map +1 -1
- package/build/cjs/lib/store/engine/index.d.ts +21 -7
- package/build/cjs/lib/store/engine/index.js +6 -3
- package/build/cjs/lib/store/engine/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +38 -8
- package/build/cjs/lib/store/engine/lib/file_system/index.js +92 -67
- package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/index.d.ts +112 -0
- package/build/cjs/lib/store/engine/lib/index.js +213 -0
- package/build/cjs/lib/store/engine/lib/index.js.map +1 -0
- package/build/cjs/lib/store/engine/lib/redis/index.d.ts +28 -13
- package/build/cjs/lib/store/engine/lib/redis/index.js +56 -42
- package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/s3/index.d.ts +44 -1
- package/build/cjs/lib/store/engine/lib/s3/index.js +112 -64
- package/build/cjs/lib/store/engine/lib/s3/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/sqlite/index.d.ts +98 -0
- package/build/cjs/lib/store/engine/lib/sqlite/index.js +114 -0
- package/build/cjs/lib/store/engine/lib/sqlite/index.js.map +1 -0
- package/build/cjs/lib/store/index.d.ts +7 -3
- package/build/cjs/lib/store/index.js +14 -4
- package/build/cjs/lib/store/index.js.map +1 -1
- package/build/cjs/lib/whatsapp/index.d.ts +117 -63
- package/build/cjs/lib/whatsapp/index.js +404 -184
- package/build/cjs/lib/whatsapp/index.js.map +1 -1
- package/build/cjs/test.d.ts +1 -0
- package/build/cjs/test.js +72 -0
- package/build/cjs/test.js.map +1 -0
- package/build/esm/index.d.ts +6 -4
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/bot/decorator.d.ts +2 -0
- package/build/esm/lib/bot/decorator.js +6 -0
- package/build/esm/lib/bot/decorator.js.map +1 -1
- package/build/esm/lib/chat/index.d.ts +340 -204
- package/build/esm/lib/chat/index.js +225 -213
- package/build/esm/lib/chat/index.js.map +1 -1
- package/build/esm/lib/contact/index.d.ts +162 -179
- package/build/esm/lib/contact/index.js +96 -189
- package/build/esm/lib/contact/index.js.map +1 -1
- package/build/esm/lib/internal.d.ts +40 -0
- package/build/esm/lib/internal.js +35 -0
- package/build/esm/lib/internal.js.map +1 -0
- package/build/esm/lib/message/index.d.ts +463 -278
- package/build/esm/lib/message/index.js +825 -705
- package/build/esm/lib/message/index.js.map +1 -1
- package/build/esm/lib/status/index.d.ts +60 -70
- package/build/esm/lib/status/index.js +105 -110
- package/build/esm/lib/status/index.js.map +1 -1
- package/build/esm/lib/store/engine/index.d.ts +21 -7
- package/build/esm/lib/store/engine/index.js +4 -2
- package/build/esm/lib/store/engine/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/file_system/index.d.ts +38 -8
- package/build/esm/lib/store/engine/lib/file_system/index.js +92 -67
- package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/index.d.ts +112 -0
- package/build/esm/lib/store/engine/lib/index.js +206 -0
- package/build/esm/lib/store/engine/lib/index.js.map +1 -0
- package/build/esm/lib/store/engine/lib/redis/index.d.ts +28 -13
- package/build/esm/lib/store/engine/lib/redis/index.js +54 -40
- package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/s3/index.d.ts +44 -1
- package/build/esm/lib/store/engine/lib/s3/index.js +111 -63
- package/build/esm/lib/store/engine/lib/s3/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/sqlite/index.d.ts +98 -0
- package/build/esm/lib/store/engine/lib/sqlite/index.js +110 -0
- package/build/esm/lib/store/engine/lib/sqlite/index.js.map +1 -0
- package/build/esm/lib/store/index.d.ts +7 -3
- package/build/esm/lib/store/index.js +13 -4
- package/build/esm/lib/store/index.js.map +1 -1
- package/build/esm/lib/whatsapp/index.d.ts +117 -63
- package/build/esm/lib/whatsapp/index.js +406 -186
- package/build/esm/lib/whatsapp/index.js.map +1 -1
- package/build/esm/test.d.ts +1 -0
- package/build/esm/test.js +67 -0
- package/build/esm/test.js.map +1 -0
- package/package.json +2 -2
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* @description Orquestador principal del cliente WhatsApp v3.
|
|
4
4
|
* Main orchestrator of the WhatsApp v3 client.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { message, Message } from '../../lib/message/index.js';
|
|
11
|
-
import Feed from '../../lib/status/index.js';
|
|
6
|
+
import { chat, Chat } from '../../lib/chat/index.js';
|
|
7
|
+
import { contact, Contact } from '../../lib/contact/index.js';
|
|
8
|
+
import { Audio, Document, Event, Image, Location, Message, Poll, Sticker, Text, VCard, Video } from '../../lib/message/index.js';
|
|
9
|
+
import { Feed } from '../../lib/status/index.js';
|
|
12
10
|
import { type Engine } from '../../lib/store/index.js';
|
|
13
11
|
/**
|
|
14
12
|
* Opciones del cliente WhatsApp.
|
|
@@ -30,8 +28,19 @@ export type ReconnectOption = boolean | number | {
|
|
|
30
28
|
export interface IWhatsApp {
|
|
31
29
|
/** Motor de almacenamiento. / Storage engine. */
|
|
32
30
|
engine: Engine;
|
|
33
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Teléfono de la cuenta. Su presencia habilita el emparejamiento por PIN; sin él la
|
|
33
|
+
* vinculación es siempre por QR.
|
|
34
|
+
* Account phone. Its presence enables PIN pairing; without it linking is always by QR.
|
|
35
|
+
*/
|
|
34
36
|
phone?: number | string;
|
|
37
|
+
/**
|
|
38
|
+
* Elige el canal de vinculación **cuando hay `phone`**: `otp` (default) o `qr`. Sin
|
|
39
|
+
* `phone` la opción se ignora, porque el PIN no puede pedirse sin número.
|
|
40
|
+
* Picks the linking channel **when `phone` is set**: `otp` (default) or `qr`. Without
|
|
41
|
+
* `phone` it is ignored, since a PIN cannot be requested without a number.
|
|
42
|
+
*/
|
|
43
|
+
method?: 'qr' | 'otp';
|
|
35
44
|
/**
|
|
36
45
|
* Si al recibir `loggedOut` debe limpiar todo el engine (default: `true`).
|
|
37
46
|
* Si es `false`, solo elimina `/session/creds` y preserva historial.
|
|
@@ -41,7 +50,14 @@ export interface IWhatsApp {
|
|
|
41
50
|
autoclean?: boolean;
|
|
42
51
|
/** Reconexión automática tras cierres no-loggedOut. Default: `true`. / Auto-reconnect on non-loggedOut closes. */
|
|
43
52
|
reconnect?: ReconnectOption;
|
|
44
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Descarga del historial de mensajes al vincular (default: `true`). Sólo afecta los
|
|
55
|
+
* mensajes: contactos, credenciales, LID mappings y tctokens se sincronizan siempre
|
|
56
|
+
* (rc13 los exige para enviar). `false` omite únicamente el historial de mensajes.
|
|
57
|
+
*
|
|
58
|
+
* Message-history download on link (default: `true`). Messages only: contacts,
|
|
59
|
+
* credentials, LID mappings and tctokens always sync (rc13 requires them to send).
|
|
60
|
+
*/
|
|
45
61
|
sync?: boolean;
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
@@ -49,11 +65,13 @@ export interface IWhatsApp {
|
|
|
49
65
|
* Disconnect options.
|
|
50
66
|
*/
|
|
51
67
|
export interface DisconnectOptions {
|
|
52
|
-
/** No emitir evento de cierre. / Suppress close
|
|
68
|
+
/** No emitir el evento `disconnected` de este cierre. / Suppress this close's `disconnected` event. */
|
|
53
69
|
silent?: boolean;
|
|
54
70
|
/** Vaciar el engine tras cerrar. / Clear the engine after closing. */
|
|
55
71
|
destroy?: boolean;
|
|
56
72
|
}
|
|
73
|
+
/** Argumentos de un estático de envío sin el cliente ni el cid. / Send-static arguments without client and cid. */
|
|
74
|
+
type Tail<P extends unknown[]> = P extends [unknown, unknown, ...infer R] ? R : never;
|
|
57
75
|
type MessageInstance = Message;
|
|
58
76
|
type ChatInstance = InstanceType<ReturnType<typeof chat>>;
|
|
59
77
|
type ContactInstance = InstanceType<ReturnType<typeof contact>>;
|
|
@@ -98,25 +116,69 @@ interface WhatsAppEventMap {
|
|
|
98
116
|
* await wa.connect((code) => console.log(code));
|
|
99
117
|
*/
|
|
100
118
|
export declare class WhatsApp {
|
|
101
|
-
private
|
|
102
|
-
/**
|
|
103
|
-
readonly _event: EventEmitter<WhatsAppEventMap>;
|
|
104
|
-
private readonly _autoclean;
|
|
105
|
-
private readonly _reconnect;
|
|
106
|
-
private readonly _sync;
|
|
107
|
-
/** @internal */
|
|
108
|
-
_socket: WASocket | null;
|
|
109
|
-
private _intentional_close;
|
|
110
|
-
private _has_connected;
|
|
111
|
-
private _retry_timer;
|
|
112
|
-
private _retry_count;
|
|
119
|
+
#private;
|
|
120
|
+
/** Motor de almacenamiento de la sesión. / Session storage engine. */
|
|
113
121
|
readonly engine: Engine;
|
|
122
|
+
/** Entidad `Contact` ligada a este cliente. / `Contact` entity bound to this client. */
|
|
114
123
|
readonly Contact: ReturnType<typeof contact>;
|
|
124
|
+
/** Entidad `Chat` ligada a este cliente. / `Chat` entity bound to this client. */
|
|
115
125
|
readonly Chat: ReturnType<typeof chat>;
|
|
116
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Entidad `Message` ligada a este cliente: los mismos estáticos de `Message` sin repetir
|
|
128
|
+
* la instancia, más las subclases para `instanceof`.
|
|
129
|
+
* `Message` entity bound to this client: the same `Message` statics without repeating the
|
|
130
|
+
* instance, plus the subclasses for `instanceof`.
|
|
131
|
+
*/
|
|
132
|
+
readonly Message: {
|
|
133
|
+
get: (cid: string, mid: string) => ReturnType<typeof Message.get>;
|
|
134
|
+
list: (cid: string, offset?: number, limit?: number) => ReturnType<typeof Message.list>;
|
|
135
|
+
text: (cid: string, ...rest: Tail<Parameters<typeof Message.text>>) => ReturnType<typeof Message.text>;
|
|
136
|
+
image: (cid: string, ...rest: Tail<Parameters<typeof Message.image>>) => ReturnType<typeof Message.image>;
|
|
137
|
+
video: (cid: string, ...rest: Tail<Parameters<typeof Message.video>>) => ReturnType<typeof Message.video>;
|
|
138
|
+
audio: (cid: string, ...rest: Tail<Parameters<typeof Message.audio>>) => ReturnType<typeof Message.audio>;
|
|
139
|
+
location: (cid: string, ...rest: Tail<Parameters<typeof Message.location>>) => ReturnType<typeof Message.location>;
|
|
140
|
+
poll: (cid: string, ...rest: Tail<Parameters<typeof Message.poll>>) => ReturnType<typeof Message.poll>;
|
|
141
|
+
document: (cid: string, ...rest: Tail<Parameters<typeof Message.document>>) => ReturnType<typeof Message.document>;
|
|
142
|
+
vcard: (cid: string, ...rest: Tail<Parameters<typeof Message.vcard>>) => ReturnType<typeof Message.vcard>;
|
|
143
|
+
event: (cid: string, ...rest: Tail<Parameters<typeof Message.event>>) => ReturnType<typeof Message.event>;
|
|
144
|
+
react: (cid: string, mid: string, emoji: string) => Promise<boolean>;
|
|
145
|
+
star: (cid: string, mid: string, value: boolean) => Promise<boolean>;
|
|
146
|
+
seen: (cid: string, mid: string) => Promise<boolean>;
|
|
147
|
+
edit: (cid: string, mid: string, caption: string) => Promise<boolean>;
|
|
148
|
+
forward: (cid: string, mid: string, target: string | Chat | Contact) => Promise<boolean>;
|
|
149
|
+
delete: (cid: string, mid: string, all?: boolean) => Promise<boolean>;
|
|
150
|
+
reactions: (cid: string, mid: string) => Promise<{
|
|
151
|
+
emoji: string;
|
|
152
|
+
count: number;
|
|
153
|
+
}[]>;
|
|
154
|
+
Text: typeof Text;
|
|
155
|
+
Image: typeof Image;
|
|
156
|
+
Video: typeof Video;
|
|
157
|
+
Audio: typeof Audio;
|
|
158
|
+
Sticker: typeof Sticker;
|
|
159
|
+
Document: typeof Document;
|
|
160
|
+
Location: typeof Location;
|
|
161
|
+
Poll: typeof Poll;
|
|
162
|
+
VCard: typeof VCard;
|
|
163
|
+
Event: typeof Event;
|
|
164
|
+
};
|
|
117
165
|
constructor(options: IWhatsApp);
|
|
118
|
-
/**
|
|
119
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Contacto de la cuenta autenticada, o null mientras no hay sesión abierta.
|
|
168
|
+
* Authenticated account's contact, or null while there is no open session.
|
|
169
|
+
*/
|
|
170
|
+
get contact(): InstanceType<ReturnType<typeof contact>> | null;
|
|
171
|
+
/**
|
|
172
|
+
* Emite un evento del cliente. Lo usan las entidades de la librería para propagar los
|
|
173
|
+
* cambios que provocan; el consumidor puede emitir los suyos para pruebas.
|
|
174
|
+
* Emits a client event. Library entities use it to propagate the changes they cause;
|
|
175
|
+
* consumers may emit their own for testing.
|
|
176
|
+
*
|
|
177
|
+
* @param event - Nombre del evento / Event name
|
|
178
|
+
* @param args - Argumentos del evento / Event arguments
|
|
179
|
+
* @returns true si había listeners / true when listeners were present
|
|
180
|
+
*/
|
|
181
|
+
emit<E extends keyof WhatsAppEventMap>(event: E, ...args: WhatsAppEventMap[E]): boolean;
|
|
120
182
|
/**
|
|
121
183
|
* Registra un listener de evento. Retorna función para desuscribirse.
|
|
122
184
|
* Registers an event listener. Returns an unsubscribe function.
|
|
@@ -132,12 +194,6 @@ export declare class WhatsApp {
|
|
|
132
194
|
* Registers a one-shot listener. Returns an unsubscribe function.
|
|
133
195
|
*/
|
|
134
196
|
once<E extends keyof WhatsAppEventMap>(event: E, handler: (...args: WhatsAppEventMap[E]) => void): () => void;
|
|
135
|
-
/**
|
|
136
|
-
* @internal
|
|
137
|
-
* Normaliza cualquier identificador (JID, LID, número, etc.) a JID canónico.
|
|
138
|
-
* Uso interno de la librería — no forma parte de la API pública.
|
|
139
|
-
*/
|
|
140
|
-
_resolve_jid(uid: string): Promise<string | null>;
|
|
141
197
|
/**
|
|
142
198
|
* Inicia la conexión. El callback recibe el PIN (string) si se configuró `phone`, o el QR (Buffer PNG) si no.
|
|
143
199
|
* Resuelve cuando la sesión sincroniza; reintenta automáticamente en cierres no-loggedOut.
|
|
@@ -147,44 +203,42 @@ export declare class WhatsApp {
|
|
|
147
203
|
*/
|
|
148
204
|
connect(callback: (auth: string | Buffer) => void | Promise<void>): Promise<void>;
|
|
149
205
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
206
|
+
* Actualiza el perfil de la cuenta en WhatsApp: nombre público, bio y/o foto. Sólo se
|
|
207
|
+
* envía lo que llega en el parche; `photo: null` elimina la foto actual.
|
|
208
|
+
* Updates the account profile on WhatsApp: public name, bio and/or picture. Only the
|
|
209
|
+
* given fields are sent; `photo: null` removes the current picture.
|
|
210
|
+
*
|
|
211
|
+
* @param patch - Campos a actualizar / Fields to update
|
|
212
|
+
* @returns true si todo lo pedido se envió / true when everything requested was sent
|
|
213
|
+
* @throws ERR_PROFILE_PICTURE_LIB si falta `sharp` o `jimp` para procesar la foto / when `sharp` or `jimp` is missing to process the picture
|
|
152
214
|
*/
|
|
153
|
-
|
|
215
|
+
profile(patch: {
|
|
216
|
+
name?: string;
|
|
217
|
+
content?: string;
|
|
218
|
+
photo?: string | Buffer | null;
|
|
219
|
+
}): Promise<boolean>;
|
|
154
220
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
221
|
+
* Publica un estado (status broadcast). Con sólo `caption` publica texto; con `content`
|
|
222
|
+
* publica imagen o video (el tipo se deduce del binario) usando `caption` como pie.
|
|
223
|
+
* `contacts` es la audiencia: WhatsApp no reparte el estado a quien no esté en la lista.
|
|
224
|
+
* Publishes a status broadcast. With only `caption` it posts text; with `content` it
|
|
225
|
+
* posts an image or video (type inferred from the binary) using `caption` as its footer.
|
|
226
|
+
* `contacts` is the audience: WhatsApp does not deliver the status to anyone outside it.
|
|
157
227
|
*
|
|
158
|
-
* @
|
|
228
|
+
* @param post - Contenido, pie y audiencia / Content, caption and audience
|
|
229
|
+
* @returns Publicación creada, o null si no hay sesión / Created post, or null without a session
|
|
230
|
+
* @throws ERR_FEED_EMPTY sin `content` ni `caption` / when neither `content` nor `caption` is given
|
|
231
|
+
* @throws ERR_FEED_MEDIA si el binario no es imagen ni video / when the binary is neither image nor video
|
|
159
232
|
*/
|
|
160
|
-
|
|
233
|
+
feed(post: {
|
|
234
|
+
content?: Buffer;
|
|
235
|
+
caption?: string;
|
|
236
|
+
contacts: (string | number)[];
|
|
237
|
+
}): Promise<Feed | null>;
|
|
161
238
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @param raw - Documento del contacto a persistir / Contact document to persist
|
|
166
|
-
* @internal
|
|
239
|
+
* Cierra la conexión. Con `destroy: true` vacía el engine completo.
|
|
240
|
+
* Closes the connection. With `destroy: true` clears the engine entirely.
|
|
167
241
|
*/
|
|
168
|
-
|
|
169
|
-
/** @internal */
|
|
170
|
-
private _handle_contacts_upsert;
|
|
171
|
-
/** @internal */
|
|
172
|
-
private _handle_contacts_update;
|
|
173
|
-
/** @internal */
|
|
174
|
-
private _handle_lid_mapping;
|
|
175
|
-
/** @internal */
|
|
176
|
-
private _handle_chats_upsert;
|
|
177
|
-
/** @internal */
|
|
178
|
-
private _handle_chats_update;
|
|
179
|
-
/** @internal */
|
|
180
|
-
private _handle_chats_delete;
|
|
181
|
-
/** @internal */
|
|
182
|
-
private _handle_message_receipt;
|
|
183
|
-
/** @internal */
|
|
184
|
-
private _handle_messages_upsert;
|
|
185
|
-
/** @internal */
|
|
186
|
-
private _handle_messages_update;
|
|
187
|
-
/** @internal */
|
|
188
|
-
private _handle_messages_reaction;
|
|
242
|
+
disconnect(options?: DisconnectOptions): Promise<void>;
|
|
189
243
|
}
|
|
190
244
|
export default WhatsApp;
|