@wppconnect-team/wppconnect 1.16.1 → 1.17.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,21 @@
1
+ ## 1.17.1 (2022-10-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @wppconnect/wa-js to ^2.13.1 ([#1364](https://github.com/wppconnect-team/wppconnect/issues/1364)) ([ff92035](https://github.com/wppconnect-team/wppconnect/commit/ff92035cb05abc21a8e241d8c7d3d5be4614edfb))
7
+
8
+
9
+
10
+ # 1.17.0 (2022-09-17)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **deps:** update dependency @wppconnect/wa-version to ^1.1.154 ([#1334](https://github.com/wppconnect-team/wppconnect/issues/1334)) ([daa94ef](https://github.com/wppconnect-team/wppconnect/commit/daa94ef808660bd5acb143ceb8c9bff9a3a25a18))
16
+
17
+
18
+
1
19
  ## 1.16.1 (2022-08-09)
2
20
 
3
21
 
package/README.md CHANGED
@@ -13,8 +13,8 @@
13
13
  > WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, 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... 😀🤔💭
14
14
 
15
15
  <p align="center">
16
- <a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/installation.html">Getting Started</a> •
17
- <a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/basic-functions.html">Basic Function</a> •
16
+ <a href="https://wppconnect.io/wppconnect/pages/getting-started/installation.html">Getting Started</a> •
17
+ <a href="https://wppconnect.io/wppconnect/pages/getting-started/basic-functions.html">Basic Function</a> •
18
18
  <a href="https://wppconnect.io/wppconnect/">Documentation</a>
19
19
  </p>
20
20
 
@@ -52,7 +52,7 @@ The first thing that you had to do is install the `npm package` :
52
52
  npm i --save @wppconnect-team/wppconnect
53
53
  ```
54
54
 
55
- See more at <a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/installation.html">Getting Started</a>
55
+ See more at <a href="https://wppconnect.io/wppconnect/pages/getting-started/installation.html">Getting Started</a>
56
56
 
57
57
  ## Development
58
58
 
@@ -0,0 +1,143 @@
1
+ import { Page } from 'puppeteer';
2
+ import { CreateConfig } from '../../config/create-config';
3
+ import { HostLayer } from './host.layer';
4
+ export declare class CatalogLayer extends HostLayer {
5
+ page: Page;
6
+ constructor(page: Page, session?: string, options?: CreateConfig);
7
+ /**
8
+ * Querys all products
9
+ * @param id Buisness profile id ('00000@c.us')
10
+ * @param qnt limit to load products - Default: 10
11
+ */
12
+ getProducts(id: string, qnt: number): Promise<any[]>;
13
+ /**
14
+ * Create a new product on catalog
15
+ * @param id Buisness profile id ('00000@c.us')
16
+ * @param productId ID of Product
17
+ */
18
+ getProductById(id: string, productId: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductModel>;
19
+ /**
20
+ * Edit product on catalog
21
+ * @param productId Product ID
22
+ * @param options Object with options
23
+ * @example
24
+ * ```javascript
25
+ * client.editProduct('56989897878' {
26
+ * name: 'Product name',
27
+ * description: 'product description',
28
+ * price: '89.90',
29
+ * isHidden: true,
30
+ * url: 'https://wppconnect.io',
31
+ * retailerId: 'AKA001',
32
+ * });
33
+ * ```
34
+ */
35
+ editProduct(productId: string, options: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductModel>;
36
+ /**
37
+ * Delete product(s) on catalog
38
+ * @param productsId Products ID
39
+ * @example
40
+ * ```javascript
41
+ * //Delete one product
42
+ * client.delProducts(['56989897878']);
43
+ *
44
+ * // Delete various products
45
+ * client.delProducts(['56989897878','565657878']);
46
+ * ```
47
+ */
48
+ delProducts(productsId: string[]): Promise<any>;
49
+ /**
50
+ * Add image on product This function change main image of product, for change additional images use client.addImage
51
+ * @param productId Product ID
52
+ * @param image Image in base64
53
+ * @example
54
+ * ```javascript
55
+ * client.changeProductImage('56989897878', 'base64/string');
56
+ * ```
57
+ */
58
+ changeProductImage(productId: string, image: string): Promise<any>;
59
+ /**
60
+ * Add image on product This function include additional images on product for change main image use client.changeProductImage
61
+ * @param productId Product ID
62
+ * @param image Image in base64
63
+ * @example
64
+ * ```javascript
65
+ * client.addProductImage('56989897878', 'base64/string');
66
+ * ```
67
+ */
68
+ addProductImage(productId: string, image: string): Promise<any>;
69
+ /**
70
+ * Remove image on product This function remove additional images of product for change main image use client.changeProductImage
71
+ * @param productId Product ID
72
+ * @param index Index array of additional imagens
73
+ * @example
74
+ * ```javascript
75
+ * client.removeProductImage('56989897878', '1');
76
+ * ```
77
+ */
78
+ removeProductImage(productId: string, index: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductModel>;
79
+ /**
80
+ * Query all collections
81
+ * @param id Product ID
82
+ * @param qnt Max qnt collections - Default 10
83
+ * @param maxProducts Max products in array products of collection - Default 10
84
+ * @example
85
+ * ```javascript
86
+ * client.getCollections('5521988556558@c.us', '10','20');
87
+ * ```
88
+ */
89
+ getCollections(id: string, qnt: string, maxProducts: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ProductCollModel[]>;
90
+ /**
91
+ * Create new collection
92
+ * @param collectionName Product ID
93
+ * @param productsId Index array of additional imagens
94
+ * @example
95
+ * ```javascript
96
+ * client.createCollection('Name of collection', ['655632565','5689859898']);
97
+ * ```
98
+ */
99
+ createCollection(collectionName: string, productsId: string): Promise<any>;
100
+ /**
101
+ * Edit a collection
102
+ * @param collectionId Collection id
103
+ * @param options Options arguments
104
+ * @example
105
+ * ```javascript
106
+ * client.editCollection('656565898', {
107
+ * collectionName: 'New Name for collection',
108
+ * productsToAdd: ['5656523223'],
109
+ * productsToRemove: ['5656523232']
110
+ * });
111
+ * ```
112
+ */
113
+ editCollection(collectionId: string, options: string): Promise<any>;
114
+ /**
115
+ * Delete a collection
116
+ * @param collectionId Collection id
117
+ * @param options Options arguments
118
+ * @example
119
+ * ```javascript
120
+ * client.deleteCollection('65666565898');
121
+ * ```
122
+ */
123
+ deleteCollection(collectionId: string): Promise<any>;
124
+ /**
125
+ * Set product visibility
126
+ * @param productId Product id
127
+ * @param value True for visibility, false for non visible
128
+ * @example
129
+ * ```javascript
130
+ * client.setProductVisibility('65666565898', false);
131
+ * ```
132
+ */
133
+ setProductVisibility(productId: string, value: boolean): Promise<any>;
134
+ /**
135
+ * Update options to customer cart your products
136
+ * @param value True for enabled, false for non enabled
137
+ * @example
138
+ * ```javascript
139
+ * client.updateCartEnabled(false);
140
+ * ```
141
+ */
142
+ updateCartEnabled(value: boolean): Promise<any>;
143
+ }
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+ /*
3
+ * This file is part of WPPConnect.
4
+ *
5
+ * WPPConnect is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Lesser General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * WPPConnect is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public License
16
+ * along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ var __extends = (this && this.__extends) || (function () {
19
+ var extendStatics = function (d, b) {
20
+ extendStatics = Object.setPrototypeOf ||
21
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
+ return extendStatics(d, b);
24
+ };
25
+ return function (d, b) {
26
+ if (typeof b !== "function" && b !== null)
27
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28
+ extendStatics(d, b);
29
+ function __() { this.constructor = d; }
30
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
+ };
32
+ })();
33
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ };
42
+ var __generator = (this && this.__generator) || function (thisArg, body) {
43
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
44
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45
+ function verb(n) { return function (v) { return step([n, v]); }; }
46
+ function step(op) {
47
+ if (f) throw new TypeError("Generator is already executing.");
48
+ while (_) try {
49
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
50
+ if (y = 0, t) op = [op[0] & 2, t.value];
51
+ switch (op[0]) {
52
+ case 0: case 1: t = op; break;
53
+ case 4: _.label++; return { value: op[1], done: false };
54
+ case 5: _.label++; y = op[1]; op = [0]; continue;
55
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
56
+ default:
57
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
58
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
59
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
60
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
61
+ if (t[2]) _.ops.pop();
62
+ _.trys.pop(); continue;
63
+ }
64
+ op = body.call(thisArg, _);
65
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
66
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
67
+ }
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.CatalogLayer = void 0;
71
+ var helpers_1 = require("../helpers");
72
+ var host_layer_1 = require("./host.layer");
73
+ var CatalogLayer = /** @class */ (function (_super) {
74
+ __extends(CatalogLayer, _super);
75
+ function CatalogLayer(page, session, options) {
76
+ var _this = _super.call(this, page, session, options) || this;
77
+ _this.page = page;
78
+ return _this;
79
+ }
80
+ /**
81
+ * Querys all products
82
+ * @param id Buisness profile id ('00000@c.us')
83
+ * @param qnt limit to load products - Default: 10
84
+ */
85
+ CatalogLayer.prototype.getProducts = function (id, qnt) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ return __generator(this, function (_a) {
88
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
89
+ var id = _a.id, qnt = _a.qnt;
90
+ return WPP.catalog.getProducts(id, qnt);
91
+ }, { id: id, qnt: qnt })];
92
+ });
93
+ });
94
+ };
95
+ /**
96
+ * Create a new product on catalog
97
+ * @param id Buisness profile id ('00000@c.us')
98
+ * @param productId ID of Product
99
+ */
100
+ CatalogLayer.prototype.getProductById = function (id, productId) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
104
+ var id = _a.id, productId = _a.productId;
105
+ return WPP.catalog.getProductById(id, productId);
106
+ }, { id: id, productId: productId })];
107
+ });
108
+ });
109
+ };
110
+ /**
111
+ * Edit product on catalog
112
+ * @param productId Product ID
113
+ * @param options Object with options
114
+ * @example
115
+ * ```javascript
116
+ * client.editProduct('56989897878' {
117
+ * name: 'Product name',
118
+ * description: 'product description',
119
+ * price: '89.90',
120
+ * isHidden: true,
121
+ * url: 'https://wppconnect.io',
122
+ * retailerId: 'AKA001',
123
+ * });
124
+ * ```
125
+ */
126
+ CatalogLayer.prototype.editProduct = function (productId, options) {
127
+ return __awaiter(this, void 0, void 0, function () {
128
+ return __generator(this, function (_a) {
129
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
130
+ var productId = _a.productId, options = _a.options;
131
+ return WPP.catalog.editProduct(productId, options);
132
+ }, { productId: productId, options: options })];
133
+ });
134
+ });
135
+ };
136
+ /**
137
+ * Delete product(s) on catalog
138
+ * @param productsId Products ID
139
+ * @example
140
+ * ```javascript
141
+ * //Delete one product
142
+ * client.delProducts(['56989897878']);
143
+ *
144
+ * // Delete various products
145
+ * client.delProducts(['56989897878','565657878']);
146
+ * ```
147
+ */
148
+ CatalogLayer.prototype.delProducts = function (productsId) {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ return __generator(this, function (_a) {
151
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
152
+ var productsId = _a.productsId;
153
+ return WPP.catalog.delProducts(productsId);
154
+ }, { productsId: productsId })];
155
+ });
156
+ });
157
+ };
158
+ /**
159
+ * Add image on product This function change main image of product, for change additional images use client.addImage
160
+ * @param productId Product ID
161
+ * @param image Image in base64
162
+ * @example
163
+ * ```javascript
164
+ * client.changeProductImage('56989897878', 'base64/string');
165
+ * ```
166
+ */
167
+ CatalogLayer.prototype.changeProductImage = function (productId, image) {
168
+ return __awaiter(this, void 0, void 0, function () {
169
+ return __generator(this, function (_a) {
170
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
171
+ var productId = _a.productId, image = _a.image;
172
+ return WPP.catalog.changeProductImage(productId, image);
173
+ }, { productId: productId, image: image })];
174
+ });
175
+ });
176
+ };
177
+ /**
178
+ * Add image on product This function include additional images on product for change main image use client.changeProductImage
179
+ * @param productId Product ID
180
+ * @param image Image in base64
181
+ * @example
182
+ * ```javascript
183
+ * client.addProductImage('56989897878', 'base64/string');
184
+ * ```
185
+ */
186
+ CatalogLayer.prototype.addProductImage = function (productId, image) {
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ return __generator(this, function (_a) {
189
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
190
+ var productId = _a.productId, image = _a.image;
191
+ return WPP.catalog.addProductImage(productId, image);
192
+ }, { productId: productId, image: image })];
193
+ });
194
+ });
195
+ };
196
+ /**
197
+ * Remove image on product This function remove additional images of product for change main image use client.changeProductImage
198
+ * @param productId Product ID
199
+ * @param index Index array of additional imagens
200
+ * @example
201
+ * ```javascript
202
+ * client.removeProductImage('56989897878', '1');
203
+ * ```
204
+ */
205
+ CatalogLayer.prototype.removeProductImage = function (productId, index) {
206
+ return __awaiter(this, void 0, void 0, function () {
207
+ return __generator(this, function (_a) {
208
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
209
+ var productId = _a.productId, index = _a.index;
210
+ return WPP.catalog.removeProductImage(productId, index);
211
+ }, { productId: productId, index: index })];
212
+ });
213
+ });
214
+ };
215
+ /**
216
+ * Query all collections
217
+ * @param id Product ID
218
+ * @param qnt Max qnt collections - Default 10
219
+ * @param maxProducts Max products in array products of collection - Default 10
220
+ * @example
221
+ * ```javascript
222
+ * client.getCollections('5521988556558@c.us', '10','20');
223
+ * ```
224
+ */
225
+ CatalogLayer.prototype.getCollections = function (id, qnt, maxProducts) {
226
+ return __awaiter(this, void 0, void 0, function () {
227
+ return __generator(this, function (_a) {
228
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
229
+ var id = _a.id, qnt = _a.qnt, maxProducts = _a.maxProducts;
230
+ return WPP.catalog.getCollections(id, qnt, maxProducts);
231
+ }, { id: id, qnt: qnt, maxProducts: maxProducts })];
232
+ });
233
+ });
234
+ };
235
+ /**
236
+ * Create new collection
237
+ * @param collectionName Product ID
238
+ * @param productsId Index array of additional imagens
239
+ * @example
240
+ * ```javascript
241
+ * client.createCollection('Name of collection', ['655632565','5689859898']);
242
+ * ```
243
+ */
244
+ CatalogLayer.prototype.createCollection = function (collectionName, productsId) {
245
+ return __awaiter(this, void 0, void 0, function () {
246
+ return __generator(this, function (_a) {
247
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
248
+ var collectionName = _a.collectionName, productsId = _a.productsId;
249
+ return WPP.catalog.createCollection(collectionName, productsId);
250
+ }, { collectionName: collectionName, productsId: productsId })];
251
+ });
252
+ });
253
+ };
254
+ /**
255
+ * Edit a collection
256
+ * @param collectionId Collection id
257
+ * @param options Options arguments
258
+ * @example
259
+ * ```javascript
260
+ * client.editCollection('656565898', {
261
+ * collectionName: 'New Name for collection',
262
+ * productsToAdd: ['5656523223'],
263
+ * productsToRemove: ['5656523232']
264
+ * });
265
+ * ```
266
+ */
267
+ CatalogLayer.prototype.editCollection = function (collectionId, options) {
268
+ return __awaiter(this, void 0, void 0, function () {
269
+ return __generator(this, function (_a) {
270
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
271
+ var collectionId = _a.collectionId, options = _a.options;
272
+ return WPP.catalog.editCollection(collectionId, options);
273
+ }, { collectionId: collectionId, options: options })];
274
+ });
275
+ });
276
+ };
277
+ /**
278
+ * Delete a collection
279
+ * @param collectionId Collection id
280
+ * @param options Options arguments
281
+ * @example
282
+ * ```javascript
283
+ * client.deleteCollection('65666565898');
284
+ * ```
285
+ */
286
+ CatalogLayer.prototype.deleteCollection = function (collectionId) {
287
+ return __awaiter(this, void 0, void 0, function () {
288
+ return __generator(this, function (_a) {
289
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
290
+ var collectionId = _a.collectionId;
291
+ return WPP.catalog.deleteCollection(collectionId);
292
+ }, { collectionId: collectionId })];
293
+ });
294
+ });
295
+ };
296
+ /**
297
+ * Set product visibility
298
+ * @param productId Product id
299
+ * @param value True for visibility, false for non visible
300
+ * @example
301
+ * ```javascript
302
+ * client.setProductVisibility('65666565898', false);
303
+ * ```
304
+ */
305
+ CatalogLayer.prototype.setProductVisibility = function (productId, value) {
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ return __generator(this, function (_a) {
308
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
309
+ var productId = _a.productId, value = _a.value;
310
+ return WPP.catalog.setProductVisibility(productId, value);
311
+ }, { productId: productId, value: value })];
312
+ });
313
+ });
314
+ };
315
+ /**
316
+ * Update options to customer cart your products
317
+ * @param value True for enabled, false for non enabled
318
+ * @example
319
+ * ```javascript
320
+ * client.updateCartEnabled(false);
321
+ * ```
322
+ */
323
+ CatalogLayer.prototype.updateCartEnabled = function (value) {
324
+ return __awaiter(this, void 0, void 0, function () {
325
+ return __generator(this, function (_a) {
326
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
327
+ var value = _a.value;
328
+ return WPP.catalog.updateCartEnabled(value);
329
+ }, { value: value })];
330
+ });
331
+ });
332
+ };
333
+ return CatalogLayer;
334
+ }(host_layer_1.HostLayer));
335
+ exports.CatalogLayer = CatalogLayer;
@@ -138,9 +138,6 @@ var HostLayer = /** @class */ (function () {
138
138
  }
139
139
  hasUserDataDir = !!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.puppeteerOptions) === null || _b === void 0 ? void 0 : _b.userDataDir);
140
140
  clear = !hasUserDataDir || (hasUserDataDir && !isValidToken);
141
- return [4 /*yield*/, (0, browser_1.initWhatsapp)(this.page, sessionToken, clear, this.options.whatsappVersion)];
142
- case 3:
143
- _c.sent();
144
141
  this.page.on('load', function () {
145
142
  _this.log('verbose', 'Page loaded', { type: 'page' });
146
143
  _this.afterPageLoad();
@@ -149,6 +146,9 @@ var HostLayer = /** @class */ (function () {
149
146
  _this.cancelAutoClose();
150
147
  _this.log('verbose', 'Page Closed', { type: 'page' });
151
148
  });
149
+ return [4 /*yield*/, (0, browser_1.initWhatsapp)(this.page, sessionToken, clear, this.options.whatsappVersion)];
150
+ case 3:
151
+ _c.sent();
152
152
  return [2 /*return*/];
153
153
  }
154
154
  });
@@ -1,11 +1,12 @@
1
1
  import { Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../../config/create-config';
3
- import { HostLayer } from './host.layer';
4
- export declare class LabelsLayer extends HostLayer {
3
+ import { CatalogLayer } from './catalog.layer';
4
+ export declare class LabelsLayer extends CatalogLayer {
5
5
  page: Page;
6
6
  constructor(page: Page, session?: string, options?: CreateConfig);
7
7
  /**
8
8
  * Create New Label
9
+ * @category Labels
9
10
  *
10
11
  * @example
11
12
  * ```javascript
@@ -21,6 +22,7 @@ export declare class LabelsLayer extends HostLayer {
21
22
  addNewLabel(name: string, options?: string): Promise<void>;
22
23
  /**
23
24
  * Add or delete label of chatId
25
+ * @category Labels
24
26
  *
25
27
  * @example
26
28
  * ```javascript
@@ -28,7 +30,7 @@ export declare class LabelsLayer extends HostLayer {
28
30
  * [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
29
31
  * //or
30
32
  * ```
31
- * @param name Name of label
33
+ * @param chatIds ChatIds
32
34
  * @param options options to remove or add
33
35
  */
34
36
  addOrRemoveLabels(chatIds: string, options: string): Promise<void>;
@@ -41,8 +43,20 @@ export declare class LabelsLayer extends HostLayer {
41
43
  * ```
42
44
  */
43
45
  getAllLabels(): Promise<import("@wppconnect/wa-js/dist/labels").Label[]>;
46
+ /**
47
+ * Get Label by id
48
+ * @category Labels
49
+ * @param id - Id of label
50
+ *
51
+ * @example
52
+ * ```javascript
53
+ * client.getLabelById('1');
54
+ * ```
55
+ */
56
+ getLabelById(id: string): Promise<void>;
44
57
  /**
45
58
  * Delete all Labels
59
+ * @category Labels
46
60
  *
47
61
  * @example
48
62
  * ```javascript
@@ -52,6 +66,7 @@ export declare class LabelsLayer extends HostLayer {
52
66
  deleteAllLabels(): Promise<void>;
53
67
  /**
54
68
  * Add or delete label of chatId
69
+ * @category Labels
55
70
  *
56
71
  * @example
57
72
  * ```javascript
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  Object.defineProperty(exports, "__esModule", { value: true });
70
70
  exports.LabelsLayer = void 0;
71
- var host_layer_1 = require("./host.layer");
72
71
  var helpers_1 = require("../helpers");
72
+ var catalog_layer_1 = require("./catalog.layer");
73
73
  var LabelsLayer = /** @class */ (function (_super) {
74
74
  __extends(LabelsLayer, _super);
75
75
  function LabelsLayer(page, session, options) {
@@ -79,6 +79,7 @@ var LabelsLayer = /** @class */ (function (_super) {
79
79
  }
80
80
  /**
81
81
  * Create New Label
82
+ * @category Labels
82
83
  *
83
84
  * @example
84
85
  * ```javascript
@@ -106,6 +107,7 @@ var LabelsLayer = /** @class */ (function (_super) {
106
107
  };
107
108
  /**
108
109
  * Add or delete label of chatId
110
+ * @category Labels
109
111
  *
110
112
  * @example
111
113
  * ```javascript
@@ -113,7 +115,7 @@ var LabelsLayer = /** @class */ (function (_super) {
113
115
  * [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
114
116
  * //or
115
117
  * ```
116
- * @param name Name of label
118
+ * @param chatIds ChatIds
117
119
  * @param options options to remove or add
118
120
  */
119
121
  LabelsLayer.prototype.addOrRemoveLabels = function (chatIds, options) {
@@ -144,8 +146,32 @@ var LabelsLayer = /** @class */ (function (_super) {
144
146
  });
145
147
  });
146
148
  };
149
+ /**
150
+ * Get Label by id
151
+ * @category Labels
152
+ * @param id - Id of label
153
+ *
154
+ * @example
155
+ * ```javascript
156
+ * client.getLabelById('1');
157
+ * ```
158
+ */
159
+ LabelsLayer.prototype.getLabelById = function (id) {
160
+ return __awaiter(this, void 0, void 0, function () {
161
+ return __generator(this, function (_a) {
162
+ switch (_a.label) {
163
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
164
+ var id = _a.id;
165
+ WPP.labels.getLabelById(id);
166
+ }, { id: id })];
167
+ case 1: return [2 /*return*/, _a.sent()];
168
+ }
169
+ });
170
+ });
171
+ };
147
172
  /**
148
173
  * Delete all Labels
174
+ * @category Labels
149
175
  *
150
176
  * @example
151
177
  * ```javascript
@@ -166,6 +192,7 @@ var LabelsLayer = /** @class */ (function (_super) {
166
192
  };
167
193
  /**
168
194
  * Add or delete label of chatId
195
+ * @category Labels
169
196
  *
170
197
  * @example
171
198
  * ```javascript
@@ -187,5 +214,5 @@ var LabelsLayer = /** @class */ (function (_super) {
187
214
  });
188
215
  };
189
216
  return LabelsLayer;
190
- }(host_layer_1.HostLayer));
217
+ }(catalog_layer_1.CatalogLayer));
191
218
  exports.LabelsLayer = LabelsLayer;
@@ -184,4 +184,16 @@ export declare class RetrieverLayer extends SenderLayer {
184
184
  * @param chatId chat id: xxxxx@c.us
185
185
  */
186
186
  getLastSeen(chatId: string): Promise<number | boolean>;
187
+ /**
188
+ * Get the platform message from message ID
189
+ *
190
+ * The platform can be:
191
+ * android
192
+ * iphone
193
+ * web
194
+ * unknown
195
+ * @category Chat
196
+ * @param chatId chat id: xxxxx@c.us
197
+ */
198
+ getPlatformFromMessage(msgId: string): Promise<string>;
187
199
  }
@@ -543,6 +543,27 @@ var RetrieverLayer = /** @class */ (function (_super) {
543
543
  });
544
544
  });
545
545
  };
546
+ /**
547
+ * Get the platform message from message ID
548
+ *
549
+ * The platform can be:
550
+ * android
551
+ * iphone
552
+ * web
553
+ * unknown
554
+ * @category Chat
555
+ * @param chatId chat id: xxxxx@c.us
556
+ */
557
+ RetrieverLayer.prototype.getPlatformFromMessage = function (msgId) {
558
+ return __awaiter(this, void 0, void 0, function () {
559
+ return __generator(this, function (_a) {
560
+ switch (_a.label) {
561
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (msgId) { return WPP.chat.getPlatformFromMessage(msgId); }, msgId)];
562
+ case 1: return [2 /*return*/, _a.sent()];
563
+ }
564
+ });
565
+ });
566
+ };
546
567
  return RetrieverLayer;
547
568
  }(sender_layer_1.SenderLayer));
548
569
  exports.RetrieverLayer = RetrieverLayer;
@@ -334,6 +334,12 @@ export declare class SenderLayer extends ListenerLayer {
334
334
  wid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
335
335
  unreadCount: number;
336
336
  }>;
337
+ /**
338
+ * Sets a audio or image view once. Marks message as played
339
+ * @category Chat
340
+ * @param msgId Message id: xxxxx@us.c
341
+ */
342
+ markPlayed(msgId: string): Promise<any>;
337
343
  /**
338
344
  * Starts typing ('Typing...' state)
339
345
  *
@@ -382,7 +388,7 @@ export declare class SenderLayer extends ListenerLayer {
382
388
  * @category Chat
383
389
  * @param online true for available presence and false for unavailable
384
390
  */
385
- setOnlinePresence(online?: boolean): Promise<void>;
391
+ setOnlinePresence(online?: boolean): Promise<boolean>;
386
392
  /**
387
393
  * Sends text with tags
388
394
  * @category Chat
@@ -1073,6 +1073,18 @@ var SenderLayer = /** @class */ (function (_super) {
1073
1073
  });
1074
1074
  });
1075
1075
  };
1076
+ /**
1077
+ * Sets a audio or image view once. Marks message as played
1078
+ * @category Chat
1079
+ * @param msgId Message id: xxxxx@us.c
1080
+ */
1081
+ SenderLayer.prototype.markPlayed = function (msgId) {
1082
+ return __awaiter(this, void 0, void 0, function () {
1083
+ return __generator(this, function (_a) {
1084
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (msgId) { return WPP.chat.markPlayed(msgId); }, msgId)];
1085
+ });
1086
+ });
1087
+ };
1076
1088
  /**
1077
1089
  * Starts typing ('Typing...' state)
1078
1090
  *
@@ -1173,7 +1185,7 @@ var SenderLayer = /** @class */ (function (_super) {
1173
1185
  return __generator(this, function (_a) {
1174
1186
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1175
1187
  var online = _a.online;
1176
- return WAPI.setOnlinePresence(online);
1188
+ return WPP.conn.markAvailable(online);
1177
1189
  }, {
1178
1190
  online: online,
1179
1191
  })];
@@ -6,6 +6,7 @@ export declare class StatusLayer extends LabelsLayer {
6
6
  constructor(page: Page, session?: string, options?: CreateConfig);
7
7
  /**
8
8
  * Send a image message to status stories
9
+ * @category Status
9
10
  *
10
11
  * @example
11
12
  * ```javascript
@@ -16,6 +17,7 @@ export declare class StatusLayer extends LabelsLayer {
16
17
  sendImageStatus(pathOrBase64: string): Promise<void>;
17
18
  /**
18
19
  * Send a video message to status stories
20
+ * @category Status
19
21
  *
20
22
  * @example
21
23
  * ```javascript
@@ -26,6 +28,7 @@ export declare class StatusLayer extends LabelsLayer {
26
28
  sendVideoStatus(pathOrBase64: string): Promise<void>;
27
29
  /**
28
30
  * Send a text to status stories
31
+ * @category Status
29
32
  *
30
33
  * @example
31
34
  * ```javascript
@@ -34,4 +37,16 @@ export declare class StatusLayer extends LabelsLayer {
34
37
  * @param pathOrBase64 Path or base 64 image
35
38
  */
36
39
  sendTextStatus(text: string, options: string): Promise<void>;
40
+ /**
41
+ * Mark status as read/seen
42
+ * @category Status
43
+ *
44
+ * @example
45
+ * ```javascript
46
+ * client.sendReadStatus('[phone_number]@c.us', 'false_status@broadcast_3A169E0FD4BC6E92212F_[]@c.us');
47
+ * ```
48
+ * @param chatId Chat ID of contact
49
+ * @param statusId ID of status msg
50
+ */
51
+ sendReadStatus(chatId: string, statusId: string): Promise<void>;
37
52
  }
@@ -79,6 +79,7 @@ var StatusLayer = /** @class */ (function (_super) {
79
79
  }
80
80
  /**
81
81
  * Send a image message to status stories
82
+ * @category Status
82
83
  *
83
84
  * @example
84
85
  * ```javascript
@@ -142,6 +143,7 @@ var StatusLayer = /** @class */ (function (_super) {
142
143
  };
143
144
  /**
144
145
  * Send a video message to status stories
146
+ * @category Status
145
147
  *
146
148
  * @example
147
149
  * ```javascript
@@ -191,6 +193,7 @@ var StatusLayer = /** @class */ (function (_super) {
191
193
  };
192
194
  /**
193
195
  * Send a text to status stories
196
+ * @category Status
194
197
  *
195
198
  * @example
196
199
  * ```javascript
@@ -211,6 +214,30 @@ var StatusLayer = /** @class */ (function (_super) {
211
214
  });
212
215
  });
213
216
  };
217
+ /**
218
+ * Mark status as read/seen
219
+ * @category Status
220
+ *
221
+ * @example
222
+ * ```javascript
223
+ * client.sendReadStatus('[phone_number]@c.us', 'false_status@broadcast_3A169E0FD4BC6E92212F_[]@c.us');
224
+ * ```
225
+ * @param chatId Chat ID of contact
226
+ * @param statusId ID of status msg
227
+ */
228
+ StatusLayer.prototype.sendReadStatus = function (chatId, statusId) {
229
+ return __awaiter(this, void 0, void 0, function () {
230
+ return __generator(this, function (_a) {
231
+ switch (_a.label) {
232
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
233
+ var chatId = _a.chatId, statusId = _a.statusId;
234
+ WPP.status.sendReadStatus(chatId, statusId);
235
+ }, { chatId: chatId, statusId: statusId })];
236
+ case 1: return [2 /*return*/, _a.sent()];
237
+ }
238
+ });
239
+ });
240
+ };
214
241
  return StatusLayer;
215
242
  }(labels_layer_1.LabelsLayer));
216
243
  exports.StatusLayer = StatusLayer;
@@ -19,7 +19,7 @@ exports.defaultOptions = {
19
19
  waitForLogin: true,
20
20
  logger: logger_1.defaultLogger,
21
21
  tokenStore: 'file',
22
- whatsappVersion: '2.2220.x',
22
+ whatsappVersion: '2.2234.x',
23
23
  deviceName: false,
24
24
  linkPreviewApiServers: null,
25
25
  disableGoogleAnalytics: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.16.1",
3
+ "version": "1.17.1",
4
4
  "description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, 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... 😀🤔💭",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,30 +54,30 @@
54
54
  },
55
55
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
56
56
  "devDependencies": {
57
- "@babel/core": "^7.18.10",
58
- "@babel/eslint-parser": "^7.18.9",
59
- "@babel/eslint-plugin": "^7.18.10",
60
- "@babel/preset-env": "^7.18.10",
61
- "@commitlint/cli": "^17.0.3",
62
- "@commitlint/config-conventional": "^17.0.3",
63
- "@commitlint/cz-commitlint": "^17.0.3",
57
+ "@babel/core": "^7.19.3",
58
+ "@babel/eslint-parser": "^7.19.1",
59
+ "@babel/eslint-plugin": "^7.19.1",
60
+ "@babel/preset-env": "^7.19.3",
61
+ "@commitlint/cli": "^17.1.2",
62
+ "@commitlint/config-conventional": "^17.1.0",
63
+ "@commitlint/cz-commitlint": "^17.1.2",
64
64
  "@knodes/typedoc-plugin-pages": "^0.23.1",
65
65
  "@types/atob": "^2.1.2",
66
66
  "@types/mime-types": "^2.1.1",
67
67
  "@types/mocha": "^9.1.1",
68
- "@types/node": "^16.11.47",
68
+ "@types/node": "^16.11.64",
69
69
  "@types/rimraf": "^3.0.2",
70
- "@types/sharp": "^0.30.4",
70
+ "@types/sharp": "^0.31.0",
71
71
  "@types/shelljs": "^0.8.11",
72
72
  "@types/tmp": "^0.2.3",
73
73
  "@types/ws": "^8.5.3",
74
- "@typescript-eslint/eslint-plugin": "^5.32.0",
75
- "@typescript-eslint/parser": "^5.32.0",
74
+ "@typescript-eslint/eslint-plugin": "^5.39.0",
75
+ "@typescript-eslint/parser": "^5.39.0",
76
76
  "babel-loader": "^8.2.5",
77
77
  "commitizen": "^4.2.5",
78
- "concurrently": "^7.3.0",
78
+ "concurrently": "^7.4.0",
79
79
  "conventional-changelog-cli": "^2.2.2",
80
- "eslint": "^8.21.0",
80
+ "eslint": "^8.25.0",
81
81
  "eslint-config-prettier": "^8.5.0",
82
82
  "eslint-plugin-header": "^3.1.1",
83
83
  "eslint-plugin-prettier": "^4.2.1",
@@ -86,17 +86,17 @@
86
86
  "prettier": "^2.7.1",
87
87
  "pretty-quick": "^3.1.3",
88
88
  "regenerator-runtime": "^0.13.9",
89
- "release-it": "^15.2.0",
89
+ "release-it": "^15.5.0",
90
90
  "shx": "^0.3.4",
91
91
  "ts-node": "^10.9.1",
92
- "typedoc": "^0.23.10",
93
- "typescript": "^4.7.4",
92
+ "typedoc": "^0.23.15",
93
+ "typescript": "^4.8.4",
94
94
  "webpack": "^5.74.0",
95
95
  "webpack-cli": "^4.10.0"
96
96
  },
97
97
  "dependencies": {
98
- "@wppconnect/wa-js": "^2.10.1",
99
- "@wppconnect/wa-version": "^1.1.123",
98
+ "@wppconnect/wa-js": "^2.13.1",
99
+ "@wppconnect/wa-version": "^1.1.168",
100
100
  "atob": "^2.1.2",
101
101
  "axios": "^0.27.2",
102
102
  "boxen": "^5.1.2",
@@ -112,18 +112,18 @@
112
112
  "mime-types": "^2.1.35",
113
113
  "puppeteer": "*",
114
114
  "puppeteer-extra": "^3.3.4",
115
- "puppeteer-extra-plugin-stealth": "^2.11.0",
115
+ "puppeteer-extra-plugin-stealth": "^2.11.1",
116
116
  "puppeteer-extra-plugin-user-data-dir": "^2.4.0",
117
117
  "puppeteer-extra-plugin-user-preferences": "^2.4.0",
118
118
  "qrcode-terminal": "^0.12.0",
119
119
  "reflect-metadata": "^0.1.13",
120
120
  "rimraf": "^3.0.2",
121
121
  "sanitize-filename": "^1.6.3",
122
- "sharp": "^0.30.7",
122
+ "sharp": "^0.31.1",
123
123
  "tmp": "^0.2.1",
124
124
  "tree-kill": "^1.2.2",
125
- "winston": "^3.8.1",
126
- "ws": "^8.8.1"
125
+ "winston": "^3.8.2",
126
+ "ws": "^8.9.0"
127
127
  },
128
128
  "optionalDependencies": {
129
129
  "fsevents": "^2.3.2"