@arcaelas/whatsapp 1.0.3 → 1.0.5

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/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import Store, { Engine } from './static/Store';
11
11
  */
12
12
  interface IWhatsAppBase {
13
13
  phone: string;
14
- store?: Engine;
14
+ store: Engine;
15
15
  }
16
16
  /**
17
17
  * @description Configuración condicional según tipo de login.
@@ -23,6 +23,10 @@ type IWhatsApp<T extends 'qr' | 'code'> = IWhatsAppBase & {
23
23
  } : {
24
24
  code: Noop<[code: string]>;
25
25
  });
26
+ /**
27
+ * @description
28
+ * Event map for WhatsApp.
29
+ */
26
30
  interface EventMap {
27
31
  error: [error: Error];
28
32
  open: [];
@@ -35,6 +39,7 @@ interface EventMap {
35
39
  'message:created': [message: Message];
36
40
  'message:updated': [message: Message];
37
41
  'message:deleted': [id: string];
42
+ process: [event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store];
38
43
  }
39
44
  /**
40
45
  * @description
@@ -46,18 +51,22 @@ interface EventMap {
46
51
  * qr: (code) => console.log(code),
47
52
  * });
48
53
  */
49
- export default class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
50
- protected readonly options: IWhatsApp<T>;
54
+ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
51
55
  /**
52
56
  * @description
53
- * Socket for WhatsApp Web.
57
+ * Store for WhatsApp Web.
54
58
  */
55
- protected socket: Baileys.WASocket;
59
+ protected store: Store;
56
60
  /**
57
61
  * @description
58
- * Store for WhatsApp Web.
62
+ * Options for WhatsApp Web.
59
63
  */
60
- protected store: Store;
64
+ protected options: IWhatsApp<T>;
65
+ /**
66
+ * @description
67
+ * Socket for WhatsApp Web.
68
+ */
69
+ protected socket: Baileys.WASocket;
61
70
  /**
62
71
  * @description
63
72
  * Mutex, used to prevent concurrent access to the socket.
@@ -71,8 +80,30 @@ export default class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<Even
71
80
  * @returns Result of the function.
72
81
  */
73
82
  tick<T extends Noop<[socket: Baileys.WASocket, store: Store], any>>(func: T): Promise<Awaited<ReturnType<T>>>;
83
+ /**
84
+ * @description
85
+ * Process events from the socket.
86
+ * @param func Function to execute.
87
+ * @returns Handler to remove the event listener.
88
+ */
89
+ process(func: Noop<[event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store]>): this;
90
+ /**
91
+ * @description
92
+ * Returns all documents in the store.
93
+ * @returns Promise that resolves to an object containing all documents.
94
+ */
74
95
  documents(): Promise<Record<string, any>>;
96
+ /**
97
+ * @description
98
+ * Returns all chats in the store.
99
+ * @returns Promise that resolves to an array of chats.
100
+ */
75
101
  chats(): Promise<Chat[]>;
102
+ /**
103
+ * @description
104
+ * Returns all messages in the store.
105
+ * @returns Promise that resolves to an array of messages.
106
+ */
76
107
  messages(): Promise<Message[]>;
77
108
  /**
78
109
  * @description
@@ -224,4 +255,10 @@ export default class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<Even
224
255
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
225
256
  }>;
226
257
  }
227
- export {};
258
+ export default WhatsApp;
259
+ export * from './static/Store';
260
+ export { default as Store } from './static/Store';
261
+ export * from './model/chat';
262
+ export { default as Chat } from './model/chat';
263
+ export * from './model/message';
264
+ export { default as Message } from './model/message';
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var T=Object.create;var l=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var q=(o,r)=>{for(var t in r)l(o,t,{get:r[t],enumerable:!0})},y=(o,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of A(r))!W.call(o,s)&&s!==t&&l(o,s,{get:()=>r[s],enumerable:!(i=M(r,s))||i.enumerable});return o};var d=(o,r,t)=>(t=o!=null?T(C(o)):{},y(r||!o||!o.__esModule?l(t,"default",{value:o,enumerable:!0}):t,o)),P=o=>y(l({},"__esModule",{value:!0}),o);var x={};q(x,{default:()=>S});module.exports=P(x);var h=require("@arcaelas/utils"),w=require("async-mutex"),m=d(require("baileys")),f=d(require("node:events")),u=d(require("./model/chat")),g=d(require("./model/message")),k=d(require("./static/Store")),B=d(require("./static/useCache"));class S extends f.default{constructor(t){super({captureRejections:!0});this.options=t;this.store=new Map;this.mutex=new w.Mutex;this.on("error",i=>{this.listenerCount("error")===1&&console.error(i)}),this.store=new k.default(this.options.store??new Map),this.connect()}async tick(t){return this.mutex.acquire().then(()=>t(this.socket,this.store))}async documents(){return await this.tick(async(t,i)=>{const s={};for await(const n of i.document.values())s[n.key]=n.value;return s})}async chats(){return await this.tick(async(t,i)=>{const s=[];for await(const n of i.chat.values())s.push(new u.default(this,n));return s})}async messages(){return await this.tick(async(t,i)=>{const s=[];for await(const n of i.message.values())s.push(new g.default(this,n));return s})}async connect(){const t=(0,h.promify)(),{state:i,save:s}=await(0,B.default)(this.store),{version:n}=await m.fetchLatestBaileysVersion();if(this.socket=m.makeWASocket({version:n,syncFullHistory:!0,browser:m.Browsers.macOS("Descktop"),auth:{creds:i.creds,keys:m.makeCacheableSignalKeyStore(i.keys)},getMessage:async a=>{const e=await this.store.message.get(a.id);return e?e.message:void 0}}),this.socket.ev.process(async a=>{if(a["creds.update"]&&await s(),a["connection.update"]){const{connection:e,lastDisconnect:c}=a["connection.update"];if(e==="open")t.resolve(this.socket);else if(e==="close"&&c?.error?.output?.statusCode!==m.DisconnectReason.loggedOut){t.resolve(await this.connect());return}}await Promise.allSettled([].concat(a["messaging-history.set"]?.chats||[],a["chats.upsert"]||[]).map(async e=>{await this.store.chat.set(e),this.emit("chat:created",new u.default(this,e))})),await Promise.allSettled([].concat(a["chats.update"]||[]).map(async e=>{const c=await this.store.chat.get(e.id);if(c!==null){const p=(0,h.merge)(c,e);await this.store.chat.set(p),this.emit("chat:updated",new u.default(this,p))}}));for(const e of a["chats.delete"]??[])await this.store.chat.delete(e),this.emit("chat:deleted",e);await Promise.allSettled([].concat(a["messages.upsert"]?.messages||[]).map(async e=>{await this.store.message.set(e),this.emit("message:created",new g.default(this,e))})),await Promise.allSettled([].concat(a["messages.update"]||[]).map(async e=>{const c=await this.store.message.get(e.key.id);if(c!==null){const p=(0,h.merge)(c,e);await this.store.message.set(p),this.emit("message:updated",new g.default(this,p))}}))}),await this.socket.waitForSocketOpen(),await(0,h.sleep)(3e3),this.socket.authState.creds.registered)t.resolve(this.socket);else if(this.options.loginType==="code")await this.options.code(await this.socket.requestPairingCode(this.options.phone));else if(this.options.loginType==="qr"){const a=(0,h.promify)(),e=setTimeout(()=>a.reject("QR Timeout"),6e4);this.socket.ev.on("connection.update",async({qr:c})=>{if(c){clearTimeout(e);try{await this.options.qr(c),a.resolve(c)}catch(p){a.reject(p)}}}),await a}return t}}
1
+ "use strict";var C=Object.create;var y=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var R=(o,i)=>{for(var e in i)y(o,e,{get:i[e],enumerable:!0})},g=(o,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of q(i))!E.call(o,a)&&a!==e&&y(o,a,{get:()=>i[a],enumerable:!(r=P(i,a))||r.enumerable});return o},p=(o,i,e)=>(g(o,i,"default"),e&&g(e,i,"default")),m=(o,i,e)=>(e=o!=null?C(v(o)):{},g(i||!o||!o.__esModule?y(e,"default",{value:o,enumerable:!0}):e,o)),I=o=>g(y({},"__esModule",{value:!0}),o);var n={};R(n,{Chat:()=>A.default,Message:()=>W.default,Store:()=>x.default,default:()=>D});module.exports=I(n);var l=require("@arcaelas/utils"),k=require("async-mutex"),u=m(require("baileys")),S=m(require("node:events")),f=m(require("./model/chat")),w=m(require("./model/message")),B=m(require("./static/Store")),T=m(require("./static/useCache"));p(n,require("./static/Store"),module.exports);var x=m(require("./static/Store"));p(n,require("./model/chat"),module.exports);var A=m(require("./model/chat"));p(n,require("./model/message"),module.exports);var W=m(require("./model/message"));class N extends S.default{constructor(e){super({captureRejections:!0});this.mutex=new k.Mutex;this.on("error",r=>{this.listenerCount("error")===1&&console.error(r)}),this.options={...e,phone:e.phone.replace(/\D/g,"")},this.store=new B.default(this.options.store),this.connect()}async tick(e){return this.mutex.acquire().then(()=>e(this.socket,this.store))}process(e){return this.on("process",r=>{e(r,this.socket,this.store)})}async documents(){return await this.tick(async(e,r)=>{const a={};for await(const d of r.document.values())a[d.key]=d.value;return a})}async chats(){return await this.tick(async(e,r)=>{const a=[];for await(const d of r.chat.values())a.push(new f.default(this,d));return a})}async messages(){return await this.tick(async(e,r)=>{const a=[];for await(const d of r.message.values())a.push(new w.default(this,d));return a})}async connect(){const e=(0,l.promify)(),{state:r,save:a}=await(0,T.default)(this.store),{version:d}=await u.fetchLatestBaileysVersion();if(this.socket=u.makeWASocket({version:d,syncFullHistory:!0,browser:u.Browsers.macOS("Descktop"),auth:{creds:r.creds,keys:u.makeCacheableSignalKeyStore(r.keys)},getMessage:async s=>{const t=await this.store.message.get(s.id);return t?t.message:void 0}}),this.socket.ev.process(async s=>{if(s["creds.update"]&&await a(),s["connection.update"]){const{connection:t,lastDisconnect:c}=s["connection.update"];t==="open"?e.resolve(this.socket):t==="close"&&c?.error?.output?.statusCode!==u.DisconnectReason.loggedOut&&e.resolve(await this.connect())}await Promise.allSettled([...s["messaging-history.set"]?.chats||[],...s["chats.upsert"]||[]].map(async t=>{await this.store.chat.set(t),this.emit("chat:created",new f.default(this,t))})),await Promise.allSettled([...s["messaging-history.set"]?.messages||[],...s["messages.upsert"]?.messages||[]].map(async t=>{await this.store.message.set(t),this.emit("message:created",new w.default(this,t))})),await Promise.allSettled((s["chats.update"]||[]).map(async t=>{const c=await this.store.chat.get(t.id);if(c!==null){const h=(0,l.merge)(c,t);await this.store.chat.set(h),this.emit("chat:updated",new f.default(this,h))}})),await Promise.allSettled((s["messages.update"]||[]).map(async t=>{const c=await this.store.message.get(t.key.id);if(c!==null){const h=(0,l.merge)(c,t);await this.store.message.set(h),this.emit("message:updated",new w.default(this,h))}}));for(const{id:t}of s["messages.delete"]?.keys||[])await this.store.message.unset(t),this.emit("message:deleted",t);for(const t of s["chats.delete"]||[])await this.store.chat.unset(t),this.emit("chat:deleted",t);this.emit("process",s,this.socket,this.store)}),await this.socket.waitForSocketOpen(),await(0,l.sleep)(3e3),this.socket.authState.creds.registered)e.resolve(this.socket);else if(this.options.loginType==="code")await this.options.code(await this.socket.requestPairingCode(this.options.phone));else if(this.options.loginType==="qr"){const s=(0,l.promify)(),t=setTimeout(()=>s.reject("QR Timeout"),6e4),c=async({qr:h})=>{if(h)try{clearTimeout(t),await this.options.qr(h),s.resolve(h)}catch(M){s.reject(M)}};this.socket.ev.on("connection.update",c),await s.finally(()=>{this.socket.ev.off("connection.update",c)})}return e}}var D=N;0&&(module.exports={Chat,Message,Store,...require("./static/Store"),...require("./model/chat"),...require("./model/message")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { merge, Noop, promify, sleep } from '@arcaelas/utils';\nimport { type Boom } from '@hapi/boom';\nimport { Mutex } from 'async-mutex';\nimport * as Baileys from 'baileys';\nimport EventEmitter from 'node:events';\nimport Chat from './model/chat';\nimport Message from './model/message';\nimport Store, { Engine } from './static/Store';\nimport useCache from './static/useCache';\n\n/**\n * @description Estructura de configuraci\u00F3n para iniciar sesi\u00F3n con WhatsApp.\n */\ninterface IWhatsAppBase {\n phone: string;\n store?: Engine;\n}\n\n/**\n * @description Configuraci\u00F3n condicional seg\u00FAn tipo de login.\n */\n// prettier-ignore\ntype IWhatsApp<T extends 'qr' | 'code'> = IWhatsAppBase & {\n loginType: T } & (\n T extends 'qr'\n ? { qr: Noop<[qr: string]> }\n : { code: Noop<[code: string]> }\n );\n\ninterface EventMap {\n error: [error: Error];\n open: [];\n close: [];\n qr: [qr: string];\n code: [code: string];\n 'chat:created': [chat: Chat];\n 'chat:updated': [chat: Chat];\n 'chat:deleted': [id: string];\n 'message:created': [message: Message];\n 'message:updated': [message: Message];\n 'message:deleted': [id: string];\n}\n\n/**\n * @description\n * Client for WhatsApp Web.\n * @example\n * const client = new WhatsApp({\n * phone: '1234567890',\n * loginType: 'qr',\n * qr: (code) => console.log(code),\n * });\n */\nexport default class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {\n /**\n * @description\n * Socket for WhatsApp Web.\n */\n protected socket: Baileys.WASocket;\n /**\n * @description\n * Store for WhatsApp Web.\n */\n protected store: Store = new Map() as any;\n /**\n * @description\n * Mutex, used to prevent concurrent access to the socket.\n */\n protected readonly mutex = new Mutex();\n\n constructor(protected readonly options: IWhatsApp<T>) {\n super({ captureRejections: true });\n this.on('error', (error) => {\n if (this.listenerCount('error') === 1) {\n console.error(error);\n }\n });\n this.store = new Store(this.options.store ?? (new Map() as any));\n this.connect();\n }\n\n /**\n * @description\n * Execute a function with the socket and store, means that the function will be executed only when the socket is ready.\n * @param func Function to execute.\n * @returns Result of the function.\n */\n async tick<T extends Noop<[socket: Baileys.WASocket, store: Store], any>>(func: T): Promise<Awaited<ReturnType<T>>> {\n return this.mutex.acquire().then(() => func(this.socket, this.store));\n }\n\n async documents(): Promise<Record<string, any>> {\n return await this.tick(async (_, store) => {\n const documents: Record<string, any> = {};\n for await (const document of store.document.values()) {\n documents[document.key] = document.value;\n }\n return documents;\n });\n }\n\n async chats(): Promise<Chat[]> {\n return await this.tick(async (_, store) => {\n const chats: Chat[] = [];\n for await (const chat of store.chat.values()) {\n chats.push(new Chat(this, chat));\n }\n return chats;\n });\n }\n\n async messages(): Promise<Message[]> {\n return await this.tick(async (_, store) => {\n const messages: Message[] = [];\n for await (const message of store.message.values()) {\n messages.push(new Message(this, message));\n }\n return messages;\n });\n }\n\n /**\n * @description\n * Connect to WhatsApp Web.\n * @returns Promise that resolves to the socket.\n */\n protected async connect() {\n const promise = promify<Baileys.WASocket>();\n const { state, save } = await useCache(this.store);\n const { version } = await Baileys.fetchLatestBaileysVersion();\n this.socket = Baileys.makeWASocket({\n version,\n syncFullHistory: true,\n browser: Baileys.Browsers.macOS('Descktop'),\n auth: {\n creds: state.creds,\n keys: Baileys.makeCacheableSignalKeyStore(state.keys),\n },\n getMessage: async (key) => {\n const message = await this.store.message.get(key.id!);\n return message ? message.message! : undefined;\n },\n });\n this.socket.ev.process(async (event) => {\n if (event['creds.update']) {\n await save();\n }\n if (event['connection.update']) {\n const { connection, lastDisconnect } = event['connection.update'];\n if (connection === 'open') promise.resolve(this.socket);\n else if (connection === 'close' && (lastDisconnect?.error as Boom)?.output?.statusCode !== Baileys.DisconnectReason.loggedOut) {\n promise.resolve(await this.connect());\n return;\n }\n }\n // prettier-ignore\n await Promise.allSettled(\n ([] as Baileys.Chat[])\n .concat(event['messaging-history.set']?.chats || [], event['chats.upsert'] || [])\n .map(async chat => {\n await this.store.chat.set(chat);\n this.emit('chat:created', new Chat(this, chat));\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n ([] as Baileys.ChatUpdate[])\n .concat(event['chats.update'] || [])\n .map(async update => {\n const payload = await this.store.chat.get(update.id!);\n if (payload !== null) {\n const chat = merge(payload, update) as Baileys.Chat;\n await this.store.chat.set(chat);\n this.emit('chat:updated', new Chat(this, chat));\n }\n })\n );\n for (const key of (event['chats.delete'] ?? []) as string[]) {\n await this.store.chat.delete(key);\n this.emit('chat:deleted', key);\n }\n // prettier-ignore\n await Promise.allSettled(\n ([] as Baileys.WAMessage[])\n .concat(event['messages.upsert']?.messages || [])\n .map(async message => {\n await this.store.message.set(message);\n this.emit('message:created', new Message(this, message));\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n ([] as Baileys.WAMessageUpdate[])\n .concat(event['messages.update'] || [])\n .map(async message => {\n const payload = await this.store.message.get(message.key.id!);\n if (payload !== null) {\n const chat = merge(payload, message) as Baileys.WAProto.WebMessageInfo;\n await this.store.message.set(chat);\n this.emit('message:updated', new Message(this, chat));\n }\n })\n );\n // TODO: Handle messages.delete\n });\n\n await this.socket.waitForSocketOpen();\n await sleep(3000);\n\n if (this.socket.authState.creds.registered) {\n promise.resolve(this.socket);\n } else if (this.options.loginType === 'code') {\n await this.options['code'](await this.socket.requestPairingCode(this.options.phone));\n } else if (this.options.loginType === 'qr') {\n const _qr = promify<string>();\n const timeout = setTimeout(() => _qr.reject('QR Timeout'), 60000);\n this.socket.ev.on('connection.update', async ({ qr }) => {\n if (qr) {\n clearTimeout(timeout);\n try {\n await this.options['qr'](qr);\n _qr.resolve(qr);\n } catch (error) {\n _qr.reject(error);\n }\n }\n });\n await _qr;\n }\n return promise;\n }\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,2BAE5CC,EAAsB,uBACtBC,EAAyB,sBACzBC,EAAyB,0BACzBC,EAAiB,2BACjBC,EAAoB,8BACpBC,EAA8B,6BAC9BC,EAAqB,gCA6CrB,MAAOT,UAAwD,EAAAU,OAAuB,CAiBlF,YAA+BC,EAAuB,CAClD,MAAM,CAAE,kBAAmB,EAAK,CAAC,EADN,aAAAA,EAP/B,KAAU,MAAe,IAAI,IAK7B,KAAmB,MAAQ,IAAI,QAI3B,KAAK,GAAG,QAAUC,GAAU,CACpB,KAAK,cAAc,OAAO,IAAM,GAChC,QAAQ,MAAMA,CAAK,CAE3B,CAAC,EACD,KAAK,MAAQ,IAAI,EAAAC,QAAM,KAAK,QAAQ,OAAU,IAAI,GAAa,EAC/D,KAAK,QAAQ,CACjB,CAQA,MAAM,KAAoEC,EAA0C,CAChH,OAAO,KAAK,MAAM,QAAQ,EAAE,KAAK,IAAMA,EAAK,KAAK,OAAQ,KAAK,KAAK,CAAC,CACxE,CAEA,MAAM,WAA0C,CAC5C,OAAO,MAAM,KAAK,KAAK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EAEA,MAAM,QAAQ,WACT,CAAC,EACG,OAAOQ,EAAM,iBAAiB,GAAK,CAAC,CAAC,EACrC,IAAI,MAAMR,GAAW,CAClB,MAAMY,EAAU,MAAM,KAAK,MAAM,QAAQ,IAAIZ,EAAQ,IAAI,EAAG,EAC5D,GAAIY,IAAY,KAAM,CAClB,MAAMf,KAAO,SAAMe,EAASZ,CAAO,EACnC,MAAM,KAAK,MAAM,QAAQ,IAAIH,CAAI,EACjC,KAAK,KAAK,kBAAmB,IAAI,EAAAI,QAAQ,KAAMJ,CAAI,CAAC,EAE5D,CAAC,CACT,CAEJ,CAAC,EAED,MAAM,KAAK,OAAO,kBAAkB,EACpC,QAAM,SAAM,GAAI,EAEZ,KAAK,OAAO,UAAU,MAAM,WAC5BK,EAAQ,QAAQ,KAAK,MAAM,UACpB,KAAK,QAAQ,YAAc,OAClC,MAAM,KAAK,QAAQ,KAAQ,MAAM,KAAK,OAAO,mBAAmB,KAAK,QAAQ,KAAK,CAAC,UAC5E,KAAK,QAAQ,YAAc,KAAM,CACxC,MAAMW,KAAM,WAAgB,EACtBC,EAAU,WAAW,IAAMD,EAAI,OAAO,YAAY,EAAG,GAAK,EAChE,KAAK,OAAO,GAAG,GAAG,oBAAqB,MAAO,CAAE,GAAAE,CAAG,IAAM,CACrD,GAAIA,EAAI,CACJ,aAAaD,CAAO,EACpB,GAAI,CACA,MAAM,KAAK,QAAQ,GAAMC,CAAE,EAC3BF,EAAI,QAAQE,CAAE,CAClB,OAAS1B,EAAP,CACEwB,EAAI,OAAOxB,CAAK,CACpB,EAER,CAAC,EACD,MAAMwB,EAEV,OAAOX,CACX,CACJ",
6
- "names": ["src_exports", "__export", "WhatsApp", "__toCommonJS", "import_utils", "import_async_mutex", "Baileys", "import_node_events", "import_chat", "import_message", "import_Store", "import_useCache", "EventEmitter", "options", "error", "Store", "func", "_", "store", "documents", "document", "chats", "chat", "Chat", "messages", "message", "Message", "promise", "state", "save", "useCache", "version", "key", "event", "connection", "lastDisconnect", "update", "payload", "_qr", "timeout", "qr"]
4
+ "sourcesContent": ["import { merge, Noop, promify, sleep } from '@arcaelas/utils';\nimport { type Boom } from '@hapi/boom';\nimport { Mutex } from 'async-mutex';\nimport * as Baileys from 'baileys';\nimport EventEmitter from 'node:events';\nimport Chat from './model/chat';\nimport Message from './model/message';\nimport Store, { Engine } from './static/Store';\nimport useCache from './static/useCache';\n\n/**\n * @description Estructura de configuraci\u00F3n para iniciar sesi\u00F3n con WhatsApp.\n */\ninterface IWhatsAppBase {\n phone: string;\n store: Engine;\n}\n\n/**\n * @description Configuraci\u00F3n condicional seg\u00FAn tipo de login.\n */\n// prettier-ignore\ntype IWhatsApp<T extends 'qr' | 'code'> = IWhatsAppBase & {\n loginType: T } & (\n T extends 'qr'\n ? { qr: Noop<[qr: string]> }\n : { code: Noop<[code: string]> }\n );\n\n/**\n * @description\n * Event map for WhatsApp.\n */\ninterface EventMap {\n error: [error: Error];\n open: [];\n close: [];\n qr: [qr: string];\n code: [code: string];\n 'chat:created': [chat: Chat];\n 'chat:updated': [chat: Chat];\n 'chat:deleted': [id: string];\n 'message:created': [message: Message];\n 'message:updated': [message: Message];\n 'message:deleted': [id: string];\n process: [event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store];\n}\n\n/**\n * @description\n * Client for WhatsApp Web.\n * @example\n * const client = new WhatsApp({\n * phone: '1234567890',\n * loginType: 'qr',\n * qr: (code) => console.log(code),\n * });\n */\nclass WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {\n /**\n * @description\n * Store for WhatsApp Web.\n */\n protected store: Store;\n /**\n * @description\n * Options for WhatsApp Web.\n */\n protected options: IWhatsApp<T>;\n /**\n * @description\n * Socket for WhatsApp Web.\n */\n protected socket: Baileys.WASocket;\n /**\n * @description\n * Mutex, used to prevent concurrent access to the socket.\n */\n protected readonly mutex = new Mutex();\n\n constructor(options: IWhatsApp<T>) {\n super({ captureRejections: true });\n this.on('error', (error) => {\n if (this.listenerCount('error') === 1) {\n console.error(error);\n }\n });\n this.options = {\n ...options,\n phone: options.phone.replace(/\\D/g, ''),\n };\n this.store = new Store(this.options.store);\n this.connect();\n }\n\n /**\n * @description\n * Execute a function with the socket and store, means that the function will be executed only when the socket is ready.\n * @param func Function to execute.\n * @returns Result of the function.\n */\n async tick<T extends Noop<[socket: Baileys.WASocket, store: Store], any>>(func: T): Promise<Awaited<ReturnType<T>>> {\n return this.mutex.acquire().then(() => func(this.socket, this.store));\n }\n\n /**\n * @description\n * Process events from the socket.\n * @param func Function to execute.\n * @returns Handler to remove the event listener.\n */\n process(func: Noop<[event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store]>) {\n return this.on('process', (event) => {\n func(event, this.socket, this.store);\n });\n }\n\n /**\n * @description\n * Returns all documents in the store.\n * @returns Promise that resolves to an object containing all documents.\n */\n async documents(): Promise<Record<string, any>> {\n return await this.tick(async (_, store) => {\n const documents: Record<string, any> = {};\n for await (const document of store.document.values()) {\n documents[document.key] = document.value;\n }\n return documents;\n });\n }\n\n /**\n * @description\n * Returns all chats in the store.\n * @returns Promise that resolves to an array of chats.\n */\n async chats(): Promise<Chat[]> {\n return await this.tick(async (_, store) => {\n const chats: Chat[] = [];\n for await (const chat of store.chat.values()) {\n chats.push(new Chat(this, chat));\n }\n return chats;\n });\n }\n\n /**\n * @description\n * Returns all messages in the store.\n * @returns Promise that resolves to an array of messages.\n */\n async messages(): Promise<Message[]> {\n return await this.tick(async (_, store) => {\n const messages: Message[] = [];\n for await (const message of store.message.values()) {\n messages.push(new Message(this, message));\n }\n return messages;\n });\n }\n\n /**\n * @description\n * Connect to WhatsApp Web.\n * @returns Promise that resolves to the socket.\n */\n protected async connect() {\n const promise = promify<Baileys.WASocket>();\n const { state, save } = await useCache(this.store);\n const { version } = await Baileys.fetchLatestBaileysVersion();\n this.socket = Baileys.makeWASocket({\n version,\n syncFullHistory: true,\n browser: Baileys.Browsers.macOS('Descktop'),\n auth: {\n creds: state.creds,\n keys: Baileys.makeCacheableSignalKeyStore(state.keys),\n },\n getMessage: async (key) => {\n const message = await this.store.message.get(key.id!);\n return message ? message.message! : undefined;\n },\n });\n this.socket.ev.process(async (event) => {\n if (event['creds.update']) {\n await save();\n }\n if (event['connection.update']) {\n const { connection, lastDisconnect } = event['connection.update'];\n if (connection === 'open') promise.resolve(this.socket);\n else if (connection === 'close' && (lastDisconnect?.error as Boom)?.output?.statusCode !== Baileys.DisconnectReason.loggedOut) {\n promise.resolve(await this.connect());\n }\n }\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.chats || [], ...event['chats.upsert'] || []]\n .map(async chat => {\n await this.store.chat.set(chat);\n this.emit('chat:created', new Chat(this, chat));\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.messages || [], ...event['messages.upsert']?.messages || []]\n .map(async message=> {\n await this.store.message.set(message);\n this.emit('message:created', new Message(this, message));\n })\n )\n // prettier-ignore\n await Promise.allSettled(\n (event['chats.update'] || [])\n .map(async update => {\n const payload = await this.store.chat.get(update.id!);\n if (payload !== null) {\n const chat = merge(payload, update) as Baileys.Chat;\n await this.store.chat.set(chat);\n this.emit('chat:updated', new Chat(this, chat));\n }\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n (event['messages.update'] || [])\n .map(async message => {\n const payload = await this.store.message.get(message.key.id!);\n if (payload !== null) {\n const chat = merge(payload, message) as Baileys.WAProto.WebMessageInfo;\n await this.store.message.set(chat);\n this.emit('message:updated', new Message(this, chat));\n }\n })\n );\n\n for (const { id } of event['messages.delete']?.['keys'] || []) {\n await this.store.message.unset(id);\n this.emit('message:deleted', id);\n }\n for (const key of event['chats.delete'] || []) {\n await this.store.chat.unset(key);\n this.emit('chat:deleted', key);\n }\n\n this.emit('process', event, this.socket, this.store);\n });\n\n await this.socket.waitForSocketOpen();\n await sleep(3000);\n\n if (this.socket.authState.creds.registered) {\n promise.resolve(this.socket);\n } else if (this.options.loginType === 'code') {\n await this.options['code'](await this.socket.requestPairingCode(this.options.phone));\n } else if (this.options.loginType === 'qr') {\n const _qr = promify<string>();\n const timeout = setTimeout(() => _qr.reject('QR Timeout'), 60000);\n const QR = async ({ qr }) => {\n if (qr) {\n try {\n clearTimeout(timeout);\n await this.options['qr'](qr);\n _qr.resolve(qr);\n } catch (error) {\n _qr.reject(error);\n }\n }\n };\n this.socket.ev.on('connection.update', QR as any);\n await _qr.finally(() => {\n this.socket.ev.off('connection.update', QR as any);\n });\n }\n return promise;\n }\n}\n\nexport default WhatsApp;\nexport * from './static/Store';\nexport { default as Store } from './static/Store';\n\nexport * from './model/chat';\nexport { default as Chat } from './model/chat';\n\nexport * from './model/message';\nexport { default as Message } from './model/message';\n"],
5
+ "mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0EAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,2BAE5CC,EAAsB,uBACtBC,EAAyB,sBACzBC,EAAyB,0BACzBC,EAAiB,2BACjBC,EAAoB,8BACpBC,EAA8B,6BAC9BC,EAAqB,gCA+QrBC,EAAAZ,EAAc,0BAvRd,gBAwRA,IAAAU,EAAiC,6BAEjCE,EAAAZ,EAAc,wBA1Rd,gBA2RA,IAAAQ,EAAgC,2BAEhCI,EAAAZ,EAAc,2BA7Rd,gBA8RA,IAAAS,EAAmC,8BApOnC,MAAMI,UAA0C,EAAAC,OAAuB,CAsBnE,YAAYC,EAAuB,CAC/B,MAAM,CAAE,kBAAmB,EAAK,CAAC,EAHrC,KAAmB,MAAQ,IAAI,QAI3B,KAAK,GAAG,QAAUC,GAAU,CACpB,KAAK,cAAc,OAAO,IAAM,GAChC,QAAQ,MAAMA,CAAK,CAE3B,CAAC,EACD,KAAK,QAAU,CACX,GAAGD,EACH,MAAOA,EAAQ,MAAM,QAAQ,MAAO,EAAE,CAC1C,EACA,KAAK,MAAQ,IAAI,EAAAE,QAAM,KAAK,QAAQ,KAAK,EACzC,KAAK,QAAQ,CACjB,CAQA,MAAM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AAAC,CAAG,IAAM,CACzB,GAAIA,EACA,GAAI,CACA,aAAaF,CAAO,EACpB,MAAM,KAAK,QAAQ,GAAME,CAAE,EAC3BH,EAAI,QAAQG,CAAE,CAClB,OAAS5B,EAAP,CACEyB,EAAI,OAAOzB,CAAK,CACpB,CAER,EACA,KAAK,OAAO,GAAG,GAAG,oBAAqB2B,CAAS,EAChD,MAAMF,EAAI,QAAQ,IAAM,CACpB,KAAK,OAAO,GAAG,IAAI,oBAAqBE,CAAS,CACrD,CAAC,EAEL,OAAOb,CACX,CACJ,CAEA,IAAO5B,EAAQW",
6
+ "names": ["src_exports", "__export", "src_default", "__toCommonJS", "import_utils", "import_async_mutex", "Baileys", "import_node_events", "import_chat", "import_message", "import_Store", "import_useCache", "__reExport", "WhatsApp", "EventEmitter", "options", "error", "Store", "func", "event", "_", "store", "documents", "document", "chats", "chat", "Chat", "messages", "message", "Message", "promise", "state", "save", "useCache", "version", "key", "connection", "lastDisconnect", "update", "payload", "id", "_qr", "timeout", "QR", "qr"]
7
7
  }
@@ -3,11 +3,26 @@ import WhatsApp from 'src';
3
3
  type Serialize<T> = {
4
4
  [K in keyof T as T[K] extends Noop ? never : K]: T[K];
5
5
  };
6
+ /**
7
+ * @module Base
8
+ * @description
9
+ * Base class for WhatsApp entities.
10
+ */
6
11
  export default class Base<T> {
7
12
  protected readonly $: WhatsApp<'code' | 'qr'>;
8
13
  protected readonly _: Serialize<T>;
9
14
  constructor($: WhatsApp<'code' | 'qr'>, _: Serialize<T>);
15
+ /**
16
+ * @description
17
+ * Returns a JSON representation of this entity.
18
+ * @returns A JSON representation of this entity.
19
+ */
10
20
  toJSON(): any;
21
+ /**
22
+ * @description
23
+ * Returns a string representation of this entity.
24
+ * @returns A string representation of this entity.
25
+ */
11
26
  toString(): string;
12
27
  }
13
28
  export {};
@@ -34,11 +34,21 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const Baileys = __importStar(require("baileys"));
37
+ /**
38
+ * @module Base
39
+ * @description
40
+ * Base class for WhatsApp entities.
41
+ */
37
42
  class Base {
38
43
  constructor($, _) {
39
44
  this.$ = $;
40
45
  this._ = _;
41
46
  }
47
+ /**
48
+ * @description
49
+ * Returns a JSON representation of this entity.
50
+ * @returns A JSON representation of this entity.
51
+ */
42
52
  toJSON() {
43
53
  const o = {};
44
54
  for (const k in this) {
@@ -48,6 +58,11 @@ class Base {
48
58
  }
49
59
  return o;
50
60
  }
61
+ /**
62
+ * @description
63
+ * Returns a string representation of this entity.
64
+ * @returns A string representation of this entity.
65
+ */
51
66
  toString() {
52
67
  return JSON.stringify(this.toJSON(), Baileys.BufferJSON.replacer);
53
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC,MAAqB,IAAI;IACrB,YAA+B,CAA0B,EAAqB,CAAe;QAA9D,MAAC,GAAD,CAAC,CAAyB;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAI,CAAC;IAClG,MAAM;QACF,MAAM,CAAC,GAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,SAAS;YAC5C,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACJ;AAbD,uBAaC"}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC;;;;GAIG;AACH,MAAqB,IAAI;IACrB,YAA+B,CAA0B,EAAqB,CAAe;QAA9D,MAAC,GAAD,CAAC,CAAyB;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAG,CAAC;IACjG;;;;OAIG;IACH,MAAM;QACF,MAAM,CAAC,GAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,SAAS;YAC5C,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC;IACb,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;AAvBD,uBAuBC"}
@@ -1,15 +1,66 @@
1
1
  import * as Baileys from 'baileys';
2
2
  import Base from './base';
3
3
  import Message, { MessageOptions } from './message';
4
+ /**
5
+ * @module Chat
6
+ * @description
7
+ * Represents a chat in WhatsApp.
8
+ */
4
9
  export default class Chat extends Base<Baileys.Chat> {
10
+ /**
11
+ * @description
12
+ * Sends a text message to this chat.
13
+ * @param text The text to send.
14
+ * @param options Additional options for the message.
15
+ * @returns Promise that resolves to a boolean indicating success.
16
+ */
5
17
  send(text: string, options?: {
6
18
  once: boolean;
7
19
  }): Promise<boolean>;
20
+ /**
21
+ * @description
22
+ * Sends a media message to this chat.
23
+ * @param media The media to send.
24
+ * @param options Additional options for the message.
25
+ * @returns Promise that resolves to a boolean indicating success.
26
+ */
8
27
  send(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<boolean>;
28
+ /**
29
+ * @description
30
+ * Returns the messages in this chat.
31
+ * @returns Promise that resolves to an array of messages.
32
+ */
9
33
  messages(): Promise<Message[]>;
34
+ /**
35
+ * @description
36
+ * Pins this chat.
37
+ * @returns Promise that resolves to a boolean indicating success.
38
+ */
10
39
  pin(): Promise<boolean>;
40
+ /**
41
+ * @description
42
+ * Marks this chat as seen.
43
+ * @returns Promise that resolves to a boolean indicating success.
44
+ */
11
45
  seen(): Promise<boolean>;
46
+ /**
47
+ * @description
48
+ * Mutes this chat.
49
+ * @param time The time to mute for.
50
+ * @returns Promise that resolves to a boolean indicating success.
51
+ */
12
52
  mute(time?: number): Promise<boolean>;
53
+ /**
54
+ * @description
55
+ * Updates the presence of this chat.
56
+ * @param status The status to update to.
57
+ * @returns Promise that resolves to a boolean indicating success.
58
+ */
13
59
  presence(status: Baileys.WAPresence): Promise<boolean>;
60
+ /**
61
+ * @description
62
+ * Deletes this chat.
63
+ * @returns Promise that resolves to a boolean indicating success.
64
+ */
14
65
  delete(): Promise<boolean>;
15
66
  }
@@ -5,6 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const base_1 = __importDefault(require("./base"));
7
7
  const message_1 = __importDefault(require("./message"));
8
+ /**
9
+ * @module Chat
10
+ * @description
11
+ * Represents a chat in WhatsApp.
12
+ */
8
13
  class Chat extends base_1.default {
9
14
  async send(content, options) {
10
15
  return this.$.tick(async (socket) => {
@@ -33,26 +38,27 @@ class Chat extends base_1.default {
33
38
  return false;
34
39
  });
35
40
  }
41
+ /**
42
+ * @description
43
+ * Returns the messages in this chat.
44
+ * @returns Promise that resolves to an array of messages.
45
+ */
36
46
  async messages() {
37
47
  return await this.$.tick(async (_, store) => {
38
48
  const messages = [];
39
- if (store.engine.scan) {
40
- for (const key of await store.engine.scan(`chat/${this._.id}/message/*`)) {
41
- const id = key.slice(`chat/${this._.id}/message/`.length);
42
- messages.push(new message_1.default(this.$, (await store.message.get(id))));
43
- }
44
- }
45
- else {
46
- for await (const key of store.engine.keys()) {
47
- if (key.startsWith(`chat/${this._.id}/message/`)) {
48
- const id = key.slice(`chat/${this._.id}/message/`.length);
49
- messages.push(new message_1.default(this.$, (await store.message.get(id))));
50
- }
51
- }
49
+ const keys = await store.engine.match(`chat/${this._.id}/message/*/index`);
50
+ for (const key of keys) {
51
+ const [, , id] = key.match(/chat\/[^/]+\/message\/([^/]+)/);
52
+ messages.push(new message_1.default(this.$, (await store.message.get(id))));
52
53
  }
53
54
  return messages;
54
55
  });
55
56
  }
57
+ /**
58
+ * @description
59
+ * Pins this chat.
60
+ * @returns Promise that resolves to a boolean indicating success.
61
+ */
56
62
  async pin() {
57
63
  return await this.$.tick(async (socket) => {
58
64
  // prettier-ignore
@@ -63,6 +69,11 @@ class Chat extends base_1.default {
63
69
  return true;
64
70
  });
65
71
  }
72
+ /**
73
+ * @description
74
+ * Marks this chat as seen.
75
+ * @returns Promise that resolves to a boolean indicating success.
76
+ */
66
77
  async seen() {
67
78
  return await this.$.tick(async (socket) => {
68
79
  // prettier-ignore
@@ -73,6 +84,12 @@ class Chat extends base_1.default {
73
84
  return true;
74
85
  });
75
86
  }
87
+ /**
88
+ * @description
89
+ * Mutes this chat.
90
+ * @param time The time to mute for.
91
+ * @returns Promise that resolves to a boolean indicating success.
92
+ */
76
93
  async mute(time = 0) {
77
94
  return await this.$.tick(async (socket) => {
78
95
  // prettier-ignore
@@ -83,12 +100,23 @@ class Chat extends base_1.default {
83
100
  return true;
84
101
  });
85
102
  }
103
+ /**
104
+ * @description
105
+ * Updates the presence of this chat.
106
+ * @param status The status to update to.
107
+ * @returns Promise that resolves to a boolean indicating success.
108
+ */
86
109
  async presence(status) {
87
110
  return await this.$.tick(async (socket) => {
88
111
  await socket.sendPresenceUpdate(status, this._.id);
89
112
  return true;
90
113
  });
91
114
  }
115
+ /**
116
+ * @description
117
+ * Deletes this chat.
118
+ * @returns Promise that resolves to a boolean indicating success.
119
+ */
92
120
  async delete() {
93
121
  return this.$.tick(async (socket) => {
94
122
  await socket.chatModify({
@@ -1 +1 @@
1
- {"version":3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AC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,MAAM,MAAM,CAAC,UAAU,CACnB;gBACI,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,QAAS,CAAC,IAAI,CAAC,CAAC,CAAC,QAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAQ,CAAC;aACzE,EACD,IAAI,CAAC,CAAC,CAAC,EAAE,CACZ,CAAC;YACF,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA3ID,uBA2IC"}
@@ -1,19 +1,82 @@
1
1
  import * as Baileys from 'baileys';
2
2
  import Base from './base';
3
+ import Chat from './chat';
3
4
  export interface MessageOptions {
4
- type?: "audio" | "video" | "image" | "location";
5
+ /**
6
+ * @description
7
+ * The type of the message.
8
+ * @default 'text'
9
+ */
10
+ type?: 'audio' | 'video' | 'image' | 'location';
11
+ /**
12
+ * @description
13
+ * The caption for the image.
14
+ */
5
15
  caption?: string;
16
+ /**
17
+ * @description
18
+ * Whether the audio is a voice note.
19
+ */
6
20
  ptt?: boolean;
21
+ /**
22
+ * @description
23
+ * Whether the video is a video note.
24
+ */
7
25
  ptv?: boolean;
26
+ /**
27
+ * @description
28
+ * Whether the message is a view once message.
29
+ */
8
30
  once?: boolean;
9
31
  }
32
+ /**
33
+ * @module Message
34
+ * @description
35
+ * Represents a message in WhatsApp.
36
+ */
10
37
  export default class Message extends Base<Baileys.WAProto.IWebMessageInfo> {
38
+ /**
39
+ * @description
40
+ * Returns the chat associated with this message.
41
+ * @returns Promise that resolves to the chat.
42
+ */
43
+ chat(): Promise<Chat>;
44
+ /**
45
+ * @description
46
+ * Replies to this message.
47
+ * @param content The content to reply with.
48
+ * @param options Additional options for the reply.
49
+ * @returns Promise that resolves to a boolean indicating success.
50
+ */
11
51
  reply(text: string, options?: {
12
52
  once: boolean;
13
53
  }): Promise<boolean>;
14
54
  reply(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<boolean>;
55
+ /**
56
+ * @description
57
+ * Marks this message as seen.
58
+ * @returns Promise that resolves to a boolean indicating success.
59
+ */
15
60
  seen(): Promise<boolean>;
61
+ /**
62
+ * @description
63
+ * Deletes this message.
64
+ * @param forall Whether to delete for all participants.
65
+ * @returns Promise that resolves to a boolean indicating success.
66
+ */
16
67
  delete(forall?: boolean): Promise<boolean>;
68
+ /**
69
+ * @description
70
+ * Likes this message.
71
+ * @param emoji The emoji to use for the like.
72
+ * @returns Promise that resolves to a boolean indicating success.
73
+ */
17
74
  like(emoji: string): Promise<boolean>;
75
+ /**
76
+ * @description
77
+ * Forwards this message to another chat.
78
+ * @param chat_id The ID of the chat to forward the message to.
79
+ * @returns Promise that resolves to a boolean indicating success.
80
+ */
18
81
  forward(chat_id: string): Promise<boolean>;
19
82
  }
@@ -4,7 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const base_1 = __importDefault(require("./base"));
7
+ const chat_1 = __importDefault(require("./chat"));
8
+ /**
9
+ * @module Message
10
+ * @description
11
+ * Represents a message in WhatsApp.
12
+ */
7
13
  class Message extends base_1.default {
14
+ /**
15
+ * @description
16
+ * Returns the chat associated with this message.
17
+ * @returns Promise that resolves to the chat.
18
+ */
19
+ async chat() {
20
+ // prettier-ignore
21
+ return this.$.tick(async (_, store) => {
22
+ return new chat_1.default(this.$, (await store.chat.get(this._.key.remoteJid)));
23
+ });
24
+ }
8
25
  async reply(content, options) {
9
26
  return this.$.tick(async (socket) => {
10
27
  // prettier-ignore
@@ -30,6 +47,11 @@ class Message extends base_1.default {
30
47
  return false;
31
48
  });
32
49
  }
50
+ /**
51
+ * @description
52
+ * Marks this message as seen.
53
+ * @returns Promise that resolves to a boolean indicating success.
54
+ */
33
55
  async seen() {
34
56
  return this.$.tick(async (socket) => {
35
57
  // prettier-ignore
@@ -40,6 +62,12 @@ class Message extends base_1.default {
40
62
  return true;
41
63
  });
42
64
  }
65
+ /**
66
+ * @description
67
+ * Deletes this message.
68
+ * @param forall Whether to delete for all participants.
69
+ * @returns Promise that resolves to a boolean indicating success.
70
+ */
43
71
  async delete(forall = false) {
44
72
  return this.$.tick(async (socket) => {
45
73
  if (forall) {
@@ -60,14 +88,26 @@ class Message extends base_1.default {
60
88
  return true;
61
89
  });
62
90
  }
91
+ /**
92
+ * @description
93
+ * Likes this message.
94
+ * @param emoji The emoji to use for the like.
95
+ * @returns Promise that resolves to a boolean indicating success.
96
+ */
63
97
  async like(emoji) {
64
98
  return this.$.tick(async (socket) => {
65
99
  await socket.sendMessage(this._.key.remoteJid, {
66
- react: { text: emoji, key: this._.key, },
100
+ react: { text: emoji, key: this._.key },
67
101
  });
68
102
  return true;
69
103
  });
70
104
  }
105
+ /**
106
+ * @description
107
+ * Forwards this message to another chat.
108
+ * @param chat_id The ID of the chat to forward the message to.
109
+ * @returns Promise that resolves to a boolean indicating success.
110
+ */
71
111
  async forward(chat_id) {
72
112
  return this.$.tick(async (socket) => {
73
113
  await socket.sendMessage(chat_id, {
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/model/message.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAW1B,MAAqB,OAAQ,SAAQ,cAAqC;IAItE,KAAK,CAAC,KAAK,CAAC,OAAY,EAAE,OAAa;QACnC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,kBAAkB;YAClB,MAAM,QAAQ,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAS,CAAC;YACrE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC9B,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,SAAU,EAAE;oBAC5C,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI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,MAAM,MAAM,CAAC,WAAW,CAAC,OAAQ,EAAE;gBAC/B,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE;aAC/B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAjID,0BAiIC"}
@@ -52,71 +52,33 @@ export interface Engine {
52
52
  /**
53
53
  * Remove a key.
54
54
  *
55
- * @param key Key to delete.
55
+ * @param key Key to unset.
56
56
  * @returns `true` if removed; `false` if it did not exist.
57
57
  *
58
58
  * @example
59
- * await store.delete('cache:config');
59
+ * await store.unset('cache:config');
60
60
  */
61
- delete(key: string): Promise<boolean>;
61
+ unset(key: string): Promise<boolean>;
62
62
  /**
63
- * Iterate over all keys.
64
- *
65
- * @returns `AsyncGenerator` yielding each key.
66
- *
67
- * @example
68
- * for await (const key of store.keys()) console.log(key);
69
- */
70
- keys(): AsyncGenerator<string>;
71
- /**
72
- * Iterate over all values (`string | null`).
73
- *
74
- * @returns `AsyncGenerator` yielding each value.
75
- *
76
- * @example
77
- * for await (const value of store.values()) console.log(value);
78
- */
79
- values(): AsyncGenerator<string | null>;
80
- /**
81
- * Iterate over `[key, value]` pairs.
82
- *
83
- * @returns `AsyncGenerator<[string, string | null]>`.
84
- *
85
- * @example
86
- * for await (const [k, v] of store.entries()) console.log(k, v);
87
- */
88
- entries(): AsyncGenerator<[string, string | null]>;
89
- /**
90
- * Remove **all** keys.
91
- *
92
- * @returns `true` when the store is empty; `false` if an error occurred.
93
- *
94
- * @example
95
- * await store.clear();
96
- */
97
- clear(): Promise<boolean>;
98
- /**
99
- * (Optional) Filter keys using a **glob pattern** (`*` as wildcard).
100
- *
63
+ * @description
64
+ * Filter keys using a **glob pattern** (`*` as wildcard).
101
65
  * - `user:*` → everything starting with `user:`
102
66
  * - `log:*:error` → simultaneous prefix and suffix
103
- *
104
67
  * @param pattern Glob pattern.
105
68
  * @returns Array of matching keys.
106
- *
107
69
  * @example
108
- * const keys = await store.scan?.('user:*:active');
70
+ * const keys = await store.match('user:*:active');
109
71
  */
110
- scan?(pattern: string): Promise<string[]>;
72
+ match(pattern: string): Promise<string[]>;
111
73
  }
112
74
  export default class Store {
113
75
  readonly engine: Engine;
114
76
  constructor(engine: Engine);
115
77
  document: {
116
- set: (filename: string, content: any) => Promise<boolean>;
117
- get: <T>(filename: string) => Promise<T | null>;
118
- has: (filename: string) => Promise<boolean>;
119
- delete: (filename: string) => Promise<boolean>;
78
+ set: (pathname: string, content: any) => Promise<boolean>;
79
+ get: <T>(pathname: string) => Promise<T | null>;
80
+ has: (pathname: string) => Promise<boolean>;
81
+ unset: (pathname: string) => Promise<boolean>;
120
82
  keys: () => {
121
83
  [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
122
84
  };
@@ -129,9 +91,9 @@ export default class Store {
129
91
  };
130
92
  chat: {
131
93
  set: (chat: Baileys.Chat) => Promise<boolean>;
132
- get: (id: string) => Promise<Baileys.Chat | null>;
133
- has: (id: string) => Promise<boolean>;
134
- delete: (id: string) => Promise<boolean>;
94
+ get: (id: Baileys.Chat["id"]) => Promise<Baileys.Chat | null>;
95
+ has: (id: Baileys.Chat["id"]) => Promise<boolean>;
96
+ unset: (id: Baileys.Chat["id"]) => Promise<boolean>;
135
97
  keys: () => {
136
98
  [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
137
99
  };
@@ -146,7 +108,7 @@ export default class Store {
146
108
  set: (message: Baileys.WAProto.IWebMessageInfo) => Promise<boolean>;
147
109
  get: (id: string) => Promise<Baileys.WAProto.IWebMessageInfo | null>;
148
110
  has: (id: string) => Promise<boolean>;
149
- delete: (id: string) => Promise<boolean>;
111
+ unset: (id: string) => Promise<boolean>;
150
112
  keys: () => {
151
113
  [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
152
114
  };
@@ -38,35 +38,28 @@ class Store {
38
38
  constructor(engine) {
39
39
  this.engine = engine;
40
40
  this.document = {
41
- set: async (filename, content) => {
41
+ set: async (pathname, content) => {
42
42
  // prettier-ignore
43
- return await this.engine.set(`document/${filename}`, JSON.stringify(content, Baileys.BufferJSON.replacer));
43
+ return await this.engine.set(`document/${pathname}`, JSON.stringify(content, Baileys.BufferJSON.replacer));
44
44
  },
45
- get: async (filename) => {
45
+ get: async (pathname) => {
46
46
  // prettier-ignore
47
- return JSON.parse(await this.engine.get(`document/${filename}`) ?? 'null', Baileys.BufferJSON.reviver);
47
+ return JSON.parse(await this.engine.get(`document/${pathname}`) ?? 'null', Baileys.BufferJSON.reviver);
48
48
  },
49
- has: async (filename) => {
50
- return this.engine.has(`document/${filename}`);
49
+ has: async (pathname) => {
50
+ return await this.engine.has(`document/${pathname}`);
51
51
  },
52
- delete: async (filename) => {
53
- return this.engine.delete(`document/${filename}`);
52
+ unset: async (pathname) => {
53
+ return await this.engine.unset(`document/${pathname}`);
54
54
  },
55
55
  keys: () => {
56
56
  const _this = this;
57
57
  return {
58
58
  async *[Symbol.asyncIterator]() {
59
- if (_this.engine.scan) {
60
- for (const key of await _this.engine.scan('document/*')) {
61
- yield key.slice('document/'.length);
62
- }
59
+ for (const key of await _this.engine.match('document/*')) {
60
+ const [, _key] = key.match(/document\/(.*)/) ?? [];
61
+ yield _key;
63
62
  }
64
- else
65
- for await (const key of _this.engine.keys()) {
66
- if (key.startsWith('document/')) {
67
- yield key.slice('document/'.length);
68
- }
69
- }
70
63
  },
71
64
  };
72
65
  },
@@ -101,44 +94,28 @@ class Store {
101
94
  return JSON.parse(await this.engine.get(`chat/${id}/index`) ?? 'null', Baileys.BufferJSON.reviver);
102
95
  },
103
96
  has: async (id) => {
104
- return this.engine.has(`chat/${id}/index`);
97
+ return await this.engine.has(`chat/${id}/index`);
105
98
  },
106
- delete: async (id) => {
107
- if (this.engine.scan)
108
- for (const key of await this.engine.scan(`chat/${id}/*`)) {
109
- await this.engine.delete(key);
110
- }
111
- else
112
- for await (const key of this.engine.keys()) {
113
- if (key.startsWith(`chat/${id}/`))
114
- await this.engine.delete(key);
115
- }
99
+ unset: async (id) => {
100
+ for (const key of await this.engine.match(`chat/${id}/*`)) {
101
+ await this.engine.unset(key);
102
+ }
116
103
  return true;
117
104
  },
118
105
  keys: () => {
119
106
  const _this = this;
120
107
  return {
121
108
  async *[Symbol.asyncIterator]() {
122
- if (_this.engine.scan) {
123
- for (const key of await _this.engine.scan('chat/*/index')) {
124
- const [, id] = key.split('/');
125
- yield id;
126
- }
109
+ for await (const key of await _this.engine.match('chat/*/index')) {
110
+ const [, id] = key.match(/chat\/([^/]+)\/index/) ?? [];
111
+ yield id;
127
112
  }
128
- else
129
- for await (const key of _this.engine.keys()) {
130
- if (key.startsWith('chat/')) {
131
- const [, id] = key.split('/');
132
- yield id;
133
- }
134
- }
135
113
  },
136
114
  };
137
115
  },
138
116
  values: () => {
139
117
  const _this = this;
140
118
  return {
141
- // prettier-ignore
142
119
  async *[Symbol.asyncIterator]() {
143
120
  for await (const id of _this.chat.keys()) {
144
121
  yield (await _this.chat.get(id));
@@ -149,7 +126,6 @@ class Store {
149
126
  entries: () => {
150
127
  const _this = this;
151
128
  return {
152
- // prettier-ignore
153
129
  async *[Symbol.asyncIterator]() {
154
130
  for await (const id of _this.chat.keys()) {
155
131
  yield [id, (await _this.chat.get(id))];
@@ -164,73 +140,33 @@ class Store {
164
140
  return await this.engine.set(`chat/${message.key.remoteJid}/message/${message.key.id}/index`, JSON.stringify(message, Baileys.BufferJSON.replacer));
165
141
  },
166
142
  get: async (id) => {
143
+ const [key] = await this.engine.match(`chat/*/${id}/index`);
167
144
  // prettier-ignore
168
- if (this.engine.scan) {
169
- const [key] = await this.engine.scan(`chat/*/${id}/index`);
170
- return JSON.parse((await this.engine.get(key)), Baileys.BufferJSON.reviver);
171
- }
172
- else {
173
- for await (const key of this.engine.keys()) {
174
- const [chat, mid] = key.match(/chat\/([^/]+)\/message\/([^/]+)\/index/) ?? [];
175
- if (chat && mid === id) {
176
- return JSON.parse((await this.engine.get(`chat/${chat}/message/${id}/index`)), Baileys.BufferJSON.reviver);
177
- }
178
- }
179
- }
180
- return null;
145
+ return JSON.parse((await this.engine.get(key)), Baileys.BufferJSON.reviver);
181
146
  },
182
147
  has: async (id) => {
183
- if (this.engine.scan) {
184
- const [key] = await this.engine.scan(`chat/*/message/${id}/index`);
185
- return !!key;
186
- }
187
- for await (const key of this.engine.keys()) {
188
- const [chat, mid] = key.match(/chat\/([^/]+)\/message\/([^/]+)\/index/) ?? [];
189
- if (chat && mid === id)
190
- return true;
191
- }
192
- return false;
148
+ const [key] = await this.engine.match(`chat/*/${id}/index`);
149
+ return !!key;
193
150
  },
194
- delete: async (id) => {
195
- if (this.engine.scan) {
196
- for (const key of await this.engine.scan(`chat/*/message/${id}/*`)) {
197
- await this.engine.delete(key);
198
- }
199
- return true;
200
- }
201
- else {
202
- for await (const key of this.engine.keys()) {
203
- const [chat, mid] = key.match(/chat\/([^/]+)\/message\/([^/]+)\/index/) ?? [];
204
- if (chat && mid === id)
205
- await this.engine.delete(key);
206
- }
207
- return true;
208
- }
151
+ unset: async (id) => {
152
+ const [key] = await this.engine.match(`chat/*/${id}/index`);
153
+ return await this.engine.unset(key);
209
154
  },
210
155
  keys: () => {
211
156
  const _this = this;
212
157
  return {
213
158
  async *[Symbol.asyncIterator]() {
214
- if (_this.engine.scan) {
215
- for (const key of await _this.engine.scan('chat/*/message/*')) {
216
- const [, , , m] = key.split('/');
217
- yield m;
218
- }
159
+ const keys = await _this.engine.match('chat/*/message/*/index');
160
+ for (const key of keys) {
161
+ const [, , id] = key.match(/chat\/([^/]+)\/message\/([^/]+)\/index/) ?? [];
162
+ yield id;
219
163
  }
220
- else
221
- for await (const key of _this.engine.keys()) {
222
- if (key.startsWith('chat/')) {
223
- const [, , , m] = key.split('/');
224
- yield m;
225
- }
226
- }
227
164
  },
228
165
  };
229
166
  },
230
167
  values: () => {
231
168
  const _this = this;
232
169
  return {
233
- // prettier-ignore
234
170
  async *[Symbol.asyncIterator]() {
235
171
  for await (const key of _this.message.keys()) {
236
172
  yield (await _this.message.get(key));
@@ -241,7 +177,6 @@ class Store {
241
177
  entries: () => {
242
178
  const _this = this;
243
179
  return {
244
- // prettier-ignore
245
180
  async *[Symbol.asyncIterator]() {
246
181
  for await (const key of _this.message.keys()) {
247
182
  yield [key, (await _this.message.get(key))];
@@ -1 +1 @@
1
- {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../src/static/Store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAyHnC,MAAqB,KAAK;IACtB,YAAqB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAEnC,aAAQ,GAAG;YACP,GAAG,EAAE,KAAK,EAAE,QAAgB,EAAE,OAAY,EAAoB,EAAE;gBAC5D,kBAAkB;gBAClB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACxB,YAAY,QAAQ,EAAE,EACtB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CACvD,CAAC;YACN,CAAC;YACD,GAAG,EAAE,KAAK,EAAK,QAAgB,EAAqB,EAAE;gBAClD,kBAAkB;gBAClB,OAAO,IAAI,CAAC,KAAK,CACb,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,QAAQ,EAAE,CAAC,IAAI,MAAM,EACvD,OAAO,CAAC,UAAU,CAAC,OAAO,CAC7B,CAAC;YACN,CAAC;YACD,GAAG,EAAE,KAAK,EAAE,QAAgB,EAAoB,EAAE;gBAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,QAAgB,EAAoB,EAAE;gBACjD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;YACtD,CAAC;YACD,IAAI,EAAE,GAAG,EAA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AAG,CAAC,CAAE,CAAU,CAAC;wBAC1D,CAAC;oBACL,CAAC;iBACJ,CAAC;YACN,CAAC;SACJ,CAAC;IAzKoC,CAAC;CA0K1C;AA3KD,wBA2KC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = useCache;
4
4
  const baileys_1 = require("baileys");
5
5
  async function useCache(store) {
6
+ // prettier-ignore
6
7
  const creds = await store
7
8
  .document.get('creds.json')
8
9
  .then((e) => e ?? (0, baileys_1.initAuthCreds)());
@@ -30,7 +31,7 @@ async function useCache(store) {
30
31
  const value = data[category][id];
31
32
  tasks.push(value
32
33
  ? store.document.set(`${category}/${id}.json`, value)
33
- : store.document.delete(`${category}/${id}.json`));
34
+ : store.document.unset(`${category}/${id}.json`));
34
35
  }
35
36
  }
36
37
  await Promise.all(tasks);
@@ -1 +1 @@
1
- {"version":3,"file":"useCache.js","sourceRoot":"","sources":["../../src/static/useCache.ts"],"names":[],"mappings":";;AAIA,2BAqCC;AAxCD,qCAA+C;AAGhC,KAAK,UAAU,QAAQ,CAAC,KAAY;IAC/C,MAAM,KAAK,GAAG,MAAM,KAAK;SACpB,QAAQ,CAAC,GAAG,CAA8B,YAAY,CAAC;SACvD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAA,uBAAa,GAAE,CAAC,CAAC;IACvC,OAAO;QACH,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC;QACnD,KAAK,EAAE;YACH,KAAK;YACL,IAAI,EAAE;gBACF,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,GAAa;oBACjC,MAAM,IAAI,GAAQ,EAAE,CAAC;oBACrB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;wBACnB,IAAI,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAA4C,GAAG,IAAI,IAAI,EA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,CAAC;wBACN,CAAC;oBACL,CAAC;oBACD,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;aACJ;SACJ;KACJ,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "license": "ISC",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "name": "@arcaelas/whatsapp",
5
5
  "homepage": "https://github.com/arcaelas/whatsapp",
6
6
  "description": "A small box of tools, which are implemented in different factions of the library.",