@wppconnect-team/wppconnect 1.28.2 → 1.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## <small>1.28.3 (2023-11-15)</small>
2
+
3
+ - feat: Added client.getCommonGroups function ([194c898](https://github.com/wppconnect-team/wppconnect/commit/194c898))
4
+
1
5
  ## <small>1.28.2 (2023-11-04)</small>
2
6
 
3
7
  - 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 { HostLayer } from './host.layer';
5
- export declare class CommunityLayer extends HostLayer {
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 host_layer_1 = require("./host.layer");
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
- }(host_layer_1.HostLayer));
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<import("../model").Contact>;
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<import("../model").Contact[]>;
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
  }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.28.2",
3
+ "version": "1.28.3",
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,29 +54,29 @@
54
54
  },
55
55
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
56
56
  "devDependencies": {
57
- "@babel/core": "^7.23.2",
58
- "@babel/eslint-parser": "^7.22.15",
57
+ "@babel/core": "^7.23.3",
58
+ "@babel/eslint-parser": "^7.23.3",
59
59
  "@babel/eslint-plugin": "^7.22.10",
60
- "@babel/preset-env": "^7.23.2",
61
- "@commitlint/cli": "^17.7.2",
62
- "@commitlint/config-conventional": "^17.7.0",
63
- "@commitlint/cz-commitlint": "^17.7.2",
64
- "@types/atob": "^2.1.3",
65
- "@types/mime-types": "^2.1.3",
66
- "@types/mocha": "^10.0.3",
67
- "@types/node": "^18.17.19",
60
+ "@babel/preset-env": "^7.23.3",
61
+ "@commitlint/cli": "^17.8.1",
62
+ "@commitlint/config-conventional": "^17.8.1",
63
+ "@commitlint/cz-commitlint": "^17.8.1",
64
+ "@types/atob": "^2.1.4",
65
+ "@types/mime-types": "^2.1.4",
66
+ "@types/mocha": "^10.0.4",
67
+ "@types/node": "^18.18.9",
68
68
  "@types/rimraf": "^3.0.2",
69
69
  "@types/sharp": "^0.31.1",
70
- "@types/shelljs": "^0.8.14",
71
- "@types/tmp": "^0.2.5",
72
- "@types/ws": "^8.5.8",
70
+ "@types/shelljs": "^0.8.15",
71
+ "@types/tmp": "^0.2.6",
72
+ "@types/ws": "^8.5.9",
73
73
  "@typescript-eslint/eslint-plugin": "^5.62.0",
74
74
  "@typescript-eslint/parser": "^5.62.0",
75
75
  "babel-loader": "^9.1.3",
76
76
  "commitizen": "^4.3.0",
77
77
  "concurrently": "^8.2.2",
78
78
  "conventional-changelog-cli": "^4.1.0",
79
- "eslint": "^8.51.0",
79
+ "eslint": "^8.53.0",
80
80
  "eslint-config-prettier": "^9.0.0",
81
81
  "eslint-plugin-header": "^3.1.1",
82
82
  "eslint-plugin-prettier": "^4.2.1",
@@ -85,19 +85,19 @@
85
85
  "prettier": "^2.8.8",
86
86
  "pretty-quick": "^3.1.3",
87
87
  "regenerator-runtime": "^0.14.0",
88
- "release-it": "^15.11.0",
88
+ "release-it": "^17.0.0",
89
89
  "shx": "^0.3.4",
90
90
  "ts-node": "^10.9.1",
91
91
  "typedoc": "^0.25.3",
92
92
  "typescript": "^5.2.2",
93
- "webpack": "^5.88.2",
93
+ "webpack": "^5.89.0",
94
94
  "webpack-cli": "^5.1.4"
95
95
  },
96
96
  "dependencies": {
97
97
  "@wppconnect/wa-js": "^2.28.0",
98
- "@wppconnect/wa-version": "^1.2.135",
98
+ "@wppconnect/wa-version": "^1.2.148",
99
99
  "atob": "^2.1.2",
100
- "axios": "^1.6.0",
100
+ "axios": "^1.6.2",
101
101
  "boxen": "^5.1.2",
102
102
  "catch-exit": "^1.2.2",
103
103
  "chalk": "~4.1.2",
@@ -109,7 +109,7 @@
109
109
  "logform": "^2.6.0",
110
110
  "lookpath": "^1.2.2",
111
111
  "mime-types": "^2.1.35",
112
- "puppeteer": "^21.3.8",
112
+ "puppeteer": "^21.5.1",
113
113
  "puppeteer-extra": "^3.3.6",
114
114
  "puppeteer-extra-plugin-stealth": "^2.11.2",
115
115
  "puppeteer-extra-plugin-user-data-dir": "^2.4.1",