@open-wa/schema 5.0.0-alpha.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 (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE.md +67 -0
  3. package/README.md +19 -0
  4. package/client_migration_doc.md +467 -0
  5. package/codecs_and_params_plan.md +936 -0
  6. package/migration_plan_doc.md +223 -0
  7. package/package.json +90 -0
  8. package/scripts/gen-client-implementation.ts +129 -0
  9. package/scripts/gen-client-reference-docs.ts +621 -0
  10. package/scripts/gen-openapi.ts +96 -0
  11. package/scripts/gen-types.ts +43 -0
  12. package/scripts/verify-v5-pipeline.ts +85 -0
  13. package/src/__tests__/generators.contract.test.ts +181 -0
  14. package/src/__tests__/registry.contract.test.ts +81 -0
  15. package/src/client-config.ts +30 -0
  16. package/src/codecs.test.ts +41 -0
  17. package/src/codecs.ts +191 -0
  18. package/src/common-types.ts +280 -0
  19. package/src/config.ts +47 -0
  20. package/src/enums.ts +63 -0
  21. package/src/events/groups.ts +33 -0
  22. package/src/events/index.ts +4 -0
  23. package/src/events/messaging.ts +72 -0
  24. package/src/events/registry.ts +114 -0
  25. package/src/events/state.ts +59 -0
  26. package/src/generated/AliasMap.ts +214 -0
  27. package/src/generated/BaseClient.ts +868 -0
  28. package/src/generated/BaseNamespacedClient.ts +212 -0
  29. package/src/generated/index.ts +5 -0
  30. package/src/generated/openapi.json +7799 -0
  31. package/src/generated/types.ts +377 -0
  32. package/src/http-manifest.ts +97 -0
  33. package/src/implementor.test.ts +88 -0
  34. package/src/implementor.ts +75 -0
  35. package/src/index.ts +43 -0
  36. package/src/methods/business.ts +51 -0
  37. package/src/methods/chats.ts +263 -0
  38. package/src/methods/communities.ts +119 -0
  39. package/src/methods/contacts.ts +158 -0
  40. package/src/methods/groups.ts +376 -0
  41. package/src/methods/index.ts +33 -0
  42. package/src/methods/labels.ts +86 -0
  43. package/src/methods/media.ts +36 -0
  44. package/src/methods/messaging.ts +828 -0
  45. package/src/methods/session.ts +261 -0
  46. package/src/methods/status.ts +120 -0
  47. package/src/open-wa-utils.d.ts +4 -0
  48. package/src/parameters.ts +237 -0
  49. package/src/registry.test.ts +30 -0
  50. package/src/registry.ts +601 -0
  51. package/tsconfig.generated.json +11 -0
  52. package/tsconfig.json +15 -0
  53. package/tsdown.config.ts +16 -0
  54. package/vitest.config.ts +10 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @open-wa/schema
2
+
3
+ ## 6.0.0-alpha.2
4
+
5
+ ### Minor Changes
6
+
7
+ - Dry run minor bump
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @open-wa/config@6.0.0-alpha.2
13
+ - @open-wa/utils@6.0.0-alpha.2
14
+
15
+ ## 5.0.1-alpha.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Dry run patch bump
20
+
21
+ - Updated dependencies []:
22
+ - @open-wa/config@5.0.1-alpha.2
23
+ - @open-wa/utils@5.0.1-alpha.2
package/LICENSE.md ADDED
@@ -0,0 +1,67 @@
1
+ ### Copyright (c) 2020 Mohammed Shah
2
+
3
+ # Hippocratic + Do Not Harm (H-DNH) Version 1.1
4
+
5
+ ## Preamble
6
+
7
+ Most software today is developed with little to no thought of how it will be used, or the consequences for our society and planet.
8
+
9
+ As software developers, we engineer the infrastructure of the 21st century. We recognise that our infrastructure has great power to shape the world and the lives of those we share it with, and we choose to consciously take responsibility for the social and environmental impacts of what we build.
10
+
11
+ We envisage a world free from injustice, inequality, and the reckless destruction of lives and our planet. We reject slavery in all its forms, whether by force, indebtedness, or by algorithms that hack human vulnerabilities. We seek a world where humankind is at peace with our neighbours, nature, and ourselves. We want our work to enrich the physical, mental and spiritual wellbeing of all society.
12
+
13
+ We build software to further this vision of a just world, or at the very least, to not put that vision further from reach.
14
+
15
+ ## Terms
16
+
17
+ Licensor hereby grants permission by this license ("License"), free of charge, to any person or entity (the "Licensee") obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ 1. All redistribution of source code or binary form, including any modifications must be under these terms. You must inform recipients that the code is governed by these conditions, and how they can obtain a copy of this license. You may not attempt to alter the conditions of who may/may not use this software.
20
+
21
+ 2. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
22
+
23
+ 3. This software must not be used by any organisation, website, product or service that:
24
+
25
+ a) lobbies for, promotes, or derives a majority of income from actions that support or contribute to:
26
+ * sex trafficking
27
+ * human trafficking
28
+ * slavery
29
+ * indentured servitude
30
+ * gambling
31
+ * tobacco
32
+ * adversely addictive behaviours
33
+ * nuclear energy
34
+ * warfare
35
+ * weapons manufacturing
36
+ * war crimes
37
+ * settler colonialism
38
+ * apartheid
39
+ * vaccine misinformation
40
+ * climate misinformation
41
+ * child endangerment
42
+ * violence (except when required to protect public safety)
43
+ * burning of forests
44
+ * deforestation
45
+ * hate speech or discrimination based on age, gender, gender identity, race, sexuality, religion, nationality
46
+
47
+ b) lobbies against, or derives a majority of income from actions that discourage or frustrate:
48
+ * peace
49
+ * access to the rights set out in the Universal Declaration of Human Rights and the Convention on the Rights of the Child
50
+ * peaceful assembly and association (including worker associations)
51
+ * a safe environment or action to curtail the use of fossil fuels or prevent climate change
52
+ * democratic processes
53
+
54
+
55
+ 4. Compliance with Human Rights Laws and Human Rights Principles:
56
+
57
+ a. **Human Rights Laws**. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any applicable laws, regulations, or rules that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights (the "Human Rights Laws"). Where the Human Rights Laws of more than one jurisdiction are applicable to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
58
+
59
+ b. **Human Rights Principles**. Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights (https://www.un.org/en/universal-declaration-human-rights/) and the United Nations Global Compact (https://www.unglobalcompact.org/ what-is-gc/mission/principles) that define recognized principles of international human rights (the "Human Rights Principles"). It is Licensor's express intent that all use of the Software be consistent with Human Rights Principles. If Licensor receives notification or otherwise learns of an alleged violation of any Human Rights Principles relating to Licensee's use of the Software, Licensor may in its discretion and without obligation (i) (a) notify Licensee of such allegation and (b) allow Licensee 90 days from notification under (i)(a) to investigate and respond to Licensor regarding the allegation and (ii) (a) after the earlier of 90 days from notification under (i)(a), or Licensee's response under (i)(b), notify Licensee of License termination and (b) allow Licensee an additional 90 days from notification under (ii)(a) to cease use of the Software.
60
+
61
+ c. **Indemnity**. Licensee shall hold harmless and indemnify Licensor against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor's reasonable attorneys' fees, arising out of or relating to Licensee's non-compliance with this License or use of the Software in violation of Human Rights Laws or Human Rights Principles. 
62
+
63
+ 5. Enforceability: If any portion or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by applicable law, the court may modify this License to affect the original intent of the parties as closely as possible. The section headings are for convenience only and are not intended to affect the construction or interpretation of this License. Any rule of construction to the effect that ambiguities are to be resolved against the drafting party shall not apply in interpreting this License. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
64
+
65
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66
+
67
+ This license is an extension of the Hippocratic License - an Ethical Source license (https://ethicalsource.dev) and the Do Not Harm License - (https://github.com/raisely/NoHarm)
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @open-wa/schema
2
+
3
+ Zod-based schema definitions for open-wa
4
+
5
+ Part of the [@open-wa v5 monorepo](https://github.com/open-wa/wa-automate-nodejs).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @open-wa/schema
11
+ ```
12
+
13
+ ## Documentation
14
+
15
+ See the [docs site](https://docs.openwa.dev).
16
+
17
+ ## License
18
+
19
+ [H-DNH V1.0](https://github.com/open-wa/wa-automate-nodejs/blob/main/LICENSE.md) — Hippocratic + Do Not Harm
@@ -0,0 +1,467 @@
1
+ # Client Method Migration Checklist
2
+
3
+ This document provides a comprehensive TODO list for migrating all methods from `packages/core/src/api/Client.ts` to the new Schema V2 system in `packages/schema/src/methods/`.
4
+
5
+ ## 📊 Migration Progress Summary
6
+
7
+ **Category 1 (Standard Methods): ✅ 121/121 COMPLETE (100%)**
8
+ - ✅ Messaging: 29 methods
9
+ - ✅ Message Retrieval: 14 methods
10
+ - ✅ Chats: 18 methods
11
+ - ✅ Contacts: 10 methods
12
+ - ✅ Groups: 22 methods
13
+ - ✅ Communities: 6 methods
14
+ - ✅ Status/Stories: 7 methods
15
+ - ✅ Labels: 4 methods
16
+ - ✅ Business: 3 methods
17
+ - ✅ Utilities: 26 methods (excluding complex media/loader methods)
18
+
19
+ **Category 2 (Listeners): ⏳ 0/30 TODO**
20
+ - Requires new `defineListenerV2` pattern
21
+
22
+ **Category 3 (Complex Methods): ⏳ 0/40 TODO**
23
+ - Stickers, file transfers, media operations, etc.
24
+
25
+ **Total Progress: 121/191 methods (63%)**
26
+
27
+ ---
28
+
29
+ ## Implementation Categories
30
+
31
+ ### Category 1: Standard Methods (Use `defineMethodV2`)
32
+ Standard CRUD operations that map directly to WAPI calls. These use the standard `defineMethodV2` pattern with dual-mode support.
33
+
34
+ ### Category 2: Listeners (Requires New Pattern)
35
+ Event listeners that register callbacks. These need a special implementation pattern similar to `defineMethodV2` but for event registration.
36
+
37
+ ### Category 3: Complex Methods (Custom Implementation)
38
+ Methods with complex client-side logic, file processing, or multi-step operations. These use `defineMethodV2` with custom `implementation` parameter.
39
+
40
+ ---
41
+
42
+ ## 📨 Messaging Methods (Category 1) ✅ COMPLETE
43
+
44
+ ### Text Messages
45
+ - [x] `sendText` - ✅ **DONE**
46
+ - [x] `sendTextWithMentions` - ✅ **DONE**
47
+ - [x] `sendReplyWithMentions` - ✅ **DONE**
48
+ - [x] `sendPaymentRequest` - ✅ **DONE**
49
+
50
+ ### Rich Media Messages
51
+ - [x] `sendImage` - ✅ **DONE**
52
+ - [x] `sendFile` - ✅ **DONE**
53
+ - [x] `sendAudio` - ✅ **DONE**
54
+ - [x] `sendPtt` - ✅ **DONE**
55
+ - [x] `sendVideoAsGif` - ✅ **DONE**
56
+ - [x] `sendLocation` - ✅ **DONE**
57
+ - [x] `sendVCard` - ✅ **DONE**
58
+ - [x] `sendContact` - ✅ **DONE**
59
+ - [x] `sendMultipleContacts` - ✅ **DONE**
60
+
61
+ ### Interactive Messages
62
+ - [x] `sendButtons` - ✅ **DONE**
63
+ - [x] `sendAdvancedButtons` - ✅ **DONE**
64
+ - [x] `sendListMessage` - ✅ **DONE**
65
+ - [x] `sendPoll` - ✅ **DONE**
66
+ - [x] `sendBanner` - ✅ **DONE**
67
+
68
+ ### Link & Preview Messages
69
+ - [x] `sendYoutubeLink` - ✅ **DONE**
70
+ - [x] `sendLinkWithAutoPreview` - ✅ **DONE**
71
+ - [x] `sendMessageWithThumb` - ✅ **DONE**
72
+
73
+ ### Sticker Messages (Category 3 - Complex)
74
+ - [ ] `sendImageAsSticker` - Convert image to sticker
75
+ - [ ] `sendImageAsStickerAsReply` - Send image sticker as reply
76
+ - [ ] `sendMp4AsSticker` - Convert MP4 to animated sticker
77
+ - [ ] `sendRawWebpAsSticker` - Send raw WebP as sticker
78
+ - [ ] `sendRawWebpAsStickerAsReply` - Send raw WebP sticker as reply
79
+ - [ ] `sendStickerfromUrl` - Download and send sticker from URL
80
+ - [ ] `sendStickerfromUrlAsReply` - Download and send sticker as reply
81
+ - [ ] `sendGiphyAsSticker` - Convert Giphy to sticker
82
+ - [ ] `sendFavSticker` - Send favorite sticker
83
+ - [ ] `sendEmoji` - Send emoji reaction
84
+
85
+ ### File Transfer (Category 3 - Complex)
86
+ - [ ] `sendFileFromUrl` - Download file from URL and send
87
+ - [ ] `sendGiphy` - Download and send Giphy
88
+
89
+ ### Business/Product Messages
90
+ - [ ] `sendProduct` - Send product from catalog
91
+ - [ ] `sendImageWithProduct` - Send image with product
92
+ - [ ] `sendCustomProduct` - Send custom product
93
+
94
+ ---
95
+
96
+ ## 📥 Message Retrieval Methods (Category 1) ✅ COMPLETE
97
+
98
+ ### Get Messages
99
+ - [x] `getAllMessages` - ✅ **DONE**
100
+ - [x] `getMessageById` - ✅ **DONE**
101
+ - [x] `getMyLastMessage` - ✅ **DONE**
102
+ - [x] `getStarredMessages` - ✅ **DONE**
103
+ - [x] `getUnsentMessages` - ✅ **DONE**
104
+ - [x] `getMessageInfo` - ✅ **DONE**
105
+ - [x] `getVCards` - ✅ **DONE**
106
+ - [x] `getGptArray` - ✅ **DONE**
107
+
108
+ ### Message Operations
109
+ - [x] `deleteMessage` - ✅ **DONE**
110
+ - [x] `forwardMessages` - ✅ **DONE**
111
+ - [x] `starMessage` - ✅ **DONE**
112
+ - [x] `unstarMessage` - ✅ **DONE**
113
+ - [x] `react` - ✅ **DONE**
114
+ - [x] `sendSeen` - ✅ **DONE**
115
+
116
+ ---
117
+
118
+ ## 💬 Chat Methods (Category 1) ✅ COMPLETE
119
+
120
+ ### Get Chats
121
+ - [x] `getAllChats` - ✅ **DONE**
122
+ - [x] `getAllChatIds` - ✅ **DONE**
123
+ - [x] `getAllChatsWithMessages` - ✅ **DONE**
124
+ - [x] `getChatById` - ✅ **DONE**
125
+ - [x] `getChat` - ✅ **DONE**
126
+ - [x] `getChatsByLabel` - ✅ **DONE** (in labels.ts)
127
+ - [x] `getChatWithNonContacts` - ✅ **DONE**
128
+
129
+ ### Chat Operations
130
+ - [x] `archiveChat` - ✅ **DONE**
131
+ - [x] `unarchiveChat` - ✅ **DONE**
132
+ - [x] `clearChat` - ✅ **DONE**
133
+ - [x] `deleteChat` - ✅ **DONE**
134
+ - [x] `pinChat` - ✅ **DONE**
135
+ - [x] `unpinChat` - ✅ **DONE**
136
+ - [x] `muteChat` - ✅ **DONE**
137
+ - [x] `unmuteChat` - ✅ **DONE**
138
+ - [x] `markAsRead` - ✅ **DONE**
139
+ - [x] `markAsUnread` - ✅ **DONE**
140
+ - [x] `setChatEphemeral` - ✅ **DONE**
141
+ - [x] `isChatOnline` - ✅ **DONE**
142
+
143
+ ---
144
+
145
+ ## 👥 Contact Methods (Category 1) ✅ COMPLETE
146
+
147
+ ### Get Contacts
148
+ - [x] `getAllContacts` - ✅ **DONE**
149
+ - [x] `getContact` - ✅ **DONE**
150
+ - [x] `getCommonGroups` - ✅ **DONE**
151
+ - [x] `getNumberProfile` - ✅ **DONE**
152
+ - [x] `getBlockedIds` - ✅ **DONE**
153
+
154
+ ### Contact Operations
155
+ - [x] `contactBlock` - ✅ **DONE**
156
+ - [x] `contactUnblock` - ✅ **DONE**
157
+ - [x] `checkReadReceipts` - ✅ **DONE**
158
+ - [x] `checkNumberStatus` - ✅ **DONE**
159
+ - [x] `getProfilePicFromServer` - ✅ **DONE**
160
+
161
+ ---
162
+
163
+ ## 👨‍👩‍👧‍👦 Group Methods (Category 1) ✅ COMPLETE
164
+
165
+ ### Get Groups
166
+ - [x] `getAllGroups` - ✅ **DONE**
167
+ - [x] `getGroupMembers` - ✅ **DONE**
168
+ - [x] `getGroupMembersId` - ✅ **DONE**
169
+ - [x] `getGroupInfo` - ✅ **DONE**
170
+ - [x] `getGroupAdmins` - ✅ **DONE**
171
+ - [x] `getKickedGroups` - ✅ **DONE**
172
+ - [x] `getGroupInviteLink` - ✅ **DONE**
173
+
174
+ ### Group Operations
175
+ - [x] `createGroup` - ✅ **DONE**
176
+ - [x] `leaveGroup` - ✅ **DONE**
177
+ - [x] `joinGroupViaLink` - ✅ **DONE**
178
+ - [x] `revokeGroupInviteLink` - ✅ **DONE**
179
+ - [x] `setGroupTitle` - ✅ **DONE**
180
+ - [x] `setGroupDescription` - ✅ **DONE**
181
+ - [x] `setGroupIcon` - ✅ **DONE**
182
+ - [x] `setGroupToAdminsOnly` - ✅ **DONE**
183
+ - [x] `setGroupEditToAdminsOnly` - ✅ **DONE**
184
+
185
+ ### Group Participant Operations
186
+ - [x] `addParticipant` - ✅ **DONE**
187
+ - [x] `removeParticipant` - ✅ **DONE**
188
+ - [x] `promoteParticipant` - ✅ **DONE**
189
+ - [x] `demoteParticipant` - ✅ **DONE**
190
+ - [x] `approveGroupJoinRequest` - ✅ **DONE**
191
+ - [x] `rejectGroupJoinRequest` - ✅ **DONE**
192
+
193
+ ---
194
+
195
+ ## 🏘️ Community Methods (Category 1) ✅ COMPLETE
196
+
197
+ - [x] `getAllCommunities` - ✅ **DONE**
198
+ - [x] `getCommunityInfo` - ✅ **DONE**
199
+ - [x] `getCommunityParticipantIds` - ✅ **DONE**
200
+ - [x] `getCommunityAdminIds` - ✅ **DONE**
201
+ - [x] `getCommunityParticipants` - ✅ **DONE**
202
+ - [x] `getCommunityAdmins` - ✅ **DONE**
203
+
204
+ ---
205
+
206
+ ## 📖 Status/Story Methods (Category 1) ✅ COMPLETE
207
+
208
+ - [x] `postTextStatus` - ✅ **DONE**
209
+ - [x] `postImageStatus` - ✅ **DONE**
210
+ - [x] `postVideoStatus` - ✅ **DONE**
211
+ - [x] `getStories` - ✅ **DONE**
212
+ - [x] `getStatus` - ✅ **DONE**
213
+ - [x] `deleteStatus` - ✅ **DONE**
214
+ - [x] `deleteAllStatus` - ✅ **DONE**
215
+
216
+ ---
217
+
218
+ ## 🏷️ Label Methods (Category 1) ✅ COMPLETE
219
+
220
+ - [x] `getAllLabels` - ✅ **DONE**
221
+ - [x] `getChatsByLabel` - ✅ **DONE**
222
+ - [x] `addLabel` - ✅ **DONE**
223
+ - [x] `removeLabel` - ✅ **DONE**
224
+
225
+ ---
226
+
227
+ ## 💼 Business Methods (Category 1) ✅ COMPLETE
228
+
229
+ - [x] `getBusinessProfile` - ✅ **DONE**
230
+ - [x] `getBusinessProfilesProducts` - ✅ **DONE**
231
+ - [x] `getOrder` - ✅ **DONE**
232
+
233
+ ---
234
+
235
+ ## 🔧 Utility Methods (Category 1) ✅ COMPLETE
236
+
237
+ ### Session Info
238
+ - [x] `getMe` - ✅ **DONE**
239
+ - [x] `getHostNumber` - ✅ **DONE**
240
+ - [x] `getSessionInfo` - ✅ **DONE** (via getMe)
241
+ - [x] `getConnectionState` - ✅ **DONE**
242
+ - [x] `getWAVersion` - ✅ **DONE**
243
+ - [x] `getBatteryLevel` - ✅ **DONE**
244
+ - [x] `getIsPlugged` - ✅ **DONE**
245
+
246
+ ### Configuration
247
+ - [x] `getConfig` - ✅ **DONE** (via getMe)
248
+ - [x] `getFeatures` - ✅ **DONE**
249
+ - [x] `getLicenseType` - ✅ **DONE**
250
+ - [x] `getLicenseLink` - ✅ **DONE** (via getLicenseType)
251
+ - [x] `getGeneratedUserAgent` - ✅ **DONE**
252
+
253
+ ### Diagnostics
254
+ - [x] `getProcessStats` - ✅ **DONE**
255
+ - [x] `getAmountOfLoadedMessages` - ✅ **DONE**
256
+ - [x] `getLastMsgTimestamps` - ✅ **DONE** (via getAmountOfLoadedMessages)
257
+ - [x] `getSnapshot` - ✅ **DONE**
258
+ - [x] `healthCheck` - ✅ **DONE**
259
+
260
+ ### Media Operations
261
+ - [ ] `decryptMedia` - **TODO** (Category 3 - Complex)
262
+ - [ ] `downloadMedia` - **TODO** (Category 3 - Complex)
263
+ - [ ] `getStickerDecryptable` - **TODO** (Category 3 - Complex)
264
+ - [ ] `forceStaleMediaUpdate` - **TODO** (Category 3 - Complex)
265
+
266
+ ### Profile Operations
267
+ - [x] `setMyName` - ✅ **DONE**
268
+ - [x] `setMyStatus` - ✅ **DONE**
269
+ - [x] `setProfilePic` - ✅ **DONE**
270
+
271
+ ### Misc
272
+ - [ ] `loadEarlierMessages` - **TODO** (Category 3 - Complex)
273
+ - [ ] `loadAllEarlierMessages` - **TODO** (Category 3 - Complex)
274
+ - [ ] `loadEarlierMessagesTillDate` - **TODO** (Category 3 - Complex)
275
+ - [ ] `favSticker` - **TODO** (Category 3 - Complex)
276
+ - [ ] `getFavStickers` - **TODO** (Category 3 - Complex)
277
+
278
+ ---
279
+
280
+ ## 🎧 Listener Methods (Category 2 - Requires New Pattern)
281
+
282
+ ### Message Listeners
283
+ - [ ] `onMessage` - Listen for new messages
284
+ - [ ] `onAnyMessage` - Listen for any message (including own)
285
+ - [ ] `onMessageDeleted` - Listen for deleted messages
286
+ - [ ] `onAck` - Listen for message acknowledgments
287
+ - [ ] `onButton` - Listen for button responses
288
+ - [ ] `onPollVote` - Listen for poll votes
289
+ - [ ] `onBroadcast` - Listen for broadcast messages
290
+ - [ ] `onReaction` - Listen for reactions
291
+
292
+ ### Chat Listeners
293
+ - [ ] `onChatState` - Listen for typing/recording state
294
+ - [ ] `onChatDeleted` - Listen for deleted chats
295
+ - [ ] `onChatOpened` - Listen for opened chats
296
+
297
+ ### Group Listeners
298
+ - [ ] `onAddedToGroup` - Listen for being added to group
299
+ - [ ] `onRemovedFromGroup` - Listen for being removed from group
300
+ - [ ] `onGlobalParticipantsChanged` - Listen for any participant change
301
+ - [ ] `onParticipantsChanged` - Listen for specific group participant changes
302
+ - [ ] `onGroupApprovalRequest` - Listen for group join requests
303
+ - [ ] `onGroupChange` - Listen for group metadata changes
304
+
305
+ ### Contact Listeners
306
+ - [ ] `onContactAdded` - Listen for new contacts
307
+
308
+ ### Status Listeners
309
+ - [ ] `onStory` - Listen for new stories
310
+
311
+ ### Call Listeners
312
+ - [ ] `onIncomingCall` - Listen for incoming calls
313
+ - [ ] `onCallState` - Listen for call state changes
314
+
315
+ ### System Listeners
316
+ - [ ] `onStateChanged` - Listen for connection state changes
317
+ - [ ] `onBattery` - Listen for battery changes
318
+ - [ ] `onPlugged` - Listen for charging state changes
319
+ - [ ] `onLogout` - Listen for logout events
320
+ - [ ] `onLabel` - Listen for label changes
321
+ - [ ] `onOrder` - Listen for orders
322
+ - [ ] `onNewProduct` - Listen for new products
323
+ - [ ] `onLiveLocation` - Listen for live location updates
324
+
325
+ ### Listener Management
326
+ - [ ] `removeListener` - Remove specific listener
327
+ - [ ] `removeAllListeners` - Remove all listeners
328
+
329
+ ---
330
+
331
+ ## 📋 Implementation Notes
332
+
333
+ ### For Standard Methods (Category 1)
334
+ Use the standard `defineMethodV2` pattern:
335
+ ```typescript
336
+ export const methodName = defineMethodV2('methodName', {
337
+ meta: {
338
+ description: 'Method description',
339
+ action: 'read' | 'send' | 'update' | 'delete',
340
+ namespace: 'messages' | 'chats' | 'contacts' | 'groups',
341
+ license: 'none' | 'insiders' | 'restricted',
342
+ functionality: 'both' | 'business-only' | 'personal-only',
343
+ httpMethod: 'GET' | 'POST' | 'PUT' | 'DELETE',
344
+ },
345
+ input: z.object({
346
+ // parameters
347
+ }),
348
+ parameterOrder: ['param1', 'param2'],
349
+ output: z.object({
350
+ // return type
351
+ })
352
+ });
353
+ ```
354
+
355
+ ### For Listeners (Category 2)
356
+ **TODO**: Design a new pattern similar to `defineMethodV2` but for event listeners. This should:
357
+ 1. Register the listener with WAPI
358
+ 2. Support callback functions
359
+ 3. Handle cleanup/unregistration
360
+ 4. Support priority queues (optional)
361
+ 5. Maintain type safety for event payloads
362
+
363
+ Proposed pattern:
364
+ ```typescript
365
+ export const onMessage = defineListenerV2('onMessage', {
366
+ meta: {
367
+ description: 'Listen for new messages',
368
+ eventType: 'message',
369
+ namespace: 'listeners',
370
+ },
371
+ callbackSchema: z.function({
372
+ input: z.tuple([MessageSchema]),
373
+ output: z.void()
374
+ }),
375
+ queueOptions: z.object({
376
+ // PQueue options
377
+ }).optional()
378
+ });
379
+ ```
380
+
381
+ ### For Complex Methods (Category 3)
382
+ Use `defineMethodV2` with custom `implementation`:
383
+ ```typescript
384
+ export const sendImageAsSticker = defineMethodV2('sendImageAsSticker', {
385
+ meta: { /* ... */ },
386
+ input: z.object({ /* ... */ }),
387
+ parameterOrder: ['to', 'image', 'metadata'],
388
+ output: MessageIdReturnSchema
389
+ });
390
+
391
+ // Then in implementor or separate file:
392
+ implementMethod(sendImageAsSticker, async function(params) {
393
+ // Custom logic: convert image to sticker format
394
+ const stickerData = await convertToSticker(params.image);
395
+ // Then call WAPI
396
+ return await this.pup((p) => WAPI.sendImageAsSticker(p), {
397
+ to: params.to,
398
+ sticker: stickerData
399
+ });
400
+ });
401
+ ```
402
+
403
+ ---
404
+
405
+ ## Migration Progress
406
+
407
+ **Total Methods**: ~200+
408
+ **Completed**: 10 (5%)
409
+ **Remaining**: ~190 (95%)
410
+
411
+ ### Priority Order
412
+ 1. **High Priority**: Core messaging methods (send*, get*, delete*)
413
+ 2. **Medium Priority**: Chat/Contact/Group management
414
+ 3. **Low Priority**: Utility and diagnostic methods
415
+ 4. **Special**: Listeners (requires new pattern design)
416
+
417
+ ---
418
+
419
+ ## 🎯 Next Steps
420
+
421
+ ### Immediate Priorities
422
+
423
+ 1. **Design `defineListenerV2` Pattern** (Category 2)
424
+ - Create listener registration system
425
+ - Support callback functions with type safety
426
+ - Handle cleanup/unregistration
427
+ - Implement priority queues
428
+
429
+ 2. **Implement Complex Methods** (Category 3)
430
+ - Sticker conversion methods (10 methods)
431
+ - File transfer methods (2 methods)
432
+ - Media operations (4 methods)
433
+ - Message loading methods (3 methods)
434
+ - Product/catalog methods (3 methods)
435
+
436
+ ### Implementation Files
437
+
438
+ All Category 1 methods are now organized in:
439
+ - `src/methods/messaging.ts` - 29 methods ✅
440
+ - `src/methods/chats.ts` - 18 methods ✅
441
+ - `src/methods/contacts.ts` - 10 methods ✅
442
+ - `src/methods/groups.ts` - 22 methods ✅
443
+ - `src/methods/communities.ts` - 6 methods ✅
444
+ - `src/methods/status.ts` - 7 methods ✅
445
+ - `src/methods/labels.ts` - 4 methods ✅
446
+ - `src/methods/business.ts` - 3 methods ✅
447
+ - `src/methods/utilities.ts` - 26 methods ✅
448
+ - `src/methods/index.ts` - Consolidated exports ✅
449
+
450
+ ### Build Status
451
+
452
+ ✅ **All builds passing**
453
+ - `ts-node scripts/gen-client-implementation.ts` - SUCCESS
454
+ - `pnpm exec tsc --noEmit` - SUCCESS
455
+ - Generated `BaseClient.ts` with 121+ methods
456
+ - Full type safety maintained
457
+
458
+ ---
459
+
460
+ ## 📝 Notes
461
+
462
+ - All Category 1 methods follow the `defineMethodV2` pattern
463
+ - Dual-mode support (positional & named arguments) working correctly
464
+ - Parameter ordering explicitly defined for all methods
465
+ - Rich metadata included (action, namespace, license, functionality)
466
+ - Reusable parameter definitions in `src/parameters.ts`
467
+ - Clean separation by namespace improves maintainability