@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
@@ -1,70 +1,68 @@
1
1
  "use strict";
2
2
  /**
3
3
  * @file contact/index.ts
4
- * @description Entidad Contact — lectura/escritura documental sobre `wa.engine`.
5
- * Contact entity — documental read/write over `wa.engine`.
4
+ * @description Entidad Contact — una ficha mínima derivada del raw del contacto.
5
+ * Contact entity — a minimal card derived from the raw contact document.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.Contact = void 0;
9
- exports.contact_name = contact_name;
10
9
  exports.contact = contact;
11
10
  const baileys_1 = require("baileys");
11
+ const internal_1 = require("../../lib/internal");
12
12
  const store_1 = require("../../lib/store");
13
13
  /**
14
- * Resuelve el nombre mostrado de un contacto con prioridad local push teléfono.
15
- * Resolves a contact's display name with priority local push phone number.
16
- *
17
- * @param raw - Documento persistido del contacto / Persisted contact document
18
- * @returns Nombre mostrado / Display name
19
- */
20
- function contact_name(raw) {
21
- return raw.name ?? raw.notify ?? raw.id.split('@')[0];
22
- }
23
- /**
24
- * Clase base del contacto (forma pública, solo lectura).
25
- * Base Contact class (public shape, read-only).
14
+ * Clase base del contacto: recibe el raw de baileys y deriva todo con getters.
15
+ * Base Contact class: receives the baileys raw and derives everything via getters.
26
16
  */
27
17
  class Contact {
28
- constructor(raw, chat) {
29
- this._raw = raw;
30
- this._chat = chat;
18
+ /**
19
+ * @internal Documento crudo del contacto en snake_case. `id` llega en formato LID o PN
20
+ * según el addressing; `phone_number` es el JID PN cuando baileys lo conoce.
21
+ * Raw contact document in snake_case. `id` arrives in LID or PN format depending on
22
+ * addressing; `phone_number` is the PN JID when baileys knows it.
23
+ */
24
+ constructor(_raw) {
25
+ this._raw = _raw;
31
26
  }
32
- /** JID único. / Unique JID. */
33
- get id() {
34
- return this._raw.id;
27
+ /** Nombre: agenda → público → verificado → teléfono. / Name: address book → public → verified → phone. */
28
+ get name() {
29
+ const { name, notify, verified_name } = this._raw;
30
+ return name ?? notify ?? verified_name ?? this.phone ?? this._raw.id.split('@')[0];
35
31
  }
36
- /** JID (alias). / JID (alias). */
32
+ /**
33
+ * JID legado (`@s.whatsapp.net`): el reportado por baileys o generado desde el id
34
+ * cuando ya viene en formato PN; null si no es determinable.
35
+ * Legacy JID (`@s.whatsapp.net`): the one baileys reports or generated from the id
36
+ * when it is already PN-formatted; null when not determinable.
37
+ */
37
38
  get jid() {
38
- return this._raw.id;
39
+ if (this._raw.phone_number)
40
+ return (0, baileys_1.jidNormalizedUser)(this._raw.phone_number);
41
+ if (this._raw.id.endsWith('@s.whatsapp.net'))
42
+ return (0, baileys_1.jidNormalizedUser)(this._raw.id);
43
+ return null;
39
44
  }
40
- /** LID si está disponible. / LID when available. */
45
+ /** LID (`@lid`) cuando es definible; null si no. / LID (`@lid`) when definable; null otherwise. */
41
46
  get lid() {
42
- return this._raw.lid ?? null;
43
- }
44
- /** Nombre: local → push → teléfono. / Name: local → push → phone. */
45
- get name() {
46
- return contact_name(this._raw);
47
+ if (this._raw.lid)
48
+ return this._raw.lid;
49
+ if (this._raw.id.endsWith('@lid'))
50
+ return this._raw.id;
51
+ return null;
47
52
  }
48
- /** Número sin formato. / Raw phone number. */
53
+ /**
54
+ * Teléfono del contacto, derivado únicamente del JID PN (nunca del LID);
55
+ * null cuando no hay JID determinable.
56
+ * Contact phone, derived from the PN JID only (never from the LID);
57
+ * null when no JID is determinable.
58
+ */
49
59
  get phone() {
50
- return this._raw.id.split('@')[0];
60
+ return this.jid?.split('@')[0] ?? null;
51
61
  }
52
- /** URL de foto de perfil. / Profile picture URL. */
62
+ /** URL de la foto de perfil, o null. / Profile picture URL, or null. */
53
63
  get photo() {
54
- return this._raw.img_url ?? null;
55
- }
56
- /** Bio del contacto. / Contact bio. */
57
- get content() {
58
- return this._raw.status ?? '';
59
- }
60
- /**
61
- * Chat 1:1 asociado al contacto. Async por coherencia con `Message.chat()` /
62
- * `Message.author()`, aunque la instancia ya está hidratada en memoria.
63
- * 1:1 chat associated with the contact. Async for consistency with
64
- * `Message.chat()` / `Message.author()`, though already hydrated in memory.
65
- */
66
- async chat() {
67
- return this._chat;
64
+ const url = this._raw.img_url;
65
+ return url?.startsWith('http') ? url : null;
68
66
  }
69
67
  }
70
68
  exports.Contact = Contact;
@@ -75,173 +73,81 @@ exports.Contact = Contact;
75
73
  * @param wa - Instancia principal / Main WhatsApp instance
76
74
  */
77
75
  function contact(wa) {
78
- /**
79
- * Descubre el JID canónico y el LID (cuando aplica) de un número consultando al socket.
80
- * Discovers the canonical JID and LID (when applicable) of a phone number via the socket.
81
- */
82
- async function discover_by_phone(phone) {
83
- let result = null;
84
- if (wa._socket && phone.length > 0) {
85
- const found = (await wa._socket.onWhatsApp(phone))?.[0];
86
- if (found?.exists) {
87
- result = { jid: (0, baileys_1.jidNormalizedUser)(found.jid), lid: found.lid ?? null };
88
- }
89
- }
90
- return result;
91
- }
92
- /**
93
- * Obtiene foto y bio del contacto desde el socket.
94
- * Fetches profile picture and bio from the socket.
95
- */
96
- async function fetch_profile_data(id) {
97
- let img_url = null;
98
- let status = null;
99
- if (wa._socket) {
100
- try {
101
- img_url = (await wa._socket.profilePictureUrl(id, 'image')) ?? null;
102
- }
103
- catch {
104
- /* may not exist */
105
- }
106
- try {
107
- const result = await wa._socket.fetchStatus(id);
108
- const data = result?.[0];
109
- status = data?.status?.status ?? null;
110
- }
111
- catch {
112
- /* may fail */
113
- }
114
- }
115
- return { img_url, status };
116
- }
117
- /**
118
- * Carga la instancia Chat 1:1 del contacto. Si no existe en engine, fabrica una mínima.
119
- * Loads the 1:1 Chat instance for a contact. Falls back to a minimal instance if missing.
120
- */
121
- async function load_chat_for(jid, fallback_name) {
122
- const cached = (0, store_1.deserialize)(await wa.engine.get(`/chat/${jid}`));
123
- return new wa.Chat(cached ?? { id: jid, name: fallback_name });
124
- }
125
76
  return class _Contact extends Contact {
126
- constructor(raw, chat) {
127
- super(raw, chat);
128
- }
129
- /** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
77
+ /**
78
+ * Chat 1:1 del contacto: el persistido en el engine, o una instancia mínima.
79
+ * The contact's 1:1 chat: the engine-persisted one, or a minimal instance.
80
+ *
81
+ * @returns Instancia de Chat / Chat instance
82
+ */
130
83
  async chat() {
131
- return this._chat;
132
- }
133
- /** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
134
- get me() {
135
- const self_id = wa._socket?.user?.id;
136
- return Boolean(self_id) && (0, baileys_1.jidNormalizedUser)(self_id) === this.id;
84
+ const cid = this.jid ?? this.lid ?? this._raw.id;
85
+ const cached = (0, store_1.deserialize)(await wa.engine.get(`/chat/${cid}`));
86
+ return new wa.Chat(cached ?? { id: cid, name: this.name });
137
87
  }
138
88
  /**
139
- * Obtiene un contacto. Dispatch inteligente:
140
- * - Si `uid` contiene `@` → se interpreta como JID (`@s.whatsapp.net` / `@g.us`) o LID (`@lid`) y se resuelve con el mapping.
141
- * - Si no contiene `@` se limpian los dígitos y se consulta `socket.onWhatsApp(phone)` para obtener el JID canónico.
89
+ * Carga un contacto por teléfono, JID o LID: primero el engine; si no está
90
+ * persistido lo descubre por red (`onWhatsApp` + foto + bio) y lo materializa.
91
+ * Loads a contact by phone, JID or LID: engine first; when not persisted it
92
+ * discovers it over the network (`onWhatsApp` + photo + bio) and materializes it.
142
93
  *
143
- * Retrieves a contact. Smart dispatch:
144
- * - If `uid` contains `@` treated as JID or LID, resolved via mapping.
145
- * - If `uid` lacks `@` → digits are extracted and `socket.onWhatsApp(phone)` resolves the canonical JID.
94
+ * @param uid - Teléfono, JID o LID / Phone, JID or LID
95
+ * @returns Contacto o null si no existe en WhatsApp / Contact or null when not on WhatsApp
146
96
  */
147
97
  static async get(uid) {
148
- let result = null;
149
- let jid = null;
150
- let lid = null;
151
- if (uid.includes('@')) {
152
- jid = await wa._resolve_jid(uid);
153
- }
154
- else {
155
- const discovered = await discover_by_phone(uid.replace(/\D+/g, ''));
156
- if (discovered) {
157
- jid = discovered.jid;
158
- lid = discovered.lid;
159
- }
160
- }
98
+ const digits = String(uid).replace(/\D+/g, '');
99
+ const jid = String(uid).includes('@')
100
+ ? await (0, internal_1.internals)(wa).resolve_jid(String(uid))
101
+ : digits
102
+ ? `${digits}@s.whatsapp.net`
103
+ : null;
161
104
  if (jid && !jid.endsWith('@g.us')) {
162
105
  const cached = (0, store_1.deserialize)(await wa.engine.get(`/contact/${jid}`));
163
- if (cached) {
164
- result = new _Contact(cached, await load_chat_for(jid, contact_name(cached)));
165
- }
166
- else if (wa._socket) {
167
- const needs_check = !lid && !uid.endsWith('@lid');
168
- const discovered = needs_check
169
- ? await discover_by_phone(jid.split('@')[0])
170
- : { jid, lid };
171
- if (discovered) {
172
- const { img_url, status } = await fetch_profile_data(discovered.jid);
106
+ if (cached)
107
+ return new _Contact(cached);
108
+ const socket = (0, internal_1.internals)(wa).socket;
109
+ if (socket) {
110
+ const found = (await socket.onWhatsApp(jid.split('@')[0]))?.[0];
111
+ if (found?.exists) {
112
+ const id = (0, baileys_1.jidNormalizedUser)(found.jid);
113
+ const img_url = await socket.profilePictureUrl(id, 'image').catch(() => null);
114
+ const status = await socket
115
+ .fetchStatus(id)
116
+ .then((result) => result?.[0]?.status?.status ?? null)
117
+ .catch(() => null);
173
118
  const raw = {
174
- id: discovered.jid,
175
- lid: discovered.lid,
119
+ id,
120
+ lid: found.lid ?? null,
121
+ phone_number: id,
176
122
  name: null,
177
123
  notify: null,
178
124
  verified_name: null,
179
- img_url,
125
+ img_url: img_url ?? null,
180
126
  status,
181
127
  };
182
- await wa.engine.set(`/contact/${discovered.jid}`, (0, store_1.serialize)(raw));
183
- if (discovered.lid) {
184
- await wa.engine.set(`/lid/${discovered.lid}`, (0, store_1.serialize)(discovered.jid));
128
+ await wa.engine.set(`/contact/${id}`, (0, store_1.serialize)(raw));
129
+ if (found.lid) {
130
+ await wa.engine.set(`/lid/${found.lid}`, (0, store_1.serialize)(id));
185
131
  }
186
- result = new _Contact(raw, await load_chat_for(discovered.jid, discovered.jid.split('@')[0]));
132
+ return new _Contact(raw);
187
133
  }
188
134
  }
189
135
  }
190
- return result;
136
+ return null;
191
137
  }
192
138
  /**
193
- * Pagina los contactos persistidos por mtime DESC, pre-cargando el chat de cada uno.
194
- * Paginates persisted contacts by mtime DESC, pre-loading the chat of each one.
139
+ * Pagina los contactos persistidos.
140
+ * Paginates persisted contacts.
141
+ *
142
+ * @param offset - Desplazamiento / Offset
143
+ * @param limit - Tamaño de página / Page size
144
+ * @returns Página de contactos / Contact page
195
145
  */
196
146
  static async list(offset = 0, limit = 50) {
197
- const contacts = [];
198
- for (const raw of await wa.engine.list('/contact', offset, limit)) {
199
- const parsed = (0, store_1.deserialize)(raw);
200
- if (parsed) {
201
- contacts.push(new _Contact(parsed, await load_chat_for(parsed.id, contact_name(parsed))));
202
- }
203
- }
204
- return contacts;
205
- }
206
- /**
207
- * Renombra localmente un contacto por id.
208
- * Renames a contact locally by id.
209
- */
210
- static async rename(uid, name) {
211
- const c = await _Contact.get(uid);
212
- return c ? c.rename(name) : false;
213
- }
214
- /**
215
- * Re-hidrata los datos del contacto por id desde el socket.
216
- * Re-hydrates contact data from the socket by id.
217
- */
218
- static async refresh(uid) {
219
- const c = await _Contact.get(uid);
220
- return c ? c.refresh() : null;
221
- }
222
- /**
223
- * Renombra el contacto localmente (solo agenda del dispositivo).
224
- * Renames the contact locally (device address book only).
225
- */
226
- async rename(name) {
227
- this._raw.name = name;
228
- await wa.engine.set(`/contact/${this.id}`, (0, store_1.serialize)(this._raw));
229
- return true;
230
- }
231
- /**
232
- * Re-hidrata foto y bio desde el socket.
233
- * Re-hydrates profile picture and bio from the socket.
234
- */
235
- async refresh() {
236
- let ok = false;
237
- if (wa._socket) {
238
- const { img_url, status } = await fetch_profile_data(this.id);
239
- this._raw.img_url = img_url;
240
- this._raw.status = status;
241
- await wa.engine.set(`/contact/${this.id}`, (0, store_1.serialize)(this._raw));
242
- ok = true;
243
- }
244
- return ok ? this : null;
147
+ return (await wa.engine.list('/contact', offset, limit))
148
+ .map((raw) => (0, store_1.deserialize)(raw))
149
+ .filter((parsed) => parsed !== null)
150
+ .map((parsed) => new _Contact(parsed));
245
151
  }
246
152
  };
247
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA4BH,oCAEC;AA+DD,0BAkMC;AA7RD,qCAA4C;AAE5C,uCAAqD;AAiBrD;;;;;;GA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I;4BACxB,MAAM;yBACP,CAAC;wBACF,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,EAAE,IAAA,iBAAS,EAAC,GAAG,CAAC,CAAC,CAAC;wBACtD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;4BACd,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,GAAG,EAAE,EAAE,IAAA,iBAAS,EAAC,EAAE,CAAC,CAAC,CAAC;wBAC1D,CAAC;wBACD,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;;;WAOG;QACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE;YACtC,OAAO,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;iBACrD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,mBAAW,EAAkB,GAAG,CAAC,CAAC;iBAC/C,MAAM,CAAC,CAAC,MAAM,EAA6B,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC;iBAC9D,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @file internal.ts
3
+ * @description Canal privado entre el cliente y sus entidades. Vive en un `WeakMap` fuera de
4
+ * la instancia, así el socket de baileys y la resolución de JIDs quedan disponibles para
5
+ * `Contact`, `Chat`, `Message` y `Feed` sin exponerse en la superficie pública de `WhatsApp`:
6
+ * el consumidor sólo ve `on`/`once`/`off`/`emit` y los métodos documentados.
7
+ * Private channel between the client and its entities. It lives in a `WeakMap` outside the
8
+ * instance, so the baileys socket and JID resolution stay available to `Contact`, `Chat`,
9
+ * `Message` and `Feed` without surfacing on `WhatsApp`'s public API: consumers only see
10
+ * `on`/`once`/`off`/`emit` and the documented methods.
11
+ */
12
+ import type { WASocket } from 'baileys';
13
+ /**
14
+ * Estado que el cliente comparte con sus entidades.
15
+ * State the client shares with its entities.
16
+ */
17
+ export interface Internals {
18
+ /** Socket vivo de baileys, o null mientras no hay conexión. / Live baileys socket, or null while disconnected. */
19
+ socket: WASocket | null;
20
+ /** Normaliza cualquier identificador (JID, LID o teléfono) a JID canónico. / Normalizes any identifier (JID, LID or phone) into a canonical JID. */
21
+ resolve_jid(uid: string): Promise<string | null>;
22
+ }
23
+ /**
24
+ * Publica el estado interno de un cliente para las entidades de la librería.
25
+ * Publishes a client's internal state for the library entities.
26
+ *
27
+ * @param owner - Cliente dueño del estado / Client owning the state
28
+ * @param state - Estado compartido, mutable por el cliente / Shared state, mutated by the client
29
+ */
30
+ export declare function bind(owner: object, state: Internals): void;
31
+ /**
32
+ * Estado interno del cliente. Sólo lo resuelven los módulos de la librería: el objeto
33
+ * nunca se expone al consumidor.
34
+ * A client's internal state. Only library modules resolve it: the object is never exposed
35
+ * to the consumer.
36
+ *
37
+ * @param owner - Cliente construido por la librería / Client built by the library
38
+ * @returns Estado compartido / Shared state
39
+ */
40
+ export declare function internals(owner: object): Internals;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * @file internal.ts
4
+ * @description Canal privado entre el cliente y sus entidades. Vive en un `WeakMap` fuera de
5
+ * la instancia, así el socket de baileys y la resolución de JIDs quedan disponibles para
6
+ * `Contact`, `Chat`, `Message` y `Feed` sin exponerse en la superficie pública de `WhatsApp`:
7
+ * el consumidor sólo ve `on`/`once`/`off`/`emit` y los métodos documentados.
8
+ * Private channel between the client and its entities. It lives in a `WeakMap` outside the
9
+ * instance, so the baileys socket and JID resolution stay available to `Contact`, `Chat`,
10
+ * `Message` and `Feed` without surfacing on `WhatsApp`'s public API: consumers only see
11
+ * `on`/`once`/`off`/`emit` and the documented methods.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.bind = bind;
15
+ exports.internals = internals;
16
+ const channel = new WeakMap();
17
+ /**
18
+ * Publica el estado interno de un cliente para las entidades de la librería.
19
+ * Publishes a client's internal state for the library entities.
20
+ *
21
+ * @param owner - Cliente dueño del estado / Client owning the state
22
+ * @param state - Estado compartido, mutable por el cliente / Shared state, mutated by the client
23
+ */
24
+ function bind(owner, state) {
25
+ channel.set(owner, state);
26
+ }
27
+ /**
28
+ * Estado interno del cliente. Sólo lo resuelven los módulos de la librería: el objeto
29
+ * nunca se expone al consumidor.
30
+ * A client's internal state. Only library modules resolve it: the object is never exposed
31
+ * to the consumer.
32
+ *
33
+ * @param owner - Cliente construido por la librería / Client built by the library
34
+ * @returns Estado compartido / Shared state
35
+ */
36
+ function internals(owner) {
37
+ return channel.get(owner);
38
+ }
39
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/lib/internal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAwBH,oBAEC;AAWD,8BAEC;AAxBD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAqB,CAAC;AAEjD;;;;;;GAMG;AACH,SAAgB,IAAI,CAAC,KAAa,EAAE,KAAgB;IAChD,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,SAAS,CAAC,KAAa;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;AAC/B,CAAC"}