@arcaelas/whatsapp 1.2.3 → 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.
Files changed (78) hide show
  1. package/build/cjs/Chat.d.ts +317 -0
  2. package/build/cjs/Chat.js +273 -0
  3. package/build/cjs/Chat.js.map +1 -0
  4. package/build/{Contact.d.ts → cjs/Contact.d.ts} +317 -304
  5. package/build/cjs/Contact.js +144 -0
  6. package/build/cjs/Contact.js.map +1 -0
  7. package/build/cjs/Message.d.ts +882 -0
  8. package/build/cjs/Message.js +483 -0
  9. package/build/cjs/Message.js.map +1 -0
  10. package/build/{WhatsApp.d.ts → cjs/WhatsApp.d.ts} +16 -4
  11. package/build/{WhatsApp.js → cjs/WhatsApp.js} +84 -81
  12. package/build/cjs/WhatsApp.js.map +1 -0
  13. package/build/{index.d.ts → cjs/index.d.ts} +2 -2
  14. package/build/cjs/index.js +17 -0
  15. package/build/cjs/index.js.map +1 -0
  16. package/build/cjs/package.json +1 -0
  17. package/build/cjs/store/driver/FileEngine.d.ts +34 -0
  18. package/build/{store → cjs/store}/driver/FileEngine.js +16 -20
  19. package/build/cjs/store/driver/FileEngine.js.map +1 -0
  20. package/build/{store → cjs/store}/driver/RedisEngine.d.ts +14 -5
  21. package/build/{store → cjs/store}/driver/RedisEngine.js +23 -22
  22. package/build/cjs/store/driver/RedisEngine.js.map +1 -0
  23. package/build/{store → cjs/store}/engine.d.ts +9 -10
  24. package/build/cjs/store/engine.js.map +1 -0
  25. package/build/cjs/store/index.d.ts +8 -0
  26. package/build/{store → cjs/store}/index.js +2 -2
  27. package/build/cjs/store/index.js.map +1 -0
  28. package/build/esm/Chat.d.ts +317 -0
  29. package/build/esm/Chat.js +268 -0
  30. package/build/esm/Chat.js.map +1 -0
  31. package/build/esm/Contact.d.ts +869 -0
  32. package/build/esm/Contact.js +139 -0
  33. package/build/esm/Contact.js.map +1 -0
  34. package/build/esm/Message.d.ts +882 -0
  35. package/build/esm/Message.js +478 -0
  36. package/build/esm/Message.js.map +1 -0
  37. package/build/esm/WhatsApp.d.ts +80 -0
  38. package/build/esm/WhatsApp.js +362 -0
  39. package/build/esm/WhatsApp.js.map +1 -0
  40. package/build/esm/index.d.ts +13 -0
  41. package/build/esm/index.js +10 -0
  42. package/build/esm/index.js.map +1 -0
  43. package/build/esm/package.json +1 -0
  44. package/build/esm/store/driver/FileEngine.d.ts +34 -0
  45. package/build/esm/store/driver/FileEngine.js +82 -0
  46. package/build/esm/store/driver/FileEngine.js.map +1 -0
  47. package/build/esm/store/driver/RedisEngine.d.ts +47 -0
  48. package/build/esm/store/driver/RedisEngine.js +66 -0
  49. package/build/esm/store/driver/RedisEngine.js.map +1 -0
  50. package/build/esm/store/engine.d.ts +53 -0
  51. package/build/esm/store/engine.js +6 -0
  52. package/build/{store → esm/store}/engine.js.map +1 -1
  53. package/build/esm/store/index.d.ts +8 -0
  54. package/build/esm/store/index.js +7 -0
  55. package/build/esm/store/index.js.map +1 -0
  56. package/package.json +70 -58
  57. package/API.md +0 -776
  58. package/CHANGELOG.md +0 -53
  59. package/DOC.md +0 -532
  60. package/build/Chat.d.ts +0 -335
  61. package/build/Chat.js +0 -396
  62. package/build/Chat.js.map +0 -1
  63. package/build/Contact.js +0 -188
  64. package/build/Contact.js.map +0 -1
  65. package/build/Message.d.ts +0 -580
  66. package/build/Message.js +0 -463
  67. package/build/Message.js.map +0 -1
  68. package/build/WhatsApp.js.map +0 -1
  69. package/build/index.js +0 -2
  70. package/build/index.js.map +0 -7
  71. package/build/store/driver/FileEngine.d.ts +0 -23
  72. package/build/store/driver/FileEngine.js.map +0 -1
  73. package/build/store/driver/RedisEngine.js.map +0 -1
  74. package/build/store/index.d.ts +0 -8
  75. package/build/store/index.js.map +0 -1
  76. package/context7.json +0 -4
  77. package/tsconfig.json +0 -27
  78. /package/build/{store → cjs/store}/engine.js +0 -0
@@ -0,0 +1,66 @@
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
+ * Redis persistence engine.
11
+ * Receives an existing ioredis or redis connection.
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
+ export class RedisEngine {
20
+ constructor(_client, _prefix = 'wa:default') {
21
+ this._client = _client;
22
+ this._prefix = _prefix;
23
+ }
24
+ /** @description Obtiene un valor por su key. / Retrieves a value by its key. */
25
+ async get(key) {
26
+ return this._client.get(`${this._prefix}:${key}`);
27
+ }
28
+ /**
29
+ * @description Guarda o elimina un valor. Si value es null, elimina la key y todas las sub-keys con ese prefijo.
30
+ * Saves or deletes a value. If value is null, deletes the key and all sub-keys matching the prefix.
31
+ */
32
+ async set(key, value) {
33
+ const full_key = `${this._prefix}:${key}`;
34
+ if (value) {
35
+ await this._client.set(full_key, value);
36
+ }
37
+ else {
38
+ await this._client.del(full_key);
39
+ const pattern = `${full_key}/*`;
40
+ let cursor = '0';
41
+ do {
42
+ const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
43
+ cursor = next;
44
+ if (batch.length)
45
+ await this._client.del(batch);
46
+ } while (cursor !== '0');
47
+ }
48
+ }
49
+ /**
50
+ * @description Lista keys bajo un prefijo.
51
+ * Lists keys under a prefix.
52
+ * @note Redis SCAN no garantiza orden. / Redis SCAN does not guarantee order.
53
+ */
54
+ async list(prefix, offset = 0, limit = 50) {
55
+ const pattern = `${this._prefix}:${prefix}*`;
56
+ const keys = [];
57
+ let cursor = '0';
58
+ do {
59
+ const [next, batch] = await this._client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
60
+ cursor = next;
61
+ keys.push(...batch);
62
+ } while (cursor !== '0' && keys.length < offset + limit + 100);
63
+ return keys.map((k) => k.slice(this._prefix.length + 1)).slice(offset, offset + limit);
64
+ }
65
+ }
66
+ //# sourceMappingURL=RedisEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedisEngine.js","sourceRoot":"","sources":["../../../../src/store/driver/RedisEngine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,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"}
@@ -0,0 +1,53 @@
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
+ * Interface that defines the contract for persistence providers.
11
+ * Stores plain text (JSON stringified with BufferJSON for binaries).
12
+ *
13
+ * @example
14
+ * class CustomEngine implements Engine {
15
+ * async get(key: string): Promise<string | null> {
16
+ * return localStorage.getItem(key);
17
+ * }
18
+ *
19
+ * async set(key: string, value: string | null): Promise<void> {
20
+ * if (value === null) localStorage.removeItem(key);
21
+ * else localStorage.setItem(key, value);
22
+ * }
23
+ *
24
+ * async list(prefix: string, offset?: number, limit?: number): Promise<string[]> {
25
+ * return Object.keys(localStorage).filter(k => k.startsWith(prefix));
26
+ * }
27
+ * }
28
+ */
29
+ export interface Engine {
30
+ /**
31
+ * @description Obtiene un valor por su key.
32
+ * Retrieves a value by its key.
33
+ * @param key Ruta del documento (ej: 'creds', 'contact/123@s.whatsapp.net').
34
+ * @returns Texto JSON o null si no existe.
35
+ */
36
+ get(key: string): Promise<string | null>;
37
+ /**
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.
40
+ * @param key Ruta del documento.
41
+ * @param value Texto a guardar o null para eliminar recursivamente.
42
+ */
43
+ set(key: string, value: string | null): Promise<void>;
44
+ /**
45
+ * @description Lista keys bajo un prefijo, ordenados por más reciente.
46
+ * Lists keys under a prefix, ordered by most recent.
47
+ * @param prefix Prefijo de búsqueda (ej: 'contact/', 'chat/123/message/').
48
+ * @param offset Inicio de paginación (default: 0).
49
+ * @param limit Cantidad máxima (default: 50).
50
+ * @returns Array de keys.
51
+ */
52
+ list(prefix: string, offset?: number, limit?: number): Promise<string[]>;
53
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file store/engine.ts
3
+ * @description Interface Engine - contrato para proveedores de persistencia key-value
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/store/engine.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
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,7 @@
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
+ //# sourceMappingURL=index.js.map
@@ -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
- "license": "ISC",
3
- "version": "1.2.3",
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"
2
+ "name": "@arcaelas/whatsapp",
3
+ "version": "2.0.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": "7.0.0-rc.9",
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
  }