miaw-core 0.9.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.
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', { targets: { node: 'current' } }],
4
+ ],
5
+ };
@@ -0,0 +1,580 @@
1
+ import { EventEmitter } from 'events';
2
+ import { MiawClientOptions, ConnectionState, SendTextOptions, SendMessageResult, MiawClientEvents, MediaSource, SendImageOptions, SendDocumentOptions, SendVideoOptions, SendAudioOptions, MiawMessage, CheckNumberResult, ContactInfo, BusinessProfile, GroupParticipant, GroupInfo, PresenceStatus, ParticipantOperationResult, CreateGroupResult, GroupOperationResult, GroupInviteInfo, ProfileOperationResult, Label, LabelOperationResult, ProductCatalog, ProductOperationResult, ProductOptions, ProductCollection, NewsletterMetadata, NewsletterMessagesResult, NewsletterOperationResult, NewsletterSubscriptionInfo, ContactData, ContactOperationResult } from '../types';
3
+ /**
4
+ * Main client class for interacting with WhatsApp
5
+ */
6
+ export declare class MiawClient extends EventEmitter {
7
+ private options;
8
+ private socket;
9
+ private authHandler;
10
+ private connectionState;
11
+ private reconnectAttempts;
12
+ private reconnectTimer;
13
+ private logger;
14
+ private lidToJidMap;
15
+ constructor(options: MiawClientOptions);
16
+ /**
17
+ * Connect to WhatsApp
18
+ */
19
+ connect(): Promise<void>;
20
+ /**
21
+ * Register socket event handlers
22
+ */
23
+ private registerSocketEvents;
24
+ /**
25
+ * Handle protocol messages (edits, deletes)
26
+ */
27
+ private handleProtocolMessage;
28
+ /**
29
+ * Update LID to JID mapping from contacts
30
+ */
31
+ private updateLidToJidMapping;
32
+ /**
33
+ * Update LID to JID mapping from chat data
34
+ */
35
+ private updateLidFromChats;
36
+ /**
37
+ * Resolve LID to phone number JID
38
+ * @param lid - The LID format JID (e.g., '12345@lid')
39
+ * @returns The phone number JID if found, or the original LID
40
+ */
41
+ resolveLidToJid(lid: string): string;
42
+ /**
43
+ * Get phone number from LID or JID
44
+ * @param jid - Any JID format
45
+ * @returns Phone number string or undefined
46
+ */
47
+ getPhoneFromJid(jid: string): string | undefined;
48
+ /**
49
+ * Manually register a LID to phone number mapping
50
+ * Useful for persisting mappings across sessions
51
+ * @param lid - The LID (e.g., '12345@lid' or just '12345')
52
+ * @param phoneJid - The phone JID (e.g., '6281234567890@s.whatsapp.net' or just '6281234567890')
53
+ */
54
+ registerLidMapping(lid: string, phoneJid: string): void;
55
+ /**
56
+ * Get all registered LID mappings
57
+ * Useful for persisting mappings to storage
58
+ */
59
+ getLidMappings(): Map<string, string>;
60
+ /**
61
+ * Handle disconnection
62
+ * @returns true if should reconnect
63
+ */
64
+ private handleDisconnect;
65
+ /**
66
+ * Schedule reconnection attempt
67
+ */
68
+ private scheduleReconnect;
69
+ /**
70
+ * Update connection state and emit event
71
+ */
72
+ private updateConnectionState;
73
+ /**
74
+ * Send a text message
75
+ * @param to - Recipient phone number or JID
76
+ * @param text - Text content to send
77
+ * @param options - Optional settings (quoted for reply)
78
+ */
79
+ sendText(to: string, text: string, options?: SendTextOptions): Promise<SendMessageResult>;
80
+ /**
81
+ * Send an image message
82
+ * @param to - Recipient phone number or JID
83
+ * @param image - Image source (file path, URL, or Buffer)
84
+ * @param options - Optional settings (caption, viewOnce)
85
+ */
86
+ sendImage(to: string, image: MediaSource, options?: SendImageOptions): Promise<SendMessageResult>;
87
+ /**
88
+ * Send a document message
89
+ * @param to - Recipient phone number or JID
90
+ * @param document - Document source (file path, URL, or Buffer)
91
+ * @param options - Optional settings (fileName, mimetype, caption)
92
+ */
93
+ sendDocument(to: string, document: MediaSource, options?: SendDocumentOptions): Promise<SendMessageResult>;
94
+ /**
95
+ * Send a video message
96
+ * @param to - Recipient phone number or JID
97
+ * @param video - Video source (file path, URL, or Buffer)
98
+ * @param options - Optional settings (caption, viewOnce, gifPlayback, ptv)
99
+ */
100
+ sendVideo(to: string, video: MediaSource, options?: SendVideoOptions): Promise<SendMessageResult>;
101
+ /**
102
+ * Send an audio message
103
+ * @param to - Recipient phone number or JID
104
+ * @param audio - Audio source (file path, URL, or Buffer)
105
+ * @param options - Optional settings (ptt for voice note, mimetype)
106
+ */
107
+ sendAudio(to: string, audio: MediaSource, options?: SendAudioOptions): Promise<SendMessageResult>;
108
+ /**
109
+ * Download media from a received message
110
+ * @param message - The MiawMessage containing media (must have raw field with original Baileys message)
111
+ * @returns Buffer containing the media data, or null if download fails
112
+ */
113
+ downloadMedia(message: MiawMessage): Promise<Buffer | null>;
114
+ /**
115
+ * Check if a phone number is registered on WhatsApp
116
+ * @param phone - Phone number to check (with country code, e.g., '6281234567890')
117
+ * @returns CheckNumberResult with exists flag and JID if found
118
+ */
119
+ checkNumber(phone: string): Promise<CheckNumberResult>;
120
+ /**
121
+ * Check multiple phone numbers on WhatsApp (batch check)
122
+ * @param phones - Array of phone numbers to check
123
+ * @returns Array of CheckNumberResult
124
+ */
125
+ checkNumbers(phones: string[]): Promise<CheckNumberResult[]>;
126
+ /**
127
+ * Get contact information including status
128
+ * @param jidOrPhone - Contact's JID or phone number
129
+ * @returns ContactInfo or null if not found
130
+ */
131
+ getContactInfo(jidOrPhone: string): Promise<ContactInfo | null>;
132
+ /**
133
+ * Get business profile information
134
+ * @param jidOrPhone - Contact's JID or phone number
135
+ * @returns BusinessProfile or null if not a business account
136
+ */
137
+ getBusinessProfile(jidOrPhone: string): Promise<BusinessProfile | null>;
138
+ /**
139
+ * Get profile picture URL for a contact or group
140
+ * @param jidOrPhone - Contact's JID, phone number, or group JID
141
+ * @param highRes - Whether to get high resolution image (default: false)
142
+ * @returns Profile picture URL or null if not available
143
+ */
144
+ getProfilePicture(jidOrPhone: string, highRes?: boolean): Promise<string | null>;
145
+ /**
146
+ * Get group metadata/information
147
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
148
+ * @returns GroupInfo or null if not found
149
+ */
150
+ getGroupInfo(groupJid: string): Promise<GroupInfo | null>;
151
+ /**
152
+ * Get list of participants in a group
153
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
154
+ * @returns Array of GroupParticipant or null if group not found
155
+ */
156
+ getGroupParticipants(groupJid: string): Promise<GroupParticipant[] | null>;
157
+ /**
158
+ * Send a reaction to a message
159
+ * @param message - The MiawMessage to react to (must have raw field)
160
+ * @param emoji - Emoji to react with (e.g., '❤️', '👍'). Empty string removes reaction.
161
+ * @returns SendMessageResult
162
+ */
163
+ sendReaction(message: MiawMessage, emoji: string): Promise<SendMessageResult>;
164
+ /**
165
+ * Remove a reaction from a message (alias for sendReaction with empty string)
166
+ * @param message - The MiawMessage to remove reaction from
167
+ * @returns SendMessageResult
168
+ */
169
+ removeReaction(message: MiawMessage): Promise<SendMessageResult>;
170
+ /**
171
+ * Forward a message to another chat
172
+ * @param message - The MiawMessage to forward (must have raw field)
173
+ * @param to - Recipient phone number, JID, or group JID
174
+ * @returns SendMessageResult
175
+ */
176
+ forwardMessage(message: MiawMessage, to: string): Promise<SendMessageResult>;
177
+ /**
178
+ * Edit a previously sent message (must be your own message, within 15 minutes)
179
+ * @param message - The MiawMessage to edit (must be fromMe and have raw field)
180
+ * @param newText - New text content for the message
181
+ * @returns SendMessageResult
182
+ */
183
+ editMessage(message: MiawMessage, newText: string): Promise<SendMessageResult>;
184
+ /**
185
+ * Delete a message for everyone (must be your own message or admin in group)
186
+ * @param message - The MiawMessage to delete (must have raw field)
187
+ * @returns SendMessageResult
188
+ */
189
+ deleteMessage(message: MiawMessage): Promise<SendMessageResult>;
190
+ /**
191
+ * Delete a message for yourself only (does not affect other participants)
192
+ * @param message - The MiawMessage to delete locally (must have raw field)
193
+ * @param deleteMedia - Whether to also delete associated media files (default: true)
194
+ * @returns boolean indicating success
195
+ */
196
+ deleteMessageForMe(message: MiawMessage, deleteMedia?: boolean): Promise<boolean>;
197
+ /**
198
+ * Mark a message as read (send read receipt)
199
+ * @param message - The MiawMessage to mark as read
200
+ * @returns true if successful, false otherwise
201
+ */
202
+ markAsRead(message: MiawMessage): Promise<boolean>;
203
+ /**
204
+ * Send typing indicator to a chat
205
+ * @param to - Recipient phone number, JID, or group JID
206
+ */
207
+ sendTyping(to: string): Promise<void>;
208
+ /**
209
+ * Send recording indicator to a chat (shows "recording audio...")
210
+ * @param to - Recipient phone number, JID, or group JID
211
+ */
212
+ sendRecording(to: string): Promise<void>;
213
+ /**
214
+ * Stop typing/recording indicator (send paused state)
215
+ * @param to - Recipient phone number, JID, or group JID
216
+ */
217
+ stopTyping(to: string): Promise<void>;
218
+ /**
219
+ * Set bot's presence status (online/offline)
220
+ * @param status - 'available' (online) or 'unavailable' (offline)
221
+ */
222
+ setPresence(status: PresenceStatus): Promise<void>;
223
+ /**
224
+ * Subscribe to presence updates for a contact
225
+ * After subscribing, you'll receive 'presence' events when the contact's status changes
226
+ * @param jidOrPhone - Contact's JID or phone number to monitor
227
+ */
228
+ subscribePresence(jidOrPhone: string): Promise<void>;
229
+ /**
230
+ * Helper method for group participant operations
231
+ */
232
+ private groupParticipantsOperation;
233
+ /**
234
+ * Create a new WhatsApp group
235
+ * @param name - Group name/subject
236
+ * @param participants - Array of phone numbers or JIDs to add as initial members
237
+ * @returns CreateGroupResult with group info if successful
238
+ */
239
+ createGroup(name: string, participants: string[]): Promise<CreateGroupResult>;
240
+ /**
241
+ * Add participants to a group
242
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
243
+ * @param participants - Array of phone numbers or JIDs to add
244
+ * @returns Array of ParticipantOperationResult for each participant
245
+ */
246
+ addParticipants(groupJid: string, participants: string[]): Promise<ParticipantOperationResult[]>;
247
+ /**
248
+ * Remove participants from a group
249
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
250
+ * @param participants - Array of phone numbers or JIDs to remove
251
+ * @returns Array of ParticipantOperationResult for each participant
252
+ */
253
+ removeParticipants(groupJid: string, participants: string[]): Promise<ParticipantOperationResult[]>;
254
+ /**
255
+ * Leave a group
256
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
257
+ * @returns GroupOperationResult
258
+ */
259
+ leaveGroup(groupJid: string): Promise<GroupOperationResult>;
260
+ /**
261
+ * Promote participants to group admin
262
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
263
+ * @param participants - Array of phone numbers or JIDs to promote
264
+ * @returns Array of ParticipantOperationResult for each participant
265
+ */
266
+ promoteToAdmin(groupJid: string, participants: string[]): Promise<ParticipantOperationResult[]>;
267
+ /**
268
+ * Demote admins to regular members
269
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
270
+ * @param participants - Array of phone numbers or JIDs to demote
271
+ * @returns Array of ParticipantOperationResult for each participant
272
+ */
273
+ demoteFromAdmin(groupJid: string, participants: string[]): Promise<ParticipantOperationResult[]>;
274
+ /**
275
+ * Update group name/subject
276
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
277
+ * @param name - New group name
278
+ * @returns GroupOperationResult
279
+ */
280
+ updateGroupName(groupJid: string, name: string): Promise<GroupOperationResult>;
281
+ /**
282
+ * Update group description
283
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
284
+ * @param description - New description (undefined to remove)
285
+ * @returns GroupOperationResult
286
+ */
287
+ updateGroupDescription(groupJid: string, description?: string): Promise<GroupOperationResult>;
288
+ /**
289
+ * Update group profile picture
290
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
291
+ * @param image - Image source (file path, URL, or Buffer)
292
+ * @returns GroupOperationResult
293
+ */
294
+ updateGroupPicture(groupJid: string, image: MediaSource): Promise<GroupOperationResult>;
295
+ /**
296
+ * Get group invite link
297
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
298
+ * @returns Full invite link (https://chat.whatsapp.com/...) or null if failed
299
+ */
300
+ getGroupInviteLink(groupJid: string): Promise<string | null>;
301
+ /**
302
+ * Revoke current group invite link and generate a new one
303
+ * @param groupJid - Group JID (e.g., '123456789@g.us')
304
+ * @returns New invite link (https://chat.whatsapp.com/...) or null if failed
305
+ */
306
+ revokeGroupInvite(groupJid: string): Promise<string | null>;
307
+ /**
308
+ * Accept a group invite and join the group
309
+ * @param inviteCode - Invite code (just the code, or full URL)
310
+ * @returns Group JID if successful, null if failed
311
+ */
312
+ acceptGroupInvite(inviteCode: string): Promise<string | null>;
313
+ /**
314
+ * Get group information from invite code without joining
315
+ * @param inviteCode - Invite code (just the code, or full URL)
316
+ * @returns GroupInviteInfo if successful, null if failed
317
+ */
318
+ getGroupInviteInfo(inviteCode: string): Promise<GroupInviteInfo | null>;
319
+ /**
320
+ * Update your own profile picture
321
+ * @param image - Image source (file path, URL, or Buffer)
322
+ * @returns ProfileOperationResult indicating success or failure
323
+ */
324
+ updateProfilePicture(image: MediaSource): Promise<ProfileOperationResult>;
325
+ /**
326
+ * Remove your own profile picture
327
+ * @returns ProfileOperationResult indicating success or failure
328
+ */
329
+ removeProfilePicture(): Promise<ProfileOperationResult>;
330
+ /**
331
+ * Update your profile display name (push name)
332
+ * @param name - New display name
333
+ * @returns ProfileOperationResult indicating success or failure
334
+ */
335
+ updateProfileName(name: string): Promise<ProfileOperationResult>;
336
+ /**
337
+ * Update your profile status (About text)
338
+ * @param status - New status/about text
339
+ * @returns ProfileOperationResult indicating success or failure
340
+ */
341
+ updateProfileStatus(status: string): Promise<ProfileOperationResult>;
342
+ /**
343
+ * Create or edit a label
344
+ * @param label - Label data (for edit, include the label ID)
345
+ * @returns LabelOperationResult
346
+ * @note Requires WhatsApp Business account
347
+ */
348
+ addLabel(label: Label): Promise<LabelOperationResult>;
349
+ /**
350
+ * Add a label to a chat
351
+ * @param chatJidOrPhone - Chat JID or phone number
352
+ * @param labelId - Label ID to add
353
+ * @returns LabelOperationResult
354
+ * @note Requires WhatsApp Business account
355
+ */
356
+ addChatLabel(chatJidOrPhone: string, labelId: string): Promise<LabelOperationResult>;
357
+ /**
358
+ * Remove a label from a chat
359
+ * @param chatJidOrPhone - Chat JID or phone number
360
+ * @param labelId - Label ID to remove
361
+ * @returns LabelOperationResult
362
+ * @note Requires WhatsApp Business account
363
+ */
364
+ removeChatLabel(chatJidOrPhone: string, labelId: string): Promise<LabelOperationResult>;
365
+ /**
366
+ * Add a label to a message
367
+ * @param chatJidOrPhone - Chat JID or phone number where the message is
368
+ * @param messageId - Message ID to label
369
+ * @param labelId - Label ID to add
370
+ * @returns LabelOperationResult
371
+ * @note Requires WhatsApp Business account
372
+ */
373
+ addMessageLabel(chatJidOrPhone: string, messageId: string, labelId: string): Promise<LabelOperationResult>;
374
+ /**
375
+ * Remove a label from a message
376
+ * @param chatJidOrPhone - Chat JID or phone number where the message is
377
+ * @param messageId - Message ID to unlabel
378
+ * @param labelId - Label ID to remove
379
+ * @returns LabelOperationResult
380
+ * @note Requires WhatsApp Business account
381
+ */
382
+ removeMessageLabel(chatJidOrPhone: string, messageId: string, labelId: string): Promise<LabelOperationResult>;
383
+ /**
384
+ * Get product catalog from a WhatsApp Business account
385
+ * @param businessJidOrPhone - Business JID or phone number (default: your own catalog)
386
+ * @param limit - Maximum number of products to fetch (default: 10)
387
+ * @param cursor - Pagination cursor for fetching next page
388
+ * @returns ProductCatalog
389
+ * @note Requires WhatsApp Business account
390
+ */
391
+ getCatalog(businessJidOrPhone?: string, limit?: number, cursor?: string): Promise<ProductCatalog>;
392
+ /**
393
+ * Get product collections from a WhatsApp Business account
394
+ * @param businessJidOrPhone - Business JID or phone number (default: your own collections)
395
+ * @param limit - Maximum number of collections to fetch (default: 51)
396
+ * @returns Array of ProductCollection
397
+ * @note Requires WhatsApp Business account
398
+ */
399
+ getCollections(businessJidOrPhone?: string, limit?: number): Promise<ProductCollection[]>;
400
+ /**
401
+ * Create a new product in the catalog
402
+ * @param options - Product options (name, price, images, etc.)
403
+ * @returns ProductOperationResult with product ID
404
+ * @note Requires WhatsApp Business account
405
+ */
406
+ createProduct(options: ProductOptions): Promise<ProductOperationResult>;
407
+ /**
408
+ * Update an existing product in the catalog
409
+ * @param productId - Product ID to update
410
+ * @param options - Product options (name, price, images, etc.)
411
+ * @returns ProductOperationResult
412
+ * @note Requires WhatsApp Business account
413
+ */
414
+ updateProduct(productId: string, options: ProductOptions): Promise<ProductOperationResult>;
415
+ /**
416
+ * Delete products from the catalog
417
+ * @param productIds - Array of product IDs to delete
418
+ * @returns ProductOperationResult with deleted count
419
+ * @note Requires WhatsApp Business account
420
+ */
421
+ deleteProducts(productIds: string[]): Promise<ProductOperationResult>;
422
+ /**
423
+ * Create a new newsletter/channel
424
+ * @param name - Newsletter name
425
+ * @param description - Newsletter description
426
+ * @returns NewsletterOperationResult with newsletter ID
427
+ */
428
+ createNewsletter(name: string, description?: string): Promise<NewsletterOperationResult>;
429
+ /**
430
+ * Get newsletter metadata
431
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
432
+ * @returns NewsletterMetadata or null if not found
433
+ */
434
+ getNewsletterMetadata(newsletterId: string): Promise<NewsletterMetadata | null>;
435
+ /**
436
+ * Follow a newsletter/channel
437
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
438
+ * @returns boolean indicating success
439
+ */
440
+ followNewsletter(newsletterId: string): Promise<boolean>;
441
+ /**
442
+ * Unfollow a newsletter/channel
443
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
444
+ * @returns boolean indicating success
445
+ */
446
+ unfollowNewsletter(newsletterId: string): Promise<boolean>;
447
+ /**
448
+ * Mute a newsletter/channel
449
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
450
+ * @returns boolean indicating success
451
+ */
452
+ muteNewsletter(newsletterId: string): Promise<boolean>;
453
+ /**
454
+ * Unmute a newsletter/channel
455
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
456
+ * @returns boolean indicating success
457
+ */
458
+ unmuteNewsletter(newsletterId: string): Promise<boolean>;
459
+ /**
460
+ * Update newsletter name
461
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
462
+ * @param name - New newsletter name
463
+ * @returns boolean indicating success
464
+ */
465
+ updateNewsletterName(newsletterId: string, name: string): Promise<boolean>;
466
+ /**
467
+ * Update newsletter description
468
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
469
+ * @param description - New newsletter description
470
+ * @returns boolean indicating success
471
+ */
472
+ updateNewsletterDescription(newsletterId: string, description: string): Promise<boolean>;
473
+ /**
474
+ * Update newsletter picture
475
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
476
+ * @param image - Image source (file path, URL, or Buffer)
477
+ * @returns boolean indicating success
478
+ */
479
+ updateNewsletterPicture(newsletterId: string, image: MediaSource): Promise<boolean>;
480
+ /**
481
+ * Remove newsletter picture
482
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
483
+ * @returns boolean indicating success
484
+ */
485
+ removeNewsletterPicture(newsletterId: string): Promise<boolean>;
486
+ /**
487
+ * React to a newsletter message
488
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
489
+ * @param messageId - Server message ID to react to
490
+ * @param emoji - Emoji to react with (empty string removes reaction)
491
+ * @returns boolean indicating success
492
+ */
493
+ reactToNewsletterMessage(newsletterId: string, messageId: string, emoji: string): Promise<boolean>;
494
+ /**
495
+ * Fetch messages from a newsletter
496
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
497
+ * @param count - Number of messages to fetch (default: 50)
498
+ * @param since - Timestamp to fetch messages since (default: now, backward)
499
+ * @param after - Cursor for pagination (default: 0)
500
+ * @returns NewsletterMessagesResult
501
+ */
502
+ fetchNewsletterMessages(newsletterId: string, count?: number, since?: number, after?: number): Promise<NewsletterMessagesResult>;
503
+ /**
504
+ * Subscribe to live newsletter updates
505
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
506
+ * @returns boolean indicating success
507
+ */
508
+ subscribeNewsletterUpdates(newsletterId: string): Promise<boolean>;
509
+ /**
510
+ * Get newsletter subscriber and admin count
511
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
512
+ * @returns NewsletterSubscriptionInfo or null if failed
513
+ */
514
+ getNewsletterSubscribers(newsletterId: string): Promise<NewsletterSubscriptionInfo | null>;
515
+ /**
516
+ * Get newsletter admin count
517
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
518
+ * @returns Admin count or null if failed
519
+ */
520
+ getNewsletterAdminCount(newsletterId: string): Promise<number | null>;
521
+ /**
522
+ * Change newsletter owner (transfer ownership)
523
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
524
+ * @param newOwnerJid - New owner's JID
525
+ * @returns boolean indicating success
526
+ */
527
+ changeNewsletterOwner(newsletterId: string, newOwnerJid: string): Promise<boolean>;
528
+ /**
529
+ * Demote a newsletter admin
530
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
531
+ * @param adminJid - Admin's JID to demote
532
+ * @returns boolean indicating success
533
+ */
534
+ demoteNewsletterAdmin(newsletterId: string, adminJid: string): Promise<boolean>;
535
+ /**
536
+ * Delete a newsletter/channel
537
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
538
+ * @returns boolean indicating success
539
+ */
540
+ deleteNewsletter(newsletterId: string): Promise<boolean>;
541
+ /**
542
+ * Add or edit a contact
543
+ * @param contact - Contact data (phone, name, etc.)
544
+ * @returns ContactOperationResult
545
+ */
546
+ addOrEditContact(contact: ContactData): Promise<ContactOperationResult>;
547
+ /**
548
+ * Remove a contact
549
+ * @param phone - Contact's phone number (with country code)
550
+ * @returns ContactOperationResult
551
+ */
552
+ removeContact(phone: string): Promise<ContactOperationResult>;
553
+ /**
554
+ * Get audio MIME type from file extension
555
+ */
556
+ private getAudioMimetypeFromFileName;
557
+ /**
558
+ * Get MIME type from file extension
559
+ */
560
+ private getMimetypeFromFileName;
561
+ /**
562
+ * Disconnect from WhatsApp
563
+ */
564
+ disconnect(): Promise<void>;
565
+ /**
566
+ * Get current connection state
567
+ */
568
+ getConnectionState(): ConnectionState;
569
+ /**
570
+ * Get instance ID
571
+ */
572
+ getInstanceId(): string;
573
+ /**
574
+ * Check if connected
575
+ */
576
+ isConnected(): boolean;
577
+ on<K extends keyof MiawClientEvents>(event: K, listener: MiawClientEvents[K]): this;
578
+ emit<K extends keyof MiawClientEvents>(event: K, ...args: Parameters<MiawClientEvents[K]>): boolean;
579
+ }
580
+ //# sourceMappingURL=MiawClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MiawClient.d.ts","sourceRoot":"","sources":["../../src/client/MiawClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EAIX,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,cAAc,EAGd,0BAA0B,EAC1B,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EAEf,sBAAsB,EAEtB,KAAK,EACL,oBAAoB,EAGpB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EAEjB,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAE1B,WAAW,EACX,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAKlB;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,WAAW,CAAkC;gBAEzC,OAAO,EAAE,iBAAiB;IA0BtC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAwI5B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoD7B;;OAEG;IACH,OAAO,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