@arcaelas/whatsapp 1.0.21 → 1.2.2
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/API.md +776 -0
- package/DOC.md +532 -0
- package/build/Chat.d.ts +335 -0
- package/build/Chat.js +396 -0
- package/build/Chat.js.map +1 -0
- package/build/Contact.d.ts +828 -0
- package/build/Contact.js +188 -0
- package/build/Contact.js.map +1 -0
- package/build/Message.d.ts +525 -0
- package/build/Message.js +445 -0
- package/build/Message.js.map +1 -0
- package/build/WhatsApp.d.ts +68 -0
- package/build/WhatsApp.js +399 -0
- package/build/WhatsApp.js.map +1 -0
- package/build/index.d.ts +11 -107
- package/build/index.js +1 -1
- package/build/index.js.map +3 -3
- package/build/store/driver/FileEngine.d.ts +23 -0
- package/build/store/driver/FileEngine.js +90 -0
- package/build/store/driver/FileEngine.js.map +1 -0
- package/build/store/driver/RedisEngine.d.ts +38 -0
- package/build/store/driver/RedisEngine.js +69 -0
- package/build/store/driver/RedisEngine.js.map +1 -0
- package/build/store/engine.d.ts +54 -0
- package/build/store/engine.js +7 -0
- package/build/store/engine.js.map +1 -0
- package/build/store/index.d.ts +8 -0
- package/build/store/index.js +12 -0
- package/build/store/index.js.map +1 -0
- package/context7.json +4 -0
- package/package.json +59 -52
- package/tsconfig.json +25 -25
- package/build/model/base.d.ts +0 -28
- package/build/model/base.js +0 -65
- package/build/model/base.js.map +0 -1
- package/build/model/chat.d.ts +0 -112
- package/build/model/chat.js +0 -105
- package/build/model/chat.js.map +0 -1
- package/build/model/contact.d.ts +0 -16
- package/build/model/contact.js +0 -22
- package/build/model/contact.js.map +0 -1
- package/build/model/message.d.ts +0 -159
- package/build/model/message.js +0 -206
- package/build/model/message.js.map +0 -1
- package/build/static/Store.d.ts +0 -137
- package/build/static/Store.js +0 -238
- package/build/static/Store.js.map +0 -1
- package/build/static/useCache.d.ts +0 -12
- package/build/static/useCache.js +0 -43
- package/build/static/useCache.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/driver/FileEngine.ts
|
|
3
|
+
* @description Engine de persistencia en sistema de archivos local
|
|
4
|
+
*/
|
|
5
|
+
import type { Engine } from '../engine';
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* Engine de persistencia en sistema de archivos.
|
|
9
|
+
* Almacena texto plano (JSON stringified).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const engine = new FileEngine('.baileys/5491112345678');
|
|
13
|
+
* await engine.set('contact/123', '{"name":"John"}');
|
|
14
|
+
* const data = await engine.get('contact/123');
|
|
15
|
+
*/
|
|
16
|
+
export declare class FileEngine implements Engine {
|
|
17
|
+
private readonly _base;
|
|
18
|
+
constructor(_base?: string);
|
|
19
|
+
get(key: string): Promise<string | null>;
|
|
20
|
+
set(key: string, value: string | null): Promise<void>;
|
|
21
|
+
list(prefix: string, offset?: number, limit?: number, suffix?: string): Promise<string[]>;
|
|
22
|
+
delete_prefix(prefix: string): Promise<number>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file store/driver/FileEngine.ts
|
|
4
|
+
* @description Engine de persistencia en sistema de archivos local
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FileEngine = void 0;
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* Engine de persistencia en sistema de archivos.
|
|
13
|
+
* Almacena texto plano (JSON stringified).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const engine = new FileEngine('.baileys/5491112345678');
|
|
17
|
+
* await engine.set('contact/123', '{"name":"John"}');
|
|
18
|
+
* const data = await engine.get('contact/123');
|
|
19
|
+
*/
|
|
20
|
+
class FileEngine {
|
|
21
|
+
constructor(_base = '.baileys/default') {
|
|
22
|
+
this._base = _base;
|
|
23
|
+
}
|
|
24
|
+
async get(key) {
|
|
25
|
+
try {
|
|
26
|
+
return await (0, promises_1.readFile)((0, node_path_1.join)(this._base, key.replace(/@/g, '_at_')), 'utf-8');
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async set(key, value) {
|
|
33
|
+
const path = (0, node_path_1.join)(this._base, key.replace(/@/g, '_at_'));
|
|
34
|
+
if (value) {
|
|
35
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(path), { recursive: true });
|
|
36
|
+
await (0, promises_1.writeFile)(path, value, 'utf-8');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
try {
|
|
40
|
+
await (0, promises_1.rm)(path, { force: true });
|
|
41
|
+
}
|
|
42
|
+
catch { }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async list(prefix, offset = 0, limit = 50, suffix) {
|
|
46
|
+
const base = (0, node_path_1.join)(this._base, prefix.replace(/@/g, '_at_'));
|
|
47
|
+
const suffix_escaped = suffix?.replace(/@/g, '_at_');
|
|
48
|
+
try {
|
|
49
|
+
const items = [];
|
|
50
|
+
const entries = await (0, promises_1.readdir)(base, { withFileTypes: true, recursive: true });
|
|
51
|
+
for (const file of entries) {
|
|
52
|
+
if (!file.isFile())
|
|
53
|
+
continue;
|
|
54
|
+
// Compatibilidad Node < 20: parentPath puede no existir
|
|
55
|
+
const parent = file.parentPath || file.path || base;
|
|
56
|
+
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
|
+
try {
|
|
61
|
+
items.push({
|
|
62
|
+
key: path.slice(this._base.length + 1).replace(/_at_/g, '@'),
|
|
63
|
+
mtime: (await (0, promises_1.stat)(path)).mtimeMs,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch { }
|
|
67
|
+
}
|
|
68
|
+
return items
|
|
69
|
+
.sort((a, b) => b.mtime - a.mtime)
|
|
70
|
+
.slice(offset, offset + limit)
|
|
71
|
+
.map((f) => f.key);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
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
|
+
}
|
|
89
|
+
exports.FileEngine = FileEngine;
|
|
90
|
+
//# sourceMappingURL=FileEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileEngine.js","sourceRoot":"","sources":["../../../src/store/driver/FileEngine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAiF;AACjF,yCAA0C;AAG1C;;;;;;;;;GASG;AACH,MAAa,UAAU;IACnB,YAA6B,QAAgB,kBAAkB;QAAlC,UAAK,GAAL,KAAK,CAA6B;IAAG,CAAC;IAEnE,KAAK,CAAC,GAAG,CAAC,GAAW;QACjB,IAAI,CAAC;YACD,OAAO,MAAM,IAAA,mBAAQ,EAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,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AC,CAAC;QACb,CAAC;IACL,CAAC;CACJ;AA9DD,gCA8DC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/driver/RedisEngine.ts
|
|
3
|
+
* @description Engine de persistencia con Redis
|
|
4
|
+
*/
|
|
5
|
+
import type { Engine } from '../engine';
|
|
6
|
+
/**
|
|
7
|
+
* @description Interface mínima del cliente Redis (compatible con ioredis y redis).
|
|
8
|
+
*/
|
|
9
|
+
export interface RedisClient {
|
|
10
|
+
get(key: string): Promise<string | null>;
|
|
11
|
+
set(key: string, value: string): Promise<unknown>;
|
|
12
|
+
del(key: string): Promise<unknown>;
|
|
13
|
+
scan(cursor: number | string, ...args: unknown[]): Promise<[string, string[]]>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @description
|
|
17
|
+
* Engine de persistencia con Redis.
|
|
18
|
+
* Recibe una conexión existente de ioredis o redis.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import Redis from 'ioredis';
|
|
22
|
+
* const client = new Redis();
|
|
23
|
+
* const engine = new RedisEngine(client, 'wa:5491112345678');
|
|
24
|
+
* await engine.set('contact/123', '{"name":"John"}');
|
|
25
|
+
*/
|
|
26
|
+
export declare class RedisEngine implements Engine {
|
|
27
|
+
private readonly _client;
|
|
28
|
+
private readonly _prefix;
|
|
29
|
+
constructor(_client: RedisClient, _prefix?: string);
|
|
30
|
+
get(key: string): Promise<string | null>;
|
|
31
|
+
set(key: string, value: string | null): Promise<void>;
|
|
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
|
+
list(prefix: string, offset?: number, limit?: number, suffix?: string): Promise<string[]>;
|
|
37
|
+
delete_prefix(prefix: string): Promise<number>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file store/driver/RedisEngine.ts
|
|
4
|
+
* @description Engine de persistencia con Redis
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RedisEngine = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* Engine de persistencia con Redis.
|
|
11
|
+
* Recibe una conexión existente de ioredis o redis.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import Redis from 'ioredis';
|
|
15
|
+
* const client = new Redis();
|
|
16
|
+
* const engine = new RedisEngine(client, 'wa:5491112345678');
|
|
17
|
+
* await engine.set('contact/123', '{"name":"John"}');
|
|
18
|
+
*/
|
|
19
|
+
class RedisEngine {
|
|
20
|
+
constructor(_client, _prefix = 'wa:default') {
|
|
21
|
+
this._client = _client;
|
|
22
|
+
this._prefix = _prefix;
|
|
23
|
+
}
|
|
24
|
+
async get(key) {
|
|
25
|
+
return this._client.get(`${this._prefix}:${key}`);
|
|
26
|
+
}
|
|
27
|
+
async set(key, value) {
|
|
28
|
+
if (value) {
|
|
29
|
+
await this._client.set(`${this._prefix}:${key}`, value);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
await this._client.del(`${this._prefix}:${key}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @description Lista keys bajo un prefijo.
|
|
37
|
+
* @note Redis SCAN no garantiza orden. Los resultados no están ordenados por timestamp.
|
|
38
|
+
*/
|
|
39
|
+
async list(prefix, offset = 0, limit = 50, suffix) {
|
|
40
|
+
// Si hay suffix, usamos pattern más específico
|
|
41
|
+
const pattern = suffix ? `${this._prefix}:${prefix}*${suffix}` : `${this._prefix}:${prefix}*`;
|
|
42
|
+
const keys = [];
|
|
43
|
+
let cursor = '0';
|
|
44
|
+
do {
|
|
45
|
+
const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
46
|
+
cursor = next;
|
|
47
|
+
keys.push(...batch);
|
|
48
|
+
} while (cursor !== '0' && keys.length < offset + limit + 100);
|
|
49
|
+
return keys.map((k) => k.slice(this._prefix.length + 1)).slice(offset, offset + limit);
|
|
50
|
+
}
|
|
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
|
+
exports.RedisEngine = RedisEngine;
|
|
69
|
+
//# 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,MAAa,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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,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,MAAM,GAAG,GAAG,CAAC;QAEjB,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,EAAE;QAEzB,IAAI,CAAC,IAAI,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;AApDD,kCAoDC"}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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 './driver/FileEngine';
|
|
6
|
+
export { RedisEngine } from './driver/RedisEngine';
|
|
7
|
+
export type { RedisClient } from './driver/RedisEngine';
|
|
8
|
+
export type { Engine } from './engine';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file store/index.ts
|
|
4
|
+
* @description Exportaciones del módulo de persistencia
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RedisEngine = exports.FileEngine = void 0;
|
|
8
|
+
var FileEngine_1 = require("./driver/FileEngine");
|
|
9
|
+
Object.defineProperty(exports, "FileEngine", { enumerable: true, get: function () { return FileEngine_1.FileEngine; } });
|
|
10
|
+
var RedisEngine_1 = require("./driver/RedisEngine");
|
|
11
|
+
Object.defineProperty(exports, "RedisEngine", { enumerable: true, get: function () { return RedisEngine_1.RedisEngine; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAAiD;AAAxC,wGAAA,UAAU,OAAA;AACnB,oDAAmD;AAA1C,0GAAA,WAAW,OAAA"}
|
package/context7.json
ADDED
package/package.json
CHANGED
|
@@ -1,54 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
2
|
+
"license": "ISC",
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"name": "@arcaelas/whatsapp",
|
|
5
|
+
"homepage": "https://github.com/arcaelas/whatsapp",
|
|
6
|
+
"description": "A small box of tools, which are implemented in different factions of the library.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"whatsapp",
|
|
9
|
+
"tools",
|
|
10
|
+
"arcaelas",
|
|
11
|
+
"arcaelas insiders",
|
|
12
|
+
"arcaelas-insiders",
|
|
13
|
+
"javascript"
|
|
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"
|
|
60
|
+
}
|
|
54
61
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"include": ["src"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"paths": {},
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noImplicitAny": false,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"outDir": "./build",
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"emitDecoratorMetadata": true,
|
|
20
|
+
"downlevelIteration": true,
|
|
21
|
+
"lib": ["ES2022", "DOM"],
|
|
22
|
+
"allowSyntheticDefaultImports": true,
|
|
23
|
+
"useDefineForClassFields": false,
|
|
24
|
+
"strictPropertyInitialization": false
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
|
27
27
|
}
|
package/build/model/base.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Noop } from '@arcaelas/utils';
|
|
2
|
-
import WhatsApp from '..';
|
|
3
|
-
type Serialize<T> = {
|
|
4
|
-
[K in keyof T as T[K] extends Noop ? never : K]: T[K];
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* @module Base
|
|
8
|
-
* @description
|
|
9
|
-
* Base class for WhatsApp entities.
|
|
10
|
-
*/
|
|
11
|
-
export default class Base<T> {
|
|
12
|
-
protected readonly $: WhatsApp;
|
|
13
|
-
protected readonly _: Serialize<T>;
|
|
14
|
-
constructor($: WhatsApp, _: Serialize<T>);
|
|
15
|
-
/**
|
|
16
|
-
* @description
|
|
17
|
-
* Returns a JSON representation of this entity.
|
|
18
|
-
* @returns A JSON representation of this entity.
|
|
19
|
-
*/
|
|
20
|
-
toJSON(): Serialize<T>;
|
|
21
|
-
/**
|
|
22
|
-
* @description
|
|
23
|
-
* Returns a string representation of this entity.
|
|
24
|
-
* @returns A string representation of this entity.
|
|
25
|
-
*/
|
|
26
|
-
toString(): string;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
package/build/model/base.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const Baileys = __importStar(require("baileys"));
|
|
37
|
-
/**
|
|
38
|
-
* @module Base
|
|
39
|
-
* @description
|
|
40
|
-
* Base class for WhatsApp entities.
|
|
41
|
-
*/
|
|
42
|
-
class Base {
|
|
43
|
-
constructor($, _) {
|
|
44
|
-
this.$ = $;
|
|
45
|
-
this._ = _;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @description
|
|
49
|
-
* Returns a JSON representation of this entity.
|
|
50
|
-
* @returns A JSON representation of this entity.
|
|
51
|
-
*/
|
|
52
|
-
toJSON() {
|
|
53
|
-
return this._;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @description
|
|
57
|
-
* Returns a string representation of this entity.
|
|
58
|
-
* @returns A string representation of this entity.
|
|
59
|
-
*/
|
|
60
|
-
toString() {
|
|
61
|
-
return JSON.stringify(this.toJSON(), Baileys.BufferJSON.replacer);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.default = Base;
|
|
65
|
-
//# sourceMappingURL=base.js.map
|
package/build/model/base.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC;;;;GAIG;AACH,MAAqB,IAAI;IACrB,YAA+B,CAAW,EAAqB,CAAe;QAA/C,MAAC,GAAD,CAAC,CAAU;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAG,CAAC;IAClF;;;;OAIG;IACH,MAAM;QACF,OAAO,IAAI,CAAC,CAAC,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACJ;AAlBD,uBAkBC"}
|