@arcaelas/whatsapp 3.1.1 → 3.2.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 (93) hide show
  1. package/build/cjs/_index.d.ts +14 -0
  2. package/build/cjs/_index.js +346 -0
  3. package/build/cjs/_index.js.map +1 -0
  4. package/build/cjs/decorators.d.ts +9 -0
  5. package/build/cjs/decorators.js +26 -0
  6. package/build/cjs/decorators.js.map +1 -0
  7. package/build/cjs/index.d.ts +11 -0
  8. package/build/cjs/index.js +21 -0
  9. package/build/cjs/index.js.map +1 -0
  10. package/build/cjs/lib/bot/decorator.d.ts +77 -0
  11. package/build/cjs/lib/bot/decorator.js +219 -0
  12. package/build/cjs/lib/bot/decorator.js.map +1 -0
  13. package/build/cjs/lib/bot/decorators.d.ts +113 -0
  14. package/build/cjs/lib/bot/decorators.js +253 -0
  15. package/build/cjs/lib/bot/decorators.js.map +1 -0
  16. package/build/cjs/lib/bot/index.d.ts +3 -0
  17. package/build/cjs/lib/bot/index.js +20 -0
  18. package/build/cjs/lib/bot/index.js.map +1 -0
  19. package/build/cjs/lib/chat/index.d.ts +260 -0
  20. package/build/cjs/lib/chat/index.js +341 -0
  21. package/build/cjs/lib/chat/index.js.map +1 -0
  22. package/build/cjs/lib/contact/index.d.ts +203 -0
  23. package/build/cjs/lib/contact/index.js +226 -0
  24. package/build/cjs/lib/contact/index.js.map +1 -0
  25. package/build/cjs/lib/message/index.d.ts +277 -0
  26. package/build/cjs/lib/message/index.js +767 -0
  27. package/build/cjs/lib/message/index.js.map +1 -0
  28. package/build/cjs/lib/status/index.d.ts +85 -0
  29. package/build/cjs/lib/status/index.js +137 -0
  30. package/build/cjs/lib/status/index.js.map +1 -0
  31. package/build/cjs/lib/store/engine/index.d.ts +34 -0
  32. package/build/cjs/lib/store/engine/index.js +13 -0
  33. package/build/cjs/lib/store/engine/index.js.map +1 -0
  34. package/build/cjs/lib/store/engine/lib/file_system/index.d.ts +56 -0
  35. package/build/cjs/lib/store/engine/lib/file_system/index.js +160 -0
  36. package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -0
  37. package/build/cjs/lib/store/engine/lib/redis/index.d.ts +82 -0
  38. package/build/cjs/lib/store/engine/lib/redis/index.js +132 -0
  39. package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -0
  40. package/build/cjs/lib/store/index.d.ts +22 -0
  41. package/build/cjs/lib/store/index.js +38 -0
  42. package/build/cjs/lib/store/index.js.map +1 -0
  43. package/build/cjs/lib/whatsapp/index.d.ts +185 -0
  44. package/build/cjs/lib/whatsapp/index.js +870 -0
  45. package/build/cjs/lib/whatsapp/index.js.map +1 -0
  46. package/build/cjs/package.json +1 -0
  47. package/build/esm/_index.d.ts +14 -0
  48. package/build/esm/_index.js +344 -0
  49. package/build/esm/_index.js.map +1 -0
  50. package/build/esm/decorators.d.ts +9 -0
  51. package/build/esm/decorators.js +9 -0
  52. package/build/esm/decorators.js.map +1 -0
  53. package/build/esm/index.d.ts +11 -0
  54. package/build/esm/index.js +9 -0
  55. package/build/esm/index.js.map +1 -0
  56. package/build/esm/lib/bot/decorator.d.ts +77 -0
  57. package/build/esm/lib/bot/decorator.js +210 -0
  58. package/build/esm/lib/bot/decorator.js.map +1 -0
  59. package/build/esm/lib/bot/decorators.d.ts +113 -0
  60. package/build/esm/lib/bot/decorators.js +242 -0
  61. package/build/esm/lib/bot/decorators.js.map +1 -0
  62. package/build/esm/lib/bot/index.d.ts +3 -0
  63. package/build/esm/lib/bot/index.js +3 -0
  64. package/build/esm/lib/bot/index.js.map +1 -0
  65. package/build/esm/lib/chat/index.d.ts +260 -0
  66. package/build/esm/lib/chat/index.js +336 -0
  67. package/build/esm/lib/chat/index.js.map +1 -0
  68. package/build/esm/lib/contact/index.d.ts +203 -0
  69. package/build/esm/lib/contact/index.js +221 -0
  70. package/build/esm/lib/contact/index.js.map +1 -0
  71. package/build/esm/lib/message/index.d.ts +277 -0
  72. package/build/esm/lib/message/index.js +755 -0
  73. package/build/esm/lib/message/index.js.map +1 -0
  74. package/build/esm/lib/status/index.d.ts +85 -0
  75. package/build/esm/lib/status/index.js +133 -0
  76. package/build/esm/lib/status/index.js.map +1 -0
  77. package/build/esm/lib/store/engine/index.d.ts +34 -0
  78. package/build/esm/lib/store/engine/index.js +8 -0
  79. package/build/esm/lib/store/engine/index.js.map +1 -0
  80. package/build/esm/lib/store/engine/lib/file_system/index.d.ts +56 -0
  81. package/build/esm/lib/store/engine/lib/file_system/index.js +156 -0
  82. package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -0
  83. package/build/esm/lib/store/engine/lib/redis/index.d.ts +82 -0
  84. package/build/esm/lib/store/engine/lib/redis/index.js +128 -0
  85. package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -0
  86. package/build/esm/lib/store/index.d.ts +22 -0
  87. package/build/esm/lib/store/index.js +31 -0
  88. package/build/esm/lib/store/index.js.map +1 -0
  89. package/build/esm/lib/whatsapp/index.d.ts +185 -0
  90. package/build/esm/lib/whatsapp/index.js +830 -0
  91. package/build/esm/lib/whatsapp/index.js.map +1 -0
  92. package/build/esm/package.json +1 -0
  93. package/package.json +1 -1
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ /**
3
+ * @file playground/bot/decorator.ts
4
+ * @description Infraestructura base de decoradores Stage 3 sobre WhatsApp.
5
+ * Base infrastructure for Stage 3 decorators over WhatsApp.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.WhatsAppBot = exports.HANDLERS = void 0;
12
+ exports.register_workflow_step = register_workflow_step;
13
+ exports.decorator = decorator;
14
+ const whatsapp_1 = __importDefault(require("../../lib/whatsapp"));
15
+ Symbol.metadata ??= Symbol.for('Symbol.metadata');
16
+ exports.HANDLERS = Symbol('wa:handlers');
17
+ /**
18
+ * Recupera o inicializa el schema del bot y la entrada del método indicado.
19
+ * Retrieves or initializes the bot schema and the entry for the given method.
20
+ *
21
+ * @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
22
+ * @param method_name - Nombre del método / Method name
23
+ * @returns Tupla `[schema, handler_meta]` para el método / Tuple `[schema, handler_meta]` for the method
24
+ */
25
+ function resolve(metadata, method_name) {
26
+ let schema = metadata[exports.HANDLERS];
27
+ if (!schema) {
28
+ schema = { handlers: {}, workflows: {} };
29
+ metadata[exports.HANDLERS] = schema;
30
+ }
31
+ if (!schema.workflows) {
32
+ schema.workflows = {};
33
+ }
34
+ schema.handlers[method_name] ||= {
35
+ method: method_name,
36
+ events: [],
37
+ guards: [],
38
+ transforms: [],
39
+ once: false,
40
+ };
41
+ return [schema, schema.handlers[method_name]];
42
+ }
43
+ /**
44
+ * Registra un step dentro de un workflow. Uso interno del decorador `@pipe`.
45
+ * Registers a step inside a workflow. Internal use of the `@pipe` decorator.
46
+ *
47
+ * @param metadata - Metadata del contexto del decorador / Decorator context metadata
48
+ * @param workflow - Nombre del workflow / Workflow name
49
+ * @param step - Step a registrar (índice + nombre del método) / Step to register (index + method name)
50
+ */
51
+ function register_workflow_step(metadata, workflow, step) {
52
+ let schema = metadata[exports.HANDLERS];
53
+ if (!schema) {
54
+ schema = { handlers: {}, workflows: {} };
55
+ metadata[exports.HANDLERS] = schema;
56
+ }
57
+ if (!schema.workflows) {
58
+ schema.workflows = {};
59
+ }
60
+ schema.workflows[workflow] ||= [];
61
+ schema.workflows[workflow].push(step);
62
+ }
63
+ /**
64
+ * Factory para crear decoradores paramétricos Stage 3. El callback muta la metadata
65
+ * del handler mediante la entrada resuelta.
66
+ * Factory to build Stage 3 parametric decorators. The callback mutates the handler
67
+ * metadata via the resolved entry.
68
+ *
69
+ * @param callback - Mutador de la entrada del handler / Handler entry mutator
70
+ * @returns Decorador paramétrico listo para aplicarse a un método / Parametric decorator ready to be applied to a method
71
+ */
72
+ function decorator(callback) {
73
+ return (...params) => (_value, context) => {
74
+ if (context.kind !== 'method') {
75
+ throw new Error(`Decorator only applicable to methods; got ${context.kind}`);
76
+ }
77
+ const metadata = context.metadata;
78
+ const method_name = String(context.name);
79
+ const [, handler] = resolve(metadata, method_name);
80
+ callback(metadata, handler, params);
81
+ };
82
+ }
83
+ /**
84
+ * Clase base opcional para bots declarativos. El consumer extiende `WhatsAppBot`
85
+ * (o usa `@WhatsApp` como class decorator), declara métodos decorados y al
86
+ * `connect()` los listeners se cablean automáticamente contra el event emitter real.
87
+ * Optional base class for declarative bots. The consumer extends `WhatsAppBot`
88
+ * (or uses `@WhatsApp` as a class decorator), declares decorated methods and at
89
+ * `connect()` listeners get wired against the real event emitter automatically.
90
+ */
91
+ class WhatsAppBot extends whatsapp_1.default {
92
+ constructor(options) {
93
+ super(options);
94
+ }
95
+ /**
96
+ * Inicia la conexión cableando previamente los handlers decorados. Los métodos
97
+ * `@pair` se invocan en paralelo con el `callback` opcional.
98
+ * Starts the connection wiring decorated handlers beforehand. `@pair` methods
99
+ * run in parallel alongside the optional `callback`.
100
+ *
101
+ * @param callback - Callback tradicional del PIN/QR (opcional si hay `@pair`) / Traditional PIN/QR callback (optional when `@pair` exists)
102
+ */
103
+ async connect(callback) {
104
+ this._wire_handlers();
105
+ const pair_methods = this._collect_pair_methods();
106
+ const final_callback = async (code) => {
107
+ await Promise.all(pair_methods.map((fn) => fn(code)));
108
+ if (callback) {
109
+ await callback(code);
110
+ }
111
+ };
112
+ return super.connect(final_callback);
113
+ }
114
+ /**
115
+ * Recolecta los métodos marcados con `@pair` ligados a `this`.
116
+ * Collects methods marked with `@pair` bound to `this`.
117
+ *
118
+ * @returns Lista de funciones ligadas listas para invocar con el code / List of bound functions ready to invoke with the code
119
+ */
120
+ _collect_pair_methods() {
121
+ const out = [];
122
+ const metadata = this.constructor[Symbol.metadata];
123
+ if (metadata) {
124
+ const schema = metadata[exports.HANDLERS];
125
+ if (schema) {
126
+ for (const meta of Object.values(schema.handlers)) {
127
+ if (meta.events.includes('__pair')) {
128
+ const fn = this[meta.method];
129
+ if (typeof fn === 'function') {
130
+ out.push(fn.bind(this));
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ return out;
137
+ }
138
+ /**
139
+ * Cablea los handlers decorados contra el event emitter: registra listeners
140
+ * (`@on`/`@once`), timers (`@every`) y workflows (`@pipe`).
141
+ * Wires decorated handlers against the event emitter: registers listeners
142
+ * (`@on`/`@once`), timers (`@every`) and workflows (`@pipe`).
143
+ */
144
+ _wire_handlers() {
145
+ const metadata = this.constructor[Symbol.metadata];
146
+ if (metadata) {
147
+ const schema = metadata[exports.HANDLERS];
148
+ if (schema) {
149
+ const intervals = [];
150
+ for (const meta of Object.values(schema.handlers)) {
151
+ const method = this[meta.method];
152
+ if (typeof method === 'function') {
153
+ const bound = method.bind(this);
154
+ const invoke = async (...args) => {
155
+ for (const g of meta.guards) {
156
+ if (!(await g(...args))) {
157
+ return;
158
+ }
159
+ }
160
+ let current = args;
161
+ for (const t of meta.transforms) {
162
+ current = await t(current);
163
+ }
164
+ await bound(...current);
165
+ };
166
+ if (meta.events.length === 0 && (meta.guards.length > 0 || meta.transforms.length > 0)) {
167
+ meta.events.push('message:created');
168
+ }
169
+ for (const event of meta.events) {
170
+ if (event.startsWith('__every:')) {
171
+ const ms = parseInt(event.slice('__every:'.length), 10);
172
+ if (Number.isFinite(ms) && ms > 0) {
173
+ intervals.push({ ms, run: () => invoke() });
174
+ }
175
+ }
176
+ else if (event !== '__pair') {
177
+ const register = meta.once ? this.once.bind(this) : this.on.bind(this);
178
+ register(event, invoke);
179
+ }
180
+ }
181
+ }
182
+ }
183
+ if (intervals.length > 0) {
184
+ let timer_ids = [];
185
+ this.on('connected', () => {
186
+ for (const { ms, run } of intervals) {
187
+ timer_ids.push(setInterval(() => void run(), ms));
188
+ }
189
+ });
190
+ this.on('disconnected', () => {
191
+ for (const id of timer_ids) {
192
+ clearInterval(id);
193
+ }
194
+ timer_ids = [];
195
+ });
196
+ }
197
+ for (const steps of Object.values(schema.workflows ?? {})) {
198
+ const sorted = [...steps].sort((a, b) => a.index - b.index);
199
+ const funcs = sorted
200
+ .map(({ method }) => {
201
+ const fn = this[method];
202
+ return typeof fn === 'function' ? fn.bind(this) : null;
203
+ })
204
+ .filter((f) => f !== null);
205
+ if (funcs.length > 0) {
206
+ this.on('message:created', (async (...args) => {
207
+ for (const fn of funcs) {
208
+ await fn(...args);
209
+ }
210
+ }));
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ exports.WhatsAppBot = WhatsAppBot;
218
+ exports.default = WhatsAppBot;
219
+ //# sourceMappingURL=decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AA+DH,wDAeC;AAWD,8BAaC;AApGD,8DAA0D;AAEzD,MAAgC,CAAC,QAAQ,KAAK,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEhE,QAAA,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAsB9C;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,QAAkB,EAAE,WAAmB;IACpD,IAAI,MAAM,GAAG,QAAQ,CAAC,gBAAQ,CAA0B,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QACzC,QAAQ,CAAC,gBAAQ,CAAC,GAAG,MAAM,CAAC;IAChC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK;QAC7B,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;QACd,IAAI,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CAAC,CAAU,CAAC,CAAC;oBACjB,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AArID,kCAqIC;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @file playground/bot/decorators.ts
3
+ * @description Decoradores públicos del bot.
4
+ * Public bot decorators.
5
+ */
6
+ import type { IWhatsApp } from '../../lib/whatsapp';
7
+ import { WhatsAppBot } from './decorator';
8
+ /**
9
+ * Registra el método como listener del evento indicado. Apilable: varios `@on`
10
+ * sobre el mismo método crean múltiples suscripciones.
11
+ * Registers the method as a listener of the given event. Stackable: several
12
+ * `@on` on the same method produce multiple subscriptions.
13
+ *
14
+ * @param event - Nombre del evento del cliente / Client event name
15
+ */
16
+ export declare const on: (event: string) => (_value: unknown, context: ClassMethodDecoratorContext) => void;
17
+ /**
18
+ * Pre-chequeo del handler. Los guards se acumulan y se evalúan en orden con AND.
19
+ * Si el método no tiene `@on` explícito, se auto-registra a `message:created`.
20
+ * Handler pre-check. Guards accumulate and run in order with AND semantics.
21
+ * If the method has no explicit `@on`, it auto-registers to `message:created`.
22
+ *
23
+ * @param pred - Predicate que recibe los argumentos del evento / Predicate receiving the event arguments
24
+ */
25
+ export declare const guard: (pred: (...args: unknown[]) => boolean | Promise<boolean>) => (_value: unknown, context: ClassMethodDecoratorContext) => void;
26
+ /**
27
+ * Marca el handler para ejecutarse una sola vez y luego auto-desuscribirse.
28
+ * Con `event` actúa como shortcut de `@on(event) + @once()`.
29
+ * Marks the handler to run once and then auto-unsubscribe. With `event` it acts
30
+ * as a shortcut of `@on(event) + @once()`.
31
+ *
32
+ * @param event - Evento opcional para combinar `@on + @once` en un solo decorador / Optional event to combine `@on + @once` in a single decorator
33
+ */
34
+ export declare function once(event?: string): (_value: unknown, context: ClassMethodDecoratorContext) => void;
35
+ /**
36
+ * Alias semántico de `@on('connected')`. El método se invoca al establecerse
37
+ * la conexión con WhatsApp.
38
+ * Semantic alias of `@on('connected')`. The method runs when the WhatsApp
39
+ * connection opens.
40
+ */
41
+ export declare function connect(): (_value: unknown, context: ClassMethodDecoratorContext) => void;
42
+ /**
43
+ * Alias semántico de `@on('disconnected')`. El método se invoca al cerrarse
44
+ * la conexión con WhatsApp.
45
+ * Semantic alias of `@on('disconnected')`. The method runs when the WhatsApp
46
+ * connection closes.
47
+ */
48
+ export declare function disconnect(): (_value: unknown, context: ClassMethodDecoratorContext) => void;
49
+ /**
50
+ * Ejecuta el método cada `ms` milisegundos mientras el bot esté conectado.
51
+ * Los timers arrancan en `connected` y se cancelan en `disconnected`.
52
+ * Runs the method every `ms` milliseconds while the bot is connected. Timers
53
+ * start on `connected` and are cancelled on `disconnected`.
54
+ *
55
+ * @param ms - Intervalo en milisegundos / Interval in milliseconds
56
+ */
57
+ export declare function every(ms: number): (_value: unknown, context: ClassMethodDecoratorContext) => void;
58
+ /**
59
+ * Marca el método como callback de pairing (PIN/QR). Múltiples métodos `@pair`
60
+ * se invocan en paralelo cuando baileys entrega el código.
61
+ * Marks the method as a pairing (PIN/QR) callback. Multiple `@pair` methods run
62
+ * in parallel when baileys delivers the code.
63
+ */
64
+ export declare const pair: () => (_value: unknown, context: ClassMethodDecoratorContext) => void;
65
+ /**
66
+ * Filtra por autor del mensaje. Acepta JID, LID o teléfono numérico; el string
67
+ * se normaliza vía `wa._resolve_jid` con cache lazy. Un array produce match OR.
68
+ * Filters by message author. Accepts JID, LID or numeric phone; the string is
69
+ * normalized via `wa._resolve_jid` with lazy cache. An array yields OR matching.
70
+ *
71
+ * @param source - Identificador(es) permitidos o predicate sobre `msg.from` / Allowed identifier(s) or predicate on `msg.from`
72
+ */
73
+ export declare function from(source: string | string[] | ((jid: string) => boolean)): (_value: unknown, context: ClassMethodDecoratorContext) => void;
74
+ /**
75
+ * Class decorator que convierte la clase en un bot WhatsApp con opciones default.
76
+ * La clase no necesita extender `WhatsAppBot` manualmente; el decorador produce
77
+ * una subclase que hereda de `WhatsAppBot` y copia los métodos + metadata del
78
+ * target. El constructor acepta un override parcial que se fusiona con las opts
79
+ * por default.
80
+ * Class decorator that turns the class into a WhatsApp bot with default options.
81
+ * The class does not need to extend `WhatsAppBot` manually; the decorator
82
+ * produces a subclass that inherits from `WhatsAppBot` and copies the target's
83
+ * methods and metadata. The constructor accepts a partial override that is
84
+ * merged with the default options.
85
+ *
86
+ * @param default_options - Opciones base para la instancia / Default options for the instance
87
+ */
88
+ export declare function Bot(default_options: IWhatsApp): <T extends abstract new (...args: never[]) => object>(target: T, _context: ClassDecoratorContext) => new (override?: Partial<IWhatsApp>) => InstanceType<T> & WhatsAppBot;
89
+ /**
90
+ * Registra el método como paso de un workflow. Todos los steps del mismo
91
+ * `workflow` se ejecutan secuencialmente al recibir `message:created`, ordenados
92
+ * por `index`. Comparten los mismos argumentos (msg, chat, wa), por lo que las
93
+ * mutaciones sobre esos objetos son visibles en los steps posteriores.
94
+ * Registers the method as a step of a workflow. All steps of the same
95
+ * `workflow` run sequentially on `message:created`, ordered by `index`. They
96
+ * share the same arguments (msg, chat, wa), so mutations on those objects are
97
+ * visible to later steps.
98
+ *
99
+ * @param workflow - Nombre del workflow / Workflow name
100
+ * @param index - Posición dentro del workflow (ASC) / Position within the workflow (ASC)
101
+ */
102
+ export declare function pipe(workflow: string, index: number): (_value: unknown, context: ClassMethodDecoratorContext) => void;
103
+ /**
104
+ * Registra el método como comando textual. Internamente aplica
105
+ * `@on('message:created')`, un guard que matchea el `pattern` y un transform
106
+ * que pasa `(msg, chat, args)` al método.
107
+ * Registers the method as a textual command. Internally applies
108
+ * `@on('message:created')`, a guard matching the `pattern` and a transform that
109
+ * passes `(msg, chat, args)` to the method.
110
+ *
111
+ * @param pattern - Prefijo textual o RegExp a matchear contra `msg.caption` / Text prefix or RegExp matched against `msg.caption`
112
+ */
113
+ export declare function command(pattern: string | RegExp): (value: unknown, context: ClassMethodDecoratorContext) => void;
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ /**
3
+ * @file playground/bot/decorators.ts
4
+ * @description Decoradores públicos del bot.
5
+ * Public bot decorators.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.pair = exports.guard = exports.on = void 0;
9
+ exports.once = once;
10
+ exports.connect = connect;
11
+ exports.disconnect = disconnect;
12
+ exports.every = every;
13
+ exports.from = from;
14
+ exports.Bot = Bot;
15
+ exports.pipe = pipe;
16
+ exports.command = command;
17
+ const decorator_1 = require("./decorator");
18
+ /**
19
+ * Registra el método como listener del evento indicado. Apilable: varios `@on`
20
+ * sobre el mismo método crean múltiples suscripciones.
21
+ * Registers the method as a listener of the given event. Stackable: several
22
+ * `@on` on the same method produce multiple subscriptions.
23
+ *
24
+ * @param event - Nombre del evento del cliente / Client event name
25
+ */
26
+ exports.on = (0, decorator_1.decorator)((_meta, h, [event]) => {
27
+ if (!h.events.includes(event)) {
28
+ h.events.push(event);
29
+ }
30
+ });
31
+ /**
32
+ * Pre-chequeo del handler. Los guards se acumulan y se evalúan en orden con AND.
33
+ * Si el método no tiene `@on` explícito, se auto-registra a `message:created`.
34
+ * Handler pre-check. Guards accumulate and run in order with AND semantics.
35
+ * If the method has no explicit `@on`, it auto-registers to `message:created`.
36
+ *
37
+ * @param pred - Predicate que recibe los argumentos del evento / Predicate receiving the event arguments
38
+ */
39
+ exports.guard = (0, decorator_1.decorator)((_meta, h, [pred]) => {
40
+ h.guards.push(pred);
41
+ });
42
+ /**
43
+ * Marca el handler para ejecutarse una sola vez y luego auto-desuscribirse.
44
+ * Con `event` actúa como shortcut de `@on(event) + @once()`.
45
+ * Marks the handler to run once and then auto-unsubscribe. With `event` it acts
46
+ * as a shortcut of `@on(event) + @once()`.
47
+ *
48
+ * @param event - Evento opcional para combinar `@on + @once` en un solo decorador / Optional event to combine `@on + @once` in a single decorator
49
+ */
50
+ function once(event) {
51
+ return (_value, context) => {
52
+ if (context.kind !== 'method') {
53
+ throw new Error('@once only applicable to methods');
54
+ }
55
+ const metadata = context.metadata;
56
+ if (!metadata[decorator_1.HANDLERS]) {
57
+ metadata[decorator_1.HANDLERS] = { handlers: {}, workflows: {} };
58
+ }
59
+ const schema = metadata[decorator_1.HANDLERS];
60
+ const method_name = String(context.name);
61
+ schema.handlers[method_name] ||= {
62
+ method: method_name,
63
+ events: [],
64
+ guards: [],
65
+ transforms: [],
66
+ once: false,
67
+ };
68
+ schema.handlers[method_name].once = true;
69
+ if (event && !schema.handlers[method_name].events.includes(event)) {
70
+ schema.handlers[method_name].events.push(event);
71
+ }
72
+ };
73
+ }
74
+ /**
75
+ * Alias semántico de `@on('connected')`. El método se invoca al establecerse
76
+ * la conexión con WhatsApp.
77
+ * Semantic alias of `@on('connected')`. The method runs when the WhatsApp
78
+ * connection opens.
79
+ */
80
+ function connect() {
81
+ return (0, exports.on)('connected');
82
+ }
83
+ /**
84
+ * Alias semántico de `@on('disconnected')`. El método se invoca al cerrarse
85
+ * la conexión con WhatsApp.
86
+ * Semantic alias of `@on('disconnected')`. The method runs when the WhatsApp
87
+ * connection closes.
88
+ */
89
+ function disconnect() {
90
+ return (0, exports.on)('disconnected');
91
+ }
92
+ /**
93
+ * Ejecuta el método cada `ms` milisegundos mientras el bot esté conectado.
94
+ * Los timers arrancan en `connected` y se cancelan en `disconnected`.
95
+ * Runs the method every `ms` milliseconds while the bot is connected. Timers
96
+ * start on `connected` and are cancelled on `disconnected`.
97
+ *
98
+ * @param ms - Intervalo en milisegundos / Interval in milliseconds
99
+ */
100
+ function every(ms) {
101
+ return (0, decorator_1.decorator)((_meta, h) => {
102
+ h.events.push(`__every:${ms}`);
103
+ })();
104
+ }
105
+ /**
106
+ * Marca el método como callback de pairing (PIN/QR). Múltiples métodos `@pair`
107
+ * se invocan en paralelo cuando baileys entrega el código.
108
+ * Marks the method as a pairing (PIN/QR) callback. Multiple `@pair` methods run
109
+ * in parallel when baileys delivers the code.
110
+ */
111
+ exports.pair = (0, decorator_1.decorator)((_meta, h) => {
112
+ if (!h.events.includes('__pair')) {
113
+ h.events.push('__pair');
114
+ }
115
+ });
116
+ /**
117
+ * Filtra por autor del mensaje. Acepta JID, LID o teléfono numérico; el string
118
+ * se normaliza vía `wa._resolve_jid` con cache lazy. Un array produce match OR.
119
+ * Filters by message author. Accepts JID, LID or numeric phone; the string is
120
+ * normalized via `wa._resolve_jid` with lazy cache. An array yields OR matching.
121
+ *
122
+ * @param source - Identificador(es) permitidos o predicate sobre `msg.from` / Allowed identifier(s) or predicate on `msg.from`
123
+ */
124
+ function from(source) {
125
+ return (0, decorator_1.decorator)((_meta, h) => {
126
+ if (typeof source === 'function') {
127
+ h.guards.push((...args) => source(args[0].from));
128
+ }
129
+ else {
130
+ const list = Array.isArray(source) ? source : [source];
131
+ let resolved = null;
132
+ h.guards.push(async (...args) => {
133
+ const msg = args[0];
134
+ const wa = args[args.length - 1];
135
+ if (resolved === null) {
136
+ resolved = new Set();
137
+ for (const raw of list) {
138
+ const r = await wa._resolve_jid(raw);
139
+ if (r) {
140
+ resolved.add(r);
141
+ }
142
+ }
143
+ }
144
+ return resolved.has(msg.from);
145
+ });
146
+ }
147
+ })();
148
+ }
149
+ /**
150
+ * Class decorator que convierte la clase en un bot WhatsApp con opciones default.
151
+ * La clase no necesita extender `WhatsAppBot` manualmente; el decorador produce
152
+ * una subclase que hereda de `WhatsAppBot` y copia los métodos + metadata del
153
+ * target. El constructor acepta un override parcial que se fusiona con las opts
154
+ * por default.
155
+ * Class decorator that turns the class into a WhatsApp bot with default options.
156
+ * The class does not need to extend `WhatsAppBot` manually; the decorator
157
+ * produces a subclass that inherits from `WhatsAppBot` and copies the target's
158
+ * methods and metadata. The constructor accepts a partial override that is
159
+ * merged with the default options.
160
+ *
161
+ * @param default_options - Opciones base para la instancia / Default options for the instance
162
+ */
163
+ function Bot(default_options) {
164
+ return function (target, _context) {
165
+ const Mixed = class extends decorator_1.WhatsAppBot {
166
+ constructor(override) {
167
+ super({ ...default_options, ...(override ?? {}) });
168
+ }
169
+ };
170
+ for (const key of Object.getOwnPropertyNames(target.prototype)) {
171
+ if (key !== 'constructor') {
172
+ const desc = Object.getOwnPropertyDescriptor(target.prototype, key);
173
+ if (desc) {
174
+ Object.defineProperty(Mixed.prototype, key, desc);
175
+ }
176
+ }
177
+ }
178
+ const meta = target[Symbol.metadata];
179
+ if (meta !== undefined) {
180
+ Object.defineProperty(Mixed, Symbol.metadata, {
181
+ value: meta,
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ });
186
+ }
187
+ return Mixed;
188
+ };
189
+ }
190
+ /**
191
+ * Registra el método como paso de un workflow. Todos los steps del mismo
192
+ * `workflow` se ejecutan secuencialmente al recibir `message:created`, ordenados
193
+ * por `index`. Comparten los mismos argumentos (msg, chat, wa), por lo que las
194
+ * mutaciones sobre esos objetos son visibles en los steps posteriores.
195
+ * Registers the method as a step of a workflow. All steps of the same
196
+ * `workflow` run sequentially on `message:created`, ordered by `index`. They
197
+ * share the same arguments (msg, chat, wa), so mutations on those objects are
198
+ * visible to later steps.
199
+ *
200
+ * @param workflow - Nombre del workflow / Workflow name
201
+ * @param index - Posición dentro del workflow (ASC) / Position within the workflow (ASC)
202
+ */
203
+ function pipe(workflow, index) {
204
+ return (_value, context) => {
205
+ if (context.kind !== 'method') {
206
+ throw new Error('@pipe only applicable to methods');
207
+ }
208
+ const metadata = context.metadata;
209
+ (0, decorator_1.register_workflow_step)(metadata, workflow, {
210
+ index,
211
+ method: String(context.name),
212
+ });
213
+ };
214
+ }
215
+ /**
216
+ * Registra el método como comando textual. Internamente aplica
217
+ * `@on('message:created')`, un guard que matchea el `pattern` y un transform
218
+ * que pasa `(msg, chat, args)` al método.
219
+ * Registers the method as a textual command. Internally applies
220
+ * `@on('message:created')`, a guard matching the `pattern` and a transform that
221
+ * passes `(msg, chat, args)` to the method.
222
+ *
223
+ * @param pattern - Prefijo textual o RegExp a matchear contra `msg.caption` / Text prefix or RegExp matched against `msg.caption`
224
+ */
225
+ function command(pattern) {
226
+ return (value, context) => {
227
+ (0, exports.on)('message:created')(value, context);
228
+ (0, exports.guard)((...args) => {
229
+ const msg = args[0];
230
+ const text = msg.caption ?? '';
231
+ if (typeof pattern === 'string') {
232
+ return text.startsWith(pattern);
233
+ }
234
+ return pattern.test(text);
235
+ })(value, context);
236
+ const metadata = context.metadata;
237
+ const schema = metadata[decorator_1.HANDLERS];
238
+ const handler = schema.handlers[String(context.name)];
239
+ handler.transforms.push((args) => {
240
+ const msg = args[0];
241
+ const chat = args[1];
242
+ const text = msg.caption ?? '';
243
+ if (typeof pattern === 'string') {
244
+ const rest = text.slice(pattern.length).trim();
245
+ const parsed = rest.length > 0 ? rest.split(/\s+/) : [];
246
+ return [msg, chat, parsed];
247
+ }
248
+ const match = pattern.exec(text);
249
+ return [msg, chat, match ? match.slice(1) : []];
250
+ });
251
+ };
252
+ }
253
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorators.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAiDH,oBAuBC;AAQD,0BAEC;AAQD,gCAEC;AAUD,sBAIC;AAsBD,oBAyBC;AAgBD,kBA6BC;AAeD,oBAWC;AAYD,0BA4BC;AApQD,2CAOqB;AAErB;;;;;;;GAOG;AACU,QAAA,EAAE,GAAG,IAAA,qBAAS,EAAkB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE;IAC/D,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACU,QAAA,KAAK,GAAG,IAAA,qBAAS,EAC1B,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE;IACjB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC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lerMeta, BotSchema, WorkflowStep } from './decorator';
3
+ export { on, guard, command, from, once, connect, disconnect, every, pipe, pair, Bot } from './decorators';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bot = exports.pair = exports.pipe = exports.every = exports.disconnect = exports.connect = exports.once = exports.from = exports.command = exports.guard = exports.on = exports.decorator = exports.HANDLERS = exports.WhatsAppBot = void 0;
4
+ var decorator_1 = require("./decorator");
5
+ Object.defineProperty(exports, "WhatsAppBot", { enumerable: true, get: function () { return decorator_1.WhatsAppBot; } });
6
+ Object.defineProperty(exports, "HANDLERS", { enumerable: true, get: function () { return decorator_1.HANDLERS; } });
7
+ Object.defineProperty(exports, "decorator", { enumerable: true, get: function () { return decorator_1.decorator; } });
8
+ var decorators_1 = require("./decorators");
9
+ Object.defineProperty(exports, "on", { enumerable: true, get: function () { return decorators_1.on; } });
10
+ Object.defineProperty(exports, "guard", { enumerable: true, get: function () { return decorators_1.guard; } });
11
+ Object.defineProperty(exports, "command", { enumerable: true, get: function () { return decorators_1.command; } });
12
+ Object.defineProperty(exports, "from", { enumerable: true, get: function () { return decorators_1.from; } });
13
+ Object.defineProperty(exports, "once", { enumerable: true, get: function () { return decorators_1.once; } });
14
+ Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return decorators_1.connect; } });
15
+ Object.defineProperty(exports, "disconnect", { enumerable: true, get: function () { return decorators_1.disconnect; } });
16
+ Object.defineProperty(exports, "every", { enumerable: true, get: function () { return decorators_1.every; } });
17
+ Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return decorators_1.pipe; } });
18
+ Object.defineProperty(exports, "pair", { enumerable: true, get: function () { return decorators_1.pair; } });
19
+ Object.defineProperty(exports, "Bot", { enumerable: true, get: function () { return decorators_1.Bot; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/bot/index.ts"],"names":[],"mappings":";;;AAAA,yCAA+D;AAAtD,wGAAA,WAAW,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAE,sGAAA,SAAS,OAAA;AAEzC,2CAA2G;AAAlG,gGAAA,EAAE,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,iGAAA,GAAG,OAAA"}