@areumtecnologia/wasockets 2.2.3 → 2.3.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 (31) hide show
  1. package/README.md +74 -16
  2. package/lib/Client/Builders/Buttons.js +127 -0
  3. package/lib/Client/Builders/EventBuilder.js +122 -0
  4. package/lib/Client/Builders/InteractiveMessage.js +150 -0
  5. package/lib/Client/Builders/Lists.js +78 -0
  6. package/lib/Client/Builders/PollBuilder.js +84 -0
  7. package/lib/Client/Builders/index.js +21 -0
  8. package/lib/Client/Constants.js +54 -0
  9. package/lib/Client/Context/CallContext.js +96 -0
  10. package/lib/Client/Context/MediaObject.js +155 -0
  11. package/lib/Client/Context/MessageContext.js +146 -0
  12. package/lib/Client/Modules/BusinessManager.js +155 -0
  13. package/lib/Client/Modules/ChannelManager.js +144 -0
  14. package/lib/Client/Modules/ChatManager.js +113 -0
  15. package/lib/Client/Modules/CommunityManager.js +136 -0
  16. package/lib/Client/Modules/GroupManager.js +194 -0
  17. package/lib/Client/Modules/LabelManager.js +123 -0
  18. package/lib/Client/Modules/MessageManager.js +198 -0
  19. package/lib/Client/Modules/PresenceManager.js +68 -0
  20. package/lib/Client/Modules/PrivacyManager.js +98 -0
  21. package/lib/Client/Modules/ProfileManager.js +92 -0
  22. package/lib/Client/Modules/UserManager.js +92 -0
  23. package/lib/Client/Modules/VoipManager.js +117 -0
  24. package/lib/Client/Modules/index.js +29 -0
  25. package/lib/Client/Normalizers/EventNormalizer.js +82 -0
  26. package/lib/Client/Normalizers/JidNormalizer.js +93 -0
  27. package/lib/Client/Normalizers/MessageNormalizer.js +134 -0
  28. package/lib/Client/WaClient.js +438 -0
  29. package/lib/Client/index.d.ts +464 -0
  30. package/lib/Client/index.js +76 -0
  31. package/package.json +29 -23
@@ -0,0 +1,198 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class MessageManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ /**
16
+ * Envia mensagem de texto com suporte a menções
17
+ * @param {string} jid
18
+ * @param {string} text
19
+ * @param {Object} [options={}]
20
+ */
21
+ async sendText(jid, text, options = {}) {
22
+ const payload = {
23
+ text: text || '',
24
+ ...(options.mentions ? { mentions: options.mentions.map(JidNormalizer.toJid) } : {})
25
+ }
26
+ return this.client.sendMessage(jid, payload, options)
27
+ }
28
+
29
+ /**
30
+ * Envia arquivo de mídia (imagem, vídeo, áudio, documento ou figurinha)
31
+ * @param {string} jid
32
+ * @param {'image'|'video'|'audio'|'document'|'sticker'} type
33
+ * @param {string|Buffer|Object} content - Caminho, URL ou Buffer
34
+ * @param {Object} [options={}]
35
+ */
36
+ async sendMedia(jid, type, content, options = {}) {
37
+ const mediaPayload = typeof content === 'string' ? { url: content } : content
38
+ const payload = {
39
+ [type]: mediaPayload,
40
+ ...(options.caption ? { caption: options.caption } : {}),
41
+ ...(options.fileName ? { fileName: options.fileName } : {}),
42
+ ...(options.mimetype ? { mimetype: options.mimetype } : {}),
43
+ ...(options.viewOnce ? { viewOnce: true } : {})
44
+ }
45
+ return this.client.sendMessage(jid, payload, options)
46
+ }
47
+
48
+ /**
49
+ * Envia um álbum de fotos ou vídeos agrupados nativamente
50
+ * @param {string} jid
51
+ * @param {Array<Object>} items
52
+ * @param {Object} [options={}]
53
+ */
54
+ async sendAlbum(jid, items = [], options = {}) {
55
+ const targetJid = JidNormalizer.toJid(jid)
56
+ if (this.client.sock?.sendAlbumMessage) {
57
+ return this.client.sock.sendAlbumMessage(targetJid, items, options)
58
+ }
59
+ return this.client.sendMessage(targetJid, { album: items }, options)
60
+ }
61
+
62
+ /**
63
+ * Envia áudio simulando gravação de voz (PTT / Voice Note)
64
+ * @param {string} jid
65
+ * @param {string|Buffer|Object} audioSource
66
+ * @param {Object} [options={}]
67
+ */
68
+ async sendVoice(jid, audioSource, options = {}) {
69
+ const payload = {
70
+ audio: typeof audioSource === 'string' ? { url: audioSource } : audioSource,
71
+ mimetype: 'audio/mp4',
72
+ ptt: true,
73
+ ...(options.waveform ? { waveform: options.waveform } : {})
74
+ }
75
+ return this.client.sendMessage(jid, payload, options)
76
+ }
77
+
78
+ /**
79
+ * Envia um contato com cartão vCard
80
+ * @param {string} jid
81
+ * @param {string} name
82
+ * @param {string} phoneNumber
83
+ * @param {Object} [options={}]
84
+ */
85
+ async sendContact(jid, name, phoneNumber, options = {}) {
86
+ const cleanPhone = JidNormalizer.toPhoneNumber(phoneNumber)
87
+ const vcard = 'BEGIN:VCARD\n'
88
+ + 'VERSION:3.0\n'
89
+ + `FN:${name}\n`
90
+ + `ORG:${options.org || name};\n`
91
+ + `TEL;type=CELL;type=VOICE;waid=${cleanPhone}:+${cleanPhone}\n`
92
+ + 'END:VCARD'
93
+
94
+ const payload = {
95
+ contacts: {
96
+ displayName: name,
97
+ contacts: [{ vcard }]
98
+ }
99
+ }
100
+ return this.client.sendMessage(jid, payload, options)
101
+ }
102
+
103
+ /**
104
+ * Envia localização fixa ou ao vivo
105
+ * @param {string} jid
106
+ * @param {{ latitude: number, longitude: number, name?: string, address?: string, live?: boolean }} coords
107
+ * @param {Object} [options={}]
108
+ */
109
+ async sendLocation(jid, coords, options = {}) {
110
+ const payload = {
111
+ location: {
112
+ degreesLatitude: coords.latitude,
113
+ degreesLongitude: coords.longitude,
114
+ ...(coords.name ? { name: coords.name } : {}),
115
+ ...(coords.address ? { address: coords.address } : {})
116
+ },
117
+ ...(coords.live ? { live: true } : {})
118
+ }
119
+ return this.client.sendMessage(jid, payload, options)
120
+ }
121
+
122
+ /**
123
+ * Encaminha uma mensagem existente para outro destinatário
124
+ * @param {string} targetJid
125
+ * @param {Object} message - Objeto raw da mensagem
126
+ * @param {Object} [options={}]
127
+ */
128
+ async forward(targetJid, message, options = {}) {
129
+ return this.client.sendMessage(targetJid, { forward: message }, options)
130
+ }
131
+
132
+ /**
133
+ * Apaga uma mensagem para todos no chat
134
+ * @param {string} jid
135
+ * @param {Object} messageKey - { remoteJid, id, fromMe }
136
+ */
137
+ async delete(jid, messageKey) {
138
+ return this.client.sendMessage(jid, { delete: messageKey })
139
+ }
140
+
141
+ /**
142
+ * Edita uma mensagem de texto já enviada pelo próprio bot
143
+ * @param {string} jid
144
+ * @param {Object} messageKey
145
+ * @param {string} newText
146
+ */
147
+ async edit(jid, messageKey, newText) {
148
+ return this.client.sendMessage(jid, {
149
+ edit: messageKey,
150
+ text: newText
151
+ })
152
+ }
153
+
154
+ /**
155
+ * Fixa uma mensagem no topo da conversa
156
+ * @param {string} jid
157
+ * @param {Object} messageKey
158
+ * @param {number} [durationSeconds=86400]
159
+ */
160
+ async pin(jid, messageKey, durationSeconds = 86400) {
161
+ if (!this.client.sock?.pinInChatMessage) {
162
+ throw new Error('Método pinInChatMessage indisponível no socket.')
163
+ }
164
+ const targetJid = JidNormalizer.toJid(jid)
165
+ return this.client.sock.pinInChatMessage(targetJid, messageKey, 1, durationSeconds)
166
+ }
167
+
168
+ /**
169
+ * Desafixa mensagem do topo da conversa
170
+ * @param {string} jid
171
+ * @param {Object} messageKey
172
+ */
173
+ async unpin(jid, messageKey) {
174
+ if (!this.client.sock?.pinInChatMessage) {
175
+ throw new Error('Método pinInChatMessage indisponível no socket.')
176
+ }
177
+ const targetJid = JidNormalizer.toJid(jid)
178
+ return this.client.sock.pinInChatMessage(targetJid, messageKey, 2)
179
+ }
180
+
181
+ /**
182
+ * Reage com emoji a uma mensagem
183
+ * @param {string} jid
184
+ * @param {Object} messageKey
185
+ * @param {string} emoji
186
+ */
187
+ async react(jid, messageKey, emoji) {
188
+ return this.client.sendMessage(jid, {
189
+ react: {
190
+ text: emoji || '',
191
+ key: messageKey
192
+ }
193
+ })
194
+ }
195
+ }
196
+
197
+ exports.MessageManager = MessageManager
198
+ exports.default = MessageManager
@@ -0,0 +1,68 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class PresenceManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Inicia estado 'digitando' com retorno de objeto cancelador
24
+ * @param {string} jid
25
+ * @returns {{ stop: () => Promise<void> }}
26
+ */
27
+ startTyping(jid) {
28
+ return this.client.startTyping(jid)
29
+ }
30
+
31
+ /**
32
+ * Inicia simulação de gravação de áudio com cancelador
33
+ * @param {string} jid
34
+ * @returns {{ stop: () => Promise<void> }}
35
+ */
36
+ startRecording(jid) {
37
+ return this.client.startRecording(jid)
38
+ }
39
+
40
+ /**
41
+ * Define a presença da conta como online/disponível
42
+ */
43
+ async setOnline() {
44
+ const sock = this._getSock()
45
+ return sock.sendPresenceUpdate('available')
46
+ }
47
+
48
+ /**
49
+ * Define a presença da conta como offline/indisponível
50
+ */
51
+ async setOffline() {
52
+ const sock = this._getSock()
53
+ return sock.sendPresenceUpdate('unavailable')
54
+ }
55
+
56
+ /**
57
+ * Assina atualizações de presença em tempo real de um contato
58
+ * @param {string} jid
59
+ */
60
+ async subscribe(jid) {
61
+ const sock = this._getSock()
62
+ const targetJid = JidNormalizer.toJid(jid)
63
+ return sock.presenceSubscribe(targetJid)
64
+ }
65
+ }
66
+
67
+ exports.PresenceManager = PresenceManager
68
+ exports.default = PresenceManager
@@ -0,0 +1,98 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class PrivacyManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Bloqueia um contato
24
+ * @param {string} jid
25
+ */
26
+ async block(jid) {
27
+ const sock = this._getSock()
28
+ const targetJid = JidNormalizer.toJid(jid)
29
+ return sock.updateBlockStatus(targetJid, 'block')
30
+ }
31
+
32
+ /**
33
+ * Desbloqueia um contato
34
+ * @param {string} jid
35
+ */
36
+ async unblock(jid) {
37
+ const sock = this._getSock()
38
+ const targetJid = JidNormalizer.toJid(jid)
39
+ return sock.updateBlockStatus(targetJid, 'unblock')
40
+ }
41
+
42
+ /**
43
+ * Retorna a lista de todos os JIDs bloqueados
44
+ * @returns {Promise<string[]>}
45
+ */
46
+ async getBlocklist() {
47
+ const sock = this._getSock()
48
+ return sock.fetchBlocklist()
49
+ }
50
+
51
+ /**
52
+ * Configura privacidade de Visto por Último
53
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
54
+ */
55
+ async setLastSeen(privacy) {
56
+ const sock = this._getSock()
57
+ return sock.updateLastSeenPrivacy(privacy)
58
+ }
59
+
60
+ /**
61
+ * Configura privacidade de Online
62
+ * @param {'all'|'match_last_seen'} privacy
63
+ */
64
+ async setOnline(privacy) {
65
+ const sock = this._getSock()
66
+ return sock.updateOnlinePrivacy(privacy)
67
+ }
68
+
69
+ /**
70
+ * Configura privacidade da Foto de Perfil
71
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
72
+ */
73
+ async setProfilePicture(privacy) {
74
+ const sock = this._getSock()
75
+ return sock.updateProfilePicturePrivacy(privacy)
76
+ }
77
+
78
+ /**
79
+ * Configura privacidade do Recado/Status
80
+ * @param {'all'|'contacts'|'contact_blacklist'|'none'} privacy
81
+ */
82
+ async setAbout(privacy) {
83
+ const sock = this._getSock()
84
+ return sock.updateStatusPrivacy(privacy)
85
+ }
86
+
87
+ /**
88
+ * Ativa ou desativa confirmações de leitura (ticks azuis)
89
+ * @param {boolean} enabled
90
+ */
91
+ async setReadReceipts(enabled) {
92
+ const sock = this._getSock()
93
+ return sock.updateReadReceiptsPrivacy(enabled ? 'all' : 'none')
94
+ }
95
+ }
96
+
97
+ exports.PrivacyManager = PrivacyManager
98
+ exports.default = PrivacyManager
@@ -0,0 +1,92 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class ProfileManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Atualiza o nome de exibição (pushName) do bot
24
+ * @param {string} name
25
+ */
26
+ async updateName(name) {
27
+ const sock = this._getSock()
28
+ return sock.updateProfileName(name)
29
+ }
30
+
31
+ /**
32
+ * Atualiza o recado / status de texto da conta
33
+ * @param {string} aboutText
34
+ */
35
+ async updateAbout(aboutText) {
36
+ const sock = this._getSock()
37
+ return sock.updateProfileStatus(aboutText)
38
+ }
39
+
40
+ /**
41
+ * Obtém o recado de um contato ou da própria conta
42
+ * @param {string} [jid]
43
+ */
44
+ async getAbout(jid) {
45
+ const sock = this._getSock()
46
+ const targetJid = jid ? JidNormalizer.toJid(jid) : sock.user?.id
47
+ return sock.fetchStatus(targetJid)
48
+ }
49
+
50
+ /**
51
+ * Atualiza a foto de perfil da conta ou de um grupo
52
+ * @param {string} jidOrSelf - 'me' ou JID
53
+ * @param {string|Buffer|Object} imageSource
54
+ */
55
+ async updatePicture(jidOrSelf, imageSource) {
56
+ const sock = this._getSock()
57
+ const isSelf = !jidOrSelf || jidOrSelf === 'me'
58
+ const targetJid = isSelf ? sock.user?.id : JidNormalizer.toJid(jidOrSelf)
59
+ const content = typeof imageSource === 'string' ? { url: imageSource } : imageSource
60
+ return sock.updateProfilePicture(targetJid, content)
61
+ }
62
+
63
+ /**
64
+ * Remove a foto de perfil
65
+ * @param {string} [jidOrSelf]
66
+ */
67
+ async removePicture(jidOrSelf) {
68
+ const sock = this._getSock()
69
+ const isSelf = !jidOrSelf || jidOrSelf === 'me'
70
+ const targetJid = isSelf ? sock.user?.id : JidNormalizer.toJid(jidOrSelf)
71
+ return sock.removeProfilePicture(targetJid)
72
+ }
73
+
74
+ /**
75
+ * Obtém a URL da foto de perfil
76
+ * @param {string} jid
77
+ * @param {boolean} [highRes=true] - Se true, busca imagem em alta resolução
78
+ * @returns {Promise<string|null>}
79
+ */
80
+ async getPictureUrl(jid, highRes = true) {
81
+ const sock = this._getSock()
82
+ const targetJid = JidNormalizer.toJid(jid)
83
+ try {
84
+ return await sock.profilePictureUrl(targetJid, highRes ? 'image' : 'preview')
85
+ } catch {
86
+ return null
87
+ }
88
+ }
89
+ }
90
+
91
+ exports.ProfileManager = ProfileManager
92
+ exports.default = ProfileManager
@@ -0,0 +1,92 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+
7
+ class UserManager {
8
+ /**
9
+ * @param {import('../WaClient').WaClient} client
10
+ */
11
+ constructor(client) {
12
+ this.client = client
13
+ }
14
+
15
+ _getSock() {
16
+ if (!this.client.sock) {
17
+ throw new Error('Socket is not connected.')
18
+ }
19
+ return this.client.sock
20
+ }
21
+
22
+ /**
23
+ * Verifica se um número ou JID existe no WhatsApp
24
+ * @param {string} phoneOrJid
25
+ * @returns {Promise<{ exists: boolean, jid: string } | null>}
26
+ */
27
+ async isOnWhatsApp(phoneOrJid) {
28
+ return this.client.isOnWhatsApp(phoneOrJid)
29
+ }
30
+
31
+ /**
32
+ * Resolve um JID de forma transparente para PN ou LID
33
+ * @param {string} jidOrPhone
34
+ * @param {boolean} [fetchIfMissing=false]
35
+ * @returns {Promise<string>} JID canônico resolvido
36
+ */
37
+ async resolveJid(jidOrPhone, fetchIfMissing = false) {
38
+ const sock = this._getSock()
39
+ if (sock.resolveJid) {
40
+ return sock.resolveJid(jidOrPhone, fetchIfMissing)
41
+ }
42
+ return JidNormalizer.toJid(jidOrPhone)
43
+ }
44
+
45
+ /**
46
+ * Converte um identificador LID (@lid) para o número de telefone (@s.whatsapp.net)
47
+ * @param {string} lidJid
48
+ * @param {boolean} [fetchIfMissing=false]
49
+ * @returns {Promise<string|null>} Telefone no formato JID
50
+ */
51
+ async getPnForLid(lidJid, fetchIfMissing = false) {
52
+ const sock = this._getSock()
53
+ if (sock.toPn) {
54
+ return sock.toPn(lidJid, fetchIfMissing)
55
+ }
56
+ return null
57
+ }
58
+
59
+ /**
60
+ * Converte um telefone (@s.whatsapp.net) para seu LID (@lid) correspondente
61
+ * @param {string} pnJid
62
+ * @param {boolean} [fetchIfMissing=false]
63
+ * @returns {Promise<string|null>} LID no formato JID
64
+ */
65
+ async getLidForPn(pnJid, fetchIfMissing = false) {
66
+ const sock = this._getSock()
67
+ if (sock.toLid) {
68
+ return sock.toLid(pnJid, fetchIfMissing)
69
+ }
70
+ return null
71
+ }
72
+
73
+ /**
74
+ * Obtém o perfil comercial de uma conta WhatsApp Business
75
+ * @param {string} jid
76
+ */
77
+ async getBusinessProfile(jid) {
78
+ const sock = this._getSock()
79
+ const targetJid = JidNormalizer.toJid(jid)
80
+ if (!sock.getBusinessProfile) {
81
+ return null
82
+ }
83
+ try {
84
+ return await sock.getBusinessProfile(targetJid)
85
+ } catch {
86
+ return null
87
+ }
88
+ }
89
+ }
90
+
91
+ exports.UserManager = UserManager
92
+ exports.default = UserManager
@@ -0,0 +1,117 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { JidNormalizer } = require("../Normalizers/JidNormalizer")
6
+ const { CallContext } = require("../Context/CallContext")
7
+
8
+ class VoipManager {
9
+ /**
10
+ * @param {import('../WaClient').WaClient} client
11
+ */
12
+ constructor(client) {
13
+ this.client = client
14
+ }
15
+
16
+ _getSock() {
17
+ if (!this.client.sock) {
18
+ throw new Error('Socket is not connected.')
19
+ }
20
+ return this.client.sock
21
+ }
22
+
23
+ /**
24
+ * Realiza uma chamada de voz WhatsApp via WebAssembly
25
+ * @param {string} phoneNumber - Telefone ou JID de destino
26
+ * @param {Object} [options={}]
27
+ * @returns {Promise<CallContext>}
28
+ */
29
+ async call(phoneNumber, options = {}) {
30
+ const sock = this._getSock()
31
+ if (!sock.call) {
32
+ throw new Error('VoIP engine is not enabled in this WaSockets build.')
33
+ }
34
+ const cleanNumber = JidNormalizer.toPhoneNumber(phoneNumber) || phoneNumber
35
+ const activeCall = await sock.call(cleanNumber, { ...options, isVideo: false })
36
+ return new CallContext(this.client, {
37
+ id: activeCall.callId,
38
+ from: cleanNumber,
39
+ isVideo: false,
40
+ status: 'calling'
41
+ }, activeCall)
42
+ }
43
+
44
+ /**
45
+ * Realiza uma chamada de vídeo WhatsApp
46
+ * @param {string} phoneNumber
47
+ * @param {Object} [options={}]
48
+ * @returns {Promise<CallContext>}
49
+ */
50
+ async callVideo(phoneNumber, options = {}) {
51
+ const sock = this._getSock()
52
+ if (!sock.callVideo && !sock.call) {
53
+ throw new Error('VoIP engine is not enabled in this WaSockets build.')
54
+ }
55
+ const cleanNumber = JidNormalizer.toPhoneNumber(phoneNumber) || phoneNumber
56
+ const fn = sock.callVideo ? sock.callVideo.bind(sock) : (num, opts) => sock.call(num, { ...opts, isVideo: true })
57
+ const activeCall = await fn(cleanNumber, options)
58
+ return new CallContext(this.client, {
59
+ id: activeCall.callId,
60
+ from: cleanNumber,
61
+ isVideo: true,
62
+ status: 'calling'
63
+ }, activeCall)
64
+ }
65
+
66
+ /**
67
+ * Retorna a chamada ativa no momento ou null
68
+ * @returns {CallContext|null}
69
+ */
70
+ get activeCall() {
71
+ const sock = this.client.sock
72
+ const rawCall = sock?.activeCall
73
+ if (!rawCall) return null
74
+
75
+ return new CallContext(this.client, {
76
+ id: rawCall.callId,
77
+ from: rawCall.target,
78
+ isVideo: Boolean(rawCall.isVideo),
79
+ status: rawCall.state || 'active'
80
+ }, rawCall.instance || rawCall)
81
+ }
82
+
83
+ /**
84
+ * Limpa o estado da chamada ativa atual
85
+ */
86
+ clearActiveCall() {
87
+ const sock = this.client.sock
88
+ if (sock?.clearActiveCall) {
89
+ sock.clearActiveCall()
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Atende uma chamada recebida diretamente pelo ID
95
+ * @param {string} callId
96
+ * @param {string} from
97
+ * @param {Object} [options={}]
98
+ */
99
+ async acceptCall(callId, from, options = {}) {
100
+ const ctx = new CallContext(this.client, { id: callId, from, isVideo: options.isVideo })
101
+ return ctx.accept(options)
102
+ }
103
+
104
+ /**
105
+ * Rejeita uma chamada recebida
106
+ * @param {string} callId
107
+ * @param {string} from
108
+ * @param {number|string} [reason=0]
109
+ */
110
+ async rejectCall(callId, from, reason = 0) {
111
+ const ctx = new CallContext(this.client, { id: callId, from })
112
+ return ctx.reject(reason)
113
+ }
114
+ }
115
+
116
+ exports.VoipManager = VoipManager
117
+ exports.default = VoipManager
@@ -0,0 +1,29 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const { MessageManager } = require("./MessageManager")
6
+ const { GroupManager } = require("./GroupManager")
7
+ const { ChannelManager } = require("./ChannelManager")
8
+ const { PresenceManager } = require("./PresenceManager")
9
+ const { ProfileManager } = require("./ProfileManager")
10
+ const { PrivacyManager } = require("./PrivacyManager")
11
+ const { UserManager } = require("./UserManager")
12
+ const { ChatManager } = require("./ChatManager")
13
+ const { VoipManager } = require("./VoipManager")
14
+ const { BusinessManager } = require("./BusinessManager")
15
+ const { CommunityManager } = require("./CommunityManager")
16
+ const { LabelManager } = require("./LabelManager")
17
+
18
+ exports.MessageManager = MessageManager
19
+ exports.GroupManager = GroupManager
20
+ exports.ChannelManager = ChannelManager
21
+ exports.PresenceManager = PresenceManager
22
+ exports.ProfileManager = ProfileManager
23
+ exports.PrivacyManager = PrivacyManager
24
+ exports.UserManager = UserManager
25
+ exports.ChatManager = ChatManager
26
+ exports.VoipManager = VoipManager
27
+ exports.BusinessManager = BusinessManager
28
+ exports.CommunityManager = CommunityManager
29
+ exports.LabelManager = LabelManager