@wppconnect-team/wppconnect 1.41.3 → 2.0.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/helpers/base64-mimetype.js +2 -2
  3. package/dist/api/helpers/decrypt.js +65 -72
  4. package/dist/api/helpers/download-file.js +31 -81
  5. package/dist/api/helpers/evaluate-and-return.js +98 -93
  6. package/dist/api/helpers/exposed.enum.d.ts +2 -1
  7. package/dist/api/helpers/exposed.enum.js +1 -0
  8. package/dist/api/helpers/file-to-base64.js +30 -81
  9. package/dist/api/helpers/filename-from-mimetype.js +4 -4
  10. package/dist/api/helpers/scrape-img-qr.js +37 -86
  11. package/dist/api/helpers/scrape-login.js +12 -57
  12. package/dist/api/helpers/select-sticker.js +35 -100
  13. package/dist/api/layers/business.layer.js +29 -134
  14. package/dist/api/layers/catalog.layer.js +59 -210
  15. package/dist/api/layers/community.layer.js +29 -120
  16. package/dist/api/layers/controls.layer.js +62 -262
  17. package/dist/api/layers/group.layer.js +126 -391
  18. package/dist/api/layers/host.layer.js +348 -702
  19. package/dist/api/layers/labels.layer.js +35 -131
  20. package/dist/api/layers/listener.layer.d.ts +9 -1
  21. package/dist/api/layers/listener.layer.js +392 -491
  22. package/dist/api/layers/newsletter.layer.js +20 -89
  23. package/dist/api/layers/profile.layer.js +73 -184
  24. package/dist/api/layers/retriever.layer.js +163 -468
  25. package/dist/api/layers/sender.layer.js +554 -1094
  26. package/dist/api/layers/status.layer.js +80 -179
  27. package/dist/api/layers/ui.layer.js +32 -129
  28. package/dist/api/model/enum/definitions.js +1 -1
  29. package/dist/api/whatsapp.js +200 -426
  30. package/dist/config/WAuserAgente.js +1 -1
  31. package/dist/config/create-config.js +1 -1
  32. package/dist/config/puppeteer.config.js +1 -1
  33. package/dist/controllers/auth.js +42 -110
  34. package/dist/controllers/browser.js +251 -411
  35. package/dist/controllers/initializer.js +171 -265
  36. package/dist/controllers/websocket.js +29 -28
  37. package/dist/controllers/welcome.js +38 -88
  38. package/dist/lib/wapi/wapi.js +1 -1
  39. package/dist/token-store/fileTokenStore.js +83 -173
  40. package/dist/token-store/isValidSessionToken.js +2 -2
  41. package/dist/token-store/isValidTokenStore.js +2 -2
  42. package/dist/token-store/memoryTokenStore.js +11 -14
  43. package/dist/utils/ffmpeg.js +75 -131
  44. package/dist/utils/logger.js +5 -5
  45. package/dist/utils/semver.js +6 -6
  46. package/dist/utils/sleep.js +1 -1
  47. package/package.json +8 -8
@@ -15,121 +15,40 @@
15
15
  * You should have received a copy of the GNU Lesser General Public License
16
16
  * along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
17
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
44
- return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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
18
  Object.defineProperty(exports, "__esModule", { value: true });
70
19
  exports.BusinessLayer = void 0;
71
- var controls_layer_1 = require("./controls.layer");
72
- var helpers_1 = require("../helpers");
73
- var BusinessLayer = /** @class */ (function (_super) {
74
- __extends(BusinessLayer, _super);
75
- function BusinessLayer(page, session, options) {
76
- var _this = _super.call(this, page, session, options) || this;
77
- _this.page = page;
78
- return _this;
20
+ const controls_layer_1 = require("./controls.layer");
21
+ const helpers_1 = require("../helpers");
22
+ class BusinessLayer extends controls_layer_1.ControlsLayer {
23
+ page;
24
+ constructor(page, session, options) {
25
+ super(page, session, options);
26
+ this.page = page;
79
27
  }
80
28
  /**
81
29
  * Querys product catalog
82
30
  * @param id Buisness profile id ('00000@c.us')
83
31
  */
84
- BusinessLayer.prototype.getBusinessProfilesProducts = function (id) {
85
- return __awaiter(this, void 0, void 0, function () {
86
- return __generator(this, function (_a) {
87
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
88
- var id = _a.id;
89
- return WAPI.getBusinessProfilesProducts(id);
90
- }, { id: id })];
91
- });
92
- });
93
- };
32
+ async getBusinessProfilesProducts(id) {
33
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ id }) => WAPI.getBusinessProfilesProducts(id), { id });
34
+ }
94
35
  /**
95
36
  * Get Business Profile
96
37
  * @param id Buisness profile id ('00000@c.us')
97
38
  */
98
- BusinessLayer.prototype.getBusinessProfile = function (id) {
99
- return __awaiter(this, void 0, void 0, function () {
100
- var _this = this;
101
- return __generator(this, function (_a) {
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
- }
113
- });
114
- }); }, { id: id })];
115
- });
116
- });
117
- };
39
+ async getBusinessProfile(id) {
40
+ return (0, helpers_1.evaluateAndReturn)(this.page, async ({ id }) => {
41
+ return JSON.parse(JSON.stringify(await WPP.contact.getBusinessProfile(id)));
42
+ }, { id });
43
+ }
118
44
  /**
119
45
  * Querys order catalog
120
46
  * @param messageId string
121
47
  * @returns Message object
122
48
  */
123
- BusinessLayer.prototype.getOrderbyMsg = function (messageId) {
124
- return __awaiter(this, void 0, void 0, function () {
125
- return __generator(this, function (_a) {
126
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
127
- var messageId = _a.messageId;
128
- return WAPI.getOrderbyMsg(messageId);
129
- }, { messageId: messageId })];
130
- });
131
- });
132
- };
49
+ async getOrderbyMsg(messageId) {
50
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ messageId }) => WAPI.getOrderbyMsg(messageId), { messageId });
51
+ }
133
52
  /**
134
53
  * Update your business profile
135
54
  *
@@ -285,29 +204,11 @@ var BusinessLayer = /** @class */ (function (_super) {
285
204
  *
286
205
  * ```
287
206
  */
288
- BusinessLayer.prototype.editBusinessProfile = function (options) {
289
- return __awaiter(this, void 0, void 0, function () {
290
- var _this = this;
291
- return __generator(this, function (_a) {
292
- switch (_a.label) {
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
- }
304
- });
305
- }); }, { options: options })];
306
- case 1: return [2 /*return*/, _a.sent()];
307
- }
308
- });
309
- });
310
- };
207
+ async editBusinessProfile(options) {
208
+ return await (0, helpers_1.evaluateAndReturn)(this.page, async ({ options }) => {
209
+ return JSON.parse(JSON.stringify(await WPP.profile.editBusinessProfile(options)));
210
+ }, { options });
211
+ }
311
212
  /**
312
213
  * Sends product with product image to given chat id
313
214
  * @param to Chat id
@@ -316,16 +217,10 @@ var BusinessLayer = /** @class */ (function (_super) {
316
217
  * @param businessId Business id number that owns the product ('0000@c.us')
317
218
  * @param productId Product id, see method getBusinessProfilesProducts for more info
318
219
  */
319
- BusinessLayer.prototype.sendImageWithProduct = function (to, base64, caption, businessId, productId) {
320
- return __awaiter(this, void 0, void 0, function () {
321
- return __generator(this, function (_a) {
322
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
323
- var to = _a.to, base64 = _a.base64, businessId = _a.businessId, caption = _a.caption, productId = _a.productId;
324
- WAPI.sendImageWithProduct(base64, to, caption, businessId, productId);
325
- }, { to: to, base64: base64, businessId: businessId, caption: caption, productId: productId })];
326
- });
327
- });
328
- };
329
- return BusinessLayer;
330
- }(controls_layer_1.ControlsLayer));
220
+ async sendImageWithProduct(to, base64, caption, businessId, productId) {
221
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ to, base64, businessId, caption, productId }) => {
222
+ WAPI.sendImageWithProduct(base64, to, caption, businessId, productId);
223
+ }, { to, base64, businessId, caption, productId });
224
+ }
225
+ }
331
226
  exports.BusinessLayer = BusinessLayer;
@@ -15,67 +15,15 @@
15
15
  * You should have received a copy of the GNU Lesser General Public License
16
16
  * along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
17
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
44
- return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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
18
  Object.defineProperty(exports, "__esModule", { value: true });
70
19
  exports.CatalogLayer = void 0;
71
- var helpers_1 = require("../helpers");
72
- var community_layer_1 = require("./community.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;
20
+ const helpers_1 = require("../helpers");
21
+ const community_layer_1 = require("./community.layer");
22
+ class CatalogLayer extends community_layer_1.CommunityLayer {
23
+ page;
24
+ constructor(page, session, options) {
25
+ super(page, session, options);
26
+ this.page = page;
79
27
  }
80
28
  /**
81
29
  * Create a product on catalog
@@ -100,55 +48,34 @@ var CatalogLayer = /** @class */ (function (_super) {
100
48
  * );
101
49
  * ```
102
50
  */
103
- CatalogLayer.prototype.createProduct = function (name, image, description, price, isHidden, url, retailerId, currency) {
104
- return __awaiter(this, void 0, void 0, function () {
105
- return __generator(this, function (_a) {
106
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
107
- var name = _a.name, image = _a.image, description = _a.description, price = _a.price, isHidden = _a.isHidden, url = _a.url, retailerId = _a.retailerId, currency = _a.currency;
108
- return WPP.catalog.createProduct({
109
- name: name,
110
- image: image,
111
- description: description,
112
- price: price,
113
- isHidden: isHidden,
114
- url: url,
115
- retailerId: retailerId,
116
- currency: currency,
117
- });
118
- }, { name: name, image: image, description: description, price: price, isHidden: isHidden, url: url, retailerId: retailerId, currency: currency })];
119
- });
120
- });
121
- };
51
+ async createProduct(name, image, description, price, isHidden, url, retailerId, currency) {
52
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ name, image, description, price, isHidden, url, retailerId, currency, }) => WPP.catalog.createProduct({
53
+ name,
54
+ image,
55
+ description,
56
+ price,
57
+ isHidden,
58
+ url,
59
+ retailerId,
60
+ currency,
61
+ }), { name, image, description, price, isHidden, url, retailerId, currency });
62
+ }
122
63
  /**
123
64
  * Querys all products
124
65
  * @param id Buisness profile id ('00000@c.us')
125
66
  * @param qnt limit to load products - Default: 10
126
67
  */
127
- CatalogLayer.prototype.getProducts = function (id, qnt) {
128
- return __awaiter(this, void 0, void 0, function () {
129
- return __generator(this, function (_a) {
130
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
131
- var id = _a.id, qnt = _a.qnt;
132
- return WPP.catalog.getProducts(id, qnt);
133
- }, { id: id, qnt: qnt })];
134
- });
135
- });
136
- };
68
+ async getProducts(id, qnt) {
69
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ id, qnt }) => WPP.catalog.getProducts(id, qnt), { id, qnt });
70
+ }
137
71
  /**
138
72
  * Create a new product on catalog
139
73
  * @param id Buisness profile id ('00000@c.us')
140
74
  * @param productId ID of Product
141
75
  */
142
- CatalogLayer.prototype.getProductById = function (id, productId) {
143
- return __awaiter(this, void 0, void 0, function () {
144
- return __generator(this, function (_a) {
145
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
146
- var id = _a.id, productId = _a.productId;
147
- return WPP.catalog.getProductById(id, productId);
148
- }, { id: id, productId: productId })];
149
- });
150
- });
151
- };
76
+ async getProductById(id, productId) {
77
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ id, productId }) => WPP.catalog.getProductById(id, productId), { id, productId });
78
+ }
152
79
  /**
153
80
  * Edit product on catalog
154
81
  * @param productId Product ID
@@ -165,16 +92,9 @@ var CatalogLayer = /** @class */ (function (_super) {
165
92
  * });
166
93
  * ```
167
94
  */
168
- CatalogLayer.prototype.editProduct = function (productId, options) {
169
- return __awaiter(this, void 0, void 0, function () {
170
- return __generator(this, function (_a) {
171
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
172
- var productId = _a.productId, options = _a.options;
173
- return WPP.catalog.editProduct(productId, options);
174
- }, { productId: productId, options: options })];
175
- });
176
- });
177
- };
95
+ async editProduct(productId, options) {
96
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productId, options }) => WPP.catalog.editProduct(productId, options), { productId, options });
97
+ }
178
98
  /**
179
99
  * Delete product(s) on catalog
180
100
  * @param productsId Products ID
@@ -187,16 +107,9 @@ var CatalogLayer = /** @class */ (function (_super) {
187
107
  * client.delProducts(['56989897878','565657878']);
188
108
  * ```
189
109
  */
190
- CatalogLayer.prototype.delProducts = function (productsId) {
191
- return __awaiter(this, void 0, void 0, function () {
192
- return __generator(this, function (_a) {
193
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
194
- var productsId = _a.productsId;
195
- return WPP.catalog.delProducts(productsId);
196
- }, { productsId: productsId })];
197
- });
198
- });
199
- };
110
+ async delProducts(productsId) {
111
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productsId }) => WPP.catalog.delProducts(productsId), { productsId });
112
+ }
200
113
  /**
201
114
  * Add image on product This function change main image of product, for change additional images use client.addImage
202
115
  * @param productId Product ID
@@ -206,16 +119,9 @@ var CatalogLayer = /** @class */ (function (_super) {
206
119
  * client.changeProductImage('56989897878', 'base64/string');
207
120
  * ```
208
121
  */
209
- CatalogLayer.prototype.changeProductImage = function (productId, image) {
210
- return __awaiter(this, void 0, void 0, function () {
211
- return __generator(this, function (_a) {
212
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
213
- var productId = _a.productId, image = _a.image;
214
- return WPP.catalog.changeProductImage(productId, image);
215
- }, { productId: productId, image: image })];
216
- });
217
- });
218
- };
122
+ async changeProductImage(productId, image) {
123
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productId, image }) => WPP.catalog.changeProductImage(productId, image), { productId, image });
124
+ }
219
125
  /**
220
126
  * Add image on product This function include additional images on product for change main image use client.changeProductImage
221
127
  * @param productId Product ID
@@ -225,16 +131,9 @@ var CatalogLayer = /** @class */ (function (_super) {
225
131
  * client.addProductImage('56989897878', 'base64/string');
226
132
  * ```
227
133
  */
228
- CatalogLayer.prototype.addProductImage = function (productId, image) {
229
- return __awaiter(this, void 0, void 0, function () {
230
- return __generator(this, function (_a) {
231
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
232
- var productId = _a.productId, image = _a.image;
233
- return WPP.catalog.addProductImage(productId, image);
234
- }, { productId: productId, image: image })];
235
- });
236
- });
237
- };
134
+ async addProductImage(productId, image) {
135
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productId, image }) => WPP.catalog.addProductImage(productId, image), { productId, image });
136
+ }
238
137
  /**
239
138
  * Remove image on product This function remove additional images of product for change main image use client.changeProductImage
240
139
  * @param productId Product ID
@@ -244,16 +143,9 @@ var CatalogLayer = /** @class */ (function (_super) {
244
143
  * client.removeProductImage('56989897878', '1');
245
144
  * ```
246
145
  */
247
- CatalogLayer.prototype.removeProductImage = function (productId, index) {
248
- return __awaiter(this, void 0, void 0, function () {
249
- return __generator(this, function (_a) {
250
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
251
- var productId = _a.productId, index = _a.index;
252
- return WPP.catalog.removeProductImage(productId, index);
253
- }, { productId: productId, index: index })];
254
- });
255
- });
256
- };
146
+ async removeProductImage(productId, index) {
147
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productId, index }) => WPP.catalog.removeProductImage(productId, index), { productId, index });
148
+ }
257
149
  /**
258
150
  * Query all collections
259
151
  * @param id Product ID
@@ -264,16 +156,9 @@ var CatalogLayer = /** @class */ (function (_super) {
264
156
  * client.getCollections('5521988556558@c.us', '10','20');
265
157
  * ```
266
158
  */
267
- CatalogLayer.prototype.getCollections = function (id, qnt, maxProducts) {
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 id = _a.id, qnt = _a.qnt, maxProducts = _a.maxProducts;
272
- return WPP.catalog.getCollections(id, qnt, maxProducts);
273
- }, { id: id, qnt: qnt, maxProducts: maxProducts })];
274
- });
275
- });
276
- };
159
+ async getCollections(id, qnt, maxProducts) {
160
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ id, qnt, maxProducts }) => WPP.catalog.getCollections(id, qnt, maxProducts), { id, qnt, maxProducts });
161
+ }
277
162
  /**
278
163
  * Create new collection
279
164
  * @param collectionName Product ID
@@ -283,16 +168,9 @@ var CatalogLayer = /** @class */ (function (_super) {
283
168
  * client.createCollection('Name of collection', ['655632565','5689859898']);
284
169
  * ```
285
170
  */
286
- CatalogLayer.prototype.createCollection = function (collectionName, productsId) {
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 collectionName = _a.collectionName, productsId = _a.productsId;
291
- return WPP.catalog.createCollection(collectionName, productsId);
292
- }, { collectionName: collectionName, productsId: productsId })];
293
- });
294
- });
295
- };
171
+ async createCollection(collectionName, productsId) {
172
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ collectionName, productsId }) => WPP.catalog.createCollection(collectionName, productsId), { collectionName, productsId });
173
+ }
296
174
  /**
297
175
  * Edit a collection
298
176
  * @param collectionId Collection id
@@ -306,16 +184,9 @@ var CatalogLayer = /** @class */ (function (_super) {
306
184
  * });
307
185
  * ```
308
186
  */
309
- CatalogLayer.prototype.editCollection = function (collectionId, options) {
310
- return __awaiter(this, void 0, void 0, function () {
311
- return __generator(this, function (_a) {
312
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
313
- var collectionId = _a.collectionId, options = _a.options;
314
- return WPP.catalog.editCollection(collectionId, options);
315
- }, { collectionId: collectionId, options: options })];
316
- });
317
- });
318
- };
187
+ async editCollection(collectionId, options) {
188
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ collectionId, options }) => WPP.catalog.editCollection(collectionId, options), { collectionId, options });
189
+ }
319
190
  /**
320
191
  * Delete a collection
321
192
  * @param collectionId Collection id
@@ -325,16 +196,9 @@ var CatalogLayer = /** @class */ (function (_super) {
325
196
  * client.deleteCollection('65666565898');
326
197
  * ```
327
198
  */
328
- CatalogLayer.prototype.deleteCollection = function (collectionId) {
329
- return __awaiter(this, void 0, void 0, function () {
330
- return __generator(this, function (_a) {
331
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
332
- var collectionId = _a.collectionId;
333
- return WPP.catalog.deleteCollection(collectionId);
334
- }, { collectionId: collectionId })];
335
- });
336
- });
337
- };
199
+ async deleteCollection(collectionId) {
200
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ collectionId }) => WPP.catalog.deleteCollection(collectionId), { collectionId });
201
+ }
338
202
  /**
339
203
  * Set product visibility
340
204
  * @param productId Product id
@@ -344,16 +208,9 @@ var CatalogLayer = /** @class */ (function (_super) {
344
208
  * client.setProductVisibility('65666565898', false);
345
209
  * ```
346
210
  */
347
- CatalogLayer.prototype.setProductVisibility = function (productId, value) {
348
- return __awaiter(this, void 0, void 0, function () {
349
- return __generator(this, function (_a) {
350
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
351
- var productId = _a.productId, value = _a.value;
352
- return WPP.catalog.setProductVisibility(productId, value);
353
- }, { productId: productId, value: value })];
354
- });
355
- });
356
- };
211
+ async setProductVisibility(productId, value) {
212
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ productId, value }) => WPP.catalog.setProductVisibility(productId, value), { productId, value });
213
+ }
357
214
  /**
358
215
  * Update options to customer cart your products
359
216
  * @param value True for enabled, false for non enabled
@@ -362,16 +219,8 @@ var CatalogLayer = /** @class */ (function (_super) {
362
219
  * client.updateCartEnabled(false);
363
220
  * ```
364
221
  */
365
- CatalogLayer.prototype.updateCartEnabled = function (value) {
366
- return __awaiter(this, void 0, void 0, function () {
367
- return __generator(this, function (_a) {
368
- return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
369
- var value = _a.value;
370
- return WPP.catalog.updateCartEnabled(value);
371
- }, { value: value })];
372
- });
373
- });
374
- };
375
- return CatalogLayer;
376
- }(community_layer_1.CommunityLayer));
222
+ async updateCartEnabled(value) {
223
+ return (0, helpers_1.evaluateAndReturn)(this.page, ({ value }) => WPP.catalog.updateCartEnabled(value), { value });
224
+ }
225
+ }
377
226
  exports.CatalogLayer = CatalogLayer;