@wppconnect-team/wppconnect 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/api/helpers/base64-mimetype.js +2 -2
- package/dist/api/helpers/decrypt.js +65 -72
- package/dist/api/helpers/download-file.js +31 -81
- package/dist/api/helpers/evaluate-and-return.js +98 -93
- package/dist/api/helpers/file-to-base64.js +30 -81
- package/dist/api/helpers/filename-from-mimetype.js +4 -4
- package/dist/api/helpers/scrape-img-qr.js +37 -86
- package/dist/api/helpers/scrape-login.js +12 -57
- package/dist/api/helpers/select-sticker.js +35 -100
- package/dist/api/layers/business.layer.js +29 -134
- package/dist/api/layers/catalog.layer.js +59 -210
- package/dist/api/layers/community.layer.js +29 -120
- package/dist/api/layers/controls.layer.js +62 -262
- package/dist/api/layers/group.layer.js +126 -391
- package/dist/api/layers/host.layer.js +348 -702
- package/dist/api/layers/labels.layer.js +35 -131
- package/dist/api/layers/listener.layer.js +386 -504
- package/dist/api/layers/newsletter.layer.js +20 -89
- package/dist/api/layers/profile.layer.js +73 -184
- package/dist/api/layers/retriever.layer.js +161 -468
- package/dist/api/layers/sender.layer.js +554 -1094
- package/dist/api/layers/status.layer.js +80 -179
- package/dist/api/layers/ui.layer.js +32 -129
- package/dist/api/model/enum/definitions.js +1 -1
- package/dist/api/whatsapp.js +200 -437
- package/dist/config/WAuserAgente.js +1 -1
- package/dist/config/create-config.js +1 -1
- package/dist/config/puppeteer.config.js +1 -1
- package/dist/controllers/auth.js +42 -110
- package/dist/controllers/browser.js +251 -411
- package/dist/controllers/initializer.js +171 -265
- package/dist/controllers/websocket.js +29 -28
- package/dist/controllers/welcome.js +38 -88
- package/dist/token-store/fileTokenStore.js +83 -173
- package/dist/token-store/isValidSessionToken.js +2 -2
- package/dist/token-store/isValidTokenStore.js +2 -2
- package/dist/token-store/memoryTokenStore.js +11 -14
- package/dist/utils/ffmpeg.js +75 -131
- package/dist/utils/logger.js +5 -5
- package/dist/utils/semver.js +6 -6
- package/dist/utils/sleep.js +1 -1
- 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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
85
|
-
return
|
|
86
|
-
|
|
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
|
-
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
124
|
-
return
|
|
125
|
-
|
|
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
|
-
|
|
289
|
-
return
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
128
|
-
return
|
|
129
|
-
|
|
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
|
-
|
|
143
|
-
return
|
|
144
|
-
|
|
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
|
-
|
|
169
|
-
return
|
|
170
|
-
|
|
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
|
-
|
|
191
|
-
return
|
|
192
|
-
|
|
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
|
-
|
|
210
|
-
return
|
|
211
|
-
|
|
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
|
-
|
|
229
|
-
return
|
|
230
|
-
|
|
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
|
-
|
|
248
|
-
return
|
|
249
|
-
|
|
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
|
-
|
|
268
|
-
return
|
|
269
|
-
|
|
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
|
-
|
|
287
|
-
return
|
|
288
|
-
|
|
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
|
-
|
|
310
|
-
return
|
|
311
|
-
|
|
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
|
-
|
|
329
|
-
return
|
|
330
|
-
|
|
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
|
-
|
|
348
|
-
return
|
|
349
|
-
|
|
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
|
-
|
|
366
|
-
return
|
|
367
|
-
|
|
368
|
-
|
|
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;
|