@wppconnect-team/wppconnect 1.29.0 → 1.30.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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.30.0 (2024-03-10)
2
+
3
+ - fix(deps): update dependency @wppconnect/wa-js to v3 (#2103) ([3f5a658](https://github.com/wppconnect-team/wppconnect/commit/3f5a658)), closes [#2103](https://github.com/wppconnect-team/wppconnect/issues/2103)
4
+
1
5
  ## 1.29.0 (2024-01-25)
2
6
 
3
7
  - [FIX] version whatsapp web ([716cd97](https://github.com/wppconnect-team/wppconnect/commit/716cd97))
@@ -57,10 +57,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
57
57
  Object.defineProperty(exports, "__esModule", { value: true });
58
58
  exports.downloadFileToBase64 = void 0;
59
59
  var axios_1 = __importDefault(require("axios"));
60
- function downloadFileToBase64(_path, _mines) {
61
- if (_mines === void 0) { _mines = []; }
62
- return __awaiter(this, void 0, void 0, function () {
60
+ function downloadFileToBase64(_path_1) {
61
+ return __awaiter(this, arguments, void 0, function (_path, _mines) {
63
62
  var reHttp, response, mimeType_1, isValidMime, content, error_1;
63
+ if (_mines === void 0) { _mines = []; }
64
64
  return __generator(this, function (_a) {
65
65
  switch (_a.label) {
66
66
  case 0:
@@ -99,21 +99,19 @@ var BusinessLayer = /** @class */ (function (_super) {
99
99
  return __awaiter(this, void 0, void 0, function () {
100
100
  var _this = this;
101
101
  return __generator(this, function (_a) {
102
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
103
- var id = _a.id;
104
- return __awaiter(_this, void 0, void 0, function () {
105
- var _b, _c, _d, _e;
106
- return __generator(this, function (_f) {
107
- switch (_f.label) {
108
- case 0:
109
- _c = (_b = JSON).parse;
110
- _e = (_d = JSON).stringify;
111
- return [4 /*yield*/, WPP.contact.getBusinessProfile(id)];
112
- case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
113
- }
114
- });
102
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
103
+ var _c, _d, _e, _f;
104
+ var id = _b.id;
105
+ return __generator(this, function (_g) {
106
+ switch (_g.label) {
107
+ case 0:
108
+ _d = (_c = JSON).parse;
109
+ _f = (_e = JSON).stringify;
110
+ return [4 /*yield*/, WPP.contact.getBusinessProfile(id)];
111
+ case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
112
+ }
115
113
  });
116
- }, { id: id })];
114
+ }); }, { id: id })];
117
115
  });
118
116
  });
119
117
  };
@@ -292,21 +290,19 @@ var BusinessLayer = /** @class */ (function (_super) {
292
290
  var _this = this;
293
291
  return __generator(this, function (_a) {
294
292
  switch (_a.label) {
295
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
296
- var options = _a.options;
297
- return __awaiter(_this, void 0, void 0, function () {
298
- var _b, _c, _d, _e;
299
- return __generator(this, function (_f) {
300
- switch (_f.label) {
301
- case 0:
302
- _c = (_b = JSON).parse;
303
- _e = (_d = JSON).stringify;
304
- return [4 /*yield*/, WPP.profile.editBusinessProfile(options)];
305
- case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
306
- }
307
- });
293
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
294
+ var _c, _d, _e, _f;
295
+ var options = _b.options;
296
+ return __generator(this, function (_g) {
297
+ switch (_g.label) {
298
+ case 0:
299
+ _d = (_c = JSON).parse;
300
+ _f = (_e = JSON).stringify;
301
+ return [4 /*yield*/, WPP.profile.editBusinessProfile(options)];
302
+ case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
303
+ }
308
304
  });
309
- }, { options: options })];
305
+ }); }, { options: options })];
310
306
  case 1: return [2 /*return*/, _a.sent()];
311
307
  }
312
308
  });
@@ -157,9 +157,9 @@ var ControlsLayer = /** @class */ (function (_super) {
157
157
  * @param option {boolean} true or false
158
158
  * @returns boolean
159
159
  */
160
- ControlsLayer.prototype.archiveChat = function (chatId, option) {
161
- if (option === void 0) { option = true; }
162
- return __awaiter(this, void 0, void 0, function () {
160
+ ControlsLayer.prototype.archiveChat = function (chatId_1) {
161
+ return __awaiter(this, arguments, void 0, function (chatId, option) {
162
+ if (option === void 0) { option = true; }
163
163
  return __generator(this, function (_a) {
164
164
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
165
165
  var chatId = _a.chatId, option = _a.option;
@@ -205,10 +205,10 @@ var ControlsLayer = /** @class */ (function (_super) {
205
205
  * @param keepStarred Keep starred messages
206
206
  * @returns boolean
207
207
  */
208
- ControlsLayer.prototype.clearChat = function (chatId, keepStarred) {
209
- if (keepStarred === void 0) { keepStarred = true; }
210
- return __awaiter(this, void 0, void 0, function () {
208
+ ControlsLayer.prototype.clearChat = function (chatId_1) {
209
+ return __awaiter(this, arguments, void 0, function (chatId, keepStarred) {
211
210
  var result;
211
+ if (keepStarred === void 0) { keepStarred = true; }
212
212
  return __generator(this, function (_a) {
213
213
  switch (_a.label) {
214
214
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
@@ -229,10 +229,10 @@ var ControlsLayer = /** @class */ (function (_super) {
229
229
  * @param messageId The specific message id of the message to be deleted
230
230
  * @param onlyLocal If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.
231
231
  */
232
- ControlsLayer.prototype.deleteMessage = function (chatId, messageId, onlyLocal, deleteMediaInDevice) {
233
- if (onlyLocal === void 0) { onlyLocal = false; }
234
- if (deleteMediaInDevice === void 0) { deleteMediaInDevice = true; }
235
- return __awaiter(this, void 0, void 0, function () {
232
+ ControlsLayer.prototype.deleteMessage = function (chatId_1, messageId_1) {
233
+ return __awaiter(this, arguments, void 0, function (chatId, messageId, onlyLocal, deleteMediaInDevice) {
234
+ if (onlyLocal === void 0) { onlyLocal = false; }
235
+ if (deleteMediaInDevice === void 0) { deleteMediaInDevice = true; }
236
236
  return __generator(this, function (_a) {
237
237
  switch (_a.label) {
238
238
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
@@ -259,11 +259,11 @@ var ControlsLayer = /** @class */ (function (_super) {
259
259
  * client.editMessage('true_<number>@c.us_messageId', 'new Text For Simple Message');
260
260
  * ```
261
261
  */
262
- ControlsLayer.prototype.editMessage = function (msgId, newText, options) {
263
- if (options === void 0) { options = {}; }
264
- return __awaiter(this, void 0, void 0, function () {
262
+ ControlsLayer.prototype.editMessage = function (msgId_1, newText_1) {
263
+ return __awaiter(this, arguments, void 0, function (msgId, newText, options) {
265
264
  var editResult, result;
266
265
  var _this = this;
266
+ if (options === void 0) { options = {}; }
267
267
  return __generator(this, function (_a) {
268
268
  switch (_a.label) {
269
269
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
@@ -272,21 +272,19 @@ var ControlsLayer = /** @class */ (function (_super) {
272
272
  }, { msgId: msgId, newText: newText, options: options })];
273
273
  case 1:
274
274
  editResult = _a.sent();
275
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
276
- var messageId = _a.messageId;
277
- return __awaiter(_this, void 0, void 0, function () {
278
- var _b, _c, _d, _e;
279
- return __generator(this, function (_f) {
280
- switch (_f.label) {
281
- case 0:
282
- _c = (_b = JSON).parse;
283
- _e = (_d = JSON).stringify;
284
- return [4 /*yield*/, WAPI.getMessageById(messageId)];
285
- case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
286
- }
287
- });
275
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
276
+ var _c, _d, _e, _f;
277
+ var messageId = _b.messageId;
278
+ return __generator(this, function (_g) {
279
+ switch (_g.label) {
280
+ case 0:
281
+ _d = (_c = JSON).parse;
282
+ _f = (_e = JSON).stringify;
283
+ return [4 /*yield*/, WAPI.getMessageById(messageId)];
284
+ case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
285
+ }
288
286
  });
289
- }, { messageId: editResult.id })];
287
+ }); }, { messageId: editResult.id })];
290
288
  case 2:
291
289
  result = (_a.sent());
292
290
  if (result.body !== newText)
@@ -302,9 +300,9 @@ var ControlsLayer = /** @class */ (function (_super) {
302
300
  * @param messagesId The specific message id of the message to be starred
303
301
  * @param star Add or remove star of the message. Defaults to true.
304
302
  */
305
- ControlsLayer.prototype.starMessage = function (messagesId, star) {
306
- if (star === void 0) { star = true; }
307
- return __awaiter(this, void 0, void 0, function () {
303
+ ControlsLayer.prototype.starMessage = function (messagesId_1) {
304
+ return __awaiter(this, arguments, void 0, function (messagesId, star) {
305
+ if (star === void 0) { star = true; }
308
306
  return __generator(this, function (_a) {
309
307
  switch (_a.label) {
310
308
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
@@ -93,7 +93,7 @@ export declare class GroupLayer extends RetrieverLayer {
93
93
  * @param groupId Chat id ('0000000000-00000000@g.us')
94
94
  * @param participantId Participant id'000000000000@c.us'
95
95
  */
96
- removeParticipant(groupId: string, participantId: string | string[]): Promise<boolean>;
96
+ removeParticipant(groupId: string, participantId: string | string[]): Promise<void>;
97
97
  /**
98
98
  * Adds participant to Group
99
99
  * @category Group
@@ -217,9 +217,7 @@ var GroupLayer = /** @class */ (function (_super) {
217
217
  var groupId = _a.groupId, participantId = _a.participantId;
218
218
  return WPP.group.removeParticipants(groupId, participantId);
219
219
  }, { groupId: groupId, participantId: participantId })];
220
- case 1:
221
- _a.sent();
222
- return [2 /*return*/, true];
220
+ case 1: return [2 /*return*/, _a.sent()];
223
221
  }
224
222
  });
225
223
  });
@@ -3,7 +3,7 @@ import { Page } from 'puppeteer';
3
3
  import { Logger } from 'winston';
4
4
  import { CreateConfig } from '../../config/create-config';
5
5
  import { LogLevel } from '../../utils/logger';
6
- import { CatchQRCallback, HostDevice, LoadingScreenCallback, StatusFindCallback } from '../model';
6
+ import { CatchQRCallback, HostDevice, LinkByCodeCallback, LoadingScreenCallback, StatusFindCallback } from '../model';
7
7
  import { SocketState } from '../model/enum';
8
8
  import { ScrapQrcode } from '../model/qrcode';
9
9
  export declare class HostLayer {
@@ -24,6 +24,7 @@ export declare class HostLayer {
24
24
  catchQR?: CatchQRCallback;
25
25
  statusFind?: StatusFindCallback;
26
26
  onLoadingScreen?: LoadingScreenCallback;
27
+ catchLinkCode?: LinkByCodeCallback;
27
28
  constructor(page: Page, session?: string, options?: CreateConfig);
28
29
  protected log(level: LogLevel, message: string, meta?: object): void;
29
30
  protected initialize(): Promise<void>;
@@ -32,6 +33,7 @@ export declare class HostLayer {
32
33
  start(): Promise<void>;
33
34
  protected checkStart(): Promise<void>;
34
35
  protected checkQrCode(): Promise<void>;
36
+ protected loginByCode(phone: string): Promise<void>;
35
37
  protected checkInChat(): Promise<void>;
36
38
  protected tryAutoClose(): void;
37
39
  protected startAutoClose(time?: number | null): void;
@@ -86,6 +86,7 @@ var HostLayer = /** @class */ (function () {
86
86
  this.catchQR = null;
87
87
  this.statusFind = null;
88
88
  this.onLoadingScreen = null;
89
+ this.catchLinkCode = null;
89
90
  this.session = session;
90
91
  this.options = __assign(__assign({}, create_config_1.defaultOptions), options);
91
92
  this.logger = this.options.logger || logger_1.defaultLogger;
@@ -171,8 +172,8 @@ var HostLayer = /** @class */ (function () {
171
172
  (0, helpers_1.evaluateAndReturn)(this.page, function () {
172
173
  WPP.on('conn.main_ready', window.checkInChat);
173
174
  }).catch(function () { return null; });
174
- this.checkQrCode();
175
175
  this.checkInChat();
176
+ this.checkQrCode();
176
177
  return [2 /*return*/];
177
178
  });
178
179
  });
@@ -193,8 +194,13 @@ var HostLayer = /** @class */ (function () {
193
194
  return [4 /*yield*/, this.page.exposeFunction('checkQrCode', function () { return _this.checkQrCode(); })];
194
195
  case 2:
195
196
  _a.sent();
196
- return [4 /*yield*/, this.page.exposeFunction('checkInChat', function () { return _this.checkInChat(); })];
197
+ return [4 /*yield*/, this.page.exposeFunction('loginByCode', function (phone) {
198
+ return _this.loginByCode(phone);
199
+ })];
197
200
  case 3:
201
+ _a.sent();
202
+ return [4 /*yield*/, this.page.exposeFunction('checkInChat', function () { return _this.checkInChat(); })];
203
+ case 4:
198
204
  _a.sent();
199
205
  this.checkStartInterval = setInterval(function () { return _this.checkStart(); }, 5000);
200
206
  this.page.on('close', function () {
@@ -216,9 +222,9 @@ var HostLayer = /** @class */ (function () {
216
222
  });
217
223
  };
218
224
  HostLayer.prototype.checkQrCode = function () {
219
- var _a;
220
225
  return __awaiter(this, void 0, void 0, function () {
221
226
  var needScan, result, qr;
227
+ var _a;
222
228
  return __generator(this, function (_b) {
223
229
  switch (_b.label) {
224
230
  case 0: return [4 /*yield*/, (0, auth_1.needsToScan)(this.page).catch(function () { return null; })];
@@ -235,6 +241,9 @@ var HostLayer = /** @class */ (function () {
235
241
  if (!(result === null || result === void 0 ? void 0 : result.urlCode) || this.urlCode === result.urlCode) {
236
242
  return [2 /*return*/];
237
243
  }
244
+ if (typeof this.options.phoneNumber !== undefined) {
245
+ return [2 /*return*/, this.loginByCode(this.options.phoneNumber)];
246
+ }
238
247
  this.urlCode = result.urlCode;
239
248
  this.attempt++;
240
249
  qr = '';
@@ -256,10 +265,44 @@ var HostLayer = /** @class */ (function () {
256
265
  });
257
266
  });
258
267
  };
268
+ HostLayer.prototype.loginByCode = function (phone) {
269
+ return __awaiter(this, void 0, void 0, function () {
270
+ var code;
271
+ var _this = this;
272
+ var _a;
273
+ return __generator(this, function (_b) {
274
+ switch (_b.label) {
275
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
276
+ var _c, _d, _e, _f;
277
+ var phone = _b.phone;
278
+ return __generator(this, function (_g) {
279
+ switch (_g.label) {
280
+ case 0:
281
+ _d = (_c = JSON).parse;
282
+ _f = (_e = JSON).stringify;
283
+ return [4 /*yield*/, WPP.conn.genLinkDeviceCodeForPhoneNumber(phone)];
284
+ case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
285
+ }
286
+ });
287
+ }); }, { phone: phone })];
288
+ case 1:
289
+ code = _b.sent();
290
+ if (this.options.logQR) {
291
+ this.log('info', "Waiting for Login By Code (Code: ".concat(code, ")\n"));
292
+ }
293
+ else {
294
+ this.log('verbose', "Waiting for Login By Code");
295
+ }
296
+ (_a = this.catchLinkCode) === null || _a === void 0 ? void 0 : _a.call(this, code);
297
+ return [2 /*return*/];
298
+ }
299
+ });
300
+ });
301
+ };
259
302
  HostLayer.prototype.checkInChat = function () {
260
- var _a;
261
303
  return __awaiter(this, void 0, void 0, function () {
262
304
  var inChat;
305
+ var _a;
263
306
  return __generator(this, function (_b) {
264
307
  switch (_b.label) {
265
308
  case 0: return [4 /*yield*/, (0, auth_1.isInsideChat)(this.page).catch(function () { return null; })];
@@ -409,9 +452,9 @@ var HostLayer = /** @class */ (function () {
409
452
  });
410
453
  };
411
454
  HostLayer.prototype.waitForLogin = function () {
412
- var _a, _b, _c, _d, _e, _f;
413
455
  return __awaiter(this, void 0, void 0, function () {
414
456
  var authenticated, inChat;
457
+ var _a, _b, _c, _d, _e, _f;
415
458
  return __generator(this, function (_g) {
416
459
  switch (_g.label) {
417
460
  case 0:
@@ -425,12 +468,16 @@ var HostLayer = /** @class */ (function () {
425
468
  authenticated = _g.sent();
426
469
  this.startAutoClose();
427
470
  if (!(authenticated === false)) return [3 /*break*/, 6];
428
- this.log('http', 'Waiting for QRCode Scan...');
471
+ this.log('http', typeof this.options.phoneNumber !== undefined
472
+ ? 'Waiting for Login by Code...'
473
+ : 'Waiting for QRCode Scan...');
429
474
  (_a = this.statusFind) === null || _a === void 0 ? void 0 : _a.call(this, 'notLogged', this.session);
430
475
  return [4 /*yield*/, this.waitForQrCodeScan()];
431
476
  case 3:
432
477
  _g.sent();
433
- this.log('http', 'Checking QRCode status...');
478
+ this.log('http', typeof this.options.phoneNumber !== undefined
479
+ ? 'Checking Login by Code status...'
480
+ : 'Checking QRCode status...');
434
481
  // Wait for interface update
435
482
  return [4 /*yield*/, (0, sleep_1.sleep)(200)];
436
483
  case 4:
@@ -444,11 +491,11 @@ var HostLayer = /** @class */ (function () {
444
491
  (_b = this.statusFind) === null || _b === void 0 ? void 0 : _b.call(this, 'qrReadError', this.session);
445
492
  }
446
493
  else if (authenticated) {
447
- this.log('http', 'QRCode Success');
494
+ this.log('http', 'Login with success');
448
495
  (_c = this.statusFind) === null || _c === void 0 ? void 0 : _c.call(this, 'qrReadSuccess', this.session);
449
496
  }
450
497
  else {
451
- this.log('warn', 'QRCode Fail');
498
+ this.log('warn', 'Login Fail');
452
499
  (_d = this.statusFind) === null || _d === void 0 ? void 0 : _d.call(this, 'qrReadFail', this.session);
453
500
  this.tryAutoClose();
454
501
  throw 'Failed to read the QRCode';
@@ -645,9 +692,9 @@ var HostLayer = /** @class */ (function () {
645
692
  * @category Host
646
693
  * @param interval interval number in miliseconds
647
694
  */
648
- HostLayer.prototype.startPhoneWatchdog = function (interval) {
649
- if (interval === void 0) { interval = 15000; }
650
- return __awaiter(this, void 0, void 0, function () {
695
+ HostLayer.prototype.startPhoneWatchdog = function () {
696
+ return __awaiter(this, arguments, void 0, function (interval) {
697
+ if (interval === void 0) { interval = 15000; }
651
698
  return __generator(this, function (_a) {
652
699
  switch (_a.label) {
653
700
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (interval) { return WAPI.startPhoneWatchdog(interval); }, interval)];
@@ -185,9 +185,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
185
185
  * @returns array of [Chat]
186
186
  * @deprecated Deprecated in favor of listChats.
187
187
  */
188
- RetrieverLayer.prototype.getAllChats = function (withNewMessageOnly) {
189
- if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
190
- return __awaiter(this, void 0, void 0, function () {
188
+ RetrieverLayer.prototype.getAllChats = function () {
189
+ return __awaiter(this, arguments, void 0, function (withNewMessageOnly) {
190
+ if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
191
191
  return __generator(this, function (_a) {
192
192
  this.logger.warn('Deprecated: This function [getAllChats] is deprecated in favor of the listChats function. Please update your code accordingly.');
193
193
  if (withNewMessageOnly) {
@@ -236,21 +236,19 @@ var RetrieverLayer = /** @class */ (function (_super) {
236
236
  var _this = this;
237
237
  return __generator(this, function (_a) {
238
238
  switch (_a.label) {
239
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
240
- var options = _a.options;
241
- return __awaiter(_this, void 0, void 0, function () {
242
- var chats, serialized;
243
- return __generator(this, function (_b) {
244
- switch (_b.label) {
245
- case 0: return [4 /*yield*/, WPP.chat.list(options)];
246
- case 1:
247
- chats = _b.sent();
248
- serialized = chats.map(function (c) { return WAPI._serializeChatObj(c); });
249
- return [2 /*return*/, serialized];
250
- }
251
- });
239
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
240
+ var chats, serialized;
241
+ var options = _b.options;
242
+ return __generator(this, function (_c) {
243
+ switch (_c.label) {
244
+ case 0: return [4 /*yield*/, WPP.chat.list(options)];
245
+ case 1:
246
+ chats = _c.sent();
247
+ serialized = chats.map(function (c) { return WAPI._serializeChatObj(c); });
248
+ return [2 /*return*/, serialized];
249
+ }
252
250
  });
253
- }, { options: options })];
251
+ }); }, { options: options })];
254
252
  case 1: return [2 /*return*/, _a.sent()];
255
253
  }
256
254
  });
@@ -280,9 +278,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
280
278
  * @returns array of [Chat]
281
279
  * @deprecated Deprecated in favor of listChats.
282
280
  */
283
- RetrieverLayer.prototype.getAllChatsWithMessages = function (withNewMessageOnly) {
284
- if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
285
- return __awaiter(this, void 0, void 0, function () {
281
+ RetrieverLayer.prototype.getAllChatsWithMessages = function () {
282
+ return __awaiter(this, arguments, void 0, function (withNewMessageOnly) {
283
+ if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
286
284
  return __generator(this, function (_a) {
287
285
  this.logger.warn('Deprecated: This function [getAllChatsWithMessages] is deprecated in favor of the listChats function. Please update your code accordingly.');
288
286
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (withNewMessageOnly) {
@@ -299,34 +297,32 @@ var RetrieverLayer = /** @class */ (function (_super) {
299
297
  * @returns array of groups
300
298
  * @deprecated Deprecated in favor of listChats.
301
299
  */
302
- RetrieverLayer.prototype.getAllGroups = function (withNewMessagesOnly) {
303
- if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
304
- return __awaiter(this, void 0, void 0, function () {
300
+ RetrieverLayer.prototype.getAllGroups = function () {
301
+ return __awaiter(this, arguments, void 0, function (withNewMessagesOnly) {
305
302
  var _this = this;
303
+ if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
306
304
  return __generator(this, function (_a) {
307
305
  switch (_a.label) {
308
306
  case 0:
309
307
  this.logger.warn('Deprecated: This function [getAllGroups] is deprecated in favor of the listChats function. Please update your code accordingly.');
310
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
311
- var withNewMessagesOnly = _a.withNewMessagesOnly;
312
- return __awaiter(_this, void 0, void 0, function () {
313
- var chats, groups;
314
- return __generator(this, function (_b) {
315
- switch (_b.label) {
316
- case 0: return [4 /*yield*/, WPP.chat.list({
317
- onlyGroups: true,
318
- onlyWithUnreadMessage: withNewMessagesOnly,
319
- })];
320
- case 1:
321
- chats = _b.sent();
322
- return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
323
- case 2:
324
- groups = _b.sent();
325
- return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
326
- }
327
- });
308
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
309
+ var chats, groups;
310
+ var withNewMessagesOnly = _b.withNewMessagesOnly;
311
+ return __generator(this, function (_c) {
312
+ switch (_c.label) {
313
+ case 0: return [4 /*yield*/, WPP.chat.list({
314
+ onlyGroups: true,
315
+ onlyWithUnreadMessage: withNewMessagesOnly,
316
+ })];
317
+ case 1:
318
+ chats = _c.sent();
319
+ return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
320
+ case 2:
321
+ groups = _c.sent();
322
+ return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
323
+ }
328
324
  });
329
- }, { withNewMessagesOnly: withNewMessagesOnly })];
325
+ }); }, { withNewMessagesOnly: withNewMessagesOnly })];
330
326
  case 1: return [2 /*return*/, _a.sent()];
331
327
  }
332
328
  });
@@ -567,10 +563,10 @@ var RetrieverLayer = /** @class */ (function (_super) {
567
563
  * @param includeNotifications
568
564
  * @returns any
569
565
  */
570
- RetrieverLayer.prototype.loadAndGetAllMessagesInChat = function (chatId, includeMe, includeNotifications) {
571
- if (includeMe === void 0) { includeMe = false; }
572
- if (includeNotifications === void 0) { includeNotifications = false; }
573
- return __awaiter(this, void 0, void 0, function () {
566
+ RetrieverLayer.prototype.loadAndGetAllMessagesInChat = function (chatId_1) {
567
+ return __awaiter(this, arguments, void 0, function (chatId, includeMe, includeNotifications) {
568
+ if (includeMe === void 0) { includeMe = false; }
569
+ if (includeNotifications === void 0) { includeNotifications = false; }
574
570
  return __generator(this, function (_a) {
575
571
  switch (_a.label) {
576
572
  case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {