@arcaelas/whatsapp 6.2.0 → 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.
- package/README.md +19 -15
- package/build/cjs/index.d.ts +9 -5
- package/build/cjs/index.js +8 -7
- package/build/cjs/lib/bot/decorator.d.ts +2 -9
- package/build/cjs/lib/bot/decorator.js +0 -1
- package/build/cjs/lib/bot/decorators.d.ts +48 -4
- package/build/cjs/lib/bot/decorators.js +2 -2
- package/build/cjs/lib/chat/index.d.ts +132 -152
- package/build/cjs/lib/chat/index.js +138 -219
- package/build/cjs/lib/contact/index.d.ts +114 -80
- package/build/cjs/lib/contact/index.js +187 -94
- package/build/cjs/lib/message/index.d.ts +400 -321
- package/build/cjs/lib/message/index.js +425 -913
- package/build/cjs/lib/status/index.d.ts +22 -33
- package/build/cjs/lib/status/index.js +52 -93
- package/build/cjs/lib/store/index.d.ts +16 -0
- package/build/cjs/lib/store/index.js +29 -3
- package/build/cjs/lib/whatsapp/index.d.ts +44 -212
- package/build/cjs/lib/whatsapp/index.js +473 -1099
- package/build/esm/index.d.ts +9 -5
- package/build/esm/index.js +6 -4
- package/build/esm/lib/bot/decorator.d.ts +2 -9
- package/build/esm/lib/bot/decorator.js +1 -1
- package/build/esm/lib/bot/decorators.d.ts +48 -4
- package/build/esm/lib/bot/decorators.js +2 -2
- package/build/esm/lib/chat/index.d.ts +132 -152
- package/build/esm/lib/chat/index.js +139 -219
- package/build/esm/lib/contact/index.d.ts +114 -80
- package/build/esm/lib/contact/index.js +186 -94
- package/build/esm/lib/message/index.d.ts +400 -321
- package/build/esm/lib/message/index.js +422 -913
- package/build/esm/lib/status/index.d.ts +22 -33
- package/build/esm/lib/status/index.js +49 -93
- package/build/esm/lib/store/index.d.ts +16 -0
- package/build/esm/lib/store/index.js +25 -0
- package/build/esm/lib/whatsapp/index.d.ts +44 -212
- package/build/esm/lib/whatsapp/index.js +476 -1101
- package/package.json +1 -1
- package/build/cjs/lib/internal.d.ts +0 -40
- package/build/cjs/lib/internal.js +0 -38
- package/build/esm/lib/internal.d.ts +0 -40
- package/build/esm/lib/internal.js +0 -34
package/build/esm/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
export
|
|
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';
|
package/build/esm/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
138
|
+
const r = await jid_of(wa.engine, raw);
|
|
139
139
|
if (r) {
|
|
140
140
|
resolved.add(r);
|
|
141
141
|
}
|