@wppconnect/wa-js 2.4.0 → 2.5.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
@@ -1,3 +1,30 @@
1
+ ## 2.5.1 (2022-06-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fixed revoke messages for list type ([7938ae7](https://github.com/wppconnect-team/wa-js/commit/7938ae7dab6bfa9e44f68f78dab01bbeeeeca0b6))
7
+
8
+
9
+
10
+ # 2.5.0 (2022-06-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * Added option to filter chat and contacts with label (close [#436](https://github.com/wppconnect-team/wa-js/issues/436)) ([bff74df](https://github.com/wppconnect-team/wa-js/commit/bff74df6bc55ce657b97957752e06e0aa5c09d14))
16
+
17
+
18
+
19
+ ## 2.4.1 (2022-05-31)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Fixed detect mentionedList for invalid wids ([#427](https://github.com/wppconnect-team/wa-js/issues/427)) ([c701dc3](https://github.com/wppconnect-team/wa-js/commit/c701dc3b8b04cce1e51dd5dda12bf5e80e11de2e))
25
+
26
+
27
+
1
28
  # 2.4.0 (2022-05-28)
2
29
 
3
30
 
@@ -88,6 +88,35 @@ export interface ChatEventTypes {
88
88
  chat: Wid;
89
89
  seq: number;
90
90
  };
91
+ /**
92
+ * Triggered when a new reaction is received
93
+ *
94
+ * @example
95
+ * ```javascript
96
+ * WPP.on('chat.new_reaction', (msg) => {
97
+ * // Your code
98
+ * });
99
+ * ```
100
+ */
101
+ 'chat.new_reaction': {
102
+ /**
103
+ * Reaction ID
104
+ */
105
+ id: MsgKey;
106
+ /**
107
+ * Message ID that received the reaction
108
+ */
109
+ msgId: MsgKey;
110
+ /**
111
+ * The reaction emoji or empty if removed
112
+ */
113
+ reactionText: string;
114
+ read: boolean;
115
+ sender: Wid;
116
+ orphan: number;
117
+ orphanReason: any;
118
+ timestamp: number;
119
+ };
91
120
  /**
92
121
  * On presence change
93
122
  */
@@ -18,3 +18,4 @@ import './registerLiveLocationUpdateEvent';
18
18
  import './registerNewMessageEvent';
19
19
  import './registerPresenceChange';
20
20
  import './registerRevokeMessageEvent';
21
+ import './registerReactionsEvent';
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright 2021 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
+ export {};
@@ -20,10 +20,23 @@ export interface DeleteMessageReturn {
20
20
  sendMsgResult: Promise<SendMsgResult>;
21
21
  isRevoked: boolean;
22
22
  isDeleted: boolean;
23
+ isSentByMe: boolean;
23
24
  }
24
25
  /**
25
26
  * Delete a message
26
27
  *
28
+ * @example
29
+ * ```javascript
30
+ * // Delete a message
31
+ * WPP.chat.deleteMessage('[number]@callback.us', 'msgid');
32
+ * // Delete a list of messages
33
+ * WPP.chat.deleteMessage('[number]@callback.us', ['msgid1', 'msgid2]);
34
+ * // Delete a message and delete media
35
+ * WPP.chat.deleteMessage('[number]@callback.us', 'msgid', true);
36
+ * // Revoke a message
37
+ * WPP.chat.deleteMessage('[number]@callback.us', 'msgid', true, true);
38
+ * ```
39
+ *
27
40
  * @category Message
28
41
  */
29
42
  export declare function deleteMessage(chatId: string | Wid, id: string, deleteMediaInDevice: boolean, revoke: boolean): Promise<DeleteMessageReturn>;
@@ -18,6 +18,7 @@ export interface ChatListOptions {
18
18
  onlyGroups?: boolean;
19
19
  onlyUsers?: boolean;
20
20
  onlyWithUnreadMessage?: boolean;
21
+ withLabels?: string[];
21
22
  }
22
23
  /**
23
24
  * Return a list of chats
@@ -25,15 +26,24 @@ export interface ChatListOptions {
25
26
  * @example
26
27
  * ```javascript
27
28
  * // All chats
28
- * const chat = await WPP.chat.list();
29
+ * const chats = await WPP.chat.list();
29
30
  *
30
31
  * // Only users chats
31
- * const chat = await WPP.chat.list({onlyUsers: true});
32
+ * const chats = await WPP.chat.list({onlyUsers: true});
32
33
  *
33
34
  * // Only groups chats
34
- * const chat = await WPP.chat.list({onlyGroups: true});
35
+ * const chats = await WPP.chat.list({onlyGroups: true});
36
+ *
37
+ * // Only with label Text
38
+ * const chats = await WPP.chat.list({withLabels: ['Test']});
39
+ *
40
+ * // Only with label id
41
+ * const chats = await WPP.chat.list({withLabels: ['1']});
42
+ *
43
+ * // Only with label with one of text or id
44
+ * const chats = await WPP.chat.list({withLabels: ['Alfa','5']});
35
45
  * ```
36
46
  *
37
47
  * @category Chat
38
48
  */
39
- export declare function list(options: ChatListOptions): Promise<ChatModel[]>;
49
+ export declare function list(options?: ChatListOptions): Promise<ChatModel[]>;
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2021 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';
17
+ /**
18
+ * Return the current logged user ID with device id
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * const wid = WPP.conn.getMyDeviceId();
23
+ * console.log(wid.toString()); // Output: 123:4@c.us
24
+ * ```
25
+ */
26
+ export declare function getMyDeviceId(): Wid | undefined;
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright 2021 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';
17
+ /**
18
+ * Return the current logged user ID without device id
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * const wid = WPP.conn.getMyUserId();
23
+ * console.log(wid.toString()); // Output: 123@c.us
24
+ * ```
25
+ */
26
+ export declare function getMyUserId(): Wid | undefined;
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { getAuthCode } from './getAuthCode';
17
+ export { getMyDeviceId } from './getMyDeviceId';
18
+ export { getMyUserId } from './getMyUserId';
17
19
  export { isAuthenticated } from './isAuthenticated';
18
20
  export { isIdle } from './isIdle';
19
21
  export { isMainLoaded } from './isMainLoaded';
@@ -15,4 +15,5 @@
15
15
  */
16
16
  export { getProfilePictureUrl } from './getProfilePictureUrl';
17
17
  export { getStatus } from './getStatus';
18
+ export { ContactListOptions, list } from './list';
18
19
  export { queryExists } from './queryExists';
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * Copyright 2021 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 { ContactModel } from '../../whatsapp';
17
+ export interface ContactListOptions {
18
+ onlyMyContacts?: boolean;
19
+ withLabels?: string[];
20
+ }
21
+ /**
22
+ * Return a list of contacts
23
+ *
24
+ * @example
25
+ * ```javascript
26
+ * // All contacts
27
+ * const contats = await WPP.contact.list();
28
+ *
29
+ * // Only my contacts
30
+ * const contacts = await WPP.contact.list({onlyMyContacts: true});
31
+ *
32
+ * // Only with label Text
33
+ * const contacts = await WPP.contact.list({withLabels: ['Test']});
34
+ *
35
+ * // Only with label id
36
+ * const contacts = await WPP.contact.list({withLabels: ['1']});
37
+ *
38
+ * // Only with label with one of text or id
39
+ * const contacts = await WPP.contact.list({withLabels: ['Alfa','5']});
40
+ * ```
41
+ *
42
+ * @category Contact
43
+ */
44
+ export declare function list(options?: ContactListOptions): Promise<ContactModel[]>;
@@ -32,6 +32,7 @@ export declare class Collection<M, A = M | M[]> extends EventEmitter {
32
32
  constructor(e?: any, t?: {
33
33
  parent: any;
34
34
  });
35
+ get length(): number;
35
36
  add(value: A | WritableProperties<A>, options?: Option): A;
36
37
  set(value: A, options?: Option): A;
37
38
  remove(value: A, options?: {
@@ -47,9 +48,6 @@ export declare class Collection<M, A = M | M[]> extends EventEmitter {
47
48
  get(e: Stringable): M | undefined;
48
49
  assertGet(e: Stringable): M;
49
50
  at(position: number): M | undefined;
50
- get length(): number;
51
- get isCollection(): boolean;
52
- get models(): M[];
53
51
  serialize(): any[];
54
52
  toJSON(): any[];
55
53
  isModel(model: any): model is M;
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Copyright 2021 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
+ export interface ReactionData {
17
+ msgKey: string;
18
+ orphan: number;
19
+ orphanReason: any;
20
+ parentMsgKey: string;
21
+ reactionText: string;
22
+ read: boolean;
23
+ senderUserJid: string;
24
+ timestamp: number;
25
+ }
26
+ /** @whatsapp 7394 */
27
+ export declare function createOrUpdateReactions(data: ReactionData[]): Promise<any>;
@@ -16,6 +16,7 @@
16
16
  export * from './addAndSendMsgToChat';
17
17
  export * from './blockContact';
18
18
  export * from './createMsgProtobuf';
19
+ export * from './createOrUpdateReactions';
19
20
  export * from './encryptAndSendGroupMsg';
20
21
  export * from './encryptAndSendMsg';
21
22
  export * from './fetchLinkPreview';
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ChatModel } from '..';
17
+ import { MsgModel } from '../models';
17
18
  import { EventEmitter } from '.';
18
19
  /** @whatsapp 88102
19
20
  * @whatsapp 81572 >= 2.2218.4
@@ -49,8 +50,11 @@ export declare class CmdClass extends EventEmitter {
49
50
  ephemeralDrawer(e?: any, t?: any): void;
50
51
  sendStarMsgs(e?: any, t?: any, r?: any, n?: any): void;
51
52
  sendUnstarMsgs(e?: any, t?: any, r?: any, n?: any): void;
52
- sendDeleteMsgs(e?: any, t?: any, r?: any, n?: any, i?: any): void;
53
- sendRevokeMsgs(e?: any, t?: any, r?: any, n?: any, i?: any): void;
53
+ sendDeleteMsgs(chat: ChatModel, msgs: MsgModel[], clearMedia?: boolean, toastPosition?: any): void;
54
+ sendRevokeMsgs(chat: ChatModel, msgs: MsgModel[], options?: {
55
+ clearMedia?: boolean;
56
+ toastPosition?: any;
57
+ }): void;
54
58
  _openChat(e?: any, t?: any): void;
55
59
  openChatAt(chat: ChatModel, context: ReturnType<ChatModel['getSearchContext']>): Promise<boolean>;
56
60
  openChatFromUnread(chat: ChatModel): Promise<boolean>;
@@ -29,7 +29,7 @@ interface Props {
29
29
  privacyMode?: any;
30
30
  statusMute?: any;
31
31
  sectionHeader?: any;
32
- labels?: any;
32
+ labels?: string[];
33
33
  disappearingModeDuration?: any;
34
34
  disappearingModeSettingTimestamp?: any;
35
35
  }
@@ -20,7 +20,7 @@ import { MsgModel } from './MsgModel';
20
20
  export interface PropsChatBase {
21
21
  id: Wid;
22
22
  pendingMsgs: boolean;
23
- labels: any | undefined;
23
+ labels?: string[];
24
24
  }
25
25
  export interface SessionChatBase {
26
26
  msgChunks: MsgLoad[];
@@ -292,6 +292,7 @@ interface Derived {
292
292
  };
293
293
  isGroupsV4InviteExpired: boolean;
294
294
  isPersistent: boolean;
295
+ isRevokedByMe: boolean;
295
296
  isUnreadType: boolean;
296
297
  isUserCreatedType: boolean;
297
298
  supportsMessageFooter?: any;
@@ -25,10 +25,14 @@ interface Session {
25
25
  }
26
26
  interface Derived {
27
27
  }
28
- /** @whatsapp 80666 */
28
+ /** @whatsapp 80666
29
+ * @whatsapp 81130 >= 2.2220.8
30
+ */
29
31
  export declare interface ReactionsModel extends ModelProxy<Props, Session, Derived> {
30
32
  }
31
- /** @whatsapp 80666 */
33
+ /** @whatsapp 80666
34
+ * @whatsapp 81130 >= 2.2220.8
35
+ */
32
36
  export declare class ReactionsModel extends Model {
33
37
  constructor(proterties?: ModelPropertiesContructor<ReactionsModel>, options?: ModelOptions);
34
38
  reactions: AggReactionsCollection;