@arcaelas/whatsapp 3.5.0 → 4.3.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/build/cjs/index.d.ts +1 -1
- package/build/cjs/index.js +4 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/bot/decorator.d.ts +18 -1
- package/build/cjs/lib/bot/decorator.js +20 -14
- package/build/cjs/lib/bot/decorator.js.map +1 -1
- package/build/cjs/lib/bot/decorators.d.ts +1 -1
- package/build/cjs/lib/bot/decorators.js +6 -20
- package/build/cjs/lib/bot/decorators.js.map +1 -1
- package/build/cjs/lib/contact/index.d.ts +33 -10
- package/build/cjs/lib/contact/index.js +28 -6
- package/build/cjs/lib/contact/index.js.map +1 -1
- package/build/cjs/lib/message/index.d.ts +101 -1
- package/build/cjs/lib/message/index.js +189 -3
- package/build/cjs/lib/message/index.js.map +1 -1
- package/build/cjs/lib/store/engine/index.d.ts +1 -0
- package/build/cjs/lib/store/engine/index.js +3 -1
- package/build/cjs/lib/store/engine/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/file_system/index.js +1 -7
- package/build/cjs/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/redis/index.js +1 -7
- package/build/cjs/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/cjs/lib/store/engine/lib/s3/index.d.ts +66 -0
- package/build/cjs/lib/store/engine/lib/s3/index.js +169 -0
- package/build/cjs/lib/store/engine/lib/s3/index.js.map +1 -0
- package/build/cjs/lib/store/index.d.ts +1 -1
- package/build/cjs/lib/store/index.js +2 -1
- package/build/cjs/lib/store/index.js.map +1 -1
- package/build/cjs/lib/whatsapp/index.d.ts +8 -3
- package/build/cjs/lib/whatsapp/index.js +54 -70
- package/build/cjs/lib/whatsapp/index.js.map +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/bot/decorator.d.ts +18 -1
- package/build/esm/lib/bot/decorator.js +18 -14
- package/build/esm/lib/bot/decorator.js.map +1 -1
- package/build/esm/lib/bot/decorators.d.ts +1 -1
- package/build/esm/lib/bot/decorators.js +7 -21
- package/build/esm/lib/bot/decorators.js.map +1 -1
- package/build/esm/lib/contact/index.d.ts +33 -10
- package/build/esm/lib/contact/index.js +27 -6
- package/build/esm/lib/contact/index.js.map +1 -1
- package/build/esm/lib/message/index.d.ts +101 -1
- package/build/esm/lib/message/index.js +185 -2
- package/build/esm/lib/message/index.js.map +1 -1
- package/build/esm/lib/store/engine/index.d.ts +1 -0
- package/build/esm/lib/store/engine/index.js +1 -0
- package/build/esm/lib/store/engine/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/file_system/index.js +1 -7
- package/build/esm/lib/store/engine/lib/file_system/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/redis/index.js +1 -7
- package/build/esm/lib/store/engine/lib/redis/index.js.map +1 -1
- package/build/esm/lib/store/engine/lib/s3/index.d.ts +66 -0
- package/build/esm/lib/store/engine/lib/s3/index.js +165 -0
- package/build/esm/lib/store/engine/lib/s3/index.js.map +1 -0
- package/build/esm/lib/store/index.d.ts +1 -1
- package/build/esm/lib/store/index.js +1 -1
- package/build/esm/lib/store/index.js.map +1 -1
- package/build/esm/lib/whatsapp/index.d.ts +8 -3
- package/build/esm/lib/whatsapp/index.js +55 -71
- package/build/esm/lib/whatsapp/index.js.map +1 -1
- package/package.json +3 -2
package/build/cjs/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { WhatsApp, default } from './lib/whatsapp';
|
|
7
7
|
export type { IWhatsApp, DisconnectOptions, ReconnectOption } from './lib/whatsapp';
|
|
8
|
-
export { FileSystemEngine, RedisEngine } from './lib/store';
|
|
8
|
+
export { FileSystemEngine, RedisEngine, S3Engine, serialize, deserialize } from './lib/store';
|
|
9
9
|
export type { Engine, RedisClient } from './lib/store';
|
|
10
10
|
export { default as Feed, TTL_MS as FEED_TTL_MS } from './lib/status';
|
|
11
11
|
export type { IFeedRaw, FeedType } from './lib/status';
|
package/build/cjs/index.js
CHANGED
|
@@ -8,13 +8,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.FEED_TTL_MS = exports.Feed = exports.RedisEngine = exports.FileSystemEngine = exports.default = exports.WhatsApp = void 0;
|
|
11
|
+
exports.FEED_TTL_MS = exports.Feed = exports.deserialize = exports.serialize = exports.S3Engine = exports.RedisEngine = exports.FileSystemEngine = exports.default = exports.WhatsApp = void 0;
|
|
12
12
|
var whatsapp_1 = require("./lib/whatsapp");
|
|
13
13
|
Object.defineProperty(exports, "WhatsApp", { enumerable: true, get: function () { return whatsapp_1.WhatsApp; } });
|
|
14
14
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(whatsapp_1).default; } });
|
|
15
15
|
var store_1 = require("./lib/store");
|
|
16
16
|
Object.defineProperty(exports, "FileSystemEngine", { enumerable: true, get: function () { return store_1.FileSystemEngine; } });
|
|
17
17
|
Object.defineProperty(exports, "RedisEngine", { enumerable: true, get: function () { return store_1.RedisEngine; } });
|
|
18
|
+
Object.defineProperty(exports, "S3Engine", { enumerable: true, get: function () { return store_1.S3Engine; } });
|
|
19
|
+
Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return store_1.serialize; } });
|
|
20
|
+
Object.defineProperty(exports, "deserialize", { enumerable: true, get: function () { return store_1.deserialize; } });
|
|
18
21
|
var status_1 = require("./lib/status");
|
|
19
22
|
Object.defineProperty(exports, "Feed", { enumerable: true, get: function () { return __importDefault(status_1).default; } });
|
|
20
23
|
Object.defineProperty(exports, "FEED_TTL_MS", { enumerable: true, get: function () { return status_1.TTL_MS; } });
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,2CAAmD;AAA1C,oGAAA,QAAQ,OAAA;AAAE,oHAAA,OAAO,OAAA;AAG1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,2CAAmD;AAA1C,oGAAA,QAAQ,OAAA;AAAE,oHAAA,OAAO,OAAA;AAG1B,qCAA8F;AAArF,yGAAA,gBAAgB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,oGAAA,WAAW,OAAA;AAGxE,uCAAsE;AAA7D,+GAAA,OAAO,OAAQ;AAAE,qGAAA,MAAM,OAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file bot/decorator.ts
|
|
3
3
|
* @description Infraestructura base de decoradores Stage 3 sobre WhatsApp.
|
|
4
4
|
* Base infrastructure for Stage 3 decorators over WhatsApp.
|
|
5
5
|
*/
|
|
@@ -21,6 +21,23 @@ export interface BotSchema {
|
|
|
21
21
|
workflows: Record<string, WorkflowStep[]>;
|
|
22
22
|
}
|
|
23
23
|
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
|
+
/**
|
|
33
|
+
* Recupera o inicializa el schema del bot y la entrada del método indicado.
|
|
34
|
+
* Retrieves or initializes the bot schema and the entry for the given method.
|
|
35
|
+
*
|
|
36
|
+
* @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
|
|
37
|
+
* @param method_name - Nombre del método / Method name
|
|
38
|
+
* @returns Tupla `[schema, handler_meta]` para el método / Tuple `[schema, handler_meta]` for the method
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolve(metadata: Metadata, method_name: string): [BotSchema, HandlerMeta];
|
|
24
41
|
/**
|
|
25
42
|
* Registra un step dentro de un workflow. Uso interno del decorador `@pipe`.
|
|
26
43
|
* Registers a step inside a workflow. Internal use of the `@pipe` decorator.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @file
|
|
3
|
+
* @file bot/decorator.ts
|
|
4
4
|
* @description Infraestructura base de decoradores Stage 3 sobre WhatsApp.
|
|
5
5
|
* Base infrastructure for Stage 3 decorators over WhatsApp.
|
|
6
6
|
*/
|
|
@@ -9,20 +9,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.WhatsAppBot = exports.HANDLERS = void 0;
|
|
12
|
+
exports.ensure_schema = ensure_schema;
|
|
13
|
+
exports.resolve = resolve;
|
|
12
14
|
exports.register_workflow_step = register_workflow_step;
|
|
13
15
|
exports.decorator = decorator;
|
|
14
16
|
const whatsapp_1 = __importDefault(require("../../lib/whatsapp"));
|
|
15
17
|
Symbol.metadata ??= Symbol.for('Symbol.metadata');
|
|
16
18
|
exports.HANDLERS = Symbol('wa:handlers');
|
|
17
19
|
/**
|
|
18
|
-
* Recupera o inicializa el
|
|
19
|
-
* Retrieves or initializes the
|
|
20
|
+
* Recupera o inicializa el `BotSchema` almacenado en la metadata del contexto.
|
|
21
|
+
* Retrieves or initializes the `BotSchema` stored in the context metadata.
|
|
20
22
|
*
|
|
21
23
|
* @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
|
|
22
|
-
* @
|
|
23
|
-
* @returns Tupla `[schema, handler_meta]` para el método / Tuple `[schema, handler_meta]` for the method
|
|
24
|
+
* @returns Schema del bot garantizado con `handlers` y `workflows` / Bot schema guaranteed to have `handlers` and `workflows`
|
|
24
25
|
*/
|
|
25
|
-
function
|
|
26
|
+
function ensure_schema(metadata) {
|
|
26
27
|
let schema = metadata[exports.HANDLERS];
|
|
27
28
|
if (!schema) {
|
|
28
29
|
schema = { handlers: {}, workflows: {} };
|
|
@@ -31,6 +32,18 @@ function resolve(metadata, method_name) {
|
|
|
31
32
|
if (!schema.workflows) {
|
|
32
33
|
schema.workflows = {};
|
|
33
34
|
}
|
|
35
|
+
return schema;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Recupera o inicializa el schema del bot y la entrada del método indicado.
|
|
39
|
+
* Retrieves or initializes the bot schema and the entry for the given method.
|
|
40
|
+
*
|
|
41
|
+
* @param metadata - Objeto metadata del contexto del decorador / Decorator context metadata object
|
|
42
|
+
* @param method_name - Nombre del método / Method name
|
|
43
|
+
* @returns Tupla `[schema, handler_meta]` para el método / Tuple `[schema, handler_meta]` for the method
|
|
44
|
+
*/
|
|
45
|
+
function resolve(metadata, method_name) {
|
|
46
|
+
const schema = ensure_schema(metadata);
|
|
34
47
|
schema.handlers[method_name] ||= {
|
|
35
48
|
method: method_name,
|
|
36
49
|
events: [],
|
|
@@ -49,14 +62,7 @@ function resolve(metadata, method_name) {
|
|
|
49
62
|
* @param step - Step a registrar (índice + nombre del método) / Step to register (index + method name)
|
|
50
63
|
*/
|
|
51
64
|
function register_workflow_step(metadata, workflow, step) {
|
|
52
|
-
|
|
53
|
-
if (!schema) {
|
|
54
|
-
schema = { handlers: {}, workflows: {} };
|
|
55
|
-
metadata[exports.HANDLERS] = schema;
|
|
56
|
-
}
|
|
57
|
-
if (!schema.workflows) {
|
|
58
|
-
schema.workflows = {};
|
|
59
|
-
}
|
|
65
|
+
const schema = ensure_schema(metadata);
|
|
60
66
|
schema.workflows[workflow] ||= [];
|
|
61
67
|
schema.workflows[workflow].push(step);
|
|
62
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAmCH,sCAUC;AAUD,0BAUC;AAUD,wDAQC;AAWD,8BAaC;AAzGD,8DAA0D;AAEzD,MAAgC,CAAC,QAAQ,KAAK,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEhE,QAAA,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAsB9C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,QAAkB;IAC5C,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,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,QAAkB,EAAE,WAAmB;IAC3D,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK;QAC7B,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,UAAU,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AC;gBAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;oBACxD,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC5D,MAAM,KAAK,GAAG,MAAM;yBACf,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;wBAChB,MAAM,EAAE,GAAI,IAA2C,CAAC,MAAM,CAAC,CAAC;wBAChE,OAAO,OAAO,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;oBAC3D,CAAC,CAAC;yBACD,MAAM,CAAC,CAAC,CAAC,EAAwC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;oBACrE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACnB,IAAI,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,GAAG,IAAe,EAAE,EAAE;4BACrD,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;gCACrB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;4BACtB,CAAC;wBACL,CAAC,CAAU,CAAC,CAAC;oBACjB,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AA7JD,kCA6JC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @file
|
|
3
|
+
* @file bot/decorators.ts
|
|
4
4
|
* @description Decoradores públicos del bot.
|
|
5
5
|
* Public bot decorators.
|
|
6
6
|
*/
|
|
@@ -53,22 +53,10 @@ function once(event) {
|
|
|
53
53
|
if (context.kind !== 'method') {
|
|
54
54
|
throw new Error('@once only applicable to methods');
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const schema = metadata[decorator_1.HANDLERS];
|
|
61
|
-
const method_name = String(context.name);
|
|
62
|
-
schema.handlers[method_name] ||= {
|
|
63
|
-
method: method_name,
|
|
64
|
-
events: [],
|
|
65
|
-
guards: [],
|
|
66
|
-
transforms: [],
|
|
67
|
-
once: false,
|
|
68
|
-
};
|
|
69
|
-
schema.handlers[method_name].once = true;
|
|
70
|
-
if (event && !schema.handlers[method_name].events.includes(event)) {
|
|
71
|
-
schema.handlers[method_name].events.push(event);
|
|
56
|
+
const [, handler] = (0, decorator_1.resolve)(context.metadata, String(context.name));
|
|
57
|
+
handler.once = true;
|
|
58
|
+
if (event && !handler.events.includes(event)) {
|
|
59
|
+
handler.events.push(event);
|
|
72
60
|
}
|
|
73
61
|
};
|
|
74
62
|
}
|
|
@@ -256,9 +244,7 @@ function command(pattern) {
|
|
|
256
244
|
}
|
|
257
245
|
return pattern.test(text);
|
|
258
246
|
})(value, context);
|
|
259
|
-
const
|
|
260
|
-
const schema = metadata[decorator_1.HANDLERS];
|
|
261
|
-
const handler = schema.handlers[String(context.name)];
|
|
247
|
+
const [, handler] = (0, decorator_1.resolve)(context.metadata, String(context.name));
|
|
262
248
|
handler.transforms.push((args) => {
|
|
263
249
|
const msg = args[0];
|
|
264
250
|
const chat = args[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorators.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/lib/bot/decorators.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA+CH,oBAWC;AAQD,0BAEC;AAQD,gCAEC;AAcD,sBAIC;AAeD,sBAIC;AAs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,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -18,6 +18,14 @@ export interface IContactRaw {
|
|
|
18
18
|
img_url?: string | null;
|
|
19
19
|
status?: string | null;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Resuelve el nombre mostrado de un contacto con prioridad local → push → teléfono.
|
|
23
|
+
* Resolves a contact's display name with priority local → push → phone number.
|
|
24
|
+
*
|
|
25
|
+
* @param raw - Documento persistido del contacto / Persisted contact document
|
|
26
|
+
* @returns Nombre mostrado / Display name
|
|
27
|
+
*/
|
|
28
|
+
export declare function contact_name(raw: IContactRaw): string;
|
|
21
29
|
/**
|
|
22
30
|
* Clase base del contacto (forma pública, solo lectura).
|
|
23
31
|
* Base Contact class (public shape, read-only).
|
|
@@ -25,8 +33,8 @@ export interface IContactRaw {
|
|
|
25
33
|
export declare class Contact {
|
|
26
34
|
/** @internal Shape persistido. Uso interno (convención underscore). / Internal persisted shape. */
|
|
27
35
|
readonly _raw: IContactRaw;
|
|
28
|
-
/** Chat 1:1 asociado
|
|
29
|
-
readonly
|
|
36
|
+
/** @internal Chat 1:1 asociado ya hidratado. / Internal already-hydrated 1:1 chat. */
|
|
37
|
+
readonly _chat: Chat;
|
|
30
38
|
constructor(raw: IContactRaw, chat: Chat);
|
|
31
39
|
/** JID único. / Unique JID. */
|
|
32
40
|
get id(): string;
|
|
@@ -42,6 +50,13 @@ export declare class Contact {
|
|
|
42
50
|
get photo(): string | null;
|
|
43
51
|
/** Bio del contacto. / Contact bio. */
|
|
44
52
|
get content(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Chat 1:1 asociado al contacto. Async por coherencia con `Message.chat()` /
|
|
55
|
+
* `Message.author()`, aunque la instancia ya está hidratada en memoria.
|
|
56
|
+
* 1:1 chat associated with the contact. Async for consistency with
|
|
57
|
+
* `Message.chat()` / `Message.author()`, though already hydrated in memory.
|
|
58
|
+
*/
|
|
59
|
+
chat(): Promise<Chat>;
|
|
45
60
|
}
|
|
46
61
|
/**
|
|
47
62
|
* Factoría de Contact ligada al contexto WhatsApp.
|
|
@@ -51,8 +66,10 @@ export declare class Contact {
|
|
|
51
66
|
*/
|
|
52
67
|
export declare function contact(wa: WhatsApp): {
|
|
53
68
|
new (raw: IContactRaw, chat: InstanceType<typeof wa.Chat>): {
|
|
54
|
-
/** Chat 1:1
|
|
55
|
-
readonly
|
|
69
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
70
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
71
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
72
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
56
73
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
57
74
|
get me(): boolean;
|
|
58
75
|
/**
|
|
@@ -92,8 +109,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
92
109
|
* - If `uid` lacks `@` → digits are extracted and `socket.onWhatsApp(phone)` resolves the canonical JID.
|
|
93
110
|
*/
|
|
94
111
|
get(uid: string): Promise<{
|
|
95
|
-
/** Chat 1:1
|
|
96
|
-
readonly
|
|
112
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
113
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
114
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
115
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
97
116
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
98
117
|
get me(): boolean;
|
|
99
118
|
/**
|
|
@@ -128,8 +147,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
128
147
|
* Paginates persisted contacts by mtime DESC, pre-loading the chat of each one.
|
|
129
148
|
*/
|
|
130
149
|
list(offset?: number, limit?: number): Promise<{
|
|
131
|
-
/** Chat 1:1
|
|
132
|
-
readonly
|
|
150
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
151
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
152
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
153
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
133
154
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
134
155
|
get me(): boolean;
|
|
135
156
|
/**
|
|
@@ -169,8 +190,10 @@ export declare function contact(wa: WhatsApp): {
|
|
|
169
190
|
* Re-hydrates contact data from the socket by id.
|
|
170
191
|
*/
|
|
171
192
|
refresh(uid: string): Promise<{
|
|
172
|
-
/** Chat 1:1
|
|
173
|
-
readonly
|
|
193
|
+
/** @internal Chat 1:1 hidratado como subclase enriquecida. / Internal hydrated 1:1 chat as enriched subclass. */
|
|
194
|
+
readonly _chat: InstanceType<typeof wa.Chat>;
|
|
195
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
196
|
+
chat(): Promise<InstanceType<typeof wa.Chat>>;
|
|
174
197
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
175
198
|
get me(): boolean;
|
|
176
199
|
/**
|
|
@@ -6,9 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Contact = void 0;
|
|
9
|
+
exports.contact_name = contact_name;
|
|
9
10
|
exports.contact = contact;
|
|
10
11
|
const baileys_1 = require("baileys");
|
|
11
12
|
const store_1 = require("../../lib/store");
|
|
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
|
+
}
|
|
12
23
|
/**
|
|
13
24
|
* Clase base del contacto (forma pública, solo lectura).
|
|
14
25
|
* Base Contact class (public shape, read-only).
|
|
@@ -16,7 +27,7 @@ const store_1 = require("../../lib/store");
|
|
|
16
27
|
class Contact {
|
|
17
28
|
constructor(raw, chat) {
|
|
18
29
|
this._raw = raw;
|
|
19
|
-
this.
|
|
30
|
+
this._chat = chat;
|
|
20
31
|
}
|
|
21
32
|
/** JID único. / Unique JID. */
|
|
22
33
|
get id() {
|
|
@@ -32,7 +43,7 @@ class Contact {
|
|
|
32
43
|
}
|
|
33
44
|
/** Nombre: local → push → teléfono. / Name: local → push → phone. */
|
|
34
45
|
get name() {
|
|
35
|
-
return this._raw
|
|
46
|
+
return contact_name(this._raw);
|
|
36
47
|
}
|
|
37
48
|
/** Número sin formato. / Raw phone number. */
|
|
38
49
|
get phone() {
|
|
@@ -46,6 +57,15 @@ class Contact {
|
|
|
46
57
|
get content() {
|
|
47
58
|
return this._raw.status ?? '';
|
|
48
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;
|
|
68
|
+
}
|
|
49
69
|
}
|
|
50
70
|
exports.Contact = Contact;
|
|
51
71
|
/**
|
|
@@ -106,6 +126,10 @@ function contact(wa) {
|
|
|
106
126
|
constructor(raw, chat) {
|
|
107
127
|
super(raw, chat);
|
|
108
128
|
}
|
|
129
|
+
/** Chat 1:1 asociado (subclase enriquecida). / Associated 1:1 chat (enriched subclass). */
|
|
130
|
+
async chat() {
|
|
131
|
+
return this._chat;
|
|
132
|
+
}
|
|
109
133
|
/** true si la instancia representa la cuenta autenticada. / true if this instance is the authenticated account. */
|
|
110
134
|
get me() {
|
|
111
135
|
const self_id = wa._socket?.user?.id;
|
|
@@ -137,8 +161,7 @@ function contact(wa) {
|
|
|
137
161
|
if (jid && !jid.endsWith('@g.us')) {
|
|
138
162
|
const cached = (0, store_1.deserialize)(await wa.engine.get(`/contact/${jid}`));
|
|
139
163
|
if (cached) {
|
|
140
|
-
|
|
141
|
-
result = new _Contact(cached, await load_chat_for(jid, fallback_name));
|
|
164
|
+
result = new _Contact(cached, await load_chat_for(jid, contact_name(cached)));
|
|
142
165
|
}
|
|
143
166
|
else if (wa._socket) {
|
|
144
167
|
const needs_check = !lid && !uid.endsWith('@lid');
|
|
@@ -175,8 +198,7 @@ function contact(wa) {
|
|
|
175
198
|
for (const raw of await wa.engine.list('/contact', offset, limit)) {
|
|
176
199
|
const parsed = (0, store_1.deserialize)(raw);
|
|
177
200
|
if (parsed) {
|
|
178
|
-
|
|
179
|
-
contacts.push(new _Contact(parsed, await load_chat_for(parsed.id, fallback_name)));
|
|
201
|
+
contacts.push(new _Contact(parsed, await load_chat_for(parsed.id, contact_name(parsed))));
|
|
180
202
|
}
|
|
181
203
|
}
|
|
182
204
|
return contacts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/contact/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA4BH,oCAEC;AA+DD,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;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -13,7 +13,7 @@ export type ForwardTarget = string | Chat | Contact;
|
|
|
13
13
|
type ChatInstance = InstanceType<ReturnType<typeof chat>>;
|
|
14
14
|
type ContactInstance = InstanceType<ReturnType<typeof contact>>;
|
|
15
15
|
/** Tipos de mensaje internos (no expuestos como getter público). */
|
|
16
|
-
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll';
|
|
16
|
+
export type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'poll' | 'document' | 'vcard' | 'event';
|
|
17
17
|
export declare enum MessageStatus {
|
|
18
18
|
ERROR = 0,
|
|
19
19
|
PENDING = 1,
|
|
@@ -35,6 +35,35 @@ export interface SendPollOptions extends SendOptions {
|
|
|
35
35
|
/** true para selección múltiple; default false (single). / true for multi-select; default false (single). */
|
|
36
36
|
multiple?: boolean;
|
|
37
37
|
}
|
|
38
|
+
export interface SendDocumentOptions extends SendOptions {
|
|
39
|
+
/** Nombre del archivo mostrado al receptor. / File name shown to the recipient. */
|
|
40
|
+
file_name: string;
|
|
41
|
+
/** MIME real del contenido; default `application/octet-stream`. / Real content MIME; defaults to `application/octet-stream`. */
|
|
42
|
+
mimetype?: string;
|
|
43
|
+
/** Texto adjunto opcional. / Optional attached caption. */
|
|
44
|
+
caption?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface VCardInput {
|
|
47
|
+
/** Nombre mostrado del contacto. / Contact display name. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Teléfono en formato internacional. / Phone in international format. */
|
|
50
|
+
phone: string;
|
|
51
|
+
}
|
|
52
|
+
export interface EventInput {
|
|
53
|
+
/** Nombre del evento. / Event name. */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Descripción opcional (texto del evento, expuesto como `caption`). / Optional description (event text, exposed as `caption`). */
|
|
56
|
+
caption?: string;
|
|
57
|
+
/** Fecha/hora de inicio. / Start date/time. */
|
|
58
|
+
start: Date;
|
|
59
|
+
/** Fecha/hora de fin opcional. / Optional end date/time. */
|
|
60
|
+
end?: Date;
|
|
61
|
+
/** Ubicación opcional. / Optional location. */
|
|
62
|
+
place?: {
|
|
63
|
+
lat: number;
|
|
64
|
+
lng: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
38
67
|
export interface LocationOptions {
|
|
39
68
|
lat: number;
|
|
40
69
|
lng: number;
|
|
@@ -167,6 +196,12 @@ export declare class Message {
|
|
|
167
196
|
location(loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
168
197
|
/** Responde con encuesta. */
|
|
169
198
|
poll(poll: PollOptions, opts?: SendPollOptions): Promise<Message | null>;
|
|
199
|
+
/** Responde con documento. */
|
|
200
|
+
document(buf: Buffer, opts: SendDocumentOptions): Promise<Message | null>;
|
|
201
|
+
/** Responde con tarjeta(s) de contacto. */
|
|
202
|
+
vcard(contacts: VCardInput[], opts?: SendOptions): Promise<Message | null>;
|
|
203
|
+
/** Responde con evento. */
|
|
204
|
+
event(data: EventInput, opts?: SendOptions): Promise<Message | null>;
|
|
170
205
|
}
|
|
171
206
|
/**
|
|
172
207
|
* Mensaje de texto. Override `content()` para retornar el caption como Buffer sin pasar por engine.
|
|
@@ -241,6 +276,65 @@ export declare class Poll extends Message {
|
|
|
241
276
|
*/
|
|
242
277
|
select(index: number | number[]): Promise<boolean>;
|
|
243
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Mensaje de documento. WhatsApp permite enviar cualquier archivo (PDF, imagen,
|
|
281
|
+
* audio, video, etc.) como documento; lo que lo distingue de image/video/audio es
|
|
282
|
+
* el tipo de mensaje (`documentMessage`), no el mimetype. Hereda `stream()` de la
|
|
283
|
+
* clase base; `content()` drena el stream (cache → download).
|
|
284
|
+
* Document message. WhatsApp lets you send any file (PDF, image, audio, video…)
|
|
285
|
+
* as a document; what sets it apart from image/video/audio is the message type
|
|
286
|
+
* (`documentMessage`), not the mimetype. Inherits `stream()` from the base class;
|
|
287
|
+
* `content()` drains the stream (cache → download).
|
|
288
|
+
*/
|
|
289
|
+
export declare class Document extends Message {
|
|
290
|
+
private get _doc_msg();
|
|
291
|
+
/** Nombre del archivo. / File name. */
|
|
292
|
+
get file_name(): string;
|
|
293
|
+
/** Tamaño en bytes (0 si se desconoce). / Size in bytes (0 if unknown). */
|
|
294
|
+
get size(): number;
|
|
295
|
+
/** Número de páginas (PDF); 0 si no aplica. / Page count (PDF); 0 when not applicable. */
|
|
296
|
+
get pages(): number;
|
|
297
|
+
/** Título del documento. / Document title. */
|
|
298
|
+
get title(): string;
|
|
299
|
+
content(): Promise<Buffer>;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Mensaje de tarjeta(s) de contacto (vCard). Unifica `contactMessage` (uno) y
|
|
303
|
+
* `contactsArrayMessage` (varios) bajo una sola lista `contacts`.
|
|
304
|
+
* Contact card message (vCard). Unifies `contactMessage` (single) and
|
|
305
|
+
* `contactsArrayMessage` (multiple) under a single `contacts` list.
|
|
306
|
+
*/
|
|
307
|
+
export declare class VCard extends Message {
|
|
308
|
+
/** Contactos de la tarjeta con nombre y teléfono. / Card contacts with name and phone. */
|
|
309
|
+
get contacts(): {
|
|
310
|
+
name: string;
|
|
311
|
+
phone: string;
|
|
312
|
+
}[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Mensaje de evento de calendario (`eventMessage`): nombre, descripción, rango de
|
|
316
|
+
* fechas, estado de cancelación, link de unión y ubicación.
|
|
317
|
+
* Calendar event message (`eventMessage`): name, description, date range,
|
|
318
|
+
* cancellation state, join link and location.
|
|
319
|
+
*/
|
|
320
|
+
export declare class Event extends Message {
|
|
321
|
+
private get _event();
|
|
322
|
+
/** Nombre del evento. / Event name. */
|
|
323
|
+
get name(): string;
|
|
324
|
+
/** Epoch ms de inicio. / Start epoch ms. */
|
|
325
|
+
get start(): number;
|
|
326
|
+
/** Epoch ms de fin, o null. / End epoch ms, or null. */
|
|
327
|
+
get end(): number | null;
|
|
328
|
+
/** true si el evento fue cancelado. / true if the event was canceled. */
|
|
329
|
+
get canceled(): boolean;
|
|
330
|
+
/** Link de unión (audio/video), si aplica. / Join link (audio/video), if any. */
|
|
331
|
+
get link(): string;
|
|
332
|
+
/** Ubicación del evento, o null. / Event location, or null. */
|
|
333
|
+
get place(): {
|
|
334
|
+
lat: number;
|
|
335
|
+
lng: number;
|
|
336
|
+
} | null;
|
|
337
|
+
}
|
|
244
338
|
/**
|
|
245
339
|
* Factoría que enlaza los statics a `wa` y expone las subclases.
|
|
246
340
|
* Factory binding statics to `wa` and exposing subclasses.
|
|
@@ -252,6 +346,9 @@ export declare function message(wa: WhatsApp): {
|
|
|
252
346
|
Audio: typeof Audio;
|
|
253
347
|
Gps: typeof Gps;
|
|
254
348
|
Poll: typeof Poll;
|
|
349
|
+
Document: typeof Document;
|
|
350
|
+
VCard: typeof VCard;
|
|
351
|
+
Event: typeof Event;
|
|
255
352
|
build_message_doc: typeof build_message_doc;
|
|
256
353
|
build_instance: (doc: IMessage) => Promise<Message>;
|
|
257
354
|
/** Obtiene un mensaje por CID/MID. */
|
|
@@ -266,6 +363,9 @@ export declare function message(wa: WhatsApp): {
|
|
|
266
363
|
audio(cid: string, buf: Buffer, opts?: SendAudioOptions): Promise<Message | null>;
|
|
267
364
|
location(cid: string, loc: LocationOptions, opts?: SendOptions): Promise<Message | null>;
|
|
268
365
|
poll(cid: string, p: PollOptions, opts?: SendPollOptions): Promise<Message | null>;
|
|
366
|
+
document(cid: string, buf: Buffer, opts: SendDocumentOptions): Promise<Message | null>;
|
|
367
|
+
vcard(cid: string, contacts: VCardInput[], opts?: SendOptions): Promise<Message | null>;
|
|
368
|
+
event(cid: string, data: EventInput, opts?: SendOptions): Promise<Message | null>;
|
|
269
369
|
edit(cid: string, mid: string, text: string): Promise<boolean>;
|
|
270
370
|
delete(cid: string, mid: string, all?: boolean): Promise<boolean>;
|
|
271
371
|
react(cid: string, mid: string, emoji: string): Promise<boolean>;
|