@wppconnect-team/wppconnect 1.28.2 → 1.28.4
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 +8 -0
- package/dist/api/layers/community.layer.d.ts +2 -2
- package/dist/api/layers/community.layer.js +2 -2
- package/dist/api/layers/controls.layer.d.ts +17 -0
- package/dist/api/layers/controls.layer.js +50 -0
- package/dist/api/layers/listener.layer.d.ts +13 -0
- package/dist/api/layers/listener.layer.js +25 -0
- package/dist/api/layers/newsletter.layer.d.ts +63 -0
- package/dist/api/layers/newsletter.layer.js +155 -0
- package/dist/api/layers/retriever.layer.d.ts +27 -3
- package/dist/api/layers/retriever.layer.js +42 -0
- package/dist/api/layers/sender.layer.d.ts +29 -0
- package/dist/api/layers/sender.layer.js +69 -1
- package/dist/api/whatsapp.d.ts +5 -0
- package/dist/api/whatsapp.js +15 -14
- package/dist/config/puppeteer.config.js +1 -1
- package/dist/controllers/websocket.js +1 -1
- package/dist/lib/wapi/wapi.js +1 -1
- package/package.json +30 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## <small>1.28.4 (2023-12-25)</small>
|
|
2
|
+
|
|
3
|
+
- fix: Remove unnecessary code for close instance (close #1835) ([43f2a9b](https://github.com/wppconnect-team/wppconnect/commit/43f2a9b)), closes [#1835](https://github.com/wppconnect-team/wppconnect/issues/1835)
|
|
4
|
+
|
|
5
|
+
## <small>1.28.3 (2023-11-15)</small>
|
|
6
|
+
|
|
7
|
+
- feat: Added client.getCommonGroups function ([194c898](https://github.com/wppconnect-team/wppconnect/commit/194c898))
|
|
8
|
+
|
|
1
9
|
## <small>1.28.2 (2023-11-04)</small>
|
|
2
10
|
|
|
3
11
|
- chore: Update release-it ([4869dc8](https://github.com/wppconnect-team/wppconnect/commit/4869dc8))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Page } from 'puppeteer';
|
|
2
2
|
import { CreateConfig } from '../../config/create-config';
|
|
3
3
|
import { Wid } from '../model';
|
|
4
|
-
import {
|
|
5
|
-
export declare class CommunityLayer extends
|
|
4
|
+
import { NewsletterLayer } from './newsletter.layer';
|
|
5
|
+
export declare class CommunityLayer extends NewsletterLayer {
|
|
6
6
|
page: Page;
|
|
7
7
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
8
8
|
/**
|
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.CommunityLayer = void 0;
|
|
71
71
|
var helpers_1 = require("../helpers");
|
|
72
|
-
var
|
|
72
|
+
var newsletter_layer_1 = require("./newsletter.layer");
|
|
73
73
|
var CommunityLayer = /** @class */ (function (_super) {
|
|
74
74
|
__extends(CommunityLayer, _super);
|
|
75
75
|
function CommunityLayer(page, session, options) {
|
|
@@ -178,5 +178,5 @@ var CommunityLayer = /** @class */ (function (_super) {
|
|
|
178
178
|
});
|
|
179
179
|
};
|
|
180
180
|
return CommunityLayer;
|
|
181
|
-
}(
|
|
181
|
+
}(newsletter_layer_1.NewsletterLayer));
|
|
182
182
|
exports.CommunityLayer = CommunityLayer;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { EditMessageOptions } from '@wppconnect/wa-js/dist/chat/functions/editMessage';
|
|
2
|
+
import { MsgKey } from '@wppconnect/wa-js/dist/whatsapp';
|
|
1
3
|
import { Page } from 'puppeteer';
|
|
2
4
|
import { CreateConfig } from '../../config/create-config';
|
|
3
5
|
import { UILayer } from './ui.layer';
|
|
6
|
+
import { Message } from '../model';
|
|
4
7
|
export declare class ControlsLayer extends UILayer {
|
|
5
8
|
page: Page;
|
|
6
9
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
@@ -71,6 +74,20 @@ export declare class ControlsLayer extends UILayer {
|
|
|
71
74
|
* @param onlyLocal If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.
|
|
72
75
|
*/
|
|
73
76
|
deleteMessage(chatId: string, messageId: string[] | string, onlyLocal?: boolean, deleteMediaInDevice?: boolean): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Edits message of given message id
|
|
79
|
+
* @category Chat
|
|
80
|
+
* @param msgId The specific message id of the message to be edited
|
|
81
|
+
* @param newText New content of specified message
|
|
82
|
+
* @param options Common message options
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```javascript
|
|
86
|
+
* // Simple message
|
|
87
|
+
* client.editMessage('true_<number>@c.us_messageId', 'new Text For Simple Message');
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
editMessage(msgId: string | MsgKey, newText: string, options?: EditMessageOptions): Promise<Message>;
|
|
74
91
|
/**
|
|
75
92
|
* Stars message of given message id
|
|
76
93
|
* @category Chat
|
|
@@ -246,6 +246,56 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* Edits message of given message id
|
|
251
|
+
* @category Chat
|
|
252
|
+
* @param msgId The specific message id of the message to be edited
|
|
253
|
+
* @param newText New content of specified message
|
|
254
|
+
* @param options Common message options
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```javascript
|
|
258
|
+
* // Simple message
|
|
259
|
+
* client.editMessage('true_<number>@c.us_messageId', 'new Text For Simple Message');
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
ControlsLayer.prototype.editMessage = function (msgId, newText, options) {
|
|
263
|
+
if (options === void 0) { options = {}; }
|
|
264
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
265
|
+
var editResult, result;
|
|
266
|
+
var _this = this;
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
270
|
+
var msgId = _a.msgId, newText = _a.newText, options = _a.options;
|
|
271
|
+
return WPP.chat.editMessage(msgId, newText, options);
|
|
272
|
+
}, { msgId: msgId, newText: newText, options: options })];
|
|
273
|
+
case 1:
|
|
274
|
+
editResult = _a.sent();
|
|
275
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
276
|
+
var messageId = _a.messageId;
|
|
277
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
278
|
+
var _b, _c, _d, _e;
|
|
279
|
+
return __generator(this, function (_f) {
|
|
280
|
+
switch (_f.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
_c = (_b = JSON).parse;
|
|
283
|
+
_e = (_d = JSON).stringify;
|
|
284
|
+
return [4 /*yield*/, WAPI.getMessageById(messageId)];
|
|
285
|
+
case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}, { messageId: editResult.id })];
|
|
290
|
+
case 2:
|
|
291
|
+
result = (_a.sent());
|
|
292
|
+
if (result.body !== newText)
|
|
293
|
+
throw editResult;
|
|
294
|
+
return [2 /*return*/, result];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
};
|
|
249
299
|
/**
|
|
250
300
|
* Stars message of given message id
|
|
251
301
|
* @category Chat
|
|
@@ -6,6 +6,7 @@ import { InterfaceMode } from '../model/enum/interface-mode';
|
|
|
6
6
|
import { InterfaceState } from '../model/enum/interface-state';
|
|
7
7
|
import { ProfileLayer } from './profile.layer';
|
|
8
8
|
import { Label } from '../model/label';
|
|
9
|
+
import { MsgKey } from '@wppconnect/wa-js/dist/whatsapp';
|
|
9
10
|
declare global {
|
|
10
11
|
interface Window {
|
|
11
12
|
onMessage: any;
|
|
@@ -238,4 +239,16 @@ export declare class ListenerLayer extends ProfileLayer {
|
|
|
238
239
|
}) => any): {
|
|
239
240
|
dispose: () => void;
|
|
240
241
|
};
|
|
242
|
+
/**
|
|
243
|
+
* @event Listens to update order status
|
|
244
|
+
* @returns Disposable object to stop the listening
|
|
245
|
+
*/
|
|
246
|
+
onOrderStatusUpdate(callback: (data: {
|
|
247
|
+
method: string;
|
|
248
|
+
timestamp: number;
|
|
249
|
+
reference_id: string;
|
|
250
|
+
msgId: MsgKey;
|
|
251
|
+
}) => any): {
|
|
252
|
+
dispose: () => void;
|
|
253
|
+
};
|
|
241
254
|
}
|
|
@@ -126,6 +126,7 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
126
126
|
'onReactionMessage',
|
|
127
127
|
'onPollResponse',
|
|
128
128
|
'onUpdateLabel',
|
|
129
|
+
'onOrderStatusUpdate',
|
|
129
130
|
], false);
|
|
130
131
|
_loop_1 = function (func) {
|
|
131
132
|
var has;
|
|
@@ -361,6 +362,23 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
361
362
|
catch (error) {
|
|
362
363
|
console.error(error);
|
|
363
364
|
}
|
|
365
|
+
try {
|
|
366
|
+
if (!window['onOrderStatusUpdate'].exposed) {
|
|
367
|
+
WPP.on('order.payment_status', function (data) {
|
|
368
|
+
var eventData = {
|
|
369
|
+
method: data.method,
|
|
370
|
+
timestamp: data.timestamp,
|
|
371
|
+
reference_id: data.reference_id,
|
|
372
|
+
msgId: data.msgId,
|
|
373
|
+
};
|
|
374
|
+
window['onOrderStatusUpdate'](eventData);
|
|
375
|
+
});
|
|
376
|
+
window['onOrderStatusUpdate'].exposed = true;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
console.error(error);
|
|
381
|
+
}
|
|
364
382
|
try {
|
|
365
383
|
if (!window['onParticipantsChanged'].exposed) {
|
|
366
384
|
WPP.on('group.participant_changed', function (participantChangedEvent) {
|
|
@@ -600,6 +618,13 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
600
618
|
ListenerLayer.prototype.onUpdateLabel = function (callback) {
|
|
601
619
|
return this.registerEvent('onUpdateLabel', callback);
|
|
602
620
|
};
|
|
621
|
+
/**
|
|
622
|
+
* @event Listens to update order status
|
|
623
|
+
* @returns Disposable object to stop the listening
|
|
624
|
+
*/
|
|
625
|
+
ListenerLayer.prototype.onOrderStatusUpdate = function (callback) {
|
|
626
|
+
return this.registerEvent('onOrderStatusUpdate', callback);
|
|
627
|
+
};
|
|
603
628
|
return ListenerLayer;
|
|
604
629
|
}(profile_layer_1.ProfileLayer));
|
|
605
630
|
exports.ListenerLayer = ListenerLayer;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Page } from 'puppeteer';
|
|
2
|
+
import { CreateConfig } from '../../config/create-config';
|
|
3
|
+
import { HostLayer } from './host.layer';
|
|
4
|
+
export declare class NewsletterLayer extends HostLayer {
|
|
5
|
+
page: Page;
|
|
6
|
+
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Create Newsletter
|
|
9
|
+
* @category Newsletter
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```javascript
|
|
13
|
+
* client.createNewsletter('Name for your newsletter', {description: 'Description for that', picture: '<base64_string',});
|
|
14
|
+
* ```
|
|
15
|
+
* @param name Name Newsletter
|
|
16
|
+
* @param options options Newsletter, description and picture
|
|
17
|
+
*/
|
|
18
|
+
createNewsletter(name: string, options?: {
|
|
19
|
+
description?: string;
|
|
20
|
+
picture?: string;
|
|
21
|
+
}): Promise<import("@wppconnect/wa-js/dist/newsletter/functions/create").ResultCreateNewsletter>;
|
|
22
|
+
/**
|
|
23
|
+
* Destroy a Newsletter
|
|
24
|
+
* @category Newsletter
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```javascript
|
|
28
|
+
* client.destroyNewsletter('[newsletter-id]@newsletter');
|
|
29
|
+
* ```
|
|
30
|
+
* @param name id of Newsletter
|
|
31
|
+
*/
|
|
32
|
+
destroyNewsletter(id: string): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Edit a Newsletter
|
|
35
|
+
* @category Newsletter
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```javascript
|
|
39
|
+
* client.editNewsletter('[newsletter-id]@newsletter', {
|
|
40
|
+
description: 'new description';
|
|
41
|
+
name: 'new name';
|
|
42
|
+
picture: '<new pic base64>';
|
|
43
|
+
});
|
|
44
|
+
* ```
|
|
45
|
+
* @param name id of Newsletter
|
|
46
|
+
*/
|
|
47
|
+
editNewsletter(id: string, opts?: {
|
|
48
|
+
description?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
picture?: string | null;
|
|
51
|
+
}): Promise<import("@wppconnect/wa-js/dist/newsletter/functions/edit").ResultCreateNewsletter>;
|
|
52
|
+
/**
|
|
53
|
+
* Mute a Newsletter
|
|
54
|
+
* @category Newsletter
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```javascript
|
|
58
|
+
* client.muteNewsletter('[newsletter-id]@newsletter');
|
|
59
|
+
* ```
|
|
60
|
+
* @param name id of Newsletter
|
|
61
|
+
*/
|
|
62
|
+
muteNesletter(id: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").ChatModel>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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 (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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.NewsletterLayer = void 0;
|
|
71
|
+
var helpers_1 = require("../helpers");
|
|
72
|
+
var host_layer_1 = require("./host.layer");
|
|
73
|
+
var NewsletterLayer = /** @class */ (function (_super) {
|
|
74
|
+
__extends(NewsletterLayer, _super);
|
|
75
|
+
function NewsletterLayer(page, session, options) {
|
|
76
|
+
var _this = _super.call(this, page, session, options) || this;
|
|
77
|
+
_this.page = page;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create Newsletter
|
|
82
|
+
* @category Newsletter
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```javascript
|
|
86
|
+
* client.createNewsletter('Name for your newsletter', {description: 'Description for that', picture: '<base64_string',});
|
|
87
|
+
* ```
|
|
88
|
+
* @param name Name Newsletter
|
|
89
|
+
* @param options options Newsletter, description and picture
|
|
90
|
+
*/
|
|
91
|
+
NewsletterLayer.prototype.createNewsletter = function (name, options) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (name, options) { return WPP.newsletter.create(name, options); }, name, options)];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Destroy a Newsletter
|
|
100
|
+
* @category Newsletter
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```javascript
|
|
104
|
+
* client.destroyNewsletter('[newsletter-id]@newsletter');
|
|
105
|
+
* ```
|
|
106
|
+
* @param name id of Newsletter
|
|
107
|
+
*/
|
|
108
|
+
NewsletterLayer.prototype.destroyNewsletter = function (id) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (id) { return WPP.newsletter.destroy(id); }, id)];
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Edit a Newsletter
|
|
117
|
+
* @category Newsletter
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```javascript
|
|
121
|
+
* client.editNewsletter('[newsletter-id]@newsletter', {
|
|
122
|
+
description: 'new description';
|
|
123
|
+
name: 'new name';
|
|
124
|
+
picture: '<new pic base64>';
|
|
125
|
+
});
|
|
126
|
+
* ```
|
|
127
|
+
* @param name id of Newsletter
|
|
128
|
+
*/
|
|
129
|
+
NewsletterLayer.prototype.editNewsletter = function (id, opts) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (id, opts) { return WPP.newsletter.edit(id, opts); }, id, opts)];
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Mute a Newsletter
|
|
138
|
+
* @category Newsletter
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```javascript
|
|
142
|
+
* client.muteNewsletter('[newsletter-id]@newsletter');
|
|
143
|
+
* ```
|
|
144
|
+
* @param name id of Newsletter
|
|
145
|
+
*/
|
|
146
|
+
NewsletterLayer.prototype.muteNesletter = function (id) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (id) { return WPP.newsletter.mute(id); }, id)];
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
return NewsletterLayer;
|
|
154
|
+
}(host_layer_1.HostLayer));
|
|
155
|
+
exports.NewsletterLayer = NewsletterLayer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Page } from 'puppeteer';
|
|
2
2
|
import { CreateConfig } from '../../config/create-config';
|
|
3
3
|
import { SessionToken } from '../../token-store';
|
|
4
|
-
import { Chat, ContactStatus, ProfilePicThumbObj, WhatsappProfile, Wid } from '../model';
|
|
4
|
+
import { Chat, Contact, ContactStatus, ProfilePicThumbObj, WhatsappProfile, Wid } from '../model';
|
|
5
5
|
import { SenderLayer } from './sender.layer';
|
|
6
6
|
import { ChatListOptions } from '@wppconnect/wa-js/dist/chat';
|
|
7
7
|
export declare class RetrieverLayer extends SenderLayer {
|
|
@@ -110,13 +110,13 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
110
110
|
* @param contactId
|
|
111
111
|
* @returns contact detial as promise
|
|
112
112
|
*/
|
|
113
|
-
getContact(contactId: string): Promise<
|
|
113
|
+
getContact(contactId: string): Promise<Contact>;
|
|
114
114
|
/**
|
|
115
115
|
* Retrieves all contacts
|
|
116
116
|
* @category Contact
|
|
117
117
|
* @returns array of [Contact]
|
|
118
118
|
*/
|
|
119
|
-
getAllContacts(): Promise<
|
|
119
|
+
getAllContacts(): Promise<Contact[]>;
|
|
120
120
|
/**
|
|
121
121
|
* Retrieves chat object of given contact id
|
|
122
122
|
* @category Chat
|
|
@@ -287,4 +287,28 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
287
287
|
* @category Group
|
|
288
288
|
*/
|
|
289
289
|
getGroupSizeLimit(): Promise<number>;
|
|
290
|
+
/**
|
|
291
|
+
* Get info of your sended order
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```javascript
|
|
295
|
+
* const orderInfo = await client.getOrder('<orderId>');
|
|
296
|
+
* ```
|
|
297
|
+
* @category Order
|
|
298
|
+
* @return Your order
|
|
299
|
+
*/
|
|
300
|
+
getOrder(msgId: string): Promise<boolean>;
|
|
301
|
+
/**
|
|
302
|
+
* Get all commons groups for the contact
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```javascript
|
|
306
|
+
* const groups_ids = await client.getCommonGroups('[number]@c.us');
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @category Group
|
|
310
|
+
* @param groupId Group ID ('000000-000000@g.us')
|
|
311
|
+
* @returns Promise
|
|
312
|
+
*/
|
|
313
|
+
getCommonGroups(wid: string): Promise<import("@wppconnect/wa-js/dist/whatsapp").Wid[]>;
|
|
290
314
|
}
|
|
@@ -680,6 +680,48 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
680
680
|
});
|
|
681
681
|
});
|
|
682
682
|
};
|
|
683
|
+
/**
|
|
684
|
+
* Get info of your sended order
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```javascript
|
|
688
|
+
* const orderInfo = await client.getOrder('<orderId>');
|
|
689
|
+
* ```
|
|
690
|
+
* @category Order
|
|
691
|
+
* @return Your order
|
|
692
|
+
*/
|
|
693
|
+
RetrieverLayer.prototype.getOrder = function (msgId) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
695
|
+
return __generator(this, function (_a) {
|
|
696
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (msgId) { return WPP.order.get(msgId); }, msgId)];
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Get all commons groups for the contact
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```javascript
|
|
705
|
+
* const groups_ids = await client.getCommonGroups('[number]@c.us');
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* @category Group
|
|
709
|
+
* @param groupId Group ID ('000000-000000@g.us')
|
|
710
|
+
* @returns Promise
|
|
711
|
+
*/
|
|
712
|
+
RetrieverLayer.prototype.getCommonGroups = function (wid) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
714
|
+
return __generator(this, function (_a) {
|
|
715
|
+
switch (_a.label) {
|
|
716
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
717
|
+
var wid = _a.wid;
|
|
718
|
+
return WPP.contact.getCommonGroups(wid);
|
|
719
|
+
}, { wid: wid })];
|
|
720
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
};
|
|
683
725
|
return RetrieverLayer;
|
|
684
726
|
}(sender_layer_1.SenderLayer));
|
|
685
727
|
exports.RetrieverLayer = RetrieverLayer;
|
|
@@ -4,6 +4,7 @@ import { CreateConfig } from '../../config/create-config';
|
|
|
4
4
|
import { Message } from '../model';
|
|
5
5
|
import { ChatState } from '../model/enum';
|
|
6
6
|
import { ListenerLayer } from './listener.layer';
|
|
7
|
+
import { OrderItems, OrderMessageOptions } from '@wppconnect/wa-js/dist/chat/functions/sendOrderMessage';
|
|
7
8
|
export declare class SenderLayer extends ListenerLayer {
|
|
8
9
|
page: Page;
|
|
9
10
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
@@ -481,4 +482,32 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
481
482
|
sendReactionToMessage(msgId: string, reaction: string | false): Promise<{
|
|
482
483
|
sendMsgResult: string;
|
|
483
484
|
}>;
|
|
485
|
+
/**
|
|
486
|
+
* Send a order message
|
|
487
|
+
* To send (prices, tax, shipping or discount), for example: USD 12.90, send them without dots or commas, like: 12900
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```javascript
|
|
491
|
+
* // Send Order with a product
|
|
492
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
493
|
+
* { type: 'product', id: '67689897878', qnt: 2 },
|
|
494
|
+
* { type: 'product', id: '37878774457', qnt: 1 },
|
|
495
|
+
* ]
|
|
496
|
+
*
|
|
497
|
+
* // Send Order with a custom item
|
|
498
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
499
|
+
* { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 },
|
|
500
|
+
* ]
|
|
501
|
+
*
|
|
502
|
+
* // Send Order with custom options
|
|
503
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
504
|
+
* { type: 'product', id: '37878774457', qnt: 1 },
|
|
505
|
+
* { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 },
|
|
506
|
+
* ],
|
|
507
|
+
* { tax: 10000, shipping: 4000, discount: 10000 }
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* @category Chat
|
|
511
|
+
*/
|
|
512
|
+
sendOrderMessage(to: string, items: OrderItems[], options?: OrderMessageOptions): Promise<Message>;
|
|
484
513
|
}
|
|
@@ -874,7 +874,7 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
874
874
|
return __generator(this, function (_a) {
|
|
875
875
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
876
876
|
var toChatId = _a.toChatId, msgId = _a.msgId, options = _a.options;
|
|
877
|
-
return
|
|
877
|
+
return WPP.chat.forwardMessage(toChatId, msgId, options);
|
|
878
878
|
}, { toChatId: toChatId, msgId: msgId, options: options })];
|
|
879
879
|
});
|
|
880
880
|
});
|
|
@@ -1402,6 +1402,74 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
1402
1402
|
});
|
|
1403
1403
|
});
|
|
1404
1404
|
};
|
|
1405
|
+
/**
|
|
1406
|
+
* Send a order message
|
|
1407
|
+
* To send (prices, tax, shipping or discount), for example: USD 12.90, send them without dots or commas, like: 12900
|
|
1408
|
+
*
|
|
1409
|
+
* @example
|
|
1410
|
+
* ```javascript
|
|
1411
|
+
* // Send Order with a product
|
|
1412
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
1413
|
+
* { type: 'product', id: '67689897878', qnt: 2 },
|
|
1414
|
+
* { type: 'product', id: '37878774457', qnt: 1 },
|
|
1415
|
+
* ]
|
|
1416
|
+
*
|
|
1417
|
+
* // Send Order with a custom item
|
|
1418
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
1419
|
+
* { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 },
|
|
1420
|
+
* ]
|
|
1421
|
+
*
|
|
1422
|
+
* // Send Order with custom options
|
|
1423
|
+
* client.sendOrderMessage('[number]@c.us', [
|
|
1424
|
+
* { type: 'product', id: '37878774457', qnt: 1 },
|
|
1425
|
+
* { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 },
|
|
1426
|
+
* ],
|
|
1427
|
+
* { tax: 10000, shipping: 4000, discount: 10000 }
|
|
1428
|
+
* ```
|
|
1429
|
+
*
|
|
1430
|
+
* @category Chat
|
|
1431
|
+
*/
|
|
1432
|
+
SenderLayer.prototype.sendOrderMessage = function (to, items, options) {
|
|
1433
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1434
|
+
var sendResult, result;
|
|
1435
|
+
var _this = this;
|
|
1436
|
+
return __generator(this, function (_a) {
|
|
1437
|
+
switch (_a.label) {
|
|
1438
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
1439
|
+
var to = _a.to, items = _a.items, options = _a.options;
|
|
1440
|
+
return WPP.chat.sendOrderMessage(to, items, options);
|
|
1441
|
+
}, {
|
|
1442
|
+
to: to,
|
|
1443
|
+
items: items,
|
|
1444
|
+
options: options,
|
|
1445
|
+
})];
|
|
1446
|
+
case 1:
|
|
1447
|
+
sendResult = _a.sent();
|
|
1448
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
1449
|
+
var messageId = _a.messageId;
|
|
1450
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1451
|
+
var _b, _c, _d, _e;
|
|
1452
|
+
return __generator(this, function (_f) {
|
|
1453
|
+
switch (_f.label) {
|
|
1454
|
+
case 0:
|
|
1455
|
+
_c = (_b = JSON).parse;
|
|
1456
|
+
_e = (_d = JSON).stringify;
|
|
1457
|
+
return [4 /*yield*/, WAPI.getMessageById(messageId)];
|
|
1458
|
+
case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
});
|
|
1462
|
+
}, { messageId: sendResult.id })];
|
|
1463
|
+
case 2:
|
|
1464
|
+
result = (_a.sent());
|
|
1465
|
+
if (result['erro'] == true) {
|
|
1466
|
+
throw result;
|
|
1467
|
+
}
|
|
1468
|
+
return [2 /*return*/, result];
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
};
|
|
1405
1473
|
return SenderLayer;
|
|
1406
1474
|
}(listener_layer_1.ListenerLayer));
|
|
1407
1475
|
exports.SenderLayer = SenderLayer;
|
package/dist/api/whatsapp.d.ts
CHANGED