@arcaelas/whatsapp 4.5.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.
Files changed (95) hide show
  1. package/build/cjs/index.d.ts +6 -4
  2. package/build/cjs/index.js +22 -2
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/lib/bot/decorator.d.ts +2 -0
  5. package/build/cjs/lib/bot/decorator.js +6 -0
  6. package/build/cjs/lib/bot/decorator.js.map +1 -1
  7. package/build/cjs/lib/chat/index.d.ts +340 -204
  8. package/build/cjs/lib/chat/index.js +225 -213
  9. package/build/cjs/lib/chat/index.js.map +1 -1
  10. package/build/cjs/lib/contact/index.d.ts +162 -179
  11. package/build/cjs/lib/contact/index.js +96 -190
  12. package/build/cjs/lib/contact/index.js.map +1 -1
  13. package/build/cjs/lib/internal.d.ts +40 -0
  14. package/build/cjs/lib/internal.js +39 -0
  15. package/build/cjs/lib/internal.js.map +1 -0
  16. package/build/cjs/lib/message/index.d.ts +462 -289
  17. package/build/cjs/lib/message/index.js +825 -741
  18. package/build/cjs/lib/message/index.js.map +1 -1
  19. package/build/cjs/lib/status/index.d.ts +60 -70
  20. package/build/cjs/lib/status/index.js +106 -111
  21. package/build/cjs/lib/status/index.js.map +1 -1
  22. package/build/cjs/lib/store/engine/index.d.ts +21 -7
  23. package/build/cjs/lib/store/engine/index.js +6 -3
  24. package/build/cjs/lib/store/engine/index.js.map +1 -1
  25. package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +38 -8
  26. package/build/cjs/lib/store/engine/lib/file_system/index.js +92 -67
  27. package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -1
  28. package/build/cjs/lib/store/engine/lib/index.d.ts +112 -0
  29. package/build/cjs/lib/store/engine/lib/index.js +213 -0
  30. package/build/cjs/lib/store/engine/lib/index.js.map +1 -0
  31. package/build/cjs/lib/store/engine/lib/redis/index.d.ts +28 -13
  32. package/build/cjs/lib/store/engine/lib/redis/index.js +56 -42
  33. package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -1
  34. package/build/cjs/lib/store/engine/lib/s3/index.d.ts +44 -1
  35. package/build/cjs/lib/store/engine/lib/s3/index.js +112 -64
  36. package/build/cjs/lib/store/engine/lib/s3/index.js.map +1 -1
  37. package/build/cjs/lib/store/engine/lib/sqlite/index.d.ts +98 -0
  38. package/build/cjs/lib/store/engine/lib/sqlite/index.js +114 -0
  39. package/build/cjs/lib/store/engine/lib/sqlite/index.js.map +1 -0
  40. package/build/cjs/lib/store/index.d.ts +7 -3
  41. package/build/cjs/lib/store/index.js +14 -4
  42. package/build/cjs/lib/store/index.js.map +1 -1
  43. package/build/cjs/lib/whatsapp/index.d.ts +106 -68
  44. package/build/cjs/lib/whatsapp/index.js +380 -170
  45. package/build/cjs/lib/whatsapp/index.js.map +1 -1
  46. package/build/cjs/test.js +5 -4
  47. package/build/cjs/test.js.map +1 -1
  48. package/build/esm/index.d.ts +6 -4
  49. package/build/esm/index.js +5 -2
  50. package/build/esm/index.js.map +1 -1
  51. package/build/esm/lib/bot/decorator.d.ts +2 -0
  52. package/build/esm/lib/bot/decorator.js +6 -0
  53. package/build/esm/lib/bot/decorator.js.map +1 -1
  54. package/build/esm/lib/chat/index.d.ts +340 -204
  55. package/build/esm/lib/chat/index.js +225 -213
  56. package/build/esm/lib/chat/index.js.map +1 -1
  57. package/build/esm/lib/contact/index.d.ts +162 -179
  58. package/build/esm/lib/contact/index.js +96 -189
  59. package/build/esm/lib/contact/index.js.map +1 -1
  60. package/build/esm/lib/internal.d.ts +40 -0
  61. package/build/esm/lib/internal.js +35 -0
  62. package/build/esm/lib/internal.js.map +1 -0
  63. package/build/esm/lib/message/index.d.ts +462 -289
  64. package/build/esm/lib/message/index.js +820 -736
  65. package/build/esm/lib/message/index.js.map +1 -1
  66. package/build/esm/lib/status/index.d.ts +60 -70
  67. package/build/esm/lib/status/index.js +105 -110
  68. package/build/esm/lib/status/index.js.map +1 -1
  69. package/build/esm/lib/store/engine/index.d.ts +21 -7
  70. package/build/esm/lib/store/engine/index.js +4 -2
  71. package/build/esm/lib/store/engine/index.js.map +1 -1
  72. package/build/esm/lib/store/engine/lib/file_system/index.d.ts +38 -8
  73. package/build/esm/lib/store/engine/lib/file_system/index.js +92 -67
  74. package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -1
  75. package/build/esm/lib/store/engine/lib/index.d.ts +112 -0
  76. package/build/esm/lib/store/engine/lib/index.js +206 -0
  77. package/build/esm/lib/store/engine/lib/index.js.map +1 -0
  78. package/build/esm/lib/store/engine/lib/redis/index.d.ts +28 -13
  79. package/build/esm/lib/store/engine/lib/redis/index.js +54 -40
  80. package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -1
  81. package/build/esm/lib/store/engine/lib/s3/index.d.ts +44 -1
  82. package/build/esm/lib/store/engine/lib/s3/index.js +111 -63
  83. package/build/esm/lib/store/engine/lib/s3/index.js.map +1 -1
  84. package/build/esm/lib/store/engine/lib/sqlite/index.d.ts +98 -0
  85. package/build/esm/lib/store/engine/lib/sqlite/index.js +110 -0
  86. package/build/esm/lib/store/engine/lib/sqlite/index.js.map +1 -0
  87. package/build/esm/lib/store/index.d.ts +7 -3
  88. package/build/esm/lib/store/index.js +13 -4
  89. package/build/esm/lib/store/index.js.map +1 -1
  90. package/build/esm/lib/whatsapp/index.d.ts +106 -68
  91. package/build/esm/lib/whatsapp/index.js +382 -172
  92. package/build/esm/lib/whatsapp/index.js.map +1 -1
  93. package/build/esm/test.js +5 -4
  94. package/build/esm/test.js.map +1 -1
  95. package/package.json +2 -2
@@ -3,64 +3,45 @@
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
+ };
20
+ /**
21
+ * @internal Documento crudo del chat. `id` es el identificador del engine (JID, LID o
22
+ * `@g.us`); `pinned` y `mute_end_time` son epoch ms.
23
+ * Raw chat document. `id` is the engine identifier (JID, LID or `@g.us`); `pinned` and
24
+ * `mute_end_time` are epoch ms.
25
+ */
26
+ constructor(_raw: {
27
+ id: string;
28
+ name?: string | null;
29
+ archived?: boolean | null;
30
+ pinned?: number | null;
31
+ mute_end_time?: number | null;
32
+ });
33
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
45
34
  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. */
35
+ /** Nombre del grupo o del contacto. / Group or contact name. */
51
36
  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. */
37
+ /** Tipo de conversación. / Conversation type. */
38
+ get type(): 'group' | 'contact';
39
+ /** true si el chat está archivado. / true when the chat is archived. */
57
40
  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;
41
+ /** true si el chat está fijado. / true when the chat is pinned. */
42
+ get pinned(): boolean;
43
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
44
+ get muted(): string | null;
64
45
  }
65
46
  /**
66
47
  * Factoría de Chat ligada al contexto WhatsApp.
@@ -69,184 +50,339 @@ export declare class Chat {
69
50
  * @param wa - Instancia principal / Main WhatsApp instance
70
51
  */
71
52
  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>;
53
+ new (_raw: {
54
+ id: string;
55
+ name?: string | null;
56
+ archived?: boolean | null;
57
+ pinned?: number | null;
58
+ mute_end_time?: number | null;
59
+ }): {
93
60
  /**
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.
61
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
62
+ * Chat participants: members for groups, the contact and myself for 1:1.
63
+ *
64
+ * @param offset - Desplazamiento / Offset
65
+ * @param limit - Tamaño de página / Page size
66
+ * @returns Página de contactos / Contact page
100
67
  */
101
68
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
102
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
69
+ /**
70
+ * Mensajes del chat paginados desde el más reciente.
71
+ * Chat messages paginated from the most recent one.
72
+ *
73
+ * @param offset - Desplazamiento / Offset
74
+ * @param limit - Tamaño de página / Page size
75
+ * @returns Página de mensajes / Message page
76
+ */
103
77
  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. */
78
+ /**
79
+ * Activa o desactiva el indicador «escribiendo…».
80
+ * Toggles the "typing…" indicator.
81
+ *
82
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
83
+ * @returns true si el socket estaba disponible / true when the socket was available
84
+ */
85
+ typing(value: boolean): Promise<boolean>;
86
+ /**
87
+ * Activa o desactiva el indicador «grabando audio…».
88
+ * Toggles the "recording audio…" indicator.
89
+ *
90
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
91
+ * @returns true si el socket estaba disponible / true when the socket was available
92
+ */
93
+ recording(value: boolean): Promise<boolean>;
94
+ /**
95
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
96
+ * Archives or unarchives the chat on the WhatsApp account.
97
+ *
98
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
99
+ * @returns true si la acción se envió / true when the action was sent
100
+ */
101
+ archive(value: boolean): Promise<boolean>;
102
+ /**
103
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
104
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
105
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
106
+ * chats and silently drops the fourth, so the limit is checked beforehand.
107
+ *
108
+ * @param value - true fija, false desfija / true pins, false unpins
109
+ * @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
110
+ */
111
+ pin(value: boolean): Promise<boolean>;
112
+ /**
113
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
114
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
115
+ *
116
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
117
+ * @returns true si la acción se envió / true when the action was sent
118
+ */
119
+ mute(until: string | number | Date | false): Promise<boolean>;
120
+ /**
121
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
122
+ * Marks the whole chat as read on the WhatsApp account.
123
+ *
124
+ * @returns true si la acción se envió / true when the action was sent
125
+ */
126
+ seen(): Promise<boolean>;
127
+ /**
128
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
129
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
130
+ *
131
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
132
+ */
133
+ clear(): Promise<boolean>;
134
+ /**
135
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
136
+ * abandona el grupo.
137
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
138
+ * groups it leaves the group.
139
+ *
140
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
141
+ */
142
+ delete(): Promise<boolean>;
143
+ readonly _raw: {
144
+ id: string;
145
+ name?: string | null;
146
+ archived?: boolean | null;
147
+ pinned?: number | null;
148
+ mute_end_time?: number | null;
149
+ };
150
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
107
151
  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. */
152
+ /** Nombre del grupo o del contacto. / Group or contact name. */
113
153
  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. */
154
+ /** Tipo de conversación. / Conversation type. */
155
+ get type(): "group" | "contact";
156
+ /** true si el chat está archivado. / true when the chat is archived. */
119
157
  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;
158
+ /** true si el chat está fijado. / true when the chat is pinned. */
159
+ get pinned(): boolean;
160
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
161
+ get muted(): string | null;
126
162
  };
127
163
  /**
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.
164
+ * Carga un chat por teléfono, JID, LID o id de grupo: el persistido en el engine o,
165
+ * si todavía no existe, una instancia mínima lista para usar (no se persiste).
166
+ * Loads a chat by phone, JID, LID or group id: the engine-persisted one or, when it
167
+ * does not exist yet, a minimal ready-to-use instance (not persisted).
168
+ *
169
+ * @param cid - Teléfono, JID, LID o id de grupo / Phone, JID, LID or group id
170
+ * @returns Chat o null si el identificador es irresoluble / Chat or null when the identifier cannot be resolved
130
171
  */
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>;
172
+ get(cid: string | number): Promise<{
152
173
  /**
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.
174
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
175
+ * Chat participants: members for groups, the contact and myself for 1:1.
176
+ *
177
+ * @param offset - Desplazamiento / Offset
178
+ * @param limit - Tamaño de página / Page size
179
+ * @returns Página de contactos / Contact page
159
180
  */
160
181
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
161
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
182
+ /**
183
+ * Mensajes del chat paginados desde el más reciente.
184
+ * Chat messages paginated from the most recent one.
185
+ *
186
+ * @param offset - Desplazamiento / Offset
187
+ * @param limit - Tamaño de página / Page size
188
+ * @returns Página de mensajes / Message page
189
+ */
162
190
  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. */
191
+ /**
192
+ * Activa o desactiva el indicador «escribiendo…».
193
+ * Toggles the "typing…" indicator.
194
+ *
195
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
196
+ * @returns true si el socket estaba disponible / true when the socket was available
197
+ */
198
+ typing(value: boolean): Promise<boolean>;
199
+ /**
200
+ * Activa o desactiva el indicador «grabando audio…».
201
+ * Toggles the "recording audio…" indicator.
202
+ *
203
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
204
+ * @returns true si el socket estaba disponible / true when the socket was available
205
+ */
206
+ recording(value: boolean): Promise<boolean>;
207
+ /**
208
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
209
+ * Archives or unarchives the chat on the WhatsApp account.
210
+ *
211
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
212
+ * @returns true si la acción se envió / true when the action was sent
213
+ */
214
+ archive(value: boolean): Promise<boolean>;
215
+ /**
216
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
217
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
218
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
219
+ * chats and silently drops the fourth, so the limit is checked beforehand.
220
+ *
221
+ * @param value - true fija, false desfija / true pins, false unpins
222
+ * @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
223
+ */
224
+ pin(value: boolean): Promise<boolean>;
225
+ /**
226
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
227
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
228
+ *
229
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
230
+ * @returns true si la acción se envió / true when the action was sent
231
+ */
232
+ mute(until: string | number | Date | false): Promise<boolean>;
233
+ /**
234
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
235
+ * Marks the whole chat as read on the WhatsApp account.
236
+ *
237
+ * @returns true si la acción se envió / true when the action was sent
238
+ */
239
+ seen(): Promise<boolean>;
240
+ /**
241
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
242
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
243
+ *
244
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
245
+ */
246
+ clear(): Promise<boolean>;
247
+ /**
248
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
249
+ * abandona el grupo.
250
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
251
+ * groups it leaves the group.
252
+ *
253
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
254
+ */
255
+ delete(): Promise<boolean>;
256
+ readonly _raw: {
257
+ id: string;
258
+ name?: string | null;
259
+ archived?: boolean | null;
260
+ pinned?: number | null;
261
+ mute_end_time?: number | null;
262
+ };
263
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
166
264
  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. */
265
+ /** Nombre del grupo o del contacto. / Group or contact name. */
172
266
  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. */
267
+ /** Tipo de conversación. / Conversation type. */
268
+ get type(): "group" | "contact";
269
+ /** true si el chat está archivado. / true when the chat is archived. */
178
270
  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;
271
+ /** true si el chat está fijado. / true when the chat is pinned. */
272
+ get pinned(): boolean;
273
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
274
+ get muted(): string | null;
185
275
  } | null>;
186
- /** Pagina los chats persistidos por mtime DESC. / Paginates persisted chats by mtime DESC. */
276
+ /**
277
+ * Pagina los chats persistidos, del más reciente al más antiguo.
278
+ * Paginates persisted chats, from the most recent to the oldest.
279
+ *
280
+ * @param offset - Desplazamiento / Offset
281
+ * @param limit - Tamaño de página / Page size
282
+ * @returns Página de chats / Chat page
283
+ */
187
284
  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
285
  /**
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.
286
+ * Participantes del chat: los integrantes en grupos, el contacto y yo en 1:1.
287
+ * Chat participants: members for groups, the contact and myself for 1:1.
288
+ *
289
+ * @param offset - Desplazamiento / Offset
290
+ * @param limit - Tamaño de página / Page size
291
+ * @returns Página de contactos / Contact page
215
292
  */
216
293
  members(offset?: number, limit?: number): Promise<InstanceType<typeof wa.Contact>[]>;
217
- /** Mensajes del chat paginados por mtime DESC. / Chat messages paginated by mtime DESC. */
294
+ /**
295
+ * Mensajes del chat paginados desde el más reciente.
296
+ * Chat messages paginated from the most recent one.
297
+ *
298
+ * @param offset - Desplazamiento / Offset
299
+ * @param limit - Tamaño de página / Page size
300
+ * @returns Página de mensajes / Message page
301
+ */
218
302
  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. */
303
+ /**
304
+ * Activa o desactiva el indicador «escribiendo…».
305
+ * Toggles the "typing…" indicator.
306
+ *
307
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
308
+ * @returns true si el socket estaba disponible / true when the socket was available
309
+ */
310
+ typing(value: boolean): Promise<boolean>;
311
+ /**
312
+ * Activa o desactiva el indicador «grabando audio…».
313
+ * Toggles the "recording audio…" indicator.
314
+ *
315
+ * @param value - true activa, false vuelve a pausa / true enables, false returns to paused
316
+ * @returns true si el socket estaba disponible / true when the socket was available
317
+ */
318
+ recording(value: boolean): Promise<boolean>;
319
+ /**
320
+ * Archiva o desarchiva el chat en la cuenta de WhatsApp.
321
+ * Archives or unarchives the chat on the WhatsApp account.
322
+ *
323
+ * @param value - true archiva, false desarchiva / true archives, false unarchives
324
+ * @returns true si la acción se envió / true when the action was sent
325
+ */
326
+ archive(value: boolean): Promise<boolean>;
327
+ /**
328
+ * Fija o desfija el chat en la cuenta de WhatsApp. WhatsApp acepta hasta 3 chats
329
+ * fijados y descarta el cuarto sin avisar, así que el límite se verifica antes.
330
+ * Pins or unpins the chat on the WhatsApp account. WhatsApp accepts up to 3 pinned
331
+ * chats and silently drops the fourth, so the limit is checked beforehand.
332
+ *
333
+ * @param value - true fija, false desfija / true pins, false unpins
334
+ * @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
335
+ */
336
+ pin(value: boolean): Promise<boolean>;
337
+ /**
338
+ * Silencia el chat hasta la fecha indicada. `false` o una fecha pasada lo des-silencian.
339
+ * Mutes the chat until the given date. `false` or a past date unmutes it.
340
+ *
341
+ * @param until - Fecha límite (ISO, epoch ms o Date) o false / Deadline (ISO, epoch ms or Date) or false
342
+ * @returns true si la acción se envió / true when the action was sent
343
+ */
344
+ mute(until: string | number | Date | false): Promise<boolean>;
345
+ /**
346
+ * Marca el chat completo como leído en la cuenta de WhatsApp.
347
+ * Marks the whole chat as read on the WhatsApp account.
348
+ *
349
+ * @returns true si la acción se envió / true when the action was sent
350
+ */
351
+ seen(): Promise<boolean>;
352
+ /**
353
+ * Vacía los mensajes del chat en la cuenta de WhatsApp y en el engine, conservando el chat.
354
+ * Clears the chat messages on the WhatsApp account and in the engine, keeping the chat.
355
+ *
356
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
357
+ */
358
+ clear(): Promise<boolean>;
359
+ /**
360
+ * Elimina el chat y sus mensajes en la cuenta de WhatsApp y en el engine; en grupos
361
+ * abandona el grupo.
362
+ * Deletes the chat and its messages on the WhatsApp account and in the engine; for
363
+ * groups it leaves the group.
364
+ *
365
+ * @returns true siempre; la limpieza local es idempotente / always true; local cleanup is idempotent
366
+ */
367
+ delete(): Promise<boolean>;
368
+ readonly _raw: {
369
+ id: string;
370
+ name?: string | null;
371
+ archived?: boolean | null;
372
+ pinned?: number | null;
373
+ mute_end_time?: number | null;
374
+ };
375
+ /** Teléfono del contacto, o el identificador crudo en grupos y LIDs. / Contact phone, or the raw identifier for groups and LIDs. */
222
376
  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. */
377
+ /** Nombre del grupo o del contacto. / Group or contact name. */
228
378
  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. */
379
+ /** Tipo de conversación. / Conversation type. */
380
+ get type(): "group" | "contact";
381
+ /** true si el chat está archivado. / true when the chat is archived. */
234
382
  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;
383
+ /** true si el chat está fijado. / true when the chat is pinned. */
384
+ get pinned(): boolean;
385
+ /** Fecha ISO UTC hasta la que el chat está silenciado, o null. / ISO UTC date until the chat stays muted, or null. */
386
+ get muted(): string | null;
241
387
  }[]>;
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
388
  };