@arcaelas/whatsapp 6.1.3 → 7.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 (42) hide show
  1. package/README.md +19 -15
  2. package/build/cjs/index.d.ts +9 -5
  3. package/build/cjs/index.js +8 -7
  4. package/build/cjs/lib/bot/decorator.d.ts +2 -9
  5. package/build/cjs/lib/bot/decorator.js +0 -1
  6. package/build/cjs/lib/bot/decorators.d.ts +48 -4
  7. package/build/cjs/lib/bot/decorators.js +2 -2
  8. package/build/cjs/lib/chat/index.d.ts +144 -152
  9. package/build/cjs/lib/chat/index.js +138 -209
  10. package/build/cjs/lib/contact/index.d.ts +114 -80
  11. package/build/cjs/lib/contact/index.js +187 -94
  12. package/build/cjs/lib/message/index.d.ts +400 -321
  13. package/build/cjs/lib/message/index.js +425 -913
  14. package/build/cjs/lib/status/index.d.ts +22 -33
  15. package/build/cjs/lib/status/index.js +52 -93
  16. package/build/cjs/lib/store/index.d.ts +16 -0
  17. package/build/cjs/lib/store/index.js +29 -3
  18. package/build/cjs/lib/whatsapp/index.d.ts +44 -212
  19. package/build/cjs/lib/whatsapp/index.js +473 -1067
  20. package/build/esm/index.d.ts +9 -5
  21. package/build/esm/index.js +6 -4
  22. package/build/esm/lib/bot/decorator.d.ts +2 -9
  23. package/build/esm/lib/bot/decorator.js +1 -1
  24. package/build/esm/lib/bot/decorators.d.ts +48 -4
  25. package/build/esm/lib/bot/decorators.js +2 -2
  26. package/build/esm/lib/chat/index.d.ts +144 -152
  27. package/build/esm/lib/chat/index.js +139 -209
  28. package/build/esm/lib/contact/index.d.ts +114 -80
  29. package/build/esm/lib/contact/index.js +186 -94
  30. package/build/esm/lib/message/index.d.ts +400 -321
  31. package/build/esm/lib/message/index.js +422 -913
  32. package/build/esm/lib/status/index.d.ts +22 -33
  33. package/build/esm/lib/status/index.js +49 -93
  34. package/build/esm/lib/store/index.d.ts +16 -0
  35. package/build/esm/lib/store/index.js +25 -0
  36. package/build/esm/lib/whatsapp/index.d.ts +44 -212
  37. package/build/esm/lib/whatsapp/index.js +476 -1069
  38. package/package.json +1 -1
  39. package/build/cjs/lib/internal.d.ts +0 -40
  40. package/build/cjs/lib/internal.js +0 -38
  41. package/build/esm/lib/internal.d.ts +0 -40
  42. package/build/esm/lib/internal.js +0 -34
@@ -3,11 +3,15 @@
3
3
  * @description Punto de entrada público de la librería @arcaelas/whatsapp.
4
4
  * Public entry point of the @arcaelas/whatsapp library.
5
5
  */
6
- export { WhatsApp, default } from './lib/whatsapp/index.js';
7
- export type { IWhatsApp, DisconnectOptions, ReconnectOption } from './lib/whatsapp/index.js';
6
+ import WhatsApp from './lib/whatsapp/index.js';
7
+ export { WhatsApp };
8
+ export default WhatsApp;
9
+ export type IWhatsApp = ConstructorParameters<typeof WhatsApp>[0];
10
+ export type DisconnectOptions = NonNullable<Parameters<WhatsApp['disconnect']>[0]>;
11
+ export type ReconnectOption = NonNullable<IWhatsApp['reconnect']>;
8
12
  export { FileSystemEngine, RedisEngine, S3Engine, SQLiteEngine, serialize, deserialize } from './lib/store/index.js';
9
13
  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';
14
+ export { default as Contact, contact, Account } from './lib/contact/index.js';
15
+ export { default as Chat, chat } from './lib/chat/index.js';
16
+ export { default as Message, message, Text, Image, Video, Audio, Sticker, Document, Location, Poll, VCard, Event } from './lib/message/index.js';
13
17
  export { Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
@@ -3,9 +3,11 @@
3
3
  * @description Punto de entrada público de la librería @arcaelas/whatsapp.
4
4
  * Public entry point of the @arcaelas/whatsapp library.
5
5
  */
6
- export { WhatsApp, default } from './lib/whatsapp/index.js';
6
+ import WhatsApp from './lib/whatsapp/index.js';
7
+ export { WhatsApp };
8
+ export default WhatsApp;
7
9
  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';
10
+ export { default as Contact, contact, Account } from './lib/contact/index.js';
11
+ export { default as Chat, chat } from './lib/chat/index.js';
12
+ export { default as Message, message, Text, Image, Video, Audio, Sticker, Document, Location, Poll, VCard, Event } from './lib/message/index.js';
11
13
  export { Feed, TTL_MS as FEED_TTL_MS } from './lib/status/index.js';
@@ -3,7 +3,8 @@
3
3
  * @description Infraestructura base de decoradores Stage 3 sobre WhatsApp.
4
4
  * Base infrastructure for Stage 3 decorators over WhatsApp.
5
5
  */
6
- import WhatsApp, { type IWhatsApp } from '../../lib/whatsapp/index.js';
6
+ import WhatsApp from '../../lib/whatsapp/index.js';
7
+ type IWhatsApp = ConstructorParameters<typeof WhatsApp>[0];
7
8
  export declare const HANDLERS: unique symbol;
8
9
  export interface HandlerMeta {
9
10
  method: string;
@@ -21,14 +22,6 @@ export interface BotSchema {
21
22
  workflows: Record<string, WorkflowStep[]>;
22
23
  }
23
24
  type Metadata = Record<string | symbol, unknown>;
24
- /**
25
- * Recupera o inicializa el `BotSchema` almacenado en la metadata del contexto.
26
- * Retrieves or initializes the `BotSchema` stored in the context metadata.
27
- *
28
- * @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
29
- * @returns Schema del bot garantizado con `handlers` y `workflows` / Bot schema guaranteed to have `handlers` and `workflows`
30
- */
31
- export declare function ensure_schema(metadata: Metadata): BotSchema;
32
25
  /**
33
26
  * Recupera o inicializa el schema del bot y la entrada del método indicado.
34
27
  * Retrieves or initializes the bot schema and the entry for the given method.
@@ -13,7 +13,7 @@ export const HANDLERS = Symbol('wa:handlers');
13
13
  * @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
14
14
  * @returns Schema del bot garantizado con `handlers` y `workflows` / Bot schema guaranteed to have `handlers` and `workflows`
15
15
  */
16
- export function ensure_schema(metadata) {
16
+ function ensure_schema(metadata) {
17
17
  let schema = metadata[HANDLERS];
18
18
  if (!schema) {
19
19
  schema = { handlers: {}, workflows: {} };
@@ -3,7 +3,8 @@
3
3
  * @description Decoradores públicos del bot.
4
4
  * Public bot decorators.
5
5
  */
6
- import type { IWhatsApp } from '../../lib/whatsapp/index.js';
6
+ import type WhatsApp from '../../lib/whatsapp/index.js';
7
+ type IWhatsApp = ConstructorParameters<typeof WhatsApp>[0];
7
8
  import { WhatsAppBot } from './decorator.js';
8
9
  /**
9
10
  * Registra el método como listener del evento indicado. Apilable: varios `@on`
@@ -13,7 +14,21 @@ import { WhatsAppBot } from './decorator.js';
13
14
  *
14
15
  * @param event - Nombre del evento del cliente / Client event name
15
16
  */
16
- export declare const on: (event: string) => (_value: unknown, context: ClassMethodDecoratorContext) => void;
17
+ export declare const on: (event: string) => (_value: unknown, context: ClassMethodDecoratorContext
18
+ /**
19
+ * Ejecuta el método con un retardo de `ms` milisegundos entre ejecuciones,
20
+ * usando `setTimeout` recursivo. A diferencia de `@every`, la siguiente
21
+ * ejecución solo empieza cuando la anterior ha terminado — nunca hay
22
+ * ejecuciones en paralelo. Arranca en `connected` y se detiene en
23
+ * `disconnected`.
24
+ * Runs the method with `ms` milliseconds between executions using a recursive
25
+ * `setTimeout`. Unlike `@every`, the next execution only starts after the
26
+ * previous one finishes — executions never overlap. Starts on `connected`
27
+ * and stops on `disconnected`.
28
+ *
29
+ * @param ms - Retardo entre ejecuciones en milisegundos / Delay between executions in milliseconds
30
+ */
31
+ ) => void;
17
32
  /**
18
33
  * Pre-chequeo del handler. Los guards se acumulan y se evalúan en orden con AND.
19
34
  * Si el método no tiene `@on` explícito, se auto-registra a `message:created`.
@@ -22,7 +37,21 @@ export declare const on: (event: string) => (_value: unknown, context: ClassMeth
22
37
  *
23
38
  * @param pred - Predicate que recibe los argumentos del evento / Predicate receiving the event arguments
24
39
  */
25
- export declare const guard: (pred: (...args: unknown[]) => boolean | Promise<boolean>) => (_value: unknown, context: ClassMethodDecoratorContext) => void;
40
+ export declare const guard: (pred: (...args: unknown[]) => boolean | Promise<boolean>) => (_value: unknown, context: ClassMethodDecoratorContext
41
+ /**
42
+ * Ejecuta el método con un retardo de `ms` milisegundos entre ejecuciones,
43
+ * usando `setTimeout` recursivo. A diferencia de `@every`, la siguiente
44
+ * ejecución solo empieza cuando la anterior ha terminado — nunca hay
45
+ * ejecuciones en paralelo. Arranca en `connected` y se detiene en
46
+ * `disconnected`.
47
+ * Runs the method with `ms` milliseconds between executions using a recursive
48
+ * `setTimeout`. Unlike `@every`, the next execution only starts after the
49
+ * previous one finishes — executions never overlap. Starts on `connected`
50
+ * and stops on `disconnected`.
51
+ *
52
+ * @param ms - Retardo entre ejecuciones en milisegundos / Delay between executions in milliseconds
53
+ */
54
+ ) => void;
26
55
  /**
27
56
  * Marca el handler para ejecutarse una sola vez y luego auto-desuscribirse.
28
57
  * Con `event` actúa como shortcut de `@on(event) + @once()`.
@@ -79,7 +108,21 @@ export declare function delay(ms: number): (_value: unknown, context: ClassMetho
79
108
  * Marks the method as a pairing (PIN/QR) callback. Multiple `@pair` methods run
80
109
  * in parallel when baileys delivers the code.
81
110
  */
82
- export declare const pair: () => (_value: unknown, context: ClassMethodDecoratorContext) => void;
111
+ export declare const pair: () => (_value: unknown, context: ClassMethodDecoratorContext
112
+ /**
113
+ * Ejecuta el método con un retardo de `ms` milisegundos entre ejecuciones,
114
+ * usando `setTimeout` recursivo. A diferencia de `@every`, la siguiente
115
+ * ejecución solo empieza cuando la anterior ha terminado — nunca hay
116
+ * ejecuciones en paralelo. Arranca en `connected` y se detiene en
117
+ * `disconnected`.
118
+ * Runs the method with `ms` milliseconds between executions using a recursive
119
+ * `setTimeout`. Unlike `@every`, the next execution only starts after the
120
+ * previous one finishes — executions never overlap. Starts on `connected`
121
+ * and stops on `disconnected`.
122
+ *
123
+ * @param ms - Retardo entre ejecuciones en milisegundos / Delay between executions in milliseconds
124
+ */
125
+ ) => void;
83
126
  /**
84
127
  * Filtra por autor del mensaje. Acepta JID, LID o teléfono numérico; el string
85
128
  * se normaliza con la resolución interna del cliente y cache lazy. Un array produce match OR.
@@ -129,3 +172,4 @@ export declare function pipe(workflow: string, index: number): (_value: unknown,
129
172
  * @param pattern - Prefijo textual o RegExp a matchear contra `msg.caption` / Text prefix or RegExp matched against `msg.caption`
130
173
  */
131
174
  export declare function command(pattern: string | RegExp): (value: unknown, context: ClassMethodDecoratorContext) => void;
175
+ export {};
@@ -3,7 +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
+ import { jid_of } from '../../lib/store/index.js';
7
7
  import { WhatsAppBot, decorator, register_workflow_step, resolve, } from './decorator.js';
8
8
  /**
9
9
  * Registra el método como listener del evento indicado. Apilable: varios `@on`
@@ -135,7 +135,7 @@ export function from(source) {
135
135
  if (resolved === null) {
136
136
  resolved = new Set();
137
137
  for (const raw of list) {
138
- const r = await internals(wa).resolve_jid(raw);
138
+ const r = await jid_of(wa.engine, raw);
139
139
  if (r) {
140
140
  resolved.add(r);
141
141
  }