miaw-core 1.0.0 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.0] - 2026-01-02
9
+
10
+ **Baileys v7 Migration** - ESM-only release with improved session stability
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ - **ESM-only** - Package now uses `"type": "module"`. CommonJS `require()` is no longer supported.
15
+ - **Node.js >= 18.0.0** required
16
+
17
+ ### Fixed
18
+
19
+ - **Session reconnection issue** - Fixed bug where app couldn't reconnect after QR scan and restart without re-pairing
20
+ - Includes fixes from Baileys v7: #1735, #1822, #1663, #1697
21
+
22
+ ### Changed
23
+
24
+ - **Baileys** upgraded from v6.7.21 to v7.0.0-rc.9
25
+ - TypeScript target updated to ES2022
26
+ - All imports now use `.js` extensions for ESM compatibility
27
+ - Node.js built-in imports use `node:` prefix
28
+
29
+ ### Migration
30
+
31
+ For users upgrading from v1.0.x:
32
+
33
+ ```typescript
34
+ // No code changes needed if already using ESM imports
35
+ import { MiawClient } from "miaw-core";
36
+
37
+ // If using CommonJS, migrate to ESM:
38
+ // Before (CommonJS - no longer supported):
39
+ // const { MiawClient } = require('miaw-core');
40
+
41
+ // After (ESM):
42
+ import { MiawClient } from "miaw-core";
43
+ ```
44
+
45
+ Ensure your `package.json` has `"type": "module"` or use `.mjs` file extension.
46
+
47
+ ---
48
+
8
49
  ## [1.0.0] - 2025-12-24
9
50
 
10
51
  **First Stable Release!** 🎉
@@ -21,15 +62,18 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
21
62
  ### What's New Since v0.9.1
22
63
 
23
64
  #### LID Cache Management
65
+
24
66
  - `getLidCacheSize()` - Get current LID to JID cache size
25
67
  - `clearLidCache()` - Clear the LID cache
26
68
  - `getLidMappings()` - Returns `Record<string, string>` instead of `Map`
27
69
 
28
70
  #### Resource Cleanup
71
+
29
72
  - `dispose()` - Properly clean up resources before shutdown
30
73
  - Recommended to call on process exit for clean session save
31
74
 
32
75
  #### Performance Improvements
76
+
33
77
  - LID mappings now use LRU cache with max size of 1000 entries
34
78
  - Automatic eviction of least recently used mappings
35
79
  - Improved memory management for long-running bots
@@ -37,6 +81,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
37
81
  ### API Surface
38
82
 
39
83
  81 public methods across 10 categories:
84
+
40
85
  - Core Client (7 methods)
41
86
  - Messaging (6 methods)
42
87
  - Media (5 methods)
@@ -73,6 +118,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
73
118
  ### Added
74
119
 
75
120
  #### Examples
121
+
76
122
  - `01-basic-bot.ts` - Core client, QR authentication, echo bot (v0.1.0)
77
123
  - `02-media-bot.ts` - Media sending and downloading (v0.2.0)
78
124
  - `03-message-context.ts` - Reply, edit, delete, reactions (v0.3.0)
@@ -93,6 +139,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
93
139
  ### Added
94
140
 
95
141
  #### Label Operations (WhatsApp Business only)
142
+
96
143
  - `addLabel()` - Create or edit labels
97
144
  - `addChatLabel()` - Add a label to a chat
98
145
  - `removeChatLabel()` - Remove a label from a chat
@@ -103,6 +150,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
103
150
  - `Label`, `LabelOperationResult` types
104
151
 
105
152
  #### Catalog/Product Operations (WhatsApp Business only)
153
+
106
154
  - `getCatalog()` - Fetch product catalog with pagination support
107
155
  - `getCollections()` - Fetch catalog collections
108
156
  - `createProduct()` - Add new products to catalog
@@ -111,6 +159,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
111
159
  - `Product`, `ProductCollection`, `ProductCatalog`, `ProductOperationResult`, `ProductOptions` types
112
160
 
113
161
  #### Newsletter/Channel Operations
162
+
114
163
  - `createNewsletter()` - Create WhatsApp channels/newsletters
115
164
  - `getNewsletterMetadata()` - Get newsletter information
116
165
  - `followNewsletter()` - Follow/subscribe to newsletters
@@ -132,11 +181,13 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
132
181
  - `NewsletterMetadata`, `NewsletterMessage`, `NewsletterMessagesResult`, `NewsletterOperationResult`, `NewsletterSubscriptionInfo` types
133
182
 
134
183
  #### Contact Management
184
+
135
185
  - `addOrEditContact()` - Add or update contacts
136
186
  - `removeContact()` - Remove contacts
137
187
  - `ContactData`, `ContactOperationResult` types
138
188
 
139
189
  #### Tests
190
+
140
191
  - Integration tests for all v0.9.0 features (`12-business-features.test.ts`, `13-newsletter-features.test.ts`)
141
192
 
142
193
  ## [0.8.0] - 2025-12-21
@@ -144,14 +195,17 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
144
195
  ### Added
145
196
 
146
197
  - **Profile Picture Management**
198
+
147
199
  - `updateProfilePicture()` - Update your own profile picture (file path, URL, or Buffer)
148
200
  - `removeProfilePicture()` - Remove your profile picture
149
201
 
150
202
  - **Profile Information**
203
+
151
204
  - `updateProfileName()` - Update your display name (push name)
152
205
  - `updateProfileStatus()` - Update your "About" text
153
206
 
154
207
  - **New Types**
208
+
155
209
  - `ProfileOperationResult` - Result type for profile operations (success/error)
156
210
 
157
211
  - **Integration Tests**
@@ -162,31 +216,37 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
162
216
  ### Added
163
217
 
164
218
  - **Group Creation**
219
+
165
220
  - `createGroup()` - Create new WhatsApp groups with initial participants
166
221
  - Returns `CreateGroupResult` with group JID and metadata
167
222
 
168
223
  - **Participant Management**
224
+
169
225
  - `addParticipants()` - Add members to a group (requires admin)
170
226
  - `removeParticipants()` - Remove members from a group (requires admin)
171
227
  - `leaveGroup()` - Leave a group
172
228
  - Returns `ParticipantOperationResult[]` with status for each participant
173
229
 
174
230
  - **Admin Management**
231
+
175
232
  - `promoteToAdmin()` - Promote members to group admin
176
233
  - `demoteFromAdmin()` - Demote admins to regular members
177
234
 
178
235
  - **Group Settings**
236
+
179
237
  - `updateGroupName()` - Change group name/subject
180
238
  - `updateGroupDescription()` - Set or clear group description
181
239
  - `updateGroupPicture()` - Change group profile picture
182
240
 
183
241
  - **Group Invites**
242
+
184
243
  - `getGroupInviteLink()` - Get group invite link (https://chat.whatsapp.com/...)
185
244
  - `revokeGroupInvite()` - Revoke current link and get new one
186
245
  - `acceptGroupInvite()` - Join group via invite code or URL
187
246
  - `getGroupInviteInfo()` - Preview group info before joining
188
247
 
189
248
  - **New Types**
249
+
190
250
  - `ParticipantOperationResult` - Result of add/remove/promote/demote operations
191
251
  - `CreateGroupResult` - Result of group creation with metadata
192
252
  - `GroupOperationResult` - Generic success/error result for group operations
@@ -200,13 +260,16 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
200
260
  ### Added
201
261
 
202
262
  - **Send Reactions**
263
+
203
264
  - `sendReaction()` - Send emoji reactions to messages (e.g., '❤️', '👍')
204
265
  - `removeReaction()` - Remove your reaction from a message
205
266
 
206
267
  - **Forward Messages**
268
+
207
269
  - `forwardMessage()` - Forward any message to another chat
208
270
 
209
271
  - **Edit Messages**
272
+
210
273
  - `editMessage()` - Edit your own messages (within WhatsApp's 15-minute window)
211
274
 
212
275
  - **Delete Messages**
@@ -218,21 +281,25 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
218
281
  ### Added
219
282
 
220
283
  - **Read Receipts**
284
+
221
285
  - `markAsRead()` - Mark messages as read (send read receipt)
222
286
  - Returns boolean indicating success
223
287
 
224
288
  - **Typing & Recording Indicators**
289
+
225
290
  - `sendTyping()` - Send "typing..." indicator to a chat
226
291
  - `sendRecording()` - Send "recording audio..." indicator
227
292
  - `stopTyping()` - Stop typing/recording indicator (send paused state)
228
293
  - Works with both individual contacts and groups
229
294
 
230
295
  - **Presence Management**
296
+
231
297
  - `setPresence()` - Set bot's online/offline status ('available' or 'unavailable')
232
298
  - `subscribePresence()` - Subscribe to contact's presence updates
233
299
  - `presence` event - Emitted when subscribed contact's presence changes
234
300
 
235
301
  - **New Types**
302
+
236
303
  - `PresenceStatus` - Union type for 'available' | 'unavailable'
237
304
  - `PresenceUpdate` - Presence notification data (jid, status, lastSeen)
238
305
 
@@ -244,20 +311,24 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
244
311
  ### Added
245
312
 
246
313
  - **Contact Validation**
314
+
247
315
  - `checkNumber()` - Verify if phone number is on WhatsApp
248
316
  - `checkNumbers()` - Batch check multiple phone numbers
249
317
  - Returns `CheckNumberResult` with exists flag and JID
250
318
 
251
319
  - **Contact Information**
320
+
252
321
  - `getContactInfo()` - Fetch contact info including status
253
322
  - `getBusinessProfile()` - Get business account profile details
254
323
  - `getProfilePicture()` - Get profile picture URL (supports low/high res)
255
324
 
256
325
  - **Group Information**
326
+
257
327
  - `getGroupInfo()` - Fetch group metadata (name, description, settings)
258
328
  - `getGroupParticipants()` - List all group members with roles
259
329
 
260
330
  - **New Types**
331
+
261
332
  - `CheckNumberResult` - Result of number validation
262
333
  - `ContactInfo` - Contact information structure
263
334
  - `BusinessProfile` - Business profile data
@@ -273,23 +344,28 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
273
344
  ### Added
274
345
 
275
346
  - **Reply to Messages (Quoted)**
347
+
276
348
  - All send methods now support `quoted` option
277
349
  - Pass `MiawMessage` to reply to specific messages
278
350
  - Works with `sendText()`, `sendImage()`, `sendDocument()`, `sendVideo()`, `sendAudio()`
279
351
 
280
352
  - **Edit Notifications**
353
+
281
354
  - `message_edit` event when messages are edited
282
355
  - `MessageEdit` type with messageId, chatId, newText, editTimestamp
283
356
 
284
357
  - **Delete Notifications**
358
+
285
359
  - `message_delete` event when messages are deleted/revoked
286
360
  - `MessageDelete` type with messageId, chatId, fromMe, participant
287
361
 
288
362
  - **Reactions**
363
+
289
364
  - `message_reaction` event when messages receive reactions
290
365
  - `MessageReaction` type with messageId, chatId, reactorId, emoji, isRemoval
291
366
 
292
367
  - **New Types**
368
+
293
369
  - `MessageEdit` - Edit notification data
294
370
  - `MessageDelete` - Delete notification data
295
371
  - `MessageReaction` - Reaction notification data
@@ -307,15 +383,18 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
307
383
  ### Added
308
384
 
309
385
  - **Media Sending Methods**
386
+
310
387
  - `sendImage()` - Send images with caption and view-once support
311
388
  - `sendDocument()` - Send documents with auto-mimetype detection
312
389
  - `sendVideo()` - Send videos with caption, GIF playback, and PTV (video notes)
313
390
  - `sendAudio()` - Send audio with PTT (voice notes) support
314
391
 
315
392
  - **Media Download**
393
+
316
394
  - `downloadMedia()` - Download media from received messages as Buffer
317
395
 
318
396
  - **Media Metadata**
397
+
319
398
  - `MediaInfo` type with full metadata extraction
320
399
  - Support for mimetype, fileSize, dimensions, duration
321
400
  - PTT detection for voice notes
@@ -323,6 +402,7 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
323
402
  - View-once message detection
324
403
 
325
404
  - **New Types**
405
+
326
406
  - `MediaSource` - Flexible input type (path/URL/Buffer)
327
407
  - `SendImageOptions`, `SendDocumentOptions`, `SendVideoOptions`, `SendAudioOptions`
328
408
  - `MediaInfo` - Media metadata interface
@@ -345,22 +425,26 @@ This is the first stable release of Miaw Core. After 9 pre-releases, the API is
345
425
  ### Added
346
426
 
347
427
  - **Core Client**
428
+
348
429
  - `MiawClient` class with event-driven architecture
349
430
  - Connection management with auto-reconnection
350
431
  - Session persistence using Baileys multi-file auth state
351
432
  - Multiple instance support with isolated sessions
352
433
 
353
434
  - **Messaging**
435
+
354
436
  - `sendText()` - Send text messages to individuals and groups
355
437
  - Message normalization with `MiawMessage` format
356
438
  - Support for @s.whatsapp.net, @lid, @g.us JID formats
357
439
 
358
440
  - **LID Support**
441
+
359
442
  - Handle WhatsApp's @lid privacy format
360
443
  - LID to phone number mapping
361
444
  - `resolveLidToJid()`, `getPhoneFromJid()`, `registerLidMapping()`
362
445
 
363
446
  - **Events**
447
+
364
448
  - `qr` - QR code for authentication
365
449
  - `ready` - Client connected and ready
366
450
  - `message` - Incoming message received
package/README.md CHANGED
@@ -1,13 +1,35 @@
1
1
  # Miaw Core
2
2
 
3
- **Multiple Instance of App WhatsApp** - A simplified WhatsApp API wrapper for Baileys
3
+ **Multiple Instance of Awesome WhatsApp** - A simplified WhatsApp API wrapper for Baileys
4
4
 
5
5
  Miaw Core abstracts away the complexity of Baileys, providing a clean, simple API for building WhatsApp bots and automation tools. It handles all the painful parts: session management, QR codes, reconnection logic, and message parsing.
6
6
 
7
+ > **Now powered by Baileys v7.0.0** - Full support for the latest WhatsApp Web features including newsletters/channels
8
+
9
+ ## Why Miaw Core vs Baileys Directly?
10
+
11
+ | Aspect | Baileys (Direct) | Miaw Core |
12
+ | ---------------------- | ----------------------------- | ---------------------------------- |
13
+ | **Learning Curve** | Steep - 150+ methods to learn | Gentle - 92 focused methods |
14
+ | **Setup Code** | 50-100 lines boilerplate | 10 lines to start |
15
+ | **Session Management** | Manual auth state handling | Automatic file-based persistence |
16
+ | **Reconnection** | DIY implementation | Built-in with configurable retries |
17
+ | **Message Format** | Complex nested structures | Normalized `MiawMessage` objects |
18
+ | **TypeScript** | Types available but complex | Clean, simplified types |
19
+ | **Multi-Instance** | Manual socket management | Instance ID-based separation |
20
+
21
+ **Choose Baileys directly** if you need low-level control, custom implementations, or access to every WhatsApp feature.
22
+
23
+ **Choose Miaw Core** if you want to build bots quickly with clean code, automatic session handling, and don't need every obscure feature.
24
+
25
+ For a detailed comparison, see [Baileys vs Miaw Core Comparison](./docs/BAILEYS_VS_MIAW_COMPARISON.md).
26
+
7
27
  ## Documentation
8
28
 
9
29
  - **[Usage Guide](./docs/USAGE.md)** - Complete guide for all current features
30
+ - **[Baileys Comparison](./docs/BAILEYS_VS_MIAW_COMPARISON.md)** - Feature comparison with raw Baileys
10
31
  - **[Migration Guide](./docs/MIGRATION.md)** - Upgrading between versions
32
+ - **[Test Coverage](./docs/TEST_COVERAGE_ANALYSIS.md)** - API coverage analysis
11
33
  - **[Roadmap](./docs/ROADMAP.md)** - Feature roadmap and development plan
12
34
  - **[Changelog](./CHANGELOG.md)** - Version history and changes
13
35
  - **[Examples](./examples/)** - Code examples and sample bots
@@ -26,6 +48,11 @@ Miaw Core abstracts away the complexity of Baileys, providing a clean, simple AP
26
48
  - **Group Management** - Full admin capabilities for groups
27
49
  - **Profile Management** - Customize bot profile picture, name, and status
28
50
 
51
+ ## Requirements
52
+
53
+ - **Node.js** >= 18.0.0
54
+ - **ESM** - This package is ESM-only (uses `"type": "module"`)
55
+
29
56
  ## Installation
30
57
 
31
58
  ```bash
@@ -67,9 +94,65 @@ await client.connect();
67
94
 
68
95
  For more examples and detailed usage, see the [Usage Guide](./docs/USAGE.md).
69
96
 
70
- ## Current Capabilities (v1.0.0)
97
+ ## Testing
98
+
99
+ ### Manual Interactive Testing
100
+
101
+ Test all 92 API methods interactively:
102
+
103
+ ```bash
104
+ # Show available test groups
105
+ npm run test:manual
106
+
107
+ # Run specific test groups
108
+ npm run test:manual all # All tests
109
+ npm run test:manual messaging # Messaging tests only
110
+ npm run test:manual newsletter # Newsletter tests only
111
+ npm run test:manual business # Business features only
112
+ ```
113
+
114
+ **Available test groups:**
115
+
116
+ | Group | Description | Methods |
117
+ | ------------ | ------------------------------- | ------- |
118
+ | `core` | Connection, lifecycle | 6 |
119
+ | `get` | Fetch contacts, groups, chats | 6 |
120
+ | `messaging` | Send/receive, reactions, edit | 12 |
121
+ | `contacts` | Check numbers, contact info | 7 |
122
+ | `group` | Create, manage participants | 13 |
123
+ | `profile` | Update picture, name, status | 4 |
124
+ | `business` | Labels, catalog (Business only) | 10 |
125
+ | `newsletter` | Channels, subscriptions | 6 |
126
+ | `ux` | Typing, presence, read receipts | 5 |
127
+
128
+ **Features:**
129
+
130
+ - Auto-connects using existing session (skips QR if already authenticated)
131
+ - Tracks test results with pass/fail/skip status
132
+ - Generates summary report with timestamps
133
+ - Pre-loads test configuration from `.env.test`
134
+
135
+ See [Test Coverage Analysis](./docs/TEST_COVERAGE_ANALYSIS.md) for detailed coverage report.
136
+
137
+ ### Unit & Integration Tests
138
+
139
+ ```bash
140
+ # Run all tests
141
+ npm test
142
+
143
+ # Run in watch mode
144
+ npm run test:watch
145
+
146
+ # Generate coverage report
147
+ npm run test:coverage
148
+ ```
149
+
150
+ ## Current Capabilities (v1.1.0)
151
+
152
+ Built on **Baileys v7.0.0-rc.9** - the latest WhatsApp Web protocol implementation.
71
153
 
72
154
  ### Core Features
155
+
73
156
  - ✅ Send and receive text messages
74
157
  - ✅ Send/receive media (images, videos, audio, documents)
75
158
  - ✅ QR code authentication
@@ -81,6 +164,7 @@ For more examples and detailed usage, see the [Usage Guide](./docs/USAGE.md).
81
164
  - ✅ Error handling
82
165
 
83
166
  ### Advanced Messaging
167
+
84
168
  - ✅ Reply/quote messages
85
169
  - ✅ Edit own messages
86
170
  - ✅ Delete messages
@@ -88,6 +172,7 @@ For more examples and detailed usage, see the [Usage Guide](./docs/USAGE.md).
88
172
  - ✅ Forward messages
89
173
 
90
174
  ### Group Management
175
+
91
176
  - ✅ Create groups
92
177
  - ✅ Add/remove participants
93
178
  - ✅ Promote/demote admins
@@ -95,16 +180,18 @@ For more examples and detailed usage, see the [Usage Guide](./docs/USAGE.md).
95
180
  - ✅ Update group settings
96
181
 
97
182
  ### Profile Management
183
+
98
184
  - ✅ Update profile picture
99
185
  - ✅ Remove profile picture
100
186
  - ✅ Update profile name
101
187
  - ✅ Update profile status
102
188
 
103
- ### Business & Social (v1.0.0)
189
+ ### Business & Social
190
+
104
191
  - ✅ Label operations (WhatsApp Business)
105
192
  - ✅ Product catalog management (WhatsApp Business)
106
- - ✅ Newsletter/channel operations
107
- - ✅ Contact management
193
+ - ✅ Newsletter/channel operations (create, send, manage)
194
+ - ✅ Contact management (add, edit, remove)
108
195
 
109
196
  See [ROADMAP.md](./docs/ROADMAP.md) for planned features.
110
197
 
@@ -161,8 +248,8 @@ MIT
161
248
 
162
249
  ## Credits
163
250
 
164
- Built on top of [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys)
251
+ Built on top of [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys) v7.0.0-rc.9
165
252
 
166
253
  ---
167
254
 
168
- **Version:** 1.0.0 | **Status:** Stable | **Updated:** 2025-12-24
255
+ **Version:** 1.1.0 | **Baileys:** 7.0.0-rc.9 | **Status:** Stable | **Updated:** 2026-01-03
package/babel.config.js CHANGED
@@ -1,5 +1,5 @@
1
- module.exports = {
1
+ export default {
2
2
  presets: [
3
- ['@babel/preset-env', { targets: { node: 'current' } }],
3
+ ['@babel/preset-env', { targets: { node: 'current' }, modules: false }],
4
4
  ],
5
5
  };
@@ -1,5 +1,5 @@
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';
1
+ import { EventEmitter } from "node: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, OwnProfile, FetchAllContactsResult, FetchAllGroupsResult, FetchAllLabelsResult, FetchChatMessagesResult, FetchAllChatsResult } from "../types/index.js";
3
3
  /**
4
4
  * Main client class for interacting with WhatsApp
5
5
  */
@@ -12,6 +12,10 @@ export declare class MiawClient extends EventEmitter {
12
12
  private reconnectTimer;
13
13
  private logger;
14
14
  private lidToJidMap;
15
+ private contactsStore;
16
+ private labelsStore;
17
+ private messagesStore;
18
+ private chatsStore;
15
19
  constructor(options: MiawClientOptions);
16
20
  /**
17
21
  * Connect to WhatsApp
@@ -29,6 +33,16 @@ export declare class MiawClient extends EventEmitter {
29
33
  * Update LID to JID mapping from contacts
30
34
  */
31
35
  private updateLidToJidMapping;
36
+ /**
37
+ * Update in-memory contacts store (v0.9.0)
38
+ * @param contacts - Array of contact objects from Baileys
39
+ */
40
+ private updateContactsStore;
41
+ /**
42
+ * Update in-memory chats store (v0.9.0)
43
+ * @param chats - Array of chat objects from Baileys
44
+ */
45
+ private updateChatsStore;
32
46
  /**
33
47
  * Update LID to JID mapping from chat data
34
48
  */
@@ -65,6 +79,13 @@ export declare class MiawClient extends EventEmitter {
65
79
  * Clear LID cache
66
80
  */
67
81
  clearLidCache(): void;
82
+ /**
83
+ * Clear session data for this instance.
84
+ * This will delete all stored authentication credentials.
85
+ * After calling this, the next connect() will require scanning a new QR code.
86
+ * @returns true if session was cleared, false if no session existed
87
+ */
88
+ clearSession(): boolean;
68
89
  /**
69
90
  * Dispose client and clean up resources
70
91
  */
@@ -154,6 +175,48 @@ export declare class MiawClient extends EventEmitter {
154
175
  * @returns Profile picture URL or null if not available
155
176
  */
156
177
  getProfilePicture(jidOrPhone: string, highRes?: boolean): Promise<string | null>;
178
+ /**
179
+ * Fetch all contacts from the in-memory store
180
+ * Note: Contacts are populated via history sync and contact events
181
+ * @returns FetchAllContactsResult with list of contacts
182
+ */
183
+ fetchAllContacts(): Promise<FetchAllContactsResult>;
184
+ /**
185
+ * Fetch all groups the user is participating in
186
+ * @returns FetchAllGroupsResult with list of groups
187
+ */
188
+ fetchAllGroups(): Promise<FetchAllGroupsResult>;
189
+ /**
190
+ * Get own profile information
191
+ * @returns OwnProfile or null if not available
192
+ */
193
+ getOwnProfile(): Promise<OwnProfile | null>;
194
+ /**
195
+ * Sync labels from WhatsApp app state
196
+ * This triggers a resync of the 'regular' collection which contains labels
197
+ * Labels will be emitted via labels.edit events and stored in labelsStore
198
+ */
199
+ private syncLabelsFromAppState;
200
+ /**
201
+ * Fetch all labels from the in-memory store
202
+ * Note: Labels are populated via history sync and label events
203
+ * @param forceSync - If true, force a resync from WhatsApp before returning labels
204
+ * @returns FetchAllLabelsResult with list of labels
205
+ */
206
+ fetchAllLabels(forceSync?: boolean): Promise<FetchAllLabelsResult>;
207
+ /**
208
+ * Get chat messages from the in-memory store
209
+ * Note: Messages are populated via messages.upsert events
210
+ * @param jidOrPhone - Chat JID or phone number
211
+ * @returns FetchChatMessagesResult with list of messages
212
+ */
213
+ getChatMessages(jidOrPhone: string): Promise<FetchChatMessagesResult>;
214
+ /**
215
+ * Fetch all chats from the in-memory store
216
+ * Note: Chats are populated via history sync and chat events
217
+ * @returns FetchAllChatsResult with list of chats
218
+ */
219
+ fetchAllChats(): Promise<FetchAllChatsResult>;
157
220
  /**
158
221
  * Get group metadata/information
159
222
  * @param groupJid - Group JID (e.g., '123456789@g.us')
@@ -398,7 +461,7 @@ export declare class MiawClient extends EventEmitter {
398
461
  * @param limit - Maximum number of products to fetch (default: 10)
399
462
  * @param cursor - Pagination cursor for fetching next page
400
463
  * @returns ProductCatalog
401
- * @note Requires WhatsApp Business account
464
+ * @note Requires WhatsApp Business account with catalog configured
402
465
  */
403
466
  getCatalog(businessJidOrPhone?: string, limit?: number, cursor?: string): Promise<ProductCatalog>;
404
467
  /**
@@ -406,22 +469,23 @@ export declare class MiawClient extends EventEmitter {
406
469
  * @param businessJidOrPhone - Business JID or phone number (default: your own collections)
407
470
  * @param limit - Maximum number of collections to fetch (default: 51)
408
471
  * @returns Array of ProductCollection
409
- * @note Requires WhatsApp Business account
472
+ * @note Requires WhatsApp Business account with collections created via the catalog API.
473
+ * Collections created in the WhatsApp Business app may not appear here.
410
474
  */
411
475
  getCollections(businessJidOrPhone?: string, limit?: number): Promise<ProductCollection[]>;
412
476
  /**
413
477
  * Create a new product in the catalog
414
- * @param options - Product options (name, price, images, etc.)
478
+ * @param options - Product options (name, price, currency, images, etc.)
415
479
  * @returns ProductOperationResult with product ID
416
- * @note Requires WhatsApp Business account
480
+ * @note Requires WhatsApp Business account with catalog enabled
417
481
  */
418
482
  createProduct(options: ProductOptions): Promise<ProductOperationResult>;
419
483
  /**
420
484
  * Update an existing product in the catalog
421
485
  * @param productId - Product ID to update
422
- * @param options - Product options (name, price, images, etc.)
486
+ * @param options - Product options (name, price, currency, images, etc.)
423
487
  * @returns ProductOperationResult
424
- * @note Requires WhatsApp Business account
488
+ * @note Requires WhatsApp Business account with catalog enabled
425
489
  */
426
490
  updateProduct(productId: string, options: ProductOptions): Promise<ProductOperationResult>;
427
491
  /**
@@ -431,6 +495,32 @@ export declare class MiawClient extends EventEmitter {
431
495
  * @note Requires WhatsApp Business account
432
496
  */
433
497
  deleteProducts(productIds: string[]): Promise<ProductOperationResult>;
498
+ /**
499
+ * Send a text message to a newsletter/channel
500
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
501
+ * @param text - Message text content
502
+ * @returns SendMessageResult
503
+ * @note You must be an admin/owner of the newsletter to send messages
504
+ */
505
+ sendNewsletterMessage(newsletterId: string, text: string): Promise<SendMessageResult>;
506
+ /**
507
+ * Send an image to a newsletter/channel
508
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
509
+ * @param image - Image source (file path, URL, or Buffer)
510
+ * @param caption - Optional caption
511
+ * @returns SendMessageResult
512
+ * @note You must be an admin/owner of the newsletter to send messages
513
+ */
514
+ sendNewsletterImage(newsletterId: string, image: MediaSource, caption?: string): Promise<SendMessageResult>;
515
+ /**
516
+ * Send a video to a newsletter/channel
517
+ * @param newsletterId - Newsletter JID (e.g., '1234567890@newsletter')
518
+ * @param video - Video source (file path, URL, or Buffer)
519
+ * @param caption - Optional caption
520
+ * @returns SendMessageResult
521
+ * @note You must be an admin/owner of the newsletter to send messages
522
+ */
523
+ sendNewsletterVideo(newsletterId: string, video: MediaSource, caption?: string): Promise<SendMessageResult>;
434
524
  /**
435
525
  * Create a new newsletter/channel
436
526
  * @param name - Newsletter name
@@ -571,9 +661,16 @@ export declare class MiawClient extends EventEmitter {
571
661
  */
572
662
  private getMimetypeFromFileName;
573
663
  /**
574
- * Disconnect from WhatsApp
664
+ * Disconnect from WhatsApp without logging out.
665
+ * The session is preserved and can be used to reconnect later without scanning QR again.
666
+ * Use logout() if you want to fully log out and require a new QR code.
575
667
  */
576
668
  disconnect(): Promise<void>;
669
+ /**
670
+ * Logout from WhatsApp and clear session.
671
+ * After calling this, the next connect() will require scanning a new QR code.
672
+ */
673
+ logout(): Promise<void>;
577
674
  /**
578
675
  * Get current connection state
579
676
  */