@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
@@ -3,64 +3,49 @@
3
3
  * @description Entidad Chat — conversaciones individuales y grupales.
4
4
  * Chat entity — individual and group conversations.
5
5
  */
6
- import type { Message } from '../../lib/message';
6
+ import { Message } from '../../lib/message';
7
7
  import type { WhatsApp } from '../../lib/whatsapp';
8
8
  /**
9
- * Participante de grupo.
10
- * Group participant.
11
- */
12
- export interface GroupParticipant {
13
- id: string;
14
- admin: string | null;
15
- }
16
- /**
17
- * Shape persistido del chat (snake_case).
18
- * Persisted chat shape (snake_case).
19
- */
20
- export interface IChatRaw {
21
- id: string;
22
- name?: string | null;
23
- display_name?: string | null;
24
- description?: string | null;
25
- unread_count?: number | null;
26
- read_only?: boolean | null;
27
- archived?: boolean | null;
28
- pinned?: number | null;
29
- mute_end_time?: number | null;
30
- marked_as_unread?: boolean | null;
31
- participants?: GroupParticipant[] | null;
32
- created_by?: string | null;
33
- created_at?: number | null;
34
- ephemeral_expiration?: number | null;
35
- }
36
- /**
37
- * Clase base del chat (forma pública, solo lectura).
38
- * Base Chat class (public shape, read-only).
9
+ * Clase base del chat: recibe el raw y deriva todo con getters.
10
+ * Base Chat class: receives the raw and derives everything via getters.
39
11
  */
40
12
  export declare class Chat {
41
- /** @internal Shape persistido. Uso interno. / Internal persisted shape. */
42
- readonly _raw: IChatRaw;
43
- constructor(raw: IChatRaw);
44
- /** JID del chat. / Chat JID. */
13
+ readonly _raw: {
14
+ id: string;
15
+ name?: string | null;
16
+ archived?: boolean | null;
17
+ pinned?: number | null;
18
+ mute_end_time?: number | null;
19
+ unread_count?: number | null;
20
+ };
21
+ /**
22
+ * @internal Documento crudo del chat. `id` es el identificador del engine (JID, LID o
23
+ * `@g.us`); `pinned` y `mute_end_time` son epoch ms.
24
+ * Raw chat document. `id` is the engine identifier (JID, LID or `@g.us`); `pinned` and
25
+ * `mute_end_time` are epoch ms.
26
+ */
27
+ constructor(_raw: {
28
+ id: string;
29
+ name?: string | null;
30
+ archived?: boolean | null;
31
+ pinned?: number | null;
32
+ mute_end_time?: number | null;
33
+ unread_count?: number | null;
34
+ });
35
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
45
36
  get id(): string;
46
- /** CID (alias). / CID (alias). */
47
- get cid(): string;
48
- /** Tipo: contact o group. / Type: contact or group. */
49
- get type(): 'contact' | 'group';
50
- /** Nombre del chat. / Chat name. */
37
+ /** Nombre del grupo o del contacto. / Group or contact name. */
51
38
  get name(): string;
52
- /** Descripción del grupo. / Group description. */
53
- get content(): string;
54
- /** Si está fijado. / Whether it's pinned. */
55
- get pinned(): boolean;
56
- /** Si está archivado. / Whether it's archived. */
39
+ /** Tipo de conversación. / Conversation type. */
40
+ get type(): 'group' | 'contact';
41
+ /** true si el chat está archivado. / true when the chat is archived. */
57
42
  get archived(): boolean;
58
- /** true si el chat está silenciado y el silencio aún no expira. / true if chat is muted and the mute has not expired. */
59
- get muted(): boolean;
60
- /** Si está leído. / Whether it's read. */
61
- get read(): boolean;
62
- /** Si es solo lectura. / Whether it's read-only. */
63
- get readonly(): boolean;
43
+ /** true si el chat está fijado. / true when the chat is pinned. */
44
+ get pinned(): boolean;
45
+ /** Mensajes sin leer del chat. / Chat's unread messages. */
46
+ get count(): number;
47
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
48
+ get muted(): string | null;
64
49
  }
65
50
  /**
66
51
  * Factoría de Chat ligada al contexto WhatsApp.
@@ -69,184 +54,376 @@ export declare class Chat {
69
54
  * @param wa - Instancia principal / Main WhatsApp instance
70
55
  */
71
56
  export declare function chat(wa: WhatsApp): {
72
- new (raw: IChatRaw): {
73
- /** @internal Cache TTL (15s) de la promesa de participants del grupo. Evita round-trips a `groupMetadata` y deduplica llamadas concurrentes. */
74
- _members_cache: Promise<{
75
- id: string;
76
- }[]> | null;
77
- /** Re-hidrata metadata del chat desde el socket. / Re-hydrates chat metadata from the socket. */
78
- refresh(): Promise</*elided*/ any | null>;
79
- /** Fija/desfija el chat. / Pins or unpins the chat. */
80
- pin(value: boolean): Promise<boolean>;
81
- /** Archiva/desarchiva el chat. / Archives or unarchives the chat. */
82
- archive(value: boolean): Promise<boolean>;
83
- /** Silencia/des-silencia el chat. / Mutes or unmutes the chat. */
84
- mute(value: boolean): Promise<boolean>;
85
- /** Toggle "Escribiendo...". / Toggles the "typing..." indicator. */
86
- typing(on: boolean): Promise<boolean>;
87
- /** Toggle "Grabando audio...". / Toggles the "recording audio..." indicator. */
88
- recording(on: boolean): Promise<boolean>;
89
- /** Vacía mensajes del chat (engine local). / Clears chat messages (local engine). */
90
- clear(): Promise<boolean>;
91
- /** Elimina el chat y sus mensajes (remoto + local). / Deletes the chat and its messages (remote + local). */
92
- delete(): Promise<boolean>;
57
+ new (_raw: {
58
+ id: string;
59
+ name?: string | null;
60
+ archived?: boolean | null;
61
+ pinned?: number | null;
62
+ mute_end_time?: number | null;
63
+ unread_count?: number | null;
64
+ }): {
93
65
  /**
94
- * Participantes del chat paginados (incluyéndome en grupos). Para grupos,
95
- * el `groupMetadata` se memoiza en la instancia con TTL de 15s para evitar
96
- * round-trips repetidos al socket.
97
- * Chat participants paginated (self included in groups). For groups,
98
- * `groupMetadata` is memoized on the instance with a 15s TTL to avoid
99
- * repeated socket round-trips.
66
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
67
+ * Chat participants: members for groups, the contact and myself for 1:1.
68
+ *
69
+ * @param offset - Desplazamiento / Offset
70
+ * @param limit - Tamaño de página / Page size
71
+ * @returns Página de contactos / Contact page
100
72
  */
101
73
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
102
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
74
+ /**
75
+ * Descripción del chat: el asunto del grupo o, en un 1:1, la bio del contacto.
76
+ * Es asíncrono porque ninguno de los dos vive en el documento del chat.
77
+ * Chat description: the group's subject or, on a 1:1, the contact's bio. It is async
78
+ * because neither of them lives in the chat document.
79
+ *
80
+ * @returns Descripción, o cadena vacía si no hay / Description, or an empty string when absent
81
+ */
82
+ content(): Promise<string>;
83
+ /**
84
+ * Mensajes del chat paginados desde el más reciente.
85
+ * Chat messages paginated from the most recent one.
86
+ *
87
+ * @param offset - Desplazamiento / Offset
88
+ * @param limit - Tamaño de página / Page size
89
+ * @returns Página de mensajes / Message page
90
+ */
103
91
  messages(offset?: number, limit?: number): Promise<Message[]>;
104
- /** @internal Shape persistido. Uso interno. / Internal persisted shape. */
105
- readonly _raw: IChatRaw;
106
- /** JID del chat. / Chat JID. */
92
+ /**
93
+ * Activa o desactiva el indicador «escribiendo…».
94
+ * Toggles the "typing…" indicator.
95
+ *
96
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
97
+ * @returns true si el socket estaba disponible / true when the socket was available
98
+ */
99
+ typing(value: boolean): Promise<boolean>;
100
+ /**
101
+ * Activa o desactiva el indicador «grabando audio…».
102
+ * Toggles the "recording audio…" indicator.
103
+ *
104
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
105
+ * @returns true si el socket estaba disponible / true when the socket was available
106
+ */
107
+ recording(value: boolean): Promise<boolean>;
108
+ /**
109
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
110
+ * Archives or unarchives the chat on the WhatsApp account.
111
+ *
112
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
113
+ * @returns true si la acción se envió / true when the action was sent
114
+ */
115
+ archive(value: boolean): Promise<boolean>;
116
+ /**
117
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
118
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
119
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
120
+ * chats and silently drops the fourth, so the limit is checked beforehand.
121
+ *
122
+ * @param value - true fija, false desfija / true pins, false unpins
123
+ * @returns false si el socket está caído o ya hay 3 chats fijados / false when the socket is down or 3 chats are already pinned
124
+ */
125
+ pin(value: boolean): Promise<boolean>;
126
+ /**
127
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
128
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
129
+ *
130
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
131
+ * @returns true si la acción se envió / true when the action was sent
132
+ */
133
+ mute(until: string | number | Date | false): Promise<boolean>;
134
+ /**
135
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
136
+ * Marks the whole chat as read on the WhatsApp account.
137
+ *
138
+ * @returns true si la acción se envió / true when the action was sent
139
+ */
140
+ seen(): Promise<boolean>;
141
+ /**
142
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
143
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
144
+ *
145
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
146
+ */
147
+ clear(): Promise<boolean>;
148
+ /**
149
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
150
+ * abandona el grupo.
151
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
152
+ * groups it leaves the group.
153
+ *
154
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
155
+ */
156
+ delete(): Promise<boolean>;
157
+ readonly _raw: {
158
+ id: string;
159
+ name?: string | null;
160
+ archived?: boolean | null;
161
+ pinned?: number | null;
162
+ mute_end_time?: number | null;
163
+ unread_count?: number | null;
164
+ };
165
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
107
166
  get id(): string;
108
- /** CID (alias). / CID (alias). */
109
- get cid(): string;
110
- /** Tipo: contact o group. / Type: contact or group. */
111
- get type(): "contact" | "group";
112
- /** Nombre del chat. / Chat name. */
167
+ /** Nombre del grupo o del contacto. / Group or contact name. */
113
168
  get name(): string;
114
- /** Descripción del grupo. / Group description. */
115
- get content(): string;
116
- /** Si está fijado. / Whether it's pinned. */
117
- get pinned(): boolean;
118
- /** Si está archivado. / Whether it's archived. */
169
+ /** Tipo de conversación. / Conversation type. */
170
+ get type(): "group" | "contact";
171
+ /** true si el chat está archivado. / true when the chat is archived. */
119
172
  get archived(): boolean;
120
- /** true si el chat está silenciado y el silencio aún no expira. / true if chat is muted and the mute has not expired. */
121
- get muted(): boolean;
122
- /** Si está leído. / Whether it's read. */
123
- get read(): boolean;
124
- /** Si es solo lectura. / Whether it's read-only. */
125
- get readonly(): boolean;
173
+ /** true si el chat está fijado. / true when the chat is pinned. */
174
+ get pinned(): boolean;
175
+ /** Mensajes sin leer del chat. / Chat's unread messages. */
176
+ get count(): number;
177
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
178
+ get muted(): string | null;
126
179
  };
127
180
  /**
128
- * Obtiene un chat por CID. Si no está persistido, lo crea a partir del contacto.
129
- * Retrieves a chat by CID. If not persisted, creates it from the contact.
181
+ * Carga un chat por teléfono, JID, LID o id de grupo: el persistido en el engine o,
182
+ * si todavía no existe, una instancia mínima lista para usar (no se persiste).
183
+ * Loads a chat by phone, JID, LID or group id: the engine-persisted one or, when it
184
+ * does not exist yet, a minimal ready-to-use instance (not persisted).
185
+ *
186
+ * @param cid - Teléfono, JID, LID o id de grupo / Phone, JID, LID or group id
187
+ * @returns Chat o null si el identificador es irresoluble / Chat or null when the identifier cannot be resolved
130
188
  */
131
- get(cid: string): Promise<{
132
- /** @internal Cache TTL (15s) de la promesa de participants del grupo. Evita round-trips a `groupMetadata` y deduplica llamadas concurrentes. */
133
- _members_cache: Promise<{
134
- id: string;
135
- }[]> | null;
136
- /** Re-hidrata metadata del chat desde el socket. / Re-hydrates chat metadata from the socket. */
137
- refresh(): Promise</*elided*/ any | null>;
138
- /** Fija/desfija el chat. / Pins or unpins the chat. */
139
- pin(value: boolean): Promise<boolean>;
140
- /** Archiva/desarchiva el chat. / Archives or unarchives the chat. */
141
- archive(value: boolean): Promise<boolean>;
142
- /** Silencia/des-silencia el chat. / Mutes or unmutes the chat. */
143
- mute(value: boolean): Promise<boolean>;
144
- /** Toggle "Escribiendo...". / Toggles the "typing..." indicator. */
145
- typing(on: boolean): Promise<boolean>;
146
- /** Toggle "Grabando audio...". / Toggles the "recording audio..." indicator. */
147
- recording(on: boolean): Promise<boolean>;
148
- /** Vacía mensajes del chat (engine local). / Clears chat messages (local engine). */
149
- clear(): Promise<boolean>;
150
- /** Elimina el chat y sus mensajes (remoto + local). / Deletes the chat and its messages (remote + local). */
151
- delete(): Promise<boolean>;
189
+ get(cid: string | number): Promise<{
152
190
  /**
153
- * Participantes del chat paginados (incluyéndome en grupos). Para grupos,
154
- * el `groupMetadata` se memoiza en la instancia con TTL de 15s para evitar
155
- * round-trips repetidos al socket.
156
- * Chat participants paginated (self included in groups). For groups,
157
- * `groupMetadata` is memoized on the instance with a 15s TTL to avoid
158
- * repeated socket round-trips.
191
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
192
+ * Chat participants: members for groups, the contact and myself for 1:1.
193
+ *
194
+ * @param offset - Desplazamiento / Offset
195
+ * @param limit - Tamaño de página / Page size
196
+ * @returns Página de contactos / Contact page
159
197
  */
160
198
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
161
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
199
+ /**
200
+ * Descripción del chat: el asunto del grupo o, en un 1:1, la bio del contacto.
201
+ * Es asíncrono porque ninguno de los dos vive en el documento del chat.
202
+ * Chat description: the group's subject or, on a 1:1, the contact's bio. It is async
203
+ * because neither of them lives in the chat document.
204
+ *
205
+ * @returns Descripción, o cadena vacía si no hay / Description, or an empty string when absent
206
+ */
207
+ content(): Promise<string>;
208
+ /**
209
+ * Mensajes del chat paginados desde el más reciente.
210
+ * Chat messages paginated from the most recent one.
211
+ *
212
+ * @param offset - Desplazamiento / Offset
213
+ * @param limit - Tamaño de página / Page size
214
+ * @returns Página de mensajes / Message page
215
+ */
162
216
  messages(offset?: number, limit?: number): Promise<Message[]>;
163
- /** @internal Shape persistido. Uso interno. / Internal persisted shape. */
164
- readonly _raw: IChatRaw;
165
- /** JID del chat. / Chat JID. */
217
+ /**
218
+ * Activa o desactiva el indicador «escribiendo…».
219
+ * Toggles the "typing…" indicator.
220
+ *
221
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
222
+ * @returns true si el socket estaba disponible / true when the socket was available
223
+ */
224
+ typing(value: boolean): Promise<boolean>;
225
+ /**
226
+ * Activa o desactiva el indicador «grabando audio…».
227
+ * Toggles the "recording audio…" indicator.
228
+ *
229
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
230
+ * @returns true si el socket estaba disponible / true when the socket was available
231
+ */
232
+ recording(value: boolean): Promise<boolean>;
233
+ /**
234
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
235
+ * Archives or unarchives the chat on the WhatsApp account.
236
+ *
237
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
238
+ * @returns true si la acción se envió / true when the action was sent
239
+ */
240
+ archive(value: boolean): Promise<boolean>;
241
+ /**
242
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
243
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
244
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
245
+ * chats and silently drops the fourth, so the limit is checked beforehand.
246
+ *
247
+ * @param value - true fija, false desfija / true pins, false unpins
248
+ * @returns false si el socket está caído o ya hay 3 chats fijados / false when the socket is down or 3 chats are already pinned
249
+ */
250
+ pin(value: boolean): Promise<boolean>;
251
+ /**
252
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
253
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
254
+ *
255
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
256
+ * @returns true si la acción se envió / true when the action was sent
257
+ */
258
+ mute(until: string | number | Date | false): Promise<boolean>;
259
+ /**
260
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
261
+ * Marks the whole chat as read on the WhatsApp account.
262
+ *
263
+ * @returns true si la acción se envió / true when the action was sent
264
+ */
265
+ seen(): Promise<boolean>;
266
+ /**
267
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
268
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
269
+ *
270
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
271
+ */
272
+ clear(): Promise<boolean>;
273
+ /**
274
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
275
+ * abandona el grupo.
276
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
277
+ * groups it leaves the group.
278
+ *
279
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
280
+ */
281
+ delete(): Promise<boolean>;
282
+ readonly _raw: {
283
+ id: string;
284
+ name?: string | null;
285
+ archived?: boolean | null;
286
+ pinned?: number | null;
287
+ mute_end_time?: number | null;
288
+ unread_count?: number | null;
289
+ };
290
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
166
291
  get id(): string;
167
- /** CID (alias). / CID (alias). */
168
- get cid(): string;
169
- /** Tipo: contact o group. / Type: contact or group. */
170
- get type(): "contact" | "group";
171
- /** Nombre del chat. / Chat name. */
292
+ /** Nombre del grupo o del contacto. / Group or contact name. */
172
293
  get name(): string;
173
- /** Descripción del grupo. / Group description. */
174
- get content(): string;
175
- /** Si está fijado. / Whether it's pinned. */
176
- get pinned(): boolean;
177
- /** Si está archivado. / Whether it's archived. */
294
+ /** Tipo de conversación. / Conversation type. */
295
+ get type(): "group" | "contact";
296
+ /** true si el chat está archivado. / true when the chat is archived. */
178
297
  get archived(): boolean;
179
- /** true si el chat está silenciado y el silencio aún no expira. / true if chat is muted and the mute has not expired. */
180
- get muted(): boolean;
181
- /** Si está leído. / Whether it's read. */
182
- get read(): boolean;
183
- /** Si es solo lectura. / Whether it's read-only. */
184
- get readonly(): boolean;
298
+ /** true si el chat está fijado. / true when the chat is pinned. */
299
+ get pinned(): boolean;
300
+ /** Mensajes sin leer del chat. / Chat's unread messages. */
301
+ get count(): number;
302
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
303
+ get muted(): string | null;
185
304
  } | null>;
186
- /** Pagina los chats persistidos por mtime DESC. / Paginates persisted chats by mtime DESC. */
305
+ /**
306
+ * Pagina los chats persistidos, del más reciente al más antiguo.
307
+ * Paginates persisted chats, from the most recent to the oldest.
308
+ *
309
+ * @param offset - Desplazamiento / Offset
310
+ * @param limit - Tamaño de página / Page size
311
+ * @returns Página de chats / Chat page
312
+ */
187
313
  list(offset?: number, limit?: number): Promise<{
188
- /** @internal Cache TTL (15s) de la promesa de participants del grupo. Evita round-trips a `groupMetadata` y deduplica llamadas concurrentes. */
189
- _members_cache: Promise<{
190
- id: string;
191
- }[]> | null;
192
- /** Re-hidrata metadata del chat desde el socket. / Re-hydrates chat metadata from the socket. */
193
- refresh(): Promise</*elided*/ any | null>;
194
- /** Fija/desfija el chat. / Pins or unpins the chat. */
195
- pin(value: boolean): Promise<boolean>;
196
- /** Archiva/desarchiva el chat. / Archives or unarchives the chat. */
197
- archive(value: boolean): Promise<boolean>;
198
- /** Silencia/des-silencia el chat. / Mutes or unmutes the chat. */
199
- mute(value: boolean): Promise<boolean>;
200
- /** Toggle "Escribiendo...". / Toggles the "typing..." indicator. */
201
- typing(on: boolean): Promise<boolean>;
202
- /** Toggle "Grabando audio...". / Toggles the "recording audio..." indicator. */
203
- recording(on: boolean): Promise<boolean>;
204
- /** Vacía mensajes del chat (engine local). / Clears chat messages (local engine). */
205
- clear(): Promise<boolean>;
206
- /** Elimina el chat y sus mensajes (remoto + local). / Deletes the chat and its messages (remote + local). */
207
- delete(): Promise<boolean>;
208
314
  /**
209
- * Participantes del chat paginados (incluyéndome en grupos). Para grupos,
210
- * el `groupMetadata` se memoiza en la instancia con TTL de 15s para evitar
211
- * round-trips repetidos al socket.
212
- * Chat participants paginated (self included in groups). For groups,
213
- * `groupMetadata` is memoized on the instance with a 15s TTL to avoid
214
- * repeated socket round-trips.
315
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
316
+ * Chat participants: members for groups, the contact and myself for 1:1.
317
+ *
318
+ * @param offset - Desplazamiento / Offset
319
+ * @param limit - Tamaño de página / Page size
320
+ * @returns Página de contactos / Contact page
215
321
  */
216
322
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
217
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
323
+ /**
324
+ * Descripción del chat: el asunto del grupo o, en un 1:1, la bio del contacto.
325
+ * Es asíncrono porque ninguno de los dos vive en el documento del chat.
326
+ * Chat description: the group's subject or, on a 1:1, the contact's bio. It is async
327
+ * because neither of them lives in the chat document.
328
+ *
329
+ * @returns Descripción, o cadena vacía si no hay / Description, or an empty string when absent
330
+ */
331
+ content(): Promise<string>;
332
+ /**
333
+ * Mensajes del chat paginados desde el más reciente.
334
+ * Chat messages paginated from the most recent one.
335
+ *
336
+ * @param offset - Desplazamiento / Offset
337
+ * @param limit - Tamaño de página / Page size
338
+ * @returns Página de mensajes / Message page
339
+ */
218
340
  messages(offset?: number, limit?: number): Promise<Message[]>;
219
- /** @internal Shape persistido. Uso interno. / Internal persisted shape. */
220
- readonly _raw: IChatRaw;
221
- /** JID del chat. / Chat JID. */
341
+ /**
342
+ * Activa o desactiva el indicador «escribiendo…».
343
+ * Toggles the "typing…" indicator.
344
+ *
345
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
346
+ * @returns true si el socket estaba disponible / true when the socket was available
347
+ */
348
+ typing(value: boolean): Promise<boolean>;
349
+ /**
350
+ * Activa o desactiva el indicador «grabando audio…».
351
+ * Toggles the "recording audio…" indicator.
352
+ *
353
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
354
+ * @returns true si el socket estaba disponible / true when the socket was available
355
+ */
356
+ recording(value: boolean): Promise<boolean>;
357
+ /**
358
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
359
+ * Archives or unarchives the chat on the WhatsApp account.
360
+ *
361
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
362
+ * @returns true si la acción se envió / true when the action was sent
363
+ */
364
+ archive(value: boolean): Promise<boolean>;
365
+ /**
366
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
367
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
368
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
369
+ * chats and silently drops the fourth, so the limit is checked beforehand.
370
+ *
371
+ * @param value - true fija, false desfija / true pins, false unpins
372
+ * @returns false si el socket está caído o ya hay 3 chats fijados / false when the socket is down or 3 chats are already pinned
373
+ */
374
+ pin(value: boolean): Promise<boolean>;
375
+ /**
376
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
377
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
378
+ *
379
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
380
+ * @returns true si la acción se envió / true when the action was sent
381
+ */
382
+ mute(until: string | number | Date | false): Promise<boolean>;
383
+ /**
384
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
385
+ * Marks the whole chat as read on the WhatsApp account.
386
+ *
387
+ * @returns true si la acción se envió / true when the action was sent
388
+ */
389
+ seen(): Promise<boolean>;
390
+ /**
391
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
392
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
393
+ *
394
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
395
+ */
396
+ clear(): Promise<boolean>;
397
+ /**
398
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
399
+ * abandona el grupo.
400
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
401
+ * groups it leaves the group.
402
+ *
403
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
404
+ */
405
+ delete(): Promise<boolean>;
406
+ readonly _raw: {
407
+ id: string;
408
+ name?: string | null;
409
+ archived?: boolean | null;
410
+ pinned?: number | null;
411
+ mute_end_time?: number | null;
412
+ unread_count?: number | null;
413
+ };
414
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
222
415
  get id(): string;
223
- /** CID (alias). / CID (alias). */
224
- get cid(): string;
225
- /** Tipo: contact o group. / Type: contact or group. */
226
- get type(): "contact" | "group";
227
- /** Nombre del chat. / Chat name. */
416
+ /** Nombre del grupo o del contacto. / Group or contact name. */
228
417
  get name(): string;
229
- /** Descripción del grupo. / Group description. */
230
- get content(): string;
231
- /** Si está fijado. / Whether it's pinned. */
232
- get pinned(): boolean;
233
- /** Si está archivado. / Whether it's archived. */
418
+ /** Tipo de conversación. / Conversation type. */
419
+ get type(): "group" | "contact";
420
+ /** true si el chat está archivado. / true when the chat is archived. */
234
421
  get archived(): boolean;
235
- /** true si el chat está silenciado y el silencio aún no expira. / true if chat is muted and the mute has not expired. */
236
- get muted(): boolean;
237
- /** Si está leído. / Whether it's read. */
238
- get read(): boolean;
239
- /** Si es solo lectura. / Whether it's read-only. */
240
- get readonly(): boolean;
422
+ /** true si el chat está fijado. / true when the chat is pinned. */
423
+ get pinned(): boolean;
424
+ /** Mensajes sin leer del chat. / Chat's unread messages. */
425
+ get count(): number;
426
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
427
+ get muted(): string | null;
241
428
  }[]>;
242
- /** Fija/desfija un chat por CID. / Pins or unpins a chat by CID. */
243
- pin(cid: string, value: boolean): Promise<boolean>;
244
- /** Archiva/desarchiva un chat por CID. / Archives or unarchives a chat by CID. */
245
- archive(cid: string, value: boolean): Promise<boolean>;
246
- /** Silencia/des-silencia un chat por CID. / Mutes or unmutes a chat by CID. */
247
- mute(cid: string, value: boolean): Promise<boolean>;
248
- /** Vacía mensajes del chat (local). / Clears the chat's messages (local only). */
249
- clear(cid: string): Promise<boolean>;
250
- /** Elimina el chat y sus mensajes. / Deletes the chat and its messages. */
251
- delete(cid: string): Promise<boolean>;
252
429
  };