@arcaelas/whatsapp 1.2.3 → 1.4.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/{Chat.js → cjs/Chat.js} +1 -1
- package/build/cjs/Chat.js.map +1 -0
- package/build/{Contact.js → cjs/Contact.js} +6 -5
- package/build/cjs/Contact.js.map +1 -0
- package/build/{Message.js → cjs/Message.js} +5 -3
- package/build/cjs/Message.js.map +1 -0
- package/build/{WhatsApp.js → cjs/WhatsApp.js} +11 -6
- package/build/cjs/WhatsApp.js.map +1 -0
- package/build/cjs/index.js +17 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/package.json +1 -0
- package/build/{store → cjs/store}/driver/FileEngine.d.ts +1 -1
- package/build/{store → cjs/store}/driver/FileEngine.js +2 -2
- package/build/cjs/store/driver/FileEngine.js.map +1 -0
- package/build/{store → cjs/store}/driver/RedisEngine.d.ts +1 -1
- package/build/cjs/store/driver/RedisEngine.js.map +1 -0
- package/build/cjs/store/engine.js.map +1 -0
- package/build/cjs/store/index.d.ts +8 -0
- package/build/{store → cjs/store}/index.js +2 -2
- package/build/cjs/store/index.js.map +1 -0
- package/build/esm/Chat.d.ts +335 -0
- package/build/esm/Chat.js +390 -0
- package/build/esm/Chat.js.map +1 -0
- package/build/esm/Contact.d.ts +856 -0
- package/build/esm/Contact.js +183 -0
- package/build/esm/Contact.js.map +1 -0
- package/build/esm/Message.d.ts +580 -0
- package/build/esm/Message.js +459 -0
- package/build/esm/Message.js.map +1 -0
- package/build/esm/WhatsApp.d.ts +68 -0
- package/build/esm/WhatsApp.js +364 -0
- package/build/esm/WhatsApp.js.map +1 -0
- package/build/esm/index.d.ts +13 -0
- package/build/esm/index.js +10 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/package.json +1 -0
- package/build/esm/store/driver/FileEngine.d.ts +23 -0
- package/build/esm/store/driver/FileEngine.js +86 -0
- package/build/esm/store/driver/FileEngine.js.map +1 -0
- package/build/esm/store/driver/RedisEngine.d.ts +38 -0
- package/build/esm/store/driver/RedisEngine.js +65 -0
- package/build/esm/store/driver/RedisEngine.js.map +1 -0
- package/build/esm/store/engine.d.ts +54 -0
- package/build/esm/store/engine.js +6 -0
- package/build/{store → esm/store}/engine.js.map +1 -1
- package/build/esm/store/index.d.ts +8 -0
- package/build/esm/store/index.js +7 -0
- package/build/esm/store/index.js.map +1 -0
- package/package.json +70 -58
- package/API.md +0 -776
- package/CHANGELOG.md +0 -53
- package/DOC.md +0 -532
- package/build/Chat.js.map +0 -1
- package/build/Contact.js.map +0 -1
- package/build/Message.js.map +0 -1
- package/build/WhatsApp.js.map +0 -1
- package/build/index.js +0 -2
- package/build/index.js.map +0 -7
- package/build/store/driver/FileEngine.js.map +0 -1
- package/build/store/driver/RedisEngine.js.map +0 -1
- package/build/store/index.d.ts +0 -8
- package/build/store/index.js.map +0 -1
- package/context7.json +0 -4
- package/tsconfig.json +0 -27
- /package/build/{Chat.d.ts → cjs/Chat.d.ts} +0 -0
- /package/build/{Contact.d.ts → cjs/Contact.d.ts} +0 -0
- /package/build/{Message.d.ts → cjs/Message.d.ts} +0 -0
- /package/build/{WhatsApp.d.ts → cjs/WhatsApp.d.ts} +0 -0
- /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/build/{store → cjs/store}/driver/RedisEngine.js +0 -0
- /package/build/{store → cjs/store}/engine.d.ts +0 -0
- /package/build/{store → cjs/store}/engine.js +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/driver/RedisEngine.ts
|
|
3
|
+
* @description Engine de persistencia con Redis
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* Engine de persistencia con Redis.
|
|
8
|
+
* Recibe una conexión existente de ioredis o redis.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import Redis from 'ioredis';
|
|
12
|
+
* const client = new Redis();
|
|
13
|
+
* const engine = new RedisEngine(client, 'wa:5491112345678');
|
|
14
|
+
* await engine.set('contact/123', '{"name":"John"}');
|
|
15
|
+
*/
|
|
16
|
+
export class RedisEngine {
|
|
17
|
+
constructor(_client, _prefix = 'wa:default') {
|
|
18
|
+
this._client = _client;
|
|
19
|
+
this._prefix = _prefix;
|
|
20
|
+
}
|
|
21
|
+
async get(key) {
|
|
22
|
+
return this._client.get(`${this._prefix}:${key}`);
|
|
23
|
+
}
|
|
24
|
+
async set(key, value) {
|
|
25
|
+
if (value) {
|
|
26
|
+
await this._client.set(`${this._prefix}:${key}`, value);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await this._client.del(`${this._prefix}:${key}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @description Lista keys bajo un prefijo.
|
|
34
|
+
* @note Redis SCAN no garantiza orden. Los resultados no están ordenados por timestamp.
|
|
35
|
+
*/
|
|
36
|
+
async list(prefix, offset = 0, limit = 50, suffix) {
|
|
37
|
+
// Si hay suffix, usamos pattern más específico
|
|
38
|
+
const pattern = suffix ? `${this._prefix}:${prefix}*${suffix}` : `${this._prefix}:${prefix}*`;
|
|
39
|
+
const keys = [];
|
|
40
|
+
let cursor = '0';
|
|
41
|
+
do {
|
|
42
|
+
const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
43
|
+
cursor = next;
|
|
44
|
+
keys.push(...batch);
|
|
45
|
+
} while (cursor !== '0' && keys.length < offset + limit + 100);
|
|
46
|
+
return keys.map((k) => k.slice(this._prefix.length + 1)).slice(offset, offset + limit);
|
|
47
|
+
}
|
|
48
|
+
async delete_prefix(prefix) {
|
|
49
|
+
const pattern = `${this._prefix}:${prefix}*`;
|
|
50
|
+
const keys = [];
|
|
51
|
+
let cursor = '0';
|
|
52
|
+
do {
|
|
53
|
+
const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
54
|
+
cursor = next;
|
|
55
|
+
keys.push(...batch);
|
|
56
|
+
} while (cursor !== '0');
|
|
57
|
+
if (!keys.length)
|
|
58
|
+
return 0;
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
await this._client.del(key);
|
|
61
|
+
}
|
|
62
|
+
return keys.length;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=RedisEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/RedisEngine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAW;IACpB,YAA6B,OAAoB,EAAmB,UAAkB,YAAY;QAArE,YAAO,GAAP,OAAO,CAAa;QAAmB,YAAO,GAAP,OAAO,CAAuB;IAAG,CAAC;IAEtG,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,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAoB;QACvC,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,MAAe;QAC9D,+CAA+C;QAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,MAAM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AAI,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC;QAE3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/engine.ts
|
|
3
|
+
* @description Interface Engine - contrato para proveedores de persistencia key-value
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* Interface que define el contrato para proveedores de persistencia.
|
|
8
|
+
* Almacena texto (JSON stringified con BufferJSON para binarios).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* class CustomEngine implements Engine {
|
|
12
|
+
* async get(key: string): Promise<string | null> {
|
|
13
|
+
* return localStorage.getItem(key);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* async set(key: string, value: string | null): Promise<void> {
|
|
17
|
+
* if (value === null) localStorage.removeItem(key);
|
|
18
|
+
* else localStorage.setItem(key, value);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* async list(prefix: string, offset?: number, limit?: number): Promise<string[]> {
|
|
22
|
+
* return Object.keys(localStorage).filter(k => k.startsWith(prefix));
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export interface Engine {
|
|
27
|
+
/**
|
|
28
|
+
* @description Obtiene un valor por su key.
|
|
29
|
+
* @param key Ruta del documento (ej: 'creds', 'contact/123@s.whatsapp.net').
|
|
30
|
+
* @returns Texto JSON o null si no existe.
|
|
31
|
+
*/
|
|
32
|
+
get(key: string): Promise<string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Guarda o elimina un valor.
|
|
35
|
+
* @param key Ruta del documento.
|
|
36
|
+
* @param value Texto a guardar o null para eliminar.
|
|
37
|
+
*/
|
|
38
|
+
set(key: string, value: string | null): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @description Lista keys bajo un prefijo, ordenados por más reciente.
|
|
41
|
+
* @param prefix Prefijo de búsqueda (ej: 'contact/', 'chat/123/message/').
|
|
42
|
+
* @param offset Inicio de paginación (default: 0).
|
|
43
|
+
* @param limit Cantidad máxima (default: 50).
|
|
44
|
+
* @param suffix Sufijo requerido para filtrar keys (ej: '/index').
|
|
45
|
+
* @returns Array de keys.
|
|
46
|
+
*/
|
|
47
|
+
list(prefix: string, offset?: number, limit?: number, suffix?: string): Promise<string[]>;
|
|
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>;
|
|
54
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/store/engine.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/index.ts
|
|
3
|
+
* @description Exportaciones del módulo de persistencia
|
|
4
|
+
*/
|
|
5
|
+
export { FileEngine } from '../store/driver/FileEngine';
|
|
6
|
+
export { RedisEngine } from '../store/driver/RedisEngine';
|
|
7
|
+
export type { RedisClient } from '../store/driver/RedisEngine';
|
|
8
|
+
export type { Engine } from '../store/engine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,61 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "https://github.com/arcaelas/whatsapp.git"
|
|
18
|
-
},
|
|
19
|
-
"bugs": {
|
|
20
|
-
"email": "community@arcaelas.com",
|
|
21
|
-
"url": "https://github.com/arcaelas/whatsapp/issues"
|
|
22
|
-
},
|
|
23
|
-
"main": "build/index.js",
|
|
24
|
-
"files": [
|
|
25
|
-
"build/",
|
|
26
|
-
"*.md",
|
|
27
|
-
"*.json"
|
|
28
|
-
],
|
|
29
|
-
"author": {
|
|
30
|
-
"name": "Arcaelas Insiders",
|
|
31
|
-
"email": "comunity@arcaelas.com",
|
|
32
|
-
"url": "https://github.com/arcaelas"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public",
|
|
36
|
-
"registry": "https://registry.npmjs.org/"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"build": "tsc && node esbuild.js",
|
|
40
|
-
"prepublishOnly": "yarn build && npm version patch",
|
|
41
|
-
"commit": "npm publish --access=public",
|
|
42
|
-
"postpublish": "rm -rf build"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@types/node": "^25.0.3",
|
|
46
|
-
"@types/qrcode": "^1.5.6",
|
|
47
|
-
"esbuild": "^0.17.18",
|
|
48
|
-
"typescript": "^5.0.4"
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"@arcaelas/dynamite": "^1.0.9",
|
|
52
|
-
"@arcaelas/utils": "^2.0.5",
|
|
53
|
-
"@aws-sdk/client-s3": "^3.958.0",
|
|
54
|
-
"@hapi/boom": "^10.0.1",
|
|
55
|
-
"baileys": "6.7.18",
|
|
56
|
-
"node-cache": "^5.1.2",
|
|
57
|
-
"pino": "^10.1.0",
|
|
58
|
-
"pino-pretty": "^13.1.3",
|
|
59
|
-
"qrcode": "^1.5.4"
|
|
2
|
+
"name": "@arcaelas/whatsapp",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "A small box of tools, which are implemented in different factions of the library.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"main": "./build/cjs/index.js",
|
|
7
|
+
"module": "./build/esm/index.js",
|
|
8
|
+
"types": "./build/esm/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./build/esm/index.d.ts",
|
|
12
|
+
"import": "./build/esm/index.js",
|
|
13
|
+
"require": "./build/cjs/index.js"
|
|
60
14
|
}
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Arcaelas Insiders",
|
|
18
|
+
"email": "comunity@arcaelas.com",
|
|
19
|
+
"url": "https://github.com/arcaelas"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/arcaelas/whatsapp.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"email": "community@arcaelas.com",
|
|
27
|
+
"url": "https://github.com/arcaelas/whatsapp/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/arcaelas/whatsapp",
|
|
30
|
+
"keywords": [
|
|
31
|
+
"whatsapp",
|
|
32
|
+
"tools",
|
|
33
|
+
"arcaelas",
|
|
34
|
+
"arcaelas insiders",
|
|
35
|
+
"arcaelas-insiders",
|
|
36
|
+
"javascript"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"build/"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build:esm": "tsc --module ESNext --moduleResolution bundler --outDir build/esm && tsc-alias --outDir build/esm && echo '{\"type\":\"module\"}' > build/esm/package.json",
|
|
47
|
+
"build:cjs": "tsc --module commonjs --moduleResolution node --outDir build/cjs && tsc-alias --outDir build/cjs && echo '{\"type\":\"commonjs\"}' > build/cjs/package.json",
|
|
48
|
+
"build": "yarn build:esm && yarn build:cjs",
|
|
49
|
+
"docs": "mkdocs gh-deploy --force",
|
|
50
|
+
"lint": "eslint src/ --fix",
|
|
51
|
+
"release": "npm version minor && yarn build && npm publish --access public",
|
|
52
|
+
"postpublish": "rm -rf build/"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@arcaelas/dynamite": "^1.0.9",
|
|
56
|
+
"@arcaelas/utils": "^2.0.5",
|
|
57
|
+
"@hapi/boom": "^10.0.1",
|
|
58
|
+
"baileys": "6.7.18",
|
|
59
|
+
"pino": "^10.1.0",
|
|
60
|
+
"pino-pretty": "^13.1.3",
|
|
61
|
+
"qrcode": "^1.5.4"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@eslint/js": "^9.0.0",
|
|
65
|
+
"@types/node": "^25.0.3",
|
|
66
|
+
"@types/qrcode": "^1.5.6",
|
|
67
|
+
"eslint": "^9.0.0",
|
|
68
|
+
"prettier": "^3.0.0",
|
|
69
|
+
"tsc-alias": "^1.8.16",
|
|
70
|
+
"typescript": "^5.0.4",
|
|
71
|
+
"typescript-eslint": "^8.0.0"
|
|
72
|
+
}
|
|
61
73
|
}
|