@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
@@ -6,4 +6,3 @@
6
6
  * API to build bots on top of the WhatsApp client.
7
7
  */
8
8
  export { WhatsAppBot, Bot, on, guard, command, from, once, connect, disconnect, every, delay, pipe, pair, HANDLERS, decorator, } from './lib/bot/index.js';
9
- //# sourceMappingURL=decorators.js.map
@@ -5,7 +5,9 @@
5
5
  */
6
6
  export { WhatsApp, default } from './lib/whatsapp/index.js';
7
7
  export type { IWhatsApp, DisconnectOptions, ReconnectOption } from './lib/whatsapp/index.js';
8
- export { FileSystemEngine, RedisEngine, S3Engine, serialize, deserialize } from './lib/store/index.js';
9
- export type { Engine, RedisClient } from './lib/store/index.js';
10
- export { default as Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
11
- export type { IFeedRaw, FeedType } from './lib/status/index.js';
8
+ export { FileSystemEngine, RedisEngine, S3Engine, SQLiteEngine, serialize, deserialize } from './lib/store/index.js';
9
+ export type { Engine, RedisClient, SQLiteDatabase } from './lib/store/index.js';
10
+ export { Contact, contact } from './lib/contact/index.js';
11
+ export { Chat, chat } from './lib/chat/index.js';
12
+ export { Message, message, Text, Image, Video, Audio, Sticker, Document, Location, Poll, VCard, Event } from './lib/message/index.js';
13
+ export { Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
@@ -4,6 +4,8 @@
4
4
  * Public entry point of the @arcaelas/whatsapp library.
5
5
  */
6
6
  export { WhatsApp, default } from './lib/whatsapp/index.js';
7
- export { FileSystemEngine, RedisEngine, S3Engine, serialize, deserialize } from './lib/store/index.js';
8
- export { default as Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
9
- //# sourceMappingURL=index.js.map
7
+ export { FileSystemEngine, RedisEngine, S3Engine, SQLiteEngine, serialize, deserialize } from './lib/store/index.js';
8
+ export { Contact, contact } from './lib/contact/index.js';
9
+ export { Chat, chat } from './lib/chat/index.js';
10
+ export { Message, message, Text, Image, Video, Audio, Sticker, Document, Location, Poll, VCard, Event } from './lib/message/index.js';
11
+ export { Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
@@ -66,6 +66,8 @@ export declare function decorator<P extends unknown[]>(callback: (metadata: Meta
66
66
  * `connect()` listeners get wired against the real event emitter automatically.
67
67
  */
68
68
  export declare class WhatsAppBot extends WhatsApp {
69
+ /** @internal Evita re-cablear handlers en reconexiones (duplicaría cada listener). / Prevents re-wiring handlers on reconnects (would duplicate every listener). */
70
+ private _wired;
69
71
  constructor(options: IWhatsApp);
70
72
  /**
71
73
  * Inicia la conexión cableando previamente los handlers decorados. Los métodos
@@ -87,6 +87,8 @@ export function decorator(callback) {
87
87
  export class WhatsAppBot extends WhatsApp {
88
88
  constructor(options) {
89
89
  super(options);
90
+ /** @internal Evita re-cablear handlers en reconexiones (duplicaría cada listener). / Prevents re-wiring handlers on reconnects (would duplicate every listener). */
91
+ this._wired = false;
90
92
  }
91
93
  /**
92
94
  * Inicia la conexión cableando previamente los handlers decorados. Los métodos
@@ -138,6 +140,10 @@ export class WhatsAppBot extends WhatsApp {
138
140
  * (`@on`/`@once`), timers (`@every`) and workflows (`@pipe`).
139
141
  */
140
142
  _wire_handlers() {
143
+ if (this._wired) {
144
+ return;
145
+ }
146
+ this._wired = true;
141
147
  const metadata = this.constructor[Symbol.metadata];
142
148
  if (metadata) {
143
149
  const schema = metadata[HANDLERS];
@@ -237,4 +243,3 @@ export class WhatsAppBot extends WhatsApp {
237
243
  }
238
244
  }
239
245
  export default WhatsAppBot;
240
- //# sourceMappingURL=decorator.js.map
@@ -82,9 +82,9 @@ export declare function delay(ms: number): (_value: unknown, context: ClassMetho
82
82
  export declare const pair: () => (_value: unknown, context: ClassMethodDecoratorContext) => void;
83
83
  /**
84
84
  * Filtra por autor del mensaje. Acepta JID, LID o teléfono numérico; el string
85
- * se normaliza vía `wa._resolve_jid` con cache lazy. Un array produce match OR.
85
+ * se normaliza con la resolución interna del cliente y cache lazy. Un array produce match OR.
86
86
  * Filters by message author. Accepts JID, LID or numeric phone; the string is
87
- * normalized via `wa._resolve_jid` with lazy cache. An array yields OR matching.
87
+ * normalized through the client's internal resolution with lazy cache. An array yields OR matching.
88
88
  *
89
89
  * @param source - Identificador(es) permitidos o predicate sobre `msg.from` / Allowed identifier(s) or predicate on `msg.from`
90
90
  */
@@ -3,6 +3,7 @@
3
3
  * @description Decoradores públicos del bot.
4
4
  * Public bot decorators.
5
5
  */
6
+ import { internals } from '../../lib/internal.js';
6
7
  import { WhatsAppBot, decorator, register_workflow_step, resolve, } from './decorator.js';
7
8
  /**
8
9
  * Registra el método como listener del evento indicado. Apilable: varios `@on`
@@ -114,9 +115,9 @@ export const pair = decorator((_meta, h) => {
114
115
  });
115
116
  /**
116
117
  * Filtra por autor del mensaje. Acepta JID, LID o teléfono numérico; el string
117
- * se normaliza vía `wa._resolve_jid` con cache lazy. Un array produce match OR.
118
+ * se normaliza con la resolución interna del cliente y cache lazy. Un array produce match OR.
118
119
  * Filters by message author. Accepts JID, LID or numeric phone; the string is
119
- * normalized via `wa._resolve_jid` with lazy cache. An array yields OR matching.
120
+ * normalized through the client's internal resolution with lazy cache. An array yields OR matching.
120
121
  *
121
122
  * @param source - Identificador(es) permitidos o predicate sobre `msg.from` / Allowed identifier(s) or predicate on `msg.from`
122
123
  */
@@ -134,7 +135,7 @@ export function from(source) {
134
135
  if (resolved === null) {
135
136
  resolved = new Set();
136
137
  for (const raw of list) {
137
- const r = await wa._resolve_jid(raw);
138
+ const r = await internals(wa).resolve_jid(raw);
138
139
  if (r) {
139
140
  resolved.add(r);
140
141
  }
@@ -247,4 +248,3 @@ export function command(pattern) {
247
248
  });
248
249
  };
249
250
  }
250
- //# sourceMappingURL=decorators.js.map
@@ -1,3 +1,2 @@
1
1
  export { WhatsAppBot, HANDLERS, decorator } from './decorator.js';
2
2
  export { on, guard, command, from, once, connect, disconnect, every, delay, pipe, pair, Bot } from './decorators.js';
3
- //# sourceMappingURL=index.js.map