@arcaelas/whatsapp 1.4.0 → 2.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/build/cjs/Chat.d.ts +187 -205
- package/build/cjs/Chat.js +151 -274
- package/build/cjs/Chat.js.map +1 -1
- package/build/cjs/Contact.d.ts +317 -304
- package/build/cjs/Contact.js +58 -103
- package/build/cjs/Contact.js.map +1 -1
- package/build/cjs/Message.d.ts +567 -265
- package/build/cjs/Message.js +274 -256
- package/build/cjs/Message.js.map +1 -1
- package/build/cjs/WhatsApp.d.ts +16 -4
- package/build/cjs/WhatsApp.js +77 -79
- package/build/cjs/WhatsApp.js.map +1 -1
- package/build/cjs/index.d.ts +2 -2
- package/build/cjs/store/driver/FileEngine.d.ts +13 -2
- package/build/cjs/store/driver/FileEngine.js +15 -19
- package/build/cjs/store/driver/FileEngine.js.map +1 -1
- package/build/cjs/store/driver/RedisEngine.d.ts +13 -4
- package/build/cjs/store/driver/RedisEngine.js +23 -22
- package/build/cjs/store/driver/RedisEngine.js.map +1 -1
- package/build/cjs/store/engine.d.ts +9 -10
- package/build/esm/Chat.d.ts +187 -205
- package/build/esm/Chat.js +151 -273
- package/build/esm/Chat.js.map +1 -1
- package/build/esm/Contact.d.ts +317 -304
- package/build/esm/Contact.js +58 -102
- package/build/esm/Contact.js.map +1 -1
- package/build/esm/Message.d.ts +567 -265
- package/build/esm/Message.js +275 -256
- package/build/esm/Message.js.map +1 -1
- package/build/esm/WhatsApp.d.ts +16 -4
- package/build/esm/WhatsApp.js +80 -82
- package/build/esm/WhatsApp.js.map +1 -1
- package/build/esm/index.d.ts +2 -2
- package/build/esm/store/driver/FileEngine.d.ts +13 -2
- package/build/esm/store/driver/FileEngine.js +15 -19
- package/build/esm/store/driver/FileEngine.js.map +1 -1
- package/build/esm/store/driver/RedisEngine.d.ts +13 -4
- package/build/esm/store/driver/RedisEngine.js +23 -22
- package/build/esm/store/driver/RedisEngine.js.map +1 -1
- package/build/esm/store/engine.d.ts +9 -10
- package/package.json +2 -2
|
@@ -12,6 +12,9 @@ const node_path_1 = require("node:path");
|
|
|
12
12
|
* Engine de persistencia en sistema de archivos.
|
|
13
13
|
* Almacena texto plano (JSON stringified).
|
|
14
14
|
*
|
|
15
|
+
* Filesystem persistence engine.
|
|
16
|
+
* Stores plain text (JSON stringified).
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
16
19
|
* const engine = new FileEngine('.baileys/5491112345678');
|
|
17
20
|
* await engine.set('contact/123', '{"name":"John"}');
|
|
@@ -21,6 +24,7 @@ class FileEngine {
|
|
|
21
24
|
constructor(_base = '.baileys/default') {
|
|
22
25
|
this._base = _base;
|
|
23
26
|
}
|
|
27
|
+
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
24
28
|
async get(key) {
|
|
25
29
|
try {
|
|
26
30
|
return await (0, promises_1.readFile)((0, node_path_1.join)(this._base, key.replace(/@/g, '_at_')), 'utf-8');
|
|
@@ -29,6 +33,10 @@ class FileEngine {
|
|
|
29
33
|
return null;
|
|
30
34
|
}
|
|
31
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @description Guarda o elimina un valor. Si value es null, elimina la key como archivo y como directorio recursivamente.
|
|
38
|
+
* Saves or deletes a value. If value is null, removes the key as file and as directory recursively.
|
|
39
|
+
*/
|
|
32
40
|
async set(key, value) {
|
|
33
41
|
const path = (0, node_path_1.join)(this._base, key.replace(/@/g, '_at_'));
|
|
34
42
|
if (value) {
|
|
@@ -37,26 +45,25 @@ class FileEngine {
|
|
|
37
45
|
}
|
|
38
46
|
else {
|
|
39
47
|
try {
|
|
40
|
-
await (0, promises_1.rm)(path, { force: true });
|
|
48
|
+
await (0, promises_1.rm)(path, { recursive: true, force: true });
|
|
41
49
|
}
|
|
42
|
-
catch { /*
|
|
50
|
+
catch { /* already deleted */ }
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @description Lista keys bajo un prefijo, ordenados por más reciente.
|
|
55
|
+
* Lists keys under a prefix, ordered by most recent.
|
|
56
|
+
*/
|
|
57
|
+
async list(prefix, offset = 0, limit = 50) {
|
|
46
58
|
const base = (0, node_path_1.join)(this._base, prefix.replace(/@/g, '_at_'));
|
|
47
|
-
const suffix_escaped = suffix?.replace(/@/g, '_at_');
|
|
48
59
|
try {
|
|
49
60
|
const items = [];
|
|
50
61
|
const entries = await (0, promises_1.readdir)(base, { withFileTypes: true, recursive: true });
|
|
51
62
|
for (const file of entries) {
|
|
52
63
|
if (!file.isFile())
|
|
53
64
|
continue;
|
|
54
|
-
// Compatibilidad Node < 20: parentPath puede no existir
|
|
55
65
|
const parent = file.parentPath || file.path || base;
|
|
56
66
|
const path = (0, node_path_1.join)(parent, file.name);
|
|
57
|
-
// Filtrar por sufijo ANTES de stat() para mejor performance
|
|
58
|
-
if (suffix_escaped && !path.endsWith(suffix_escaped))
|
|
59
|
-
continue;
|
|
60
67
|
try {
|
|
61
68
|
items.push({
|
|
62
69
|
key: path.slice(this._base.length + 1).replace(/_at_/g, '@'),
|
|
@@ -74,17 +81,6 @@ class FileEngine {
|
|
|
74
81
|
return [];
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
|
-
async delete_prefix(prefix) {
|
|
78
|
-
const base = (0, node_path_1.join)(this._base, prefix.replace(/@/g, '_at_'));
|
|
79
|
-
try {
|
|
80
|
-
await (0, promises_1.rm)(base, { recursive: true, force: true });
|
|
81
|
-
// Contar archivos eliminados no es posible con rm -rf, estimamos
|
|
82
|
-
return 1;
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
84
|
}
|
|
89
85
|
exports.FileEngine = FileEngine;
|
|
90
86
|
//# sourceMappingURL=FileEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/FileEngine.ts"],"names":[],"m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C;iBAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ;AAxDD,gCAwDC"}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
import type { Engine } from '../../store/engine';
|
|
6
6
|
/**
|
|
7
7
|
* @description Interface mínima del cliente Redis (compatible con ioredis y redis).
|
|
8
|
+
* Minimal Redis client interface (compatible with ioredis and redis).
|
|
8
9
|
*/
|
|
9
10
|
export interface RedisClient {
|
|
10
11
|
get(key: string): Promise<string | null>;
|
|
11
12
|
set(key: string, value: string): Promise<unknown>;
|
|
12
|
-
del(key: string): Promise<unknown>;
|
|
13
|
+
del(key: string | string[]): Promise<unknown>;
|
|
13
14
|
scan(cursor: number | string, ...args: unknown[]): Promise<[string, string[]]>;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
@@ -17,6 +18,9 @@ export interface RedisClient {
|
|
|
17
18
|
* Engine de persistencia con Redis.
|
|
18
19
|
* Recibe una conexión existente de ioredis o redis.
|
|
19
20
|
*
|
|
21
|
+
* Redis persistence engine.
|
|
22
|
+
* Receives an existing ioredis or redis connection.
|
|
23
|
+
*
|
|
20
24
|
* @example
|
|
21
25
|
* import Redis from 'ioredis';
|
|
22
26
|
* const client = new Redis();
|
|
@@ -27,12 +31,17 @@ export declare class RedisEngine implements Engine {
|
|
|
27
31
|
private readonly _client;
|
|
28
32
|
private readonly _prefix;
|
|
29
33
|
constructor(_client: RedisClient, _prefix?: string);
|
|
34
|
+
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
30
35
|
get(key: string): Promise<string | null>;
|
|
36
|
+
/**
|
|
37
|
+
* @description Guarda o elimina un valor. Si value es null, elimina la key y todas las sub-keys con ese prefijo.
|
|
38
|
+
* Saves or deletes a value. If value is null, deletes the key and all sub-keys matching the prefix.
|
|
39
|
+
*/
|
|
31
40
|
set(key: string, value: string | null): Promise<void>;
|
|
32
41
|
/**
|
|
33
42
|
* @description Lista keys bajo un prefijo.
|
|
34
|
-
*
|
|
43
|
+
* Lists keys under a prefix.
|
|
44
|
+
* @note Redis SCAN no garantiza orden. / Redis SCAN does not guarantee order.
|
|
35
45
|
*/
|
|
36
|
-
list(prefix: string, offset?: number, limit?: number
|
|
37
|
-
delete_prefix(prefix: string): Promise<number>;
|
|
46
|
+
list(prefix: string, offset?: number, limit?: number): Promise<string[]>;
|
|
38
47
|
}
|
|
@@ -10,6 +10,9 @@ exports.RedisEngine = void 0;
|
|
|
10
10
|
* Engine de persistencia con Redis.
|
|
11
11
|
* Recibe una conexión existente de ioredis o redis.
|
|
12
12
|
*
|
|
13
|
+
* Redis persistence engine.
|
|
14
|
+
* Receives an existing ioredis or redis connection.
|
|
15
|
+
*
|
|
13
16
|
* @example
|
|
14
17
|
* import Redis from 'ioredis';
|
|
15
18
|
* const client = new Redis();
|
|
@@ -21,24 +24,38 @@ class RedisEngine {
|
|
|
21
24
|
this._client = _client;
|
|
22
25
|
this._prefix = _prefix;
|
|
23
26
|
}
|
|
27
|
+
/** @description Obtiene un valor por su key. / Retrieves a value by its key. */
|
|
24
28
|
async get(key) {
|
|
25
29
|
return this._client.get(`${this._prefix}:${key}`);
|
|
26
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @description Guarda o elimina un valor. Si value es null, elimina la key y todas las sub-keys con ese prefijo.
|
|
33
|
+
* Saves or deletes a value. If value is null, deletes the key and all sub-keys matching the prefix.
|
|
34
|
+
*/
|
|
27
35
|
async set(key, value) {
|
|
36
|
+
const full_key = `${this._prefix}:${key}`;
|
|
28
37
|
if (value) {
|
|
29
|
-
await this._client.set(
|
|
38
|
+
await this._client.set(full_key, value);
|
|
30
39
|
}
|
|
31
40
|
else {
|
|
32
|
-
await this._client.del(
|
|
41
|
+
await this._client.del(full_key);
|
|
42
|
+
const pattern = `${full_key}/*`;
|
|
43
|
+
let cursor = '0';
|
|
44
|
+
do {
|
|
45
|
+
const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
46
|
+
cursor = next;
|
|
47
|
+
if (batch.length)
|
|
48
|
+
await this._client.del(batch);
|
|
49
|
+
} while (cursor !== '0');
|
|
33
50
|
}
|
|
34
51
|
}
|
|
35
52
|
/**
|
|
36
53
|
* @description Lista keys bajo un prefijo.
|
|
37
|
-
*
|
|
54
|
+
* Lists keys under a prefix.
|
|
55
|
+
* @note Redis SCAN no garantiza orden. / Redis SCAN does not guarantee order.
|
|
38
56
|
*/
|
|
39
|
-
async list(prefix, offset = 0, limit = 50
|
|
40
|
-
|
|
41
|
-
const pattern = suffix ? `${this._prefix}:${prefix}*${suffix}` : `${this._prefix}:${prefix}*`;
|
|
57
|
+
async list(prefix, offset = 0, limit = 50) {
|
|
58
|
+
const pattern = `${this._prefix}:${prefix}*`;
|
|
42
59
|
const keys = [];
|
|
43
60
|
let cursor = '0';
|
|
44
61
|
do {
|
|
@@ -48,22 +65,6 @@ class RedisEngine {
|
|
|
48
65
|
} while (cursor !== '0' && keys.length < offset + limit + 100);
|
|
49
66
|
return keys.map((k) => k.slice(this._prefix.length + 1)).slice(offset, offset + limit);
|
|
50
67
|
}
|
|
51
|
-
async delete_prefix(prefix) {
|
|
52
|
-
const pattern = `${this._prefix}:${prefix}*`;
|
|
53
|
-
const keys = [];
|
|
54
|
-
let cursor = '0';
|
|
55
|
-
do {
|
|
56
|
-
const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
57
|
-
cursor = next;
|
|
58
|
-
keys.push(...batch);
|
|
59
|
-
} while (cursor !== '0');
|
|
60
|
-
if (!keys.length)
|
|
61
|
-
return 0;
|
|
62
|
-
for (const key of keys) {
|
|
63
|
-
await this._client.del(key);
|
|
64
|
-
}
|
|
65
|
-
return keys.length;
|
|
66
|
-
}
|
|
67
68
|
}
|
|
68
69
|
exports.RedisEngine = RedisEngine;
|
|
69
70
|
//# sourceMappingURL=RedisEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/RedisEngine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"RedisEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/RedisEngine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH;;;;;;;;;;;;;GAaG;AACH,MAAa,WAAW;IACpB,YAA6B,OAAoB,EAAmB,UAAkB,YAAY;QAArE,YAAO,GAAP,OAAO,CAAa;QAAmB,YAAO,GAAP,OAAO,CAAuB;IAAI,CAAC;IAEvG,gFAAgF;IAChF,KAAK,CAAC,GAAG,CAAC,GAAW;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAoB;QACvC,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QAC1C,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACjC,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,CAAC;YAChC,IAAI,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC;gBACA,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;gBACtF,MAAM,GAAG,IAAI,CAAC;gBACd,IAAI,KAAK,CAAC,MAAM;oBAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC,QAAQ,MAAM,KAAK,GAAG,EAAE;QAC7B,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE;QAC7C,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,GAAG,CAAC;QAC7C,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,GAAG,CAAC;YACA,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;YACtF,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACxB,CAAC,QAAQ,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,GAAG,EAAE;QAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;IAC3F,CAAC;CACJ;AA5CD,kCA4CC"}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* Interface que define el contrato para proveedores de persistencia.
|
|
8
8
|
* Almacena texto (JSON stringified con BufferJSON para binarios).
|
|
9
9
|
*
|
|
10
|
+
* Interface that defines the contract for persistence providers.
|
|
11
|
+
* Stores plain text (JSON stringified with BufferJSON for binaries).
|
|
12
|
+
*
|
|
10
13
|
* @example
|
|
11
14
|
* class CustomEngine implements Engine {
|
|
12
15
|
* async get(key: string): Promise<string | null> {
|
|
@@ -26,29 +29,25 @@
|
|
|
26
29
|
export interface Engine {
|
|
27
30
|
/**
|
|
28
31
|
* @description Obtiene un valor por su key.
|
|
32
|
+
* Retrieves a value by its key.
|
|
29
33
|
* @param key Ruta del documento (ej: 'creds', 'contact/123@s.whatsapp.net').
|
|
30
34
|
* @returns Texto JSON o null si no existe.
|
|
31
35
|
*/
|
|
32
36
|
get(key: string): Promise<string | null>;
|
|
33
37
|
/**
|
|
34
|
-
* @description Guarda o elimina un valor.
|
|
38
|
+
* @description Guarda o elimina un valor. Si value es null, elimina la key y todas las sub-keys recursivamente.
|
|
39
|
+
* Saves or deletes a value. If value is null, deletes the key and all sub-keys recursively.
|
|
35
40
|
* @param key Ruta del documento.
|
|
36
|
-
* @param value Texto a guardar o null para eliminar.
|
|
41
|
+
* @param value Texto a guardar o null para eliminar recursivamente.
|
|
37
42
|
*/
|
|
38
43
|
set(key: string, value: string | null): Promise<void>;
|
|
39
44
|
/**
|
|
40
45
|
* @description Lista keys bajo un prefijo, ordenados por más reciente.
|
|
46
|
+
* Lists keys under a prefix, ordered by most recent.
|
|
41
47
|
* @param prefix Prefijo de búsqueda (ej: 'contact/', 'chat/123/message/').
|
|
42
48
|
* @param offset Inicio de paginación (default: 0).
|
|
43
49
|
* @param limit Cantidad máxima (default: 50).
|
|
44
|
-
* @param suffix Sufijo requerido para filtrar keys (ej: '/index').
|
|
45
50
|
* @returns Array de keys.
|
|
46
51
|
*/
|
|
47
|
-
list(prefix: string, offset?: number, limit?: number
|
|
48
|
-
/**
|
|
49
|
-
* @description Elimina todas las keys bajo un prefijo.
|
|
50
|
-
* @param prefix Prefijo a eliminar (ej: 'chat/123/').
|
|
51
|
-
* @returns Cantidad de keys eliminadas.
|
|
52
|
-
*/
|
|
53
|
-
delete_prefix(prefix: string): Promise<number>;
|
|
52
|
+
list(prefix: string, offset?: number, limit?: number): Promise<string[]>;
|
|
54
53
|
}
|