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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,305 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.9.0] - 2025-12-24
9
+
10
+ ### Added
11
+
12
+ #### Label Operations (WhatsApp Business only)
13
+ - `addLabel()` - Create or edit labels
14
+ - `addChatLabel()` - Add a label to a chat
15
+ - `removeChatLabel()` - Remove a label from a chat
16
+ - `addMessageLabel()` - Add a label to a message
17
+ - `removeMessageLabel()` - Remove a label from a message
18
+ - `LabelColor` enum - 20 predefined colors
19
+ - `PredefinedLabelId` enum - 5 WhatsApp predefined labels
20
+ - `Label`, `LabelOperationResult` types
21
+
22
+ #### Catalog/Product Operations (WhatsApp Business only)
23
+ - `getCatalog()` - Fetch product catalog with pagination support
24
+ - `getCollections()` - Fetch catalog collections
25
+ - `createProduct()` - Add new products to catalog
26
+ - `updateProduct()` - Modify existing products
27
+ - `deleteProducts()` - Remove products from catalog
28
+ - `Product`, `ProductCollection`, `ProductCatalog`, `ProductOperationResult`, `ProductOptions` types
29
+
30
+ #### Newsletter/Channel Operations
31
+ - `createNewsletter()` - Create WhatsApp channels/newsletters
32
+ - `getNewsletterMetadata()` - Get newsletter information
33
+ - `followNewsletter()` - Follow/subscribe to newsletters
34
+ - `unfollowNewsletter()` - Unsubscribe from newsletters
35
+ - `muteNewsletter()` - Mute newsletter notifications
36
+ - `unmuteNewsletter()` - Unmute newsletter notifications
37
+ - `updateNewsletterName()` - Update newsletter name
38
+ - `updateNewsletterDescription()` - Update newsletter description
39
+ - `updateNewsletterPicture()` - Update newsletter cover image
40
+ - `removeNewsletterPicture()` - Remove newsletter cover image
41
+ - `reactToNewsletterMessage()` - React to newsletter posts
42
+ - `fetchNewsletterMessages()` - Get newsletter message history
43
+ - `subscribeNewsletterUpdates()` - Subscribe to live newsletter updates
44
+ - `getNewsletterSubscribers()` - Get subscriber count
45
+ - `getNewsletterAdminCount()` - Get admin count
46
+ - `changeNewsletterOwner()` - Transfer newsletter ownership
47
+ - `demoteNewsletterAdmin()` - Demote a newsletter admin
48
+ - `deleteNewsletter()` - Delete a newsletter
49
+ - `NewsletterMetadata`, `NewsletterMessage`, `NewsletterMessagesResult`, `NewsletterOperationResult`, `NewsletterSubscriptionInfo` types
50
+
51
+ #### Contact Management
52
+ - `addOrEditContact()` - Add or update contacts
53
+ - `removeContact()` - Remove contacts
54
+ - `ContactData`, `ContactOperationResult` types
55
+
56
+ #### Tests
57
+ - Integration tests for all v0.9.0 features (`12-business-features.test.ts`, `13-newsletter-features.test.ts`)
58
+
59
+ ## [0.8.0] - 2025-12-21
60
+
61
+ ### Added
62
+
63
+ - **Profile Picture Management**
64
+ - `updateProfilePicture()` - Update your own profile picture (file path, URL, or Buffer)
65
+ - `removeProfilePicture()` - Remove your profile picture
66
+
67
+ - **Profile Information**
68
+ - `updateProfileName()` - Update your display name (push name)
69
+ - `updateProfileStatus()` - Update your "About" text
70
+
71
+ - **New Types**
72
+ - `ProfileOperationResult` - Result type for profile operations (success/error)
73
+
74
+ - **Integration Tests**
75
+ - Profile management tests for all v0.8.0 features
76
+
77
+ ## [0.7.0] - 2025-12-21
78
+
79
+ ### Added
80
+
81
+ - **Group Creation**
82
+ - `createGroup()` - Create new WhatsApp groups with initial participants
83
+ - Returns `CreateGroupResult` with group JID and metadata
84
+
85
+ - **Participant Management**
86
+ - `addParticipants()` - Add members to a group (requires admin)
87
+ - `removeParticipants()` - Remove members from a group (requires admin)
88
+ - `leaveGroup()` - Leave a group
89
+ - Returns `ParticipantOperationResult[]` with status for each participant
90
+
91
+ - **Admin Management**
92
+ - `promoteToAdmin()` - Promote members to group admin
93
+ - `demoteFromAdmin()` - Demote admins to regular members
94
+
95
+ - **Group Settings**
96
+ - `updateGroupName()` - Change group name/subject
97
+ - `updateGroupDescription()` - Set or clear group description
98
+ - `updateGroupPicture()` - Change group profile picture
99
+
100
+ - **Group Invites**
101
+ - `getGroupInviteLink()` - Get group invite link (https://chat.whatsapp.com/...)
102
+ - `revokeGroupInvite()` - Revoke current link and get new one
103
+ - `acceptGroupInvite()` - Join group via invite code or URL
104
+ - `getGroupInviteInfo()` - Preview group info before joining
105
+
106
+ - **New Types**
107
+ - `ParticipantOperationResult` - Result of add/remove/promote/demote operations
108
+ - `CreateGroupResult` - Result of group creation with metadata
109
+ - `GroupOperationResult` - Generic success/error result for group operations
110
+ - `GroupInviteInfo` - Group preview info from invite code
111
+
112
+ - **Integration Tests**
113
+ - Group management tests for all v0.7.0 features
114
+
115
+ ## [0.6.0] - 2025-12-14
116
+
117
+ ### Added
118
+
119
+ - **Send Reactions**
120
+ - `sendReaction()` - Send emoji reactions to messages (e.g., '❤️', '👍')
121
+ - `removeReaction()` - Remove your reaction from a message
122
+
123
+ - **Forward Messages**
124
+ - `forwardMessage()` - Forward any message to another chat
125
+
126
+ - **Edit Messages**
127
+ - `editMessage()` - Edit your own messages (within WhatsApp's 15-minute window)
128
+
129
+ - **Delete Messages**
130
+ - `deleteMessage()` - Delete messages for everyone (your own messages)
131
+ - `deleteMessageForMe()` - Delete messages locally (only for yourself)
132
+
133
+ ## [0.5.0] - 2025-12-14
134
+
135
+ ### Added
136
+
137
+ - **Read Receipts**
138
+ - `markAsRead()` - Mark messages as read (send read receipt)
139
+ - Returns boolean indicating success
140
+
141
+ - **Typing & Recording Indicators**
142
+ - `sendTyping()` - Send "typing..." indicator to a chat
143
+ - `sendRecording()` - Send "recording audio..." indicator
144
+ - `stopTyping()` - Stop typing/recording indicator (send paused state)
145
+ - Works with both individual contacts and groups
146
+
147
+ - **Presence Management**
148
+ - `setPresence()` - Set bot's online/offline status ('available' or 'unavailable')
149
+ - `subscribePresence()` - Subscribe to contact's presence updates
150
+ - `presence` event - Emitted when subscribed contact's presence changes
151
+
152
+ - **New Types**
153
+ - `PresenceStatus` - Union type for 'available' | 'unavailable'
154
+ - `PresenceUpdate` - Presence notification data (jid, status, lastSeen)
155
+
156
+ - **Integration Tests**
157
+ - UX polish tests for all v0.5.0 features
158
+
159
+ ## [0.4.0] - 2025-12-14
160
+
161
+ ### Added
162
+
163
+ - **Contact Validation**
164
+ - `checkNumber()` - Verify if phone number is on WhatsApp
165
+ - `checkNumbers()` - Batch check multiple phone numbers
166
+ - Returns `CheckNumberResult` with exists flag and JID
167
+
168
+ - **Contact Information**
169
+ - `getContactInfo()` - Fetch contact info including status
170
+ - `getBusinessProfile()` - Get business account profile details
171
+ - `getProfilePicture()` - Get profile picture URL (supports low/high res)
172
+
173
+ - **Group Information**
174
+ - `getGroupInfo()` - Fetch group metadata (name, description, settings)
175
+ - `getGroupParticipants()` - List all group members with roles
176
+
177
+ - **New Types**
178
+ - `CheckNumberResult` - Result of number validation
179
+ - `ContactInfo` - Contact information structure
180
+ - `BusinessProfile` - Business profile data
181
+ - `GroupInfo` - Group metadata
182
+ - `GroupParticipant` - Group member with role
183
+
184
+ - **Integration Tests**
185
+ - Contact validation tests
186
+ - Group info tests
187
+
188
+ ## [0.3.0] - 2025-12-14
189
+
190
+ ### Added
191
+
192
+ - **Reply to Messages (Quoted)**
193
+ - All send methods now support `quoted` option
194
+ - Pass `MiawMessage` to reply to specific messages
195
+ - Works with `sendText()`, `sendImage()`, `sendDocument()`, `sendVideo()`, `sendAudio()`
196
+
197
+ - **Edit Notifications**
198
+ - `message_edit` event when messages are edited
199
+ - `MessageEdit` type with messageId, chatId, newText, editTimestamp
200
+
201
+ - **Delete Notifications**
202
+ - `message_delete` event when messages are deleted/revoked
203
+ - `MessageDelete` type with messageId, chatId, fromMe, participant
204
+
205
+ - **Reactions**
206
+ - `message_reaction` event when messages receive reactions
207
+ - `MessageReaction` type with messageId, chatId, reactorId, emoji, isRemoval
208
+
209
+ - **New Types**
210
+ - `MessageEdit` - Edit notification data
211
+ - `MessageDelete` - Delete notification data
212
+ - `MessageReaction` - Reaction notification data
213
+
214
+ - **Integration Tests**
215
+ - Message context tests for all v0.3.0 features
216
+
217
+ ### Changed
218
+
219
+ - `SendTextOptions.quoted` now accepts `MiawMessage` instead of string
220
+ - `SendImageOptions.quoted`, `SendDocumentOptions.quoted`, `SendVideoOptions.quoted`, `SendAudioOptions.quoted` now accept `MiawMessage`
221
+
222
+ ## [0.2.0] - 2025-12-14
223
+
224
+ ### Added
225
+
226
+ - **Media Sending Methods**
227
+ - `sendImage()` - Send images with caption and view-once support
228
+ - `sendDocument()` - Send documents with auto-mimetype detection
229
+ - `sendVideo()` - Send videos with caption, GIF playback, and PTV (video notes)
230
+ - `sendAudio()` - Send audio with PTT (voice notes) support
231
+
232
+ - **Media Download**
233
+ - `downloadMedia()` - Download media from received messages as Buffer
234
+
235
+ - **Media Metadata**
236
+ - `MediaInfo` type with full metadata extraction
237
+ - Support for mimetype, fileSize, dimensions, duration
238
+ - PTT detection for voice notes
239
+ - GIF playback detection for videos
240
+ - View-once message detection
241
+
242
+ - **New Types**
243
+ - `MediaSource` - Flexible input type (path/URL/Buffer)
244
+ - `SendImageOptions`, `SendDocumentOptions`, `SendVideoOptions`, `SendAudioOptions`
245
+ - `MediaInfo` - Media metadata interface
246
+
247
+ - **Integration Tests**
248
+ - Media sending tests for all media types
249
+ - Media download tests
250
+
251
+ ### Changed
252
+
253
+ - Enhanced `MessageHandler.normalize()` with media metadata extraction
254
+ - `MiawMessage` now includes optional `media` field for metadata
255
+
256
+ ### Removed
257
+
258
+ - Removed unused `SessionStorage` utility (`src/utils/storage.ts`)
259
+
260
+ ## [0.1.0] - 2025-11-19
261
+
262
+ ### Added
263
+
264
+ - **Core Client**
265
+ - `MiawClient` class with event-driven architecture
266
+ - Connection management with auto-reconnection
267
+ - Session persistence using Baileys multi-file auth state
268
+ - Multiple instance support with isolated sessions
269
+
270
+ - **Messaging**
271
+ - `sendText()` - Send text messages to individuals and groups
272
+ - Message normalization with `MiawMessage` format
273
+ - Support for @s.whatsapp.net, @lid, @g.us JID formats
274
+
275
+ - **LID Support**
276
+ - Handle WhatsApp's @lid privacy format
277
+ - LID to phone number mapping
278
+ - `resolveLidToJid()`, `getPhoneFromJid()`, `registerLidMapping()`
279
+
280
+ - **Events**
281
+ - `qr` - QR code for authentication
282
+ - `ready` - Client connected and ready
283
+ - `message` - Incoming message received
284
+ - `disconnected` - Client disconnected
285
+ - `reconnecting` - Reconnection attempt
286
+ - `error` - Error occurred
287
+ - `session_saved` - Session persisted
288
+
289
+ - **Developer Experience**
290
+ - Full TypeScript support with strict mode
291
+ - Comprehensive type definitions
292
+ - Debug logging option
293
+
294
+ ### Dependencies
295
+
296
+ - @whiskeysockets/baileys ^6.7.21
297
+ - @hapi/boom ^10.0.1
298
+ - pino ^8.19.0
299
+
300
+ [0.6.0]: https://github.com/biji-dev/miaw-core/compare/v0.5.0...v0.6.0
301
+ [0.5.0]: https://github.com/biji-dev/miaw-core/compare/v0.4.0...v0.5.0
302
+ [0.4.0]: https://github.com/biji-dev/miaw-core/compare/v0.3.0...v0.4.0
303
+ [0.3.0]: https://github.com/biji-dev/miaw-core/compare/v0.2.0...v0.3.0
304
+ [0.2.0]: https://github.com/biji-dev/miaw-core/compare/v0.1.0...v0.2.0
305
+ [0.1.0]: https://github.com/biji-dev/miaw-core/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Miaw Core Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # Miaw Core
2
+
3
+ **Multiple Instance of App WhatsApp** - A simplified WhatsApp API wrapper for Baileys
4
+
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
+
7
+ ## Documentation
8
+
9
+ - **[Usage Guide](./USAGE.md)** - Complete guide for all current features
10
+ - **[Roadmap](./ROADMAP.md)** - Feature roadmap and development plan
11
+ - **[Examples](./examples/)** - Code examples and sample bots
12
+
13
+ ## Features
14
+
15
+ - **Simple API** - Clean, intuitive interface for sending and receiving messages
16
+ - **Auto-Reconnection** - Handles connection drops and reconnects automatically
17
+ - **Session Management** - File-based session storage with automatic persistence
18
+ - **Multiple Instances** - Run multiple WhatsApp connections in a single process
19
+ - **TypeScript Support** - Full type definitions for excellent IDE experience
20
+ - **Event-Driven** - Easy-to-use event system for messages and connection states
21
+ - **Normalized Messages** - Simplified message format, no more complex Baileys structures
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install miaw-core
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```typescript
32
+ import { MiawClient } from "miaw-core";
33
+
34
+ // Create client
35
+ const client = new MiawClient({
36
+ instanceId: "my-bot",
37
+ sessionPath: "./sessions",
38
+ });
39
+
40
+ // Handle QR code
41
+ client.on("qr", (qr) => {
42
+ console.log("Scan this QR code:", qr);
43
+ });
44
+
45
+ // When ready
46
+ client.on("ready", () => {
47
+ console.log("Bot is ready!");
48
+ });
49
+
50
+ // Receive messages
51
+ client.on("message", async (message) => {
52
+ console.log("Received:", message.text);
53
+
54
+ // Reply
55
+ await client.sendText(message.from, "Hello!");
56
+ });
57
+
58
+ // Start
59
+ await client.connect();
60
+ ```
61
+
62
+ For more examples and detailed usage, see the [Usage Guide](./USAGE.md).
63
+
64
+ ## Current Capabilities (v0.1.0)
65
+
66
+ - ✅ Send and receive text messages
67
+ - ✅ QR code authentication
68
+ - ✅ Session persistence
69
+ - ✅ Auto-reconnection
70
+ - ✅ Multiple instances
71
+ - ✅ Event-driven architecture
72
+ - ✅ TypeScript support
73
+ - ✅ Error handling
74
+
75
+ See [ROADMAP.md](./ROADMAP.md) for planned features.
76
+
77
+ ## What Miaw Core Abstracts
78
+
79
+ Miaw Core handles these Baileys complexities for you:
80
+
81
+ - ✅ QR code generation and handling
82
+ - ✅ Auth state management (save/load)
83
+ - ✅ Socket connection setup
84
+ - ✅ Reconnection logic
85
+ - ✅ Message event parsing
86
+ - ✅ Connection state tracking
87
+ - ✅ Credentials persistence
88
+ - ✅ Multi-file auth state
89
+ - ✅ Baileys version management
90
+ - ✅ Signal key store setup
91
+
92
+ ## Project Structure
93
+
94
+ ```text
95
+ miaw-core/
96
+ ├── src/
97
+ │ ├── client/ # Main MiawClient class
98
+ │ ├── handlers/ # Auth and message handlers
99
+ │ ├── types/ # TypeScript definitions
100
+ │ ├── utils/ # Storage utilities
101
+ │ └── index.ts # Public API exports
102
+ ├── examples/ # Usage examples
103
+ ├── USAGE.md # Complete usage guide
104
+ ├── ROADMAP.md # Feature roadmap
105
+ └── README.md # This file
106
+ ```
107
+
108
+ ## Contributing
109
+
110
+ Contributions are welcome! To contribute:
111
+
112
+ 1. Check [ROADMAP.md](./ROADMAP.md) for planned features
113
+ 2. Open an issue to discuss your idea
114
+ 3. Fork the repository
115
+ 4. Create a feature branch
116
+ 5. Submit a pull request
117
+
118
+ Please include:
119
+
120
+ - Tests for new features
121
+ - Updated documentation
122
+ - Examples if applicable
123
+
124
+ ## License
125
+
126
+ MIT
127
+
128
+ ## Credits
129
+
130
+ Built on top of [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys)
131
+
132
+ ---
133
+
134
+ **Version:** 0.1.0 | **Status:** Active Development | **Updated:** 2025-11-19