@arcaelas/whatsapp 4.5.0 → 6.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 (106) hide show
  1. package/README.md +282 -239
  2. package/build/cjs/decorators.js +0 -1
  3. package/build/cjs/index.d.ts +6 -4
  4. package/build/cjs/index.js +22 -3
  5. package/build/cjs/lib/bot/decorator.d.ts +2 -0
  6. package/build/cjs/lib/bot/decorator.js +6 -1
  7. package/build/cjs/lib/bot/decorators.d.ts +2 -2
  8. package/build/cjs/lib/bot/decorators.js +4 -4
  9. package/build/cjs/lib/bot/index.js +0 -1
  10. package/build/cjs/lib/chat/index.d.ts +381 -204
  11. package/build/cjs/lib/chat/index.js +243 -212
  12. package/build/cjs/lib/contact/index.d.ts +162 -179
  13. package/build/cjs/lib/contact/index.js +96 -191
  14. package/build/cjs/lib/internal.d.ts +40 -0
  15. package/build/cjs/lib/internal.js +38 -0
  16. package/build/cjs/lib/message/index.d.ts +468 -289
  17. package/build/cjs/lib/message/index.js +871 -743
  18. package/build/cjs/lib/status/index.d.ts +60 -70
  19. package/build/cjs/lib/status/index.js +106 -112
  20. package/build/cjs/lib/store/engine/index.d.ts +35 -7
  21. package/build/cjs/lib/store/engine/index.js +6 -4
  22. package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +48 -8
  23. package/build/cjs/lib/store/engine/lib/file_system/index.js +117 -66
  24. package/build/cjs/lib/store/engine/lib/index.d.ts +112 -0
  25. package/build/cjs/lib/store/engine/lib/index.js +212 -0
  26. package/build/cjs/lib/store/engine/lib/redis/index.d.ts +44 -15
  27. package/build/cjs/lib/store/engine/lib/redis/index.js +75 -43
  28. package/build/cjs/lib/store/engine/lib/s3/index.d.ts +44 -1
  29. package/build/cjs/lib/store/engine/lib/s3/index.js +112 -65
  30. package/build/cjs/lib/store/engine/lib/sqlite/index.d.ts +110 -0
  31. package/build/cjs/lib/store/engine/lib/sqlite/index.js +132 -0
  32. package/build/cjs/lib/store/index.d.ts +7 -3
  33. package/build/cjs/lib/store/index.js +14 -5
  34. package/build/cjs/lib/whatsapp/index.d.ts +106 -68
  35. package/build/cjs/lib/whatsapp/index.js +393 -167
  36. package/build/esm/decorators.js +0 -1
  37. package/build/esm/index.d.ts +6 -4
  38. package/build/esm/index.js +5 -3
  39. package/build/esm/lib/bot/decorator.d.ts +2 -0
  40. package/build/esm/lib/bot/decorator.js +6 -1
  41. package/build/esm/lib/bot/decorators.d.ts +2 -2
  42. package/build/esm/lib/bot/decorators.js +4 -4
  43. package/build/esm/lib/bot/index.js +0 -1
  44. package/build/esm/lib/chat/index.d.ts +381 -204
  45. package/build/esm/lib/chat/index.js +243 -212
  46. package/build/esm/lib/contact/index.d.ts +162 -179
  47. package/build/esm/lib/contact/index.js +96 -190
  48. package/build/esm/lib/internal.d.ts +40 -0
  49. package/build/esm/lib/internal.js +34 -0
  50. package/build/esm/lib/message/index.d.ts +468 -289
  51. package/build/esm/lib/message/index.js +866 -738
  52. package/build/esm/lib/status/index.d.ts +60 -70
  53. package/build/esm/lib/status/index.js +105 -111
  54. package/build/esm/lib/store/engine/index.d.ts +35 -7
  55. package/build/esm/lib/store/engine/index.js +4 -3
  56. package/build/esm/lib/store/engine/lib/file_system/index.d.ts +48 -8
  57. package/build/esm/lib/store/engine/lib/file_system/index.js +117 -66
  58. package/build/esm/lib/store/engine/lib/index.d.ts +112 -0
  59. package/build/esm/lib/store/engine/lib/index.js +205 -0
  60. package/build/esm/lib/store/engine/lib/redis/index.d.ts +44 -15
  61. package/build/esm/lib/store/engine/lib/redis/index.js +73 -41
  62. package/build/esm/lib/store/engine/lib/s3/index.d.ts +44 -1
  63. package/build/esm/lib/store/engine/lib/s3/index.js +111 -64
  64. package/build/esm/lib/store/engine/lib/sqlite/index.d.ts +110 -0
  65. package/build/esm/lib/store/engine/lib/sqlite/index.js +128 -0
  66. package/build/esm/lib/store/index.d.ts +7 -3
  67. package/build/esm/lib/store/index.js +13 -5
  68. package/build/esm/lib/whatsapp/index.d.ts +106 -68
  69. package/build/esm/lib/whatsapp/index.js +395 -169
  70. package/package.json +25 -6
  71. package/build/cjs/decorators.js.map +0 -1
  72. package/build/cjs/index.js.map +0 -1
  73. package/build/cjs/lib/bot/decorator.js.map +0 -1
  74. package/build/cjs/lib/bot/decorators.js.map +0 -1
  75. package/build/cjs/lib/bot/index.js.map +0 -1
  76. package/build/cjs/lib/chat/index.js.map +0 -1
  77. package/build/cjs/lib/contact/index.js.map +0 -1
  78. package/build/cjs/lib/message/index.js.map +0 -1
  79. package/build/cjs/lib/status/index.js.map +0 -1
  80. package/build/cjs/lib/store/engine/index.js.map +0 -1
  81. package/build/cjs/lib/store/engine/lib/file_system/index.js.map +0 -1
  82. package/build/cjs/lib/store/engine/lib/redis/index.js.map +0 -1
  83. package/build/cjs/lib/store/engine/lib/s3/index.js.map +0 -1
  84. package/build/cjs/lib/store/index.js.map +0 -1
  85. package/build/cjs/lib/whatsapp/index.js.map +0 -1
  86. package/build/cjs/test.d.ts +0 -1
  87. package/build/cjs/test.js +0 -71
  88. package/build/cjs/test.js.map +0 -1
  89. package/build/esm/decorators.js.map +0 -1
  90. package/build/esm/index.js.map +0 -1
  91. package/build/esm/lib/bot/decorator.js.map +0 -1
  92. package/build/esm/lib/bot/decorators.js.map +0 -1
  93. package/build/esm/lib/bot/index.js.map +0 -1
  94. package/build/esm/lib/chat/index.js.map +0 -1
  95. package/build/esm/lib/contact/index.js.map +0 -1
  96. package/build/esm/lib/message/index.js.map +0 -1
  97. package/build/esm/lib/status/index.js.map +0 -1
  98. package/build/esm/lib/store/engine/index.js.map +0 -1
  99. package/build/esm/lib/store/engine/lib/file_system/index.js.map +0 -1
  100. package/build/esm/lib/store/engine/lib/redis/index.js.map +0 -1
  101. package/build/esm/lib/store/engine/lib/s3/index.js.map +0 -1
  102. package/build/esm/lib/store/index.js.map +0 -1
  103. package/build/esm/lib/whatsapp/index.js.map +0 -1
  104. package/build/esm/test.d.ts +0 -1
  105. package/build/esm/test.js +0 -66
  106. package/build/esm/test.js.map +0 -1
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @file store/engine/lib/sqlite/index.ts
3
+ * @description Driver de persistencia con SQLite.
4
+ * SQLite persistence driver.
5
+ */
6
+ import { normalize_path, split_path } from '../../../../../lib/store/engine/lib/index.js';
7
+ /**
8
+ * Driver de persistencia con SQLite: una tabla `(path, parent, score, value)` con índice
9
+ * `(parent, score DESC)`.
10
+ *
11
+ * Es el driver más eficiente de los integrados porque delega en el motor lo que los demás
12
+ * resuelven a mano: `list` es un `ORDER BY score DESC LIMIT/OFFSET` sobre el índice (sin
13
+ * índice en memoria ni archivo de orden), `count` un `COUNT(*)` y el `unset` en cascada una
14
+ * sola sentencia por rango de `path`. Medido sobre un chat real de 55.146 mensajes frente al
15
+ * filesystem: 220 MB → 64 MB en disco, primer `list` 115 ms → 0,6 ms y dos archivos en total.
16
+ *
17
+ * SQLite persistence driver: a single `(path, parent, score, value)` table with a
18
+ * `(parent, score DESC)` index. The most efficient built-in driver, since it delegates to the
19
+ * engine what the others hand-roll: `list` is an indexed `ORDER BY score DESC LIMIT/OFFSET`
20
+ * (no in-memory index, no order file), `count` a `COUNT(*)` and cascading `unset` a single
21
+ * range statement. Measured on a real 55,146-message chat against the filesystem: 220 MB →
22
+ * 64 MB on disk, first `list` 115 ms → 0.6 ms and two files in total.
23
+ *
24
+ * @example
25
+ * import Database from 'better-sqlite3';
26
+ * const engine = new SQLiteEngine(new Database('.sessions/584144709840.db'));
27
+ *
28
+ * @example
29
+ * import { DatabaseSync } from 'node:sqlite';
30
+ * const engine = new SQLiteEngine(new DatabaseSync('.sessions/584144709840.db'));
31
+ */
32
+ export class SQLiteEngine {
33
+ /**
34
+ * @param _db - Base SQLite ya abierta / Already open SQLite database
35
+ * @param table - Tabla donde viven los documentos / Table holding the documents
36
+ */
37
+ constructor(_db, table = 'documents') {
38
+ this._db = _db;
39
+ // WAL y synchronous NORMAL multiplican el rendimiento de escritura; se aplican con
40
+ // tolerancia porque un driver puede exponerlos como no-op o rechazarlos en :memory:.
41
+ // WAL and synchronous NORMAL greatly speed up writes; applied leniently since a driver
42
+ // may expose them as no-ops or reject them on :memory:.
43
+ try {
44
+ _db.exec('PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;');
45
+ }
46
+ catch {
47
+ /* optional tuning */
48
+ }
49
+ _db.exec(`CREATE TABLE IF NOT EXISTS ${table} (path TEXT PRIMARY KEY, parent TEXT NOT NULL, score INTEGER NOT NULL, value TEXT NOT NULL DEFAULT '', binary BLOB);
50
+ CREATE INDEX IF NOT EXISTS ${table}_order ON ${table} (parent, score DESC);`);
51
+ this._read = _db.prepare(`SELECT value FROM ${table} WHERE path = ?`);
52
+ this._write = _db.prepare(`INSERT INTO ${table} (path, parent, score, value) VALUES (?, ?, ?, ?)
53
+ ON CONFLICT(path) DO UPDATE SET value = excluded.value, score = excluded.score`);
54
+ // El sub-árbol se borra por rango en vez de con LIKE: '0' es el carácter siguiente a '/',
55
+ // así el rango cubre exactamente los descendientes y se resuelve con el índice de `path`.
56
+ // The subtree is deleted by range instead of LIKE: '0' is the character right after '/',
57
+ // so the range covers exactly the descendants and is served by the `path` index.
58
+ this._remove = _db.prepare(`DELETE FROM ${table} WHERE path = ? OR (path >= ? AND path < ?)`);
59
+ this._page = _db.prepare(`SELECT value FROM ${table} WHERE parent = ? ORDER BY score DESC LIMIT ? OFFSET ?`);
60
+ this._total = _db.prepare(`SELECT COUNT(*) AS total FROM ${table} WHERE parent = ?`);
61
+ this._wipe = _db.prepare(`DELETE FROM ${table}`);
62
+ this._read_blob = _db.prepare(`SELECT binary FROM ${table} WHERE path = ?`);
63
+ this._write_blob = _db.prepare(`INSERT INTO ${table} (path, parent, score, value, binary) VALUES (?, ?, ?, '', ?)
64
+ ON CONFLICT(path) DO UPDATE SET binary = excluded.binary, score = excluded.score`);
65
+ }
66
+ /**
67
+ * Lee el valor de un documento.
68
+ * Reads a document's value.
69
+ */
70
+ async get(path) {
71
+ return this._read.get(normalize_path(path))?.value ?? null;
72
+ }
73
+ /**
74
+ * Escribe el valor del documento; `score` fija el orden de `list` (por defecto, la hora
75
+ * de escritura).
76
+ * Writes the document value; `score` drives `list` ordering (write time by default).
77
+ */
78
+ async set(path, value, score) {
79
+ const { parent } = split_path(path);
80
+ this._write.run(normalize_path(path), parent, score ?? Date.now(), value);
81
+ }
82
+ /**
83
+ * Elimina el documento y todos sus descendientes. Idempotente.
84
+ * Deletes the document and every descendant. Idempotent.
85
+ */
86
+ async unset(path) {
87
+ const full = normalize_path(path);
88
+ this._remove.run(full, `${full}/`, `${full}0`);
89
+ return true;
90
+ }
91
+ /**
92
+ * Lista los valores de los hijos directos, ordenados por score DESC.
93
+ * Lists direct children values ordered by score DESC.
94
+ */
95
+ async list(path, offset = 0, limit = 50) {
96
+ return this._page.all(normalize_path(path), limit, offset).map((row) => row.value);
97
+ }
98
+ /**
99
+ * Cuenta los hijos directos.
100
+ * Counts direct children.
101
+ */
102
+ async count(path) {
103
+ return Number(this._total.get(normalize_path(path)).total);
104
+ }
105
+ /**
106
+ * Lee el binario del documento, o null si la fila no lo tiene.
107
+ * Reads the document binary, or null when the row has none.
108
+ */
109
+ async get_buffer(path) {
110
+ const row = this._read_blob.get(normalize_path(path));
111
+ return row?.binary ? Buffer.from(row.binary) : null;
112
+ }
113
+ /**
114
+ * Escribe el binario del documento como BLOB, sin JSON ni base64.
115
+ * Writes the document binary as a BLOB, with no JSON nor base64.
116
+ */
117
+ async set_buffer(path, data, score) {
118
+ const { parent } = split_path(path);
119
+ this._write_blob.run(normalize_path(path), parent, score ?? Date.now(), data);
120
+ }
121
+ /**
122
+ * Vacía la tabla completa.
123
+ * Clears the entire table.
124
+ */
125
+ async clear() {
126
+ this._wipe.run();
127
+ }
128
+ }
@@ -3,7 +3,7 @@
3
3
  * @description Barrel del módulo store — reexporta Engine + drivers y expone helpers de serialización.
4
4
  * Store module barrel — re-exports Engine + drivers and provides serialization helpers.
5
5
  */
6
- export { FileSystemEngine, RedisEngine, S3Engine, type Engine, type RedisClient } from '../../lib/store/engine/index.js';
6
+ export { FileSystemEngine, RedisEngine, S3Engine, SQLiteEngine, type Engine, type RedisClient, type SQLiteDatabase } from '../../lib/store/engine/index.js';
7
7
  /**
8
8
  * Serializa un documento a string preservando Buffers con BufferJSON de baileys.
9
9
  * Serializes a document to string preserving Buffers via baileys BufferJSON.
@@ -13,8 +13,12 @@ export { FileSystemEngine, RedisEngine, S3Engine, type Engine, type RedisClient
13
13
  */
14
14
  export declare function serialize<T>(doc: T): string;
15
15
  /**
16
- * Deserializa un string JSON a documento aplicando BufferJSON. Retorna null si la entrada es null.
17
- * Deserializes a JSON string to document using BufferJSON. Returns null if input is null.
16
+ * Deserializa un string JSON a documento aplicando BufferJSON. Retorna null si la entrada es
17
+ * null o no es JSON válido: un documento corrupto (escritura interrumpida, truncado) se
18
+ * comporta como inexistente en vez de propagar el parse error a toda la página.
19
+ * Deserializes a JSON string to document using BufferJSON. Returns null when the input is
20
+ * null or invalid JSON: a corrupt document (interrupted write, truncation) behaves as
21
+ * missing instead of poisoning the whole page with a parse error.
18
22
  *
19
23
  * @param raw - String JSON o null / JSON string or null
20
24
  * @returns Documento parseado o null / Parsed document or null
@@ -4,7 +4,7 @@
4
4
  * Store module barrel — re-exports Engine + drivers and provides serialization helpers.
5
5
  */
6
6
  import { BufferJSON } from 'baileys';
7
- export { FileSystemEngine, RedisEngine, S3Engine } from '../../lib/store/engine/index.js';
7
+ export { FileSystemEngine, RedisEngine, S3Engine, SQLiteEngine } from '../../lib/store/engine/index.js';
8
8
  /**
9
9
  * Serializa un documento a string preservando Buffers con BufferJSON de baileys.
10
10
  * Serializes a document to string preserving Buffers via baileys BufferJSON.
@@ -16,8 +16,12 @@ export function serialize(doc) {
16
16
  return JSON.stringify(doc, BufferJSON.replacer);
17
17
  }
18
18
  /**
19
- * Deserializa un string JSON a documento aplicando BufferJSON. Retorna null si la entrada es null.
20
- * Deserializes a JSON string to document using BufferJSON. Returns null if input is null.
19
+ * Deserializa un string JSON a documento aplicando BufferJSON. Retorna null si la entrada es
20
+ * null o no es JSON válido: un documento corrupto (escritura interrumpida, truncado) se
21
+ * comporta como inexistente en vez de propagar el parse error a toda la página.
22
+ * Deserializes a JSON string to document using BufferJSON. Returns null when the input is
23
+ * null or invalid JSON: a corrupt document (interrupted write, truncation) behaves as
24
+ * missing instead of poisoning the whole page with a parse error.
21
25
  *
22
26
  * @param raw - String JSON o null / JSON string or null
23
27
  * @returns Documento parseado o null / Parsed document or null
@@ -26,6 +30,10 @@ export function deserialize(raw) {
26
30
  if (raw === null) {
27
31
  return null;
28
32
  }
29
- return JSON.parse(raw, BufferJSON.reviver);
33
+ try {
34
+ return JSON.parse(raw, BufferJSON.reviver);
35
+ }
36
+ catch {
37
+ return null;
38
+ }
30
39
  }
31
- //# sourceMappingURL=index.js.map
@@ -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 { type WASocket } from 'baileys';
7
- import { EventEmitter } from 'node:events';
8
- import { chat } from '../../lib/chat/index.js';
9
- import { contact } from '../../lib/contact/index.js';
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,14 +28,17 @@ export type ReconnectOption = boolean | number | {
30
28
  export interface IWhatsApp {
31
29
  /** Motor de almacenamiento. / Storage engine. */
32
30
  engine: Engine;
33
- /** Teléfono para emparejamiento por PIN (OTP). / Phone for PIN pairing (OTP). */
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;
35
37
  /**
36
- * Fuerza el método de vinculación. Tiene precedencia sobre la heurística por `phone`:
37
- * `auth = method ?? (phone ? 'otp' : 'qr')`. `otp` requiere `phone`.
38
- *
39
- * Forces the linking method, taking precedence over the phone heuristic:
40
- * `auth = method ?? (phone ? 'otp' : 'qr')`. `otp` requires `phone`.
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.
41
42
  */
42
43
  method?: 'qr' | 'otp';
43
44
  /**
@@ -64,11 +65,13 @@ export interface IWhatsApp {
64
65
  * Disconnect options.
65
66
  */
66
67
  export interface DisconnectOptions {
67
- /** No emitir evento de cierre. / Suppress close emission. */
68
+ /** No emitir el evento `disconnected` de este cierre. / Suppress this close's `disconnected` event. */
68
69
  silent?: boolean;
69
70
  /** Vaciar el engine tras cerrar. / Clear the engine after closing. */
70
71
  destroy?: boolean;
71
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;
72
75
  type MessageInstance = Message;
73
76
  type ChatInstance = InstanceType<ReturnType<typeof chat>>;
74
77
  type ContactInstance = InstanceType<ReturnType<typeof contact>>;
@@ -113,26 +116,69 @@ interface WhatsAppEventMap {
113
116
  * await wa.connect((code) => console.log(code));
114
117
  */
115
118
  export declare class WhatsApp {
116
- private readonly _phone?;
117
- private readonly _method?;
118
- /** @internal */
119
- readonly _event: EventEmitter<WhatsAppEventMap>;
120
- private readonly _autoclean;
121
- private readonly _reconnect;
122
- private readonly _sync;
123
- /** @internal */
124
- _socket: WASocket | null;
125
- private _intentional_close;
126
- private _has_connected;
127
- private _retry_timer;
128
- private _retry_count;
119
+ #private;
120
+ /** Motor de almacenamiento de la sesión. / Session storage engine. */
129
121
  readonly engine: Engine;
122
+ /** Entidad `Contact` ligada a este cliente. / `Contact` entity bound to this client. */
130
123
  readonly Contact: ReturnType<typeof contact>;
124
+ /** Entidad `Chat` ligada a este cliente. / `Chat` entity bound to this client. */
131
125
  readonly Chat: ReturnType<typeof chat>;
132
- readonly Message: ReturnType<typeof message>;
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
+ };
133
165
  constructor(options: IWhatsApp);
134
- /** @internal */
135
- private _parse_reconnect;
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;
136
182
  /**
137
183
  * Registra un listener de evento. Retorna función para desuscribirse.
138
184
  * Registers an event listener. Returns an unsubscribe function.
@@ -148,12 +194,6 @@ export declare class WhatsApp {
148
194
  * Registers a one-shot listener. Returns an unsubscribe function.
149
195
  */
150
196
  once<E extends keyof WhatsAppEventMap>(event: E, handler: (...args: WhatsAppEventMap[E]) => void): () => void;
151
- /**
152
- * @internal
153
- * Normaliza cualquier identificador (JID, LID, número, etc.) a JID canónico.
154
- * Uso interno de la librería — no forma parte de la API pública.
155
- */
156
- _resolve_jid(uid: string): Promise<string | null>;
157
197
  /**
158
198
  * Inicia la conexión. El callback recibe el PIN (string) si se configuró `phone`, o el QR (Buffer PNG) si no.
159
199
  * Resuelve cuando la sesión sincroniza; reintenta automáticamente en cierres no-loggedOut.
@@ -163,44 +203,42 @@ export declare class WhatsApp {
163
203
  */
164
204
  connect(callback: (auth: string | Buffer) => void | Promise<void>): Promise<void>;
165
205
  /**
166
- * Cierra la conexión. Con `destroy: true` vacía el engine completo.
167
- * Closes the connection. With `destroy: true` clears the engine entirely.
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
168
214
  */
169
- disconnect(options?: DisconnectOptions): Promise<void>;
215
+ profile(patch: {
216
+ name?: string;
217
+ content?: string;
218
+ photo?: string | Buffer | null;
219
+ }): Promise<boolean>;
170
220
  /**
171
- * Conecta los handlers de eventos de baileys: contactos, chats y mensajes.
172
- * Wires baileys event handlers: contacts, chats and messages.
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.
173
227
  *
174
- * @internal
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
175
232
  */
176
- private _attach_business_handlers;
233
+ feed(post: {
234
+ content?: Buffer;
235
+ caption?: string;
236
+ contacts: (string | number)[];
237
+ }): Promise<Feed | null>;
177
238
  /**
178
- * Persiste un contacto y su índice LID; emite `contact:created` solo si es nuevo.
179
- * Persists a contact and its LID index; emits `contact:created` only when new.
180
- *
181
- * @param raw - Documento del contacto a persistir / Contact document to persist
182
- * @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.
183
241
  */
184
- private _persist_contact;
185
- /** @internal */
186
- private _handle_contacts_upsert;
187
- /** @internal */
188
- private _handle_contacts_update;
189
- /** @internal */
190
- private _handle_lid_mapping;
191
- /** @internal */
192
- private _handle_chats_upsert;
193
- /** @internal */
194
- private _handle_chats_update;
195
- /** @internal */
196
- private _handle_chats_delete;
197
- /** @internal */
198
- private _handle_message_receipt;
199
- /** @internal */
200
- private _handle_messages_upsert;
201
- /** @internal */
202
- private _handle_messages_update;
203
- /** @internal */
204
- private _handle_messages_reaction;
242
+ disconnect(options?: DisconnectOptions): Promise<void>;
205
243
  }
206
244
  export default WhatsApp;