@wppconnect/wa-js 3.18.8 → 3.19.2

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 (52) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/README.md +78 -26
  3. package/dist/chat/functions/getMessages.d.ts +7 -0
  4. package/dist/chat/functions/list.d.ts +4 -0
  5. package/dist/chat/functions/openChatAt.d.ts +1 -1
  6. package/dist/chat/functions/openChatBottom.d.ts +1 -1
  7. package/dist/chat/functions/openChatFromUnread.d.ts +1 -1
  8. package/dist/chat/functions/pinMsg.d.ts +19 -5
  9. package/dist/chat/functions/sendTextMessage.d.ts +2 -3
  10. package/dist/chat/types.d.ts +4 -3
  11. package/dist/conn/functions/getBuildConstants.d.ts +31 -2
  12. package/dist/conn/functions/getMigrationState.d.ts +52 -0
  13. package/dist/conn/functions/index.d.ts +2 -1
  14. package/dist/contact/functions/save.d.ts +6 -2
  15. package/dist/order/functions/accept.d.ts +58 -0
  16. package/dist/order/functions/decline.d.ts +53 -0
  17. package/dist/order/functions/index.d.ts +3 -0
  18. package/dist/order/functions/update.d.ts +77 -0
  19. package/dist/order/index.d.ts +1 -0
  20. package/dist/order/types.d.ts +119 -0
  21. package/dist/whatsapp/enums/ACK.d.ts +5 -3
  22. package/dist/whatsapp/enums/PinExpiryDurationOption.d.ts +25 -0
  23. package/dist/whatsapp/enums/index.d.ts +1 -0
  24. package/dist/whatsapp/functions/addAndSendMessageEdit.d.ts +2 -2
  25. package/dist/whatsapp/functions/addAndSendMsgToChat.d.ts +2 -2
  26. package/dist/whatsapp/functions/contactFunctions.d.ts +8 -8
  27. package/dist/whatsapp/functions/createChat.d.ts +2 -0
  28. package/dist/whatsapp/functions/deleteContactAction.d.ts +39 -0
  29. package/dist/whatsapp/functions/getPhoneLangPref.d.ts +25 -0
  30. package/dist/whatsapp/functions/index.d.ts +3 -0
  31. package/dist/whatsapp/functions/isFilterExcludedFromSearchTreatmentInInboxFlow.d.ts +1 -1
  32. package/dist/whatsapp/functions/isLidMigrated.d.ts +1 -1
  33. package/dist/whatsapp/functions/msgFindQuery.d.ts +4 -2
  34. package/dist/whatsapp/functions/queryOrder.d.ts +8 -7
  35. package/dist/whatsapp/functions/saveContactAction.d.ts +21 -2
  36. package/dist/whatsapp/functions/sendOrderStatusMessageAsMerchant.d.ts +47 -0
  37. package/dist/whatsapp/functions/sendPinInChatMsg.d.ts +4 -8
  38. package/dist/whatsapp/functions/updateMessageTable.d.ts +18 -0
  39. package/dist/whatsapp/index.d.ts +1 -0
  40. package/dist/whatsapp/misc/MediaPrep.d.ts +3 -2
  41. package/dist/whatsapp/misc/UserPrefs.d.ts +26 -7
  42. package/dist/whatsapp/misc/UsernameGatingUtils.d.ts +26 -0
  43. package/dist/whatsapp/misc/Wid.d.ts +8 -0
  44. package/dist/whatsapp/misc/index.d.ts +1 -0
  45. package/dist/whatsapp/models/ChatModel.d.ts +4 -1
  46. package/dist/whatsapp/models/ContactModel.d.ts +1 -0
  47. package/dist/whatsapp/models/MsgModel.d.ts +17 -1
  48. package/dist/whatsapp/types.d.ts +21 -0
  49. package/dist/wppconnect-wa.js +1 -1
  50. package/dist/wppconnect-wa.js.LICENSE.txt +1 -1
  51. package/eslint.config.mjs +108 -0
  52. package/package.json +11 -13
package/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 3.18.8 (2025-11-10)
1
+ ## 3.19.2 (2025-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * contact save and remove functions ([#3093](https://github.com/wppconnect-team/wa-js/issues/3093)) ([285c88b](https://github.com/wppconnect-team/wa-js/commit/285c88b3b2feeb21dccb493d5f7301b5f7fa901f))
2
7
 
3
8
 
4
9
 
package/README.md CHANGED
@@ -10,10 +10,11 @@
10
10
  [![Lint Status](https://img.shields.io/github/actions/workflow/status/wppconnect-team/wa-js/lint.yml??branch=main&label=lint)](https://github.com/wppconnect-team/wa-js/actions/workflows/lint.yml)
11
11
  [![release-it](https://img.shields.io/badge/%F0%9F%93%A6%F0%9F%9A%80-release--it-e10079.svg)](https://github.com/release-it/release-it)
12
12
 
13
- > WPPConnect/WA-JS is an open-source project with the aim of exporting functions from WhatsApp Web, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination...
13
+ > WPPConnect/WA-JS is an open-source project with the aim of exporting functions from WhatsApp Web, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases and many other things, use your imagination...
14
14
 
15
15
  ## Our online channels
16
16
 
17
+ [![Discussions](https://img.shields.io/github/discussions/wppconnect-team/wa-js?label=Discussions&logo=github)](https://github.com/wppconnect-team/wa-js/discussions)
17
18
  [![Discord](https://img.shields.io/discord/844351092758413353?color=blueviolet&label=Discord&logo=discord&style=flat)](https://discord.gg/JU5JGGKGNG)
18
19
  [![YouTube](https://img.shields.io/youtube/channel/subscribers/UCD7J9LG08PmGQrF5IS7Yv9A?label=YouTube)](https://www.youtube.com/c/wppconnect)
19
20
  [![WhatsApp Group](https://img.shields.io/badge/WhatsApp-Group-25D366?logo=whatsapp)](https://chat.whatsapp.com/LJaQu6ZyNvnBPNAVRbX00K)
@@ -28,20 +29,20 @@
28
29
 
29
30
  ## How does it work
30
31
 
31
- This project extract some functions of WhatsApp sources, that uses webpack.
32
+ This project extracts some functions of WhatsApp sources.
32
33
 
33
- After build, this project generate a file `dist/wppconnect-wa.js` to be used for injection in WhatsApp Web. When injected, it will explose a global variable named `WPP`.
34
+ After build, this project generates a file `dist/wppconnect-wa.js` to be used for injection in WhatsApp Web. When injected, it will expose a global variable named `WPP`.
34
35
 
35
36
  Some parts of `WPP` variable:
36
37
 
37
- - `WPP.webpack` - Scripts to exports WhatsApp functions.
38
+ - `WPP.webpack` - Scripts to export WhatsApp functions.
38
39
  - `WPP.whatsapp` - Only exported WhatsApp functions.
39
40
  - `WPP.chat` - Chat functions and events.
40
41
  - ...
41
42
 
42
43
  ## Exported WhatsApp modules
43
44
 
44
- There are a convection name for some exported modules:
45
+ There are convention names for some exported modules:
45
46
 
46
47
  - `...Model` - Class for data structure (`ClassModel`, `MsgModel`)
47
48
  - `...Collection` - Class for collection of models (`ChatCollection`, `MsgCollection`)
@@ -55,43 +56,80 @@ There are a convection name for some exported modules:
55
56
 
56
57
  `WPP.conn.logout` - Logout from WhatsApp Web
57
58
 
58
- ### Chat Functions
59
- `WPP.chat.sendTextMessage` - Send a text message
59
+ `WPP.conn.getBuildConstants` - Current WhatsApp build constants
60
60
 
61
- `WPP.chat.sendImageMessage` - Send an image message
61
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
62
62
 
63
- `WPP.chat.sendVideoMessage` - Send a video message
63
+ `Object.keys(WPP.conn).sort()`
64
64
 
65
- `WPP.chat.sendFileMessage` - Send a file message
65
+ ### Chat Functions
66
+ `WPP.chat.sendTextMessage` - Send a text message
66
67
 
67
- `WPP.chat.sendAudioMessage` - Send an audio message
68
+ `WPP.chat.sendFileMessage` - Send a file message (medias in general [video, audio, image, pdf])
68
69
 
69
- `WPP.chat.getChat` - Get chat details
70
+ `WPP.chat.get` - Get chat details
70
71
 
71
72
  `WPP.chat.deleteMessage` - Delete a message
72
73
 
73
- ### Contact Functions
74
- `WPP.contact.getContact` - Get contact details
74
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
75
75
 
76
- `WPP.contact.blockContact` - Block a contact
76
+ `Object.keys(WPP.chat).sort()`
77
77
 
78
- `WPP.contact.unblockContact` - Unblock a contact
78
+ ### Contact Functions
79
+ `WPP.contact.get` - Get contact details
79
80
 
80
81
  `WPP.contact.getAllContacts` - Get all contacts
81
82
 
83
+ `WPP.contact.getStatus` - Get status (`about` field in profile)
84
+
85
+ `WPP.contact.getCommonGroups` - Get groups in common with one contact
86
+
87
+ `WPP.contact.getPnLidEntry` - Get PN (Phone Number), Lid and Contact from local cache
88
+
89
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
90
+
91
+ `Object.keys(WPP.contact).sort()`
92
+
93
+ ### Blocklist Functions
94
+
95
+ `WPP.blocklist.blockContact` - Block a contact
96
+
97
+ `WPP.blocklist.unblockContact` - Unblock a contact
98
+
99
+ `WPP.blocklist.all` - All blocked contacts
100
+
101
+ `WPP.blocklist.isBlocked` - Check if contact is blocked
102
+
103
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
104
+
105
+ `Object.keys(WPP.blocklist).sort()`
106
+
82
107
  ### Group Functions
83
- `WPP.group.createGroup` - Create a new group
84
108
 
85
- `WPP.group.addParticipant` - Add a participant to a group
109
+ `WPP.group.create` - Create a new group
110
+
111
+ `WPP.group.canAdd` - Check if contact can be added to group
112
+
113
+ `WPP.group.addParticipants` - Add participants to a group
114
+
115
+ `WPP.group.removeParticipants` - Remove participants from a group.
116
+
117
+ `WPP.group.canPromote` - Check if contact can be promoted
86
118
 
87
- `WPP.group.removeParticipant` - Remove a participant from a group.
119
+ `WPP.group.promoteParticipants` - Promote participants to admin
88
120
 
89
- `WPP.group.promoteParticipant` - Promote a participant to admin
121
+ `WPP.group.canDemote` - Check if contact can be demoted
90
122
 
91
- `WPP.group.demoteParticipant` - Demote a participant from admin.
123
+ `WPP.group.demoteParticipants` - Demote participants from admin.
92
124
 
93
125
  `WPP.group.getGroupInfoFromInviteCode` - Get group information from an invitation link or an invite code.
94
126
 
127
+ `WPP.group.getAllGroups` - Get all groups
128
+
129
+ For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
130
+
131
+ `Object.keys(WPP.group).sort()`
132
+
95
133
  ### Events
96
134
  `WPP.chat.on('chat.new_message')` - Event to dispatch on receive a new message
97
135
 
@@ -102,24 +140,38 @@ To see all events, check: [https://wppconnect.io/wa-js/types/ev.EventTypes.html]
102
140
  Steps to run locally:
103
141
 
104
142
  ```bash
105
- # install the depencencies
143
+ # install the dependencies
106
144
  npm install
107
145
 
108
- # download whatsapp javascript and prettify (optional)
109
- npm run wa-source
110
-
111
146
  # build javascript files
112
147
  npm run build:prd # or build:dev for development
113
148
 
114
149
  # launch a local browser with automatic injection
150
+ # this will also cache the files inside wa-source directory, for next requests
115
151
  npm run launch:local
116
152
 
117
153
  # or only run in VSCode
118
154
  ```
119
155
 
156
+ Note: to run specific versions run:
157
+
158
+ ```sh
159
+ npm run wa-source:clean
160
+
161
+ npm run build:prd
162
+
163
+ WA_VERSION="2.3000.1029560485" npm run launch:local
164
+ ```
165
+
166
+ To debug or inspect `wa-source` folder, format the files to be easier to understand
167
+
168
+ ```sh
169
+ npm run wa-source:format
170
+ ```
171
+
120
172
  ## How to use this project
121
173
 
122
- Basicaly, you need to inject the `wppconnect-wa.js` file into the browser after WhatsApp page load.
174
+ Basically, you need to inject the `wppconnect-wa.js` file into the browser after WhatsApp page load.
123
175
 
124
176
  ### TamperMonkey or GreaseMonkey
125
177
 
@@ -21,6 +21,7 @@ export interface GetMessagesOptions {
21
21
  id?: string;
22
22
  onlyUnread?: boolean;
23
23
  media?: 'url' | 'document' | 'all' | 'image';
24
+ includeCallMessages?: boolean;
24
25
  }
25
26
  /**
26
27
  * Fetch messages from a chat
@@ -79,6 +80,12 @@ export interface GetMessagesOptions {
79
80
  * count: 20,
80
81
  * media: 'url',
81
82
  * });
83
+ *
84
+ * // Include call messages along with chat messages
85
+ * WPP.chat.getMessages('[number]@c.us', {
86
+ * count: 20,
87
+ * includeCallMessages: true,
88
+ * });
82
89
  * ```
83
90
  * @category Message
84
91
  * @return {RawMessage[]} List of raw messages
@@ -23,6 +23,7 @@ export interface ChatListOptions {
23
23
  onlyNewsletter?: boolean;
24
24
  onlyUsers?: boolean;
25
25
  onlyWithUnreadMessage?: boolean;
26
+ onlyArchived?: boolean;
26
27
  withLabels?: string[];
27
28
  }
28
29
  /**
@@ -59,6 +60,9 @@ export interface ChatListOptions {
59
60
  *
60
61
  * // Only with label with one of text or id
61
62
  * const chats = await WPP.chat.list({withLabels: ['Alfa','5']});
63
+ *
64
+ * // Only archived chats
65
+ * const chats = await WPP.chat.list({onlyArchived: true});
62
66
  * ```
63
67
  *
64
68
  * @category Chat
@@ -26,4 +26,4 @@ import { Wid } from '../../whatsapp';
26
26
  *
27
27
  * @category Chat
28
28
  */
29
- export declare function openChatAt(chatId: string | Wid, messageId: string, chatEntryPoint: string | undefined): Promise<boolean>;
29
+ export declare function openChatAt(chatId: string | Wid, messageId: string, chatEntryPoint?: string | undefined): Promise<boolean>;
@@ -26,4 +26,4 @@ import { Wid } from '../../whatsapp';
26
26
  *
27
27
  * @category Chat
28
28
  */
29
- export declare function openChatBottom(chatId: string | Wid, chatEntryPoint: string | undefined): Promise<boolean>;
29
+ export declare function openChatBottom(chatId: string | Wid, chatEntryPoint?: string | undefined): Promise<boolean>;
@@ -26,4 +26,4 @@ import { Wid } from '../../whatsapp';
26
26
  *
27
27
  * @category Chat
28
28
  */
29
- export declare function openChatFromUnread(chatId: string | Wid, chatEntryPoint: string | undefined): Promise<boolean>;
29
+ export declare function openChatFromUnread(chatId: string | Wid, chatEntryPoint?: string | undefined): Promise<boolean>;
@@ -14,17 +14,31 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { MsgKey, MsgModel } from '../../whatsapp';
17
- import { SendMsgResult } from '../../whatsapp/enums';
17
+ import { PinExpiryDurationOption, SendMsgResult } from '../../whatsapp/enums';
18
18
  /**
19
19
  * Pin a message in chat
20
20
  *
21
+ * @param msgId - Message ID to pin/unpin
22
+ * @param pin - True to pin, false to unpin
23
+ * @param duration - Pin duration option. Use PinExpiryDurationOption enum for precise control.
24
+ *
25
+ * @since 3.18.9 - BREAKING CHANGE: The `seconds` parameter (number) has been replaced with `PinExpiryDurationOption` enum.
26
+ * For backward compatibility, numbers are still accepted but will ALWAYS default to 7 days,
27
+ * regardless of the value passed. Use `PinExpiryDurationOption` enum for precise duration control.
28
+ *
21
29
  * @example
22
30
  * ```javascript
23
- * // Pin a message in chat
31
+ * // Pin a message in chat with default duration (7 days)
24
32
  * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF');
25
33
  *
26
- * // Pin a message in chat for 30 days
27
- * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', 2592000);
34
+ * // Pin a message in chat for 30 days (RECOMMENDED)
35
+ * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, WPP.whatsapp.PinExpiryDurationOption.ThirtyDays);
36
+ *
37
+ * // Pin a message in chat for 1 day
38
+ * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, WPP.whatsapp.PinExpiryDurationOption.OneDay);
39
+ *
40
+ * // DEPRECATED: Passing numbers (always results in 7 days)
41
+ * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, 2592000); // Ignored, defaults to 7 days
28
42
  *
29
43
  * // Unpin a message
30
44
  * WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', false);
@@ -33,7 +47,7 @@ import { SendMsgResult } from '../../whatsapp/enums';
33
47
  * ```
34
48
  * @category Chat
35
49
  */
36
- export declare function pinMsg(msgId: string | MsgKey, pin?: boolean, seconds?: number): Promise<{
50
+ export declare function pinMsg(msgId: string | MsgKey, pin?: boolean, duration?: number | PinExpiryDurationOption): Promise<{
37
51
  message: MsgModel;
38
52
  pinned: boolean;
39
53
  result: SendMsgResult;
@@ -20,9 +20,8 @@ export type TextMessageOptions = SendMessageOptions & MessageButtonsOptions & Li
20
20
  *
21
21
  * @example
22
22
  * ```javascript
23
- * WPP.chat.sendTextMessage('[number]@c.us', 'Hello new contact', {
24
- * createChat: true
25
- * });
23
+ * // Send a simple text message
24
+ * WPP.chat.sendTextMessage('[number]@c.us', 'Hello new contact');
26
25
  *
27
26
  * // With Buttons
28
27
  * // Attention: The buttons are an alternative solution we found to make it work. There is no guarantee that they will continue functioning, or when they might stop: The only certainty is: They will stop, so use them responsibly.
@@ -13,12 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ModelPropertiesContructor, MsgKey, MsgModel, Wid } from '../whatsapp';
17
- import { SendMsgResult } from '../whatsapp/enums';
16
+ import { ModelPropertiesContructor, MsgKey, MsgModel, SendMsgResultObject, Wid } from '../whatsapp';
17
+ export type { SendMsgResultObject };
18
18
  export interface SendMessageOptions {
19
19
  /**
20
20
  * Create a new chat to a new contact
21
21
  *
22
+ * @deprecated This option is no longer used. Chats are automatically created when sending messages.
22
23
  * @default false
23
24
  *
24
25
  * @example
@@ -121,6 +122,6 @@ export interface SendMessageReturn {
121
122
  to?: string;
122
123
  latestEditMsgKey?: MsgKey;
123
124
  ack: number;
124
- sendMsgResult: Promise<SendMsgResult>;
125
+ sendMsgResult: Promise<SendMsgResultObject>;
125
126
  }
126
127
  export type RawMessage = ModelPropertiesContructor<MsgModel>;
@@ -13,6 +13,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export interface BuildConstants {
17
+ VERSION_STR: string;
18
+ VERSION_BASE: string;
19
+ VERSION_PRIMARY: string;
20
+ VERSION_SECONDARY: string;
21
+ VERSION_TERTIARY: string;
22
+ WINDOWS_BUILD: string | null;
23
+ PARSED: {
24
+ PRIMARY: number;
25
+ SECONDARY: number;
26
+ TERTIARY: number;
27
+ };
28
+ [key: string]: any;
29
+ }
16
30
  /**
17
31
  * Get the WhatsApp Web build constants
18
32
  * Retrieves the internal WAWebBuildConstants module from WhatsApp source
@@ -25,7 +39,7 @@
25
39
  * console.log('Windows Build:', buildConstants.WINDOWS_BUILD);
26
40
  * ```
27
41
  *
28
- * @returns {object|null} Object containing version constants or null if not available
42
+ * @returns {BuildConstants|null} Object containing version constants or null if not available
29
43
  * - VERSION_STR: Full version string (e.g., "2.3000.1234567")
30
44
  * - VERSION_BASE: Base version (e.g., "2.3000.1234567")
31
45
  * - VERSION_PRIMARY: Primary version number
@@ -34,4 +48,19 @@
34
48
  * - WINDOWS_BUILD: Windows build number (if applicable)
35
49
  * - And other build-related constants
36
50
  */
37
- export declare function getBuildConstants(): string | null;
51
+ export declare function getBuildConstants(): BuildConstants | null;
52
+ /**
53
+ * Check if the current WhatsApp version is greater than or equal to a specified version
54
+ *
55
+ * @example
56
+ * ```javascript
57
+ * // Check if version is >= 2.3000.1030110621
58
+ * if (WPP.conn.isWhatsAppVersionGTE('2.3000.1030110621')) {
59
+ * console.log('Using new API');
60
+ * }
61
+ * ```
62
+ *
63
+ * @param version - Version string to compare against (e.g., "2.3000.1029")
64
+ * @returns {boolean} True if current version is >= specified version
65
+ */
66
+ export declare function isWhatsAppVersionGTE(version: string): boolean;
@@ -0,0 +1,52 @@
1
+ /*!
2
+ * Copyright 2025 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Wid } from '../../whatsapp/misc';
17
+ /**
18
+ * Migration state information for the current WhatsApp account
19
+ */
20
+ export interface MigrationState {
21
+ /** Whether the account has been migrated to LID (Linked Identity) system */
22
+ isLidMigrated: boolean;
23
+ /** Whether the sync session has been migrated */
24
+ isSyncdSessionMigrated: boolean;
25
+ /** Whether old messaging rules should still be applied */
26
+ shouldApplyNonMigratedMessagingRules: boolean;
27
+ /** Whether the account should have an account LID */
28
+ shouldHaveAccountLid: boolean;
29
+ /** The current user's LID, if available */
30
+ currentLid?: Wid;
31
+ /** The current user's PN, if available */
32
+ currentPn?: Wid;
33
+ }
34
+ /**
35
+ * Get comprehensive migration state information for debugging and monitoring
36
+ *
37
+ * This function aggregates various LID (Linked Identity) migration-related
38
+ * information to help understand the current state of the account's migration
39
+ * from the legacy @c.us addressing system to the newer @lid system.
40
+ *
41
+ * @returns Object containing all available migration state information
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const state = WPP.conn.getMigrationState();
46
+ * console.log('Account migrated:', state.isLidMigrated);
47
+ * console.log('Current LID:', state.currentLid);
48
+ * console.log('Should have LID:', state.shouldHaveAccountLid);
49
+ * ```
50
+ * @category Connection
51
+ */
52
+ export declare function getMigrationState(): MigrationState;
@@ -16,8 +16,9 @@
16
16
  export { changeEnviromentDevice } from './changeEnviromentDevice';
17
17
  export { genLinkDeviceCodeForPhoneNumber } from './genLinkDeviceCodeForPhoneNumber';
18
18
  export { getAuthCode } from './getAuthCode';
19
- export { getBuildConstants } from './getBuildConstants';
19
+ export { BuildConstants, getBuildConstants, isWhatsAppVersionGTE, } from './getBuildConstants';
20
20
  export { getHistorySyncProgress, HistorySyncProgress, } from './getHistorySyncProgress';
21
+ export { getMigrationState, MigrationState } from './getMigrationState';
21
22
  export { getMyDeviceId } from './getMyDeviceId';
22
23
  export { getMyUserId } from './getMyUserId';
23
24
  export { getPlatform } from './getPlatform';
@@ -21,13 +21,17 @@ import { ContactModel } from '../../whatsapp';
21
21
  * ```javascript
22
22
  * await WPP.contact.save('5533999999999@c.us', 'John', {
23
23
  * surname: 'Doe',
24
- * syncAdressBook: true,
24
+ * syncAddressBook: true,
25
25
  * });
26
26
  * ```
27
27
  *
28
28
  * @category Contact
29
29
  */
30
- export declare function save(contactId: string | any, name: string, options?: {
30
+ export declare function save(contactId: string | any, firstName: string, options?: {
31
+ /** @deprecated Use lastName instead */
31
32
  surname?: string;
33
+ /** @deprecated Use syncAddressBook instead, this one with typo was updated */
32
34
  syncAdressBook?: boolean;
35
+ lastName?: string;
36
+ syncAddressBook?: boolean;
33
37
  }): Promise<ContactModel | undefined>;
@@ -0,0 +1,58 @@
1
+ /*!
2
+ * Copyright 2025 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { MsgKey } from '../../whatsapp';
17
+ /**
18
+ * Options for accepting an order
19
+ */
20
+ export interface AcceptOrderOptions {
21
+ /** The message ID or message key of the order message */
22
+ msgId: string | MsgKey;
23
+ }
24
+ /**
25
+ * Accept an order
26
+ *
27
+ * This function performs TWO critical operations:
28
+ * 1. Updates the order message's status field from INQUIRY (1) to ACCEPTED (2)
29
+ * - This hides the "Accept Order" button in the UI
30
+ * 2. Sends an order status update message to the customer
31
+ * - Shows "Processing" or "Confirmed" status
32
+ *
33
+ * The order information is automatically retrieved from the message.
34
+ *
35
+ * @example
36
+ * ```javascript
37
+ * // Accept an order with default "Processing" status
38
+ * await WPP.order.accept({
39
+ * msgId: 'message_id_here',
40
+ * acceptNote: 'Your order has been confirmed and is being processed'
41
+ * });
42
+ *
43
+ * // Accept with "Confirmed" status
44
+ * await WPP.order.accept({
45
+ * msgId: 'message_id_here',
46
+ * orderStatus: WPP.order.OrderStatus.Confirmed,
47
+ * acceptNote: 'Your order has been confirmed'
48
+ * });
49
+ *
50
+ * // Accept without a note
51
+ * await WPP.order.accept({
52
+ * msgId: 'message_id_here'
53
+ * });
54
+ * ```
55
+ *
56
+ * @category Order
57
+ */
58
+ export declare function accept(options: AcceptOrderOptions): Promise<void>;
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * Copyright 2025 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { MsgKey } from '../../whatsapp';
17
+ /**
18
+ * Options for declining an order
19
+ */
20
+ export interface DeclineOrderOptions {
21
+ /** The message ID or message key of the order message */
22
+ msgId: string | MsgKey;
23
+ /** Optional note to include with the decline message (recommended) */
24
+ declineNote?: string;
25
+ }
26
+ /**
27
+ * Decline an order
28
+ *
29
+ * This function performs TWO critical operations:
30
+ * 1. Updates the order message's status field from INQUIRY (1) to DECLINED (3)
31
+ * - This changes the UI to show the order as declined
32
+ * 2. Sends an order cancellation message to the customer
33
+ * - Shows "Canceled" status with optional note
34
+ *
35
+ * The order information is automatically retrieved from the message.
36
+ *
37
+ * @example
38
+ * ```javascript
39
+ * // Decline an order with a note
40
+ * await WPP.order.decline({
41
+ * msgId: 'message_id_here',
42
+ * declineNote: 'Sorry, we cannot fulfill this order at this time'
43
+ * });
44
+ *
45
+ * // Decline without a note
46
+ * await WPP.order.decline({
47
+ * msgId: 'message_id_here'
48
+ * });
49
+ * ```
50
+ *
51
+ * @category Order
52
+ */
53
+ export declare function decline(options: DeclineOrderOptions): Promise<void>;
@@ -13,4 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export { accept } from './accept';
17
+ export { decline } from './decline';
16
18
  export { get } from './get';
19
+ export { update } from './update';
@@ -0,0 +1,77 @@
1
+ /*!
2
+ * Copyright 2025 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { UpdateOrderOptions } from '../types';
17
+ /**
18
+ * Update an order status and/or payment information
19
+ *
20
+ * This function sends an order status update message to the customer.
21
+ *
22
+ * **Important:** For accepting or declining orders, use the dedicated `accept()` and `decline()`
23
+ * functions instead. Those functions properly update both the message status field (UI state)
24
+ * and send the status update message.
25
+ *
26
+ * This function is best used for status updates after an order has been accepted, such as:
27
+ * - Marking as shipped
28
+ * - Marking as delivered
29
+ * - Marking as complete
30
+ * - Updating payment information
31
+ *
32
+ * @example
33
+ * ```javascript
34
+ * // Mark as shipped
35
+ * await WPP.order.update({
36
+ * msgId: 'message_id_here',
37
+ * orderInfo: {
38
+ * items: [
39
+ * {
40
+ * id: 'product_1',
41
+ * name: 'Product Name',
42
+ * amount: 1000,
43
+ * quantity: 2,
44
+ * isCustomItem: false,
45
+ * isQuantitySet: true
46
+ * }
47
+ * ],
48
+ * totalAmount: 2000,
49
+ * subtotal: 2000,
50
+ * currency: 'USD'
51
+ * },
52
+ * orderStatus: WPP.order.OrderStatus.Shipped,
53
+ * orderNote: 'Your order has been shipped',
54
+ * referenceId: 'ORDER_12345'
55
+ * });
56
+ *
57
+ * // Mark as delivered
58
+ * await WPP.order.update({
59
+ * msgId: 'message_id_here',
60
+ * orderInfo: { ... },
61
+ * orderStatus: WPP.order.OrderStatus.Delivered,
62
+ * orderNote: 'Your order has been delivered'
63
+ * });
64
+ *
65
+ * // Update payment status
66
+ * await WPP.order.update({
67
+ * msgId: 'message_id_here',
68
+ * orderInfo: { ... },
69
+ * orderStatus: WPP.order.OrderStatus.Complete,
70
+ * paymentStatus: WPP.order.PaymentStatus.Captured,
71
+ * orderNote: 'Order completed and payment received'
72
+ * });
73
+ * ```
74
+ *
75
+ * @category Order
76
+ */
77
+ export declare function update(options: UpdateOrderOptions): Promise<void>;