wuzapi 1.4.0 → 1.5.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 (42) hide show
  1. package/README.md +513 -1217
  2. package/dist/client.d.ts +2 -1
  3. package/dist/client.js +91 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +12 -811
  7. package/dist/index.js.map +1 -1
  8. package/dist/modules/admin.d.ts +8 -0
  9. package/dist/modules/admin.js +37 -0
  10. package/dist/modules/admin.js.map +1 -0
  11. package/dist/modules/chat.d.ts +21 -1
  12. package/dist/modules/chat.js +173 -0
  13. package/dist/modules/chat.js.map +1 -0
  14. package/dist/modules/group.d.ts +25 -1
  15. package/dist/modules/group.js +142 -0
  16. package/dist/modules/group.js.map +1 -0
  17. package/dist/modules/newsletter.d.ts +9 -0
  18. package/dist/modules/newsletter.js +13 -0
  19. package/dist/modules/newsletter.js.map +1 -0
  20. package/dist/modules/session.d.ts +13 -1
  21. package/dist/modules/session.js +85 -0
  22. package/dist/modules/session.js.map +1 -0
  23. package/dist/modules/user.d.ts +5 -1
  24. package/dist/modules/user.js +40 -0
  25. package/dist/modules/user.js.map +1 -0
  26. package/dist/modules/webhook.d.ts +9 -1
  27. package/dist/modules/webhook.js +33 -0
  28. package/dist/modules/webhook.js.map +1 -0
  29. package/dist/types/chat.d.ts +55 -0
  30. package/dist/types/group.d.ts +52 -0
  31. package/dist/types/index.d.ts +1 -0
  32. package/dist/types/index.js +396 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types/newsletter.d.ts +17 -0
  35. package/dist/types/session.d.ts +16 -0
  36. package/dist/types/user.d.ts +5 -0
  37. package/dist/types/webhook.d.ts +9 -0
  38. package/dist/wuzapi-client.d.ts +2 -0
  39. package/dist/wuzapi-client.js +45 -0
  40. package/dist/wuzapi-client.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/vite-env.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1,813 +1,13 @@
1
- import axios from "axios";
2
- class WuzapiError extends Error {
3
- code;
4
- details;
5
- constructor(code, message, details) {
6
- super(message);
7
- this.name = "WuzapiError";
8
- this.code = code;
9
- this.details = details;
10
- }
11
- }
12
- class BaseClient {
13
- axios;
14
- config;
15
- constructor(config) {
16
- this.config = config;
17
- this.axios = axios.create({
18
- baseURL: config.apiUrl,
19
- headers: {
20
- "Content-Type": "application/json"
21
- }
22
- });
23
- this.axios.interceptors.response.use(
24
- (response) => response,
25
- (error) => {
26
- if (error.response) {
27
- const data = error.response.data;
28
- throw new WuzapiError(
29
- data.code || error.response.status,
30
- data.message || error.message,
31
- data
32
- );
33
- } else if (error.request) {
34
- throw new WuzapiError(0, "Network error: No response from server");
35
- } else {
36
- throw new WuzapiError(0, error.message);
37
- }
38
- }
39
- );
40
- }
41
- /**
42
- * Resolve the token from request options or instance config
43
- * Throws an error if no token is available
44
- */
45
- resolveToken(options) {
46
- const token = options?.token || this.config.token;
47
- if (!token) {
48
- throw new WuzapiError(
49
- 401,
50
- "No authentication token provided. Either set a token in the client config or provide one in the request options."
51
- );
52
- }
53
- return token;
54
- }
55
- async request(method, endpoint, data, options) {
56
- const token = this.resolveToken(options);
57
- const response = await this.axios.request({
58
- method,
59
- url: endpoint,
60
- data,
61
- headers: {
62
- Authorization: token
63
- }
64
- });
65
- if (!response.data.success) {
66
- throw new WuzapiError(
67
- response.data.code,
68
- "API request failed",
69
- response.data
70
- );
71
- }
72
- return response.data.data;
73
- }
74
- async get(endpoint, options) {
75
- return this.request("GET", endpoint, void 0, options);
76
- }
77
- async post(endpoint, data, options) {
78
- return this.request("POST", endpoint, data, options);
79
- }
80
- async delete(endpoint, options) {
81
- return this.request("DELETE", endpoint, void 0, options);
82
- }
83
- }
84
- class AdminModule extends BaseClient {
85
- /**
86
- * List all users
87
- */
88
- async listUsers(options) {
89
- return this.get("/admin/users", options);
90
- }
91
- /**
92
- * Add a new user
93
- */
94
- async addUser(user, options) {
95
- return this.post("/admin/users", user, options);
96
- }
97
- /**
98
- * Delete a user by ID
99
- */
100
- async deleteUser(id, options) {
101
- return this.delete(`/admin/users/${id}`, options);
102
- }
103
- }
104
- class SessionModule extends BaseClient {
105
- /**
106
- * Connect to WhatsApp servers
107
- */
108
- async connect(request, options) {
109
- return this.post("/session/connect", request, options);
110
- }
111
- /**
112
- * Disconnect from WhatsApp servers
113
- */
114
- async disconnect(options) {
115
- return this.post(
116
- "/session/disconnect",
117
- void 0,
118
- options
119
- );
120
- }
121
- /**
122
- * Logout and finish the session
123
- */
124
- async logout(options) {
125
- return this.post("/session/logout", void 0, options);
126
- }
127
- /**
128
- * Get session status
129
- */
130
- async getStatus(options) {
131
- return this.get("/session/status", options);
132
- }
133
- /**
134
- * Get QR code for scanning
135
- */
136
- async getQRCode(options) {
137
- return this.get("/session/qr", options);
138
- }
139
- /**
140
- * Configure S3 storage
141
- */
142
- async configureS3(config, options) {
143
- return this.post("/session/s3/config", config, options);
144
- }
145
- /**
146
- * Get S3 configuration
147
- */
148
- async getS3Config(options) {
149
- return this.get("/session/s3/config", options);
150
- }
151
- /**
152
- * Test S3 connection
153
- */
154
- async testS3(options) {
155
- return this.post("/session/s3/test", void 0, options);
156
- }
157
- /**
158
- * Delete S3 configuration
159
- */
160
- async deleteS3Config(options) {
161
- return this.delete("/session/s3/config", options);
162
- }
163
- }
164
- class UserModule extends BaseClient {
165
- /**
166
- * Get user details for specified phone numbers
167
- */
168
- async getInfo(phones, options) {
169
- const request = { Phone: phones };
170
- return this.post("/user/info", request, options);
171
- }
172
- /**
173
- * Check if phone numbers are registered WhatsApp users
174
- */
175
- async check(phones, options) {
176
- const request = { Phone: phones };
177
- return this.post("/user/check", request, options);
178
- }
179
- /**
180
- * Get user avatar/profile picture
181
- */
182
- async getAvatar(phone, preview = true, options) {
183
- const request = { Phone: phone, Preview: preview };
184
- return this.post("/user/avatar", request, options);
185
- }
186
- /**
187
- * Get all contacts
188
- */
189
- async getContacts(options) {
190
- return this.get("/user/contacts", options);
191
- }
192
- }
193
- class ChatModule extends BaseClient {
194
- /**
195
- * Send a text message
196
- */
197
- async sendText(request, options) {
198
- return this.post("/chat/send/text", request, options);
199
- }
200
- /**
201
- * Send a template message with buttons
202
- */
203
- async sendTemplate(request, options) {
204
- return this.post(
205
- "/chat/send/template",
206
- request,
207
- options
208
- );
209
- }
210
- /**
211
- * Send an audio message
212
- */
213
- async sendAudio(request, options) {
214
- return this.post("/chat/send/audio", request, options);
215
- }
216
- /**
217
- * Send an image message
218
- */
219
- async sendImage(request, options) {
220
- return this.post("/chat/send/image", request, options);
221
- }
222
- /**
223
- * Send a document message
224
- */
225
- async sendDocument(request, options) {
226
- return this.post(
227
- "/chat/send/document",
228
- request,
229
- options
230
- );
231
- }
232
- /**
233
- * Send a video message
234
- */
235
- async sendVideo(request, options) {
236
- return this.post("/chat/send/video", request, options);
237
- }
238
- /**
239
- * Send a sticker message
240
- */
241
- async sendSticker(request, options) {
242
- return this.post(
243
- "/chat/send/sticker",
244
- request,
245
- options
246
- );
247
- }
248
- /**
249
- * Send a location message
250
- */
251
- async sendLocation(request, options) {
252
- return this.post(
253
- "/chat/send/location",
254
- request,
255
- options
256
- );
257
- }
258
- /**
259
- * Send a contact message
260
- */
261
- async sendContact(request, options) {
262
- return this.post(
263
- "/chat/send/contact",
264
- request,
265
- options
266
- );
267
- }
268
- /**
269
- * Send chat presence indication (typing indicator)
270
- */
271
- async sendPresence(request, options) {
272
- await this.post("/chat/presence", request, options);
273
- }
274
- /**
275
- * Mark messages as read
276
- */
277
- async markRead(request, options) {
278
- await this.post("/chat/markread", request, options);
279
- }
280
- /**
281
- * React to a message
282
- */
283
- async react(request, options) {
284
- return this.post("/chat/react", request, options);
285
- }
286
- /**
287
- * Download an image from a message
288
- */
289
- async downloadImage(request, options) {
290
- return this.post(
291
- "/chat/downloadimage",
292
- request,
293
- options
294
- );
295
- }
296
- /**
297
- * Download a video from a message
298
- */
299
- async downloadVideo(request, options) {
300
- return this.post(
301
- "/chat/downloadvideo",
302
- request,
303
- options
304
- );
305
- }
306
- /**
307
- * Download an audio from a message
308
- */
309
- async downloadAudio(request, options) {
310
- return this.post(
311
- "/chat/downloadaudio",
312
- request,
313
- options
314
- );
315
- }
316
- /**
317
- * Download a document from a message
318
- */
319
- async downloadDocument(request, options) {
320
- return this.post(
321
- "/chat/downloaddocument",
322
- request,
323
- options
324
- );
325
- }
326
- }
327
- class GroupModule extends BaseClient {
328
- /**
329
- * List all subscribed groups
330
- */
331
- async list(options) {
332
- return this.get("/group/list", options);
333
- }
334
- /**
335
- * Get group invite link
336
- */
337
- async getInviteLink(groupJID, options) {
338
- const request = { GroupJID: groupJID };
339
- return this.post(
340
- "/group/invitelink",
341
- request,
342
- options
343
- );
344
- }
345
- /**
346
- * Get group information
347
- */
348
- async getInfo(groupJID, options) {
349
- const request = { GroupJID: groupJID };
350
- return this.post("/group/info", request, options);
351
- }
352
- /**
353
- * Change group photo (JPEG only)
354
- */
355
- async setPhoto(groupJID, image, options) {
356
- const request = { GroupJID: groupJID, Image: image };
357
- return this.post("/group/photo", request, options);
358
- }
359
- /**
360
- * Change group name
361
- */
362
- async setName(groupJID, name, options) {
363
- const request = { GroupJID: groupJID, Name: name };
364
- return this.post("/group/name", request, options);
365
- }
366
- /**
367
- * Create a new group
368
- */
369
- async create(name, participants, options) {
370
- const request = { name, participants };
371
- return this.post("/group/create", request, options);
372
- }
373
- /**
374
- * Set group locked status
375
- */
376
- async setLocked(groupJID, locked, options) {
377
- const request = { groupjid: groupJID, locked };
378
- return this.post("/group/locked", request, options);
379
- }
380
- /**
381
- * Set disappearing messages timer
382
- */
383
- async setEphemeral(groupJID, duration, options) {
384
- const request = { groupjid: groupJID, duration };
385
- return this.post(
386
- "/group/ephemeral",
387
- request,
388
- options
389
- );
390
- }
391
- /**
392
- * Remove group photo
393
- */
394
- async removePhoto(groupJID, options) {
395
- const request = { groupjid: groupJID };
396
- return this.post(
397
- "/group/photo/remove",
398
- request,
399
- options
400
- );
401
- }
402
- }
403
- class WebhookModule extends BaseClient {
404
- /**
405
- * Set webhook URL and events to subscribe to
406
- */
407
- async setWebhook(webhookURL, options) {
408
- const request = { webhookURL };
409
- return this.post("/webhook", request, options);
410
- }
411
- /**
412
- * Get current webhook configuration
413
- */
414
- async getWebhook(options) {
415
- return this.get("/webhook", options);
416
- }
417
- }
418
- class WuzapiClient {
419
- admin;
420
- session;
421
- user;
422
- chat;
423
- group;
424
- webhook;
425
- // Legacy aliases for convenience
426
- users;
427
- message;
428
- constructor(config) {
429
- this.admin = new AdminModule(config);
430
- this.session = new SessionModule(config);
431
- this.user = new UserModule(config);
432
- this.chat = new ChatModule(config);
433
- this.group = new GroupModule(config);
434
- this.webhook = new WebhookModule(config);
435
- this.users = this.user;
436
- this.message = this.chat;
437
- }
438
- /**
439
- * Test connection to the API
440
- */
441
- async ping(options) {
442
- try {
443
- await this.session.getStatus(options);
444
- return true;
445
- } catch {
446
- return false;
447
- }
448
- }
449
- }
450
- function hasS3Media(payload) {
451
- return !!payload.s3;
452
- }
453
- function hasBase64Media(payload) {
454
- return !!payload.base64;
455
- }
456
- function hasBothMedia(payload) {
457
- return hasS3Media(payload) && hasBase64Media(payload);
458
- }
459
- var DisappearingModeInitiator = /* @__PURE__ */ ((DisappearingModeInitiator2) => {
460
- DisappearingModeInitiator2[DisappearingModeInitiator2["CHANGED_IN_CHAT"] = 0] = "CHANGED_IN_CHAT";
461
- DisappearingModeInitiator2[DisappearingModeInitiator2["INITIATED_BY_ME"] = 1] = "INITIATED_BY_ME";
462
- DisappearingModeInitiator2[DisappearingModeInitiator2["INITIATED_BY_OTHER"] = 2] = "INITIATED_BY_OTHER";
463
- return DisappearingModeInitiator2;
464
- })(DisappearingModeInitiator || {});
465
- var DisappearingModeTrigger = /* @__PURE__ */ ((DisappearingModeTrigger2) => {
466
- DisappearingModeTrigger2[DisappearingModeTrigger2["UNKNOWN"] = 0] = "UNKNOWN";
467
- DisappearingModeTrigger2[DisappearingModeTrigger2["CHAT_SETTING"] = 1] = "CHAT_SETTING";
468
- DisappearingModeTrigger2[DisappearingModeTrigger2["ACCOUNT_SETTING"] = 2] = "ACCOUNT_SETTING";
469
- DisappearingModeTrigger2[DisappearingModeTrigger2["BULK_CHANGE"] = 3] = "BULK_CHANGE";
470
- return DisappearingModeTrigger2;
471
- })(DisappearingModeTrigger || {});
472
- var MediaType = /* @__PURE__ */ ((MediaType2) => {
473
- MediaType2[MediaType2["UNKNOWN"] = 0] = "UNKNOWN";
474
- MediaType2[MediaType2["IMAGE"] = 1] = "IMAGE";
475
- MediaType2[MediaType2["VIDEO"] = 2] = "VIDEO";
476
- MediaType2[MediaType2["AUDIO"] = 3] = "AUDIO";
477
- MediaType2[MediaType2["DOCUMENT"] = 4] = "DOCUMENT";
478
- MediaType2[MediaType2["STICKER"] = 5] = "STICKER";
479
- return MediaType2;
480
- })(MediaType || {});
481
- var VideoAttribution = /* @__PURE__ */ ((VideoAttribution2) => {
482
- VideoAttribution2[VideoAttribution2["NONE"] = 0] = "NONE";
483
- VideoAttribution2[VideoAttribution2["GIPHY"] = 1] = "GIPHY";
484
- VideoAttribution2[VideoAttribution2["TENOR"] = 2] = "TENOR";
485
- VideoAttribution2[VideoAttribution2["KLIPY"] = 3] = "KLIPY";
486
- return VideoAttribution2;
487
- })(VideoAttribution || {});
488
- var VideoSourceType = /* @__PURE__ */ ((VideoSourceType2) => {
489
- VideoSourceType2[VideoSourceType2["USER_VIDEO"] = 0] = "USER_VIDEO";
490
- VideoSourceType2[VideoSourceType2["AI_GENERATED"] = 1] = "AI_GENERATED";
491
- return VideoSourceType2;
492
- })(VideoSourceType || {});
493
- var ExtendedTextMessageFontType = /* @__PURE__ */ ((ExtendedTextMessageFontType2) => {
494
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["SANS_SERIF"] = 0] = "SANS_SERIF";
495
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["SERIF"] = 1] = "SERIF";
496
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["NORICAN_REGULAR"] = 2] = "NORICAN_REGULAR";
497
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["BRYNDAN_WRITE"] = 3] = "BRYNDAN_WRITE";
498
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["BEBASNEUE_REGULAR"] = 4] = "BEBASNEUE_REGULAR";
499
- ExtendedTextMessageFontType2[ExtendedTextMessageFontType2["OSWALD_HEAVY"] = 5] = "OSWALD_HEAVY";
500
- return ExtendedTextMessageFontType2;
501
- })(ExtendedTextMessageFontType || {});
502
- var ExtendedTextMessagePreviewType = /* @__PURE__ */ ((ExtendedTextMessagePreviewType2) => {
503
- ExtendedTextMessagePreviewType2[ExtendedTextMessagePreviewType2["NONE"] = 0] = "NONE";
504
- ExtendedTextMessagePreviewType2[ExtendedTextMessagePreviewType2["VIDEO"] = 1] = "VIDEO";
505
- ExtendedTextMessagePreviewType2[ExtendedTextMessagePreviewType2["PLACEHOLDER"] = 4] = "PLACEHOLDER";
506
- ExtendedTextMessagePreviewType2[ExtendedTextMessagePreviewType2["IMAGE"] = 5] = "IMAGE";
507
- return ExtendedTextMessagePreviewType2;
508
- })(ExtendedTextMessagePreviewType || {});
509
- var ExtendedTextMessageInviteLinkGroupType = /* @__PURE__ */ ((ExtendedTextMessageInviteLinkGroupType2) => {
510
- ExtendedTextMessageInviteLinkGroupType2[ExtendedTextMessageInviteLinkGroupType2["DEFAULT"] = 0] = "DEFAULT";
511
- ExtendedTextMessageInviteLinkGroupType2[ExtendedTextMessageInviteLinkGroupType2["PARENT"] = 1] = "PARENT";
512
- ExtendedTextMessageInviteLinkGroupType2[ExtendedTextMessageInviteLinkGroupType2["SUB"] = 2] = "SUB";
513
- ExtendedTextMessageInviteLinkGroupType2[ExtendedTextMessageInviteLinkGroupType2["DEFAULT_SUB"] = 3] = "DEFAULT_SUB";
514
- return ExtendedTextMessageInviteLinkGroupType2;
515
- })(ExtendedTextMessageInviteLinkGroupType || {});
516
- var InviteLinkGroupType = /* @__PURE__ */ ((InviteLinkGroupType2) => {
517
- InviteLinkGroupType2[InviteLinkGroupType2["DEFAULT"] = 0] = "DEFAULT";
518
- InviteLinkGroupType2[InviteLinkGroupType2["PARENT"] = 1] = "PARENT";
519
- InviteLinkGroupType2[InviteLinkGroupType2["SUB"] = 2] = "SUB";
520
- InviteLinkGroupType2[InviteLinkGroupType2["DEFAULT_SUB"] = 3] = "DEFAULT_SUB";
521
- return InviteLinkGroupType2;
522
- })(InviteLinkGroupType || {});
523
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
524
- ButtonType2[ButtonType2["UNKNOWN"] = 0] = "UNKNOWN";
525
- ButtonType2[ButtonType2["RESPONSE"] = 1] = "RESPONSE";
526
- ButtonType2[ButtonType2["NATIVE_FLOW"] = 2] = "NATIVE_FLOW";
527
- return ButtonType2;
528
- })(ButtonType || {});
529
- var ButtonsMessageHeaderType = /* @__PURE__ */ ((ButtonsMessageHeaderType2) => {
530
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["UNKNOWN"] = 0] = "UNKNOWN";
531
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["EMPTY"] = 1] = "EMPTY";
532
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["TEXT"] = 2] = "TEXT";
533
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["DOCUMENT"] = 3] = "DOCUMENT";
534
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["IMAGE"] = 4] = "IMAGE";
535
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["VIDEO"] = 5] = "VIDEO";
536
- ButtonsMessageHeaderType2[ButtonsMessageHeaderType2["LOCATION"] = 6] = "LOCATION";
537
- return ButtonsMessageHeaderType2;
538
- })(ButtonsMessageHeaderType || {});
539
- var ListMessageListType = /* @__PURE__ */ ((ListMessageListType2) => {
540
- ListMessageListType2[ListMessageListType2["UNKNOWN"] = 0] = "UNKNOWN";
541
- ListMessageListType2[ListMessageListType2["SINGLE_SELECT"] = 1] = "SINGLE_SELECT";
542
- ListMessageListType2[ListMessageListType2["PRODUCT_LIST"] = 2] = "PRODUCT_LIST";
543
- return ListMessageListType2;
544
- })(ListMessageListType || {});
545
- var ButtonsResponseMessageType = /* @__PURE__ */ ((ButtonsResponseMessageType2) => {
546
- ButtonsResponseMessageType2[ButtonsResponseMessageType2["UNKNOWN"] = 0] = "UNKNOWN";
547
- ButtonsResponseMessageType2[ButtonsResponseMessageType2["DISPLAY_TEXT"] = 1] = "DISPLAY_TEXT";
548
- return ButtonsResponseMessageType2;
549
- })(ButtonsResponseMessageType || {});
550
- var ListResponseMessageListType = /* @__PURE__ */ ((ListResponseMessageListType2) => {
551
- ListResponseMessageListType2[ListResponseMessageListType2["UNKNOWN"] = 0] = "UNKNOWN";
552
- ListResponseMessageListType2[ListResponseMessageListType2["SINGLE_SELECT"] = 1] = "SINGLE_SELECT";
553
- return ListResponseMessageListType2;
554
- })(ListResponseMessageListType || {});
555
- var PaymentBackgroundType = /* @__PURE__ */ ((PaymentBackgroundType2) => {
556
- PaymentBackgroundType2[PaymentBackgroundType2["UNKNOWN"] = 0] = "UNKNOWN";
557
- PaymentBackgroundType2[PaymentBackgroundType2["DEFAULT"] = 1] = "DEFAULT";
558
- return PaymentBackgroundType2;
559
- })(PaymentBackgroundType || {});
560
- var ProtocolMessageType = /* @__PURE__ */ ((ProtocolMessageType2) => {
561
- ProtocolMessageType2[ProtocolMessageType2["REVOKE"] = 0] = "REVOKE";
562
- ProtocolMessageType2[ProtocolMessageType2["EPHEMERAL_SETTING"] = 3] = "EPHEMERAL_SETTING";
563
- ProtocolMessageType2[ProtocolMessageType2["EPHEMERAL_SYNC_RESPONSE"] = 4] = "EPHEMERAL_SYNC_RESPONSE";
564
- ProtocolMessageType2[ProtocolMessageType2["HISTORY_SYNC_NOTIFICATION"] = 5] = "HISTORY_SYNC_NOTIFICATION";
565
- ProtocolMessageType2[ProtocolMessageType2["APP_STATE_SYNC_KEY_SHARE"] = 6] = "APP_STATE_SYNC_KEY_SHARE";
566
- ProtocolMessageType2[ProtocolMessageType2["APP_STATE_SYNC_KEY_REQUEST"] = 7] = "APP_STATE_SYNC_KEY_REQUEST";
567
- ProtocolMessageType2[ProtocolMessageType2["MSG_FANOUT_BACKFILL_REQUEST"] = 8] = "MSG_FANOUT_BACKFILL_REQUEST";
568
- ProtocolMessageType2[ProtocolMessageType2["INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC"] = 9] = "INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC";
569
- ProtocolMessageType2[ProtocolMessageType2["APP_STATE_FATAL_EXCEPTION_NOTIFICATION"] = 10] = "APP_STATE_FATAL_EXCEPTION_NOTIFICATION";
570
- ProtocolMessageType2[ProtocolMessageType2["SHARE_PHONE_NUMBER"] = 11] = "SHARE_PHONE_NUMBER";
571
- ProtocolMessageType2[ProtocolMessageType2["MESSAGE_EDIT"] = 14] = "MESSAGE_EDIT";
572
- ProtocolMessageType2[ProtocolMessageType2["PEER_DATA_OPERATION_REQUEST_MESSAGE"] = 16] = "PEER_DATA_OPERATION_REQUEST_MESSAGE";
573
- ProtocolMessageType2[ProtocolMessageType2["PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE"] = 17] = "PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE";
574
- return ProtocolMessageType2;
575
- })(ProtocolMessageType || {});
576
- var BotPluginType = /* @__PURE__ */ ((BotPluginType2) => {
577
- BotPluginType2[BotPluginType2["REELS"] = 0] = "REELS";
578
- BotPluginType2[BotPluginType2["SEARCH"] = 1] = "SEARCH";
579
- return BotPluginType2;
580
- })(BotPluginType || {});
581
- var BotPluginSearchProvider = /* @__PURE__ */ ((BotPluginSearchProvider2) => {
582
- BotPluginSearchProvider2[BotPluginSearchProvider2["BING"] = 0] = "BING";
583
- BotPluginSearchProvider2[BotPluginSearchProvider2["GOOGLE"] = 1] = "GOOGLE";
584
- return BotPluginSearchProvider2;
585
- })(BotPluginSearchProvider || {});
586
- var HistorySyncNotificationHistorySyncType = /* @__PURE__ */ ((HistorySyncNotificationHistorySyncType2) => {
587
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["INITIAL_BOOTSTRAP"] = 0] = "INITIAL_BOOTSTRAP";
588
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["INITIAL_STATUS_V3"] = 1] = "INITIAL_STATUS_V3";
589
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["FULL"] = 2] = "FULL";
590
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["RECENT"] = 3] = "RECENT";
591
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["PUSH_NAME"] = 4] = "PUSH_NAME";
592
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["NON_BLOCKING_DATA"] = 5] = "NON_BLOCKING_DATA";
593
- HistorySyncNotificationHistorySyncType2[HistorySyncNotificationHistorySyncType2["ON_DEMAND"] = 6] = "ON_DEMAND";
594
- return HistorySyncNotificationHistorySyncType2;
595
- })(HistorySyncNotificationHistorySyncType || {});
596
- var PeerDataOperationRequestType = /* @__PURE__ */ ((PeerDataOperationRequestType2) => {
597
- PeerDataOperationRequestType2[PeerDataOperationRequestType2["UPLOAD_STICKER"] = 0] = "UPLOAD_STICKER";
598
- PeerDataOperationRequestType2[PeerDataOperationRequestType2["SEND_RECENT_STICKER_BOOTSTRAP"] = 1] = "SEND_RECENT_STICKER_BOOTSTRAP";
599
- PeerDataOperationRequestType2[PeerDataOperationRequestType2["GENERATE_LINK_PREVIEW"] = 2] = "GENERATE_LINK_PREVIEW";
600
- return PeerDataOperationRequestType2;
601
- })(PeerDataOperationRequestType || {});
602
- var PeerDataOperationRequestResponseMessagePeerDataOperationResult = /* @__PURE__ */ ((PeerDataOperationRequestResponseMessagePeerDataOperationResult2) => {
603
- PeerDataOperationRequestResponseMessagePeerDataOperationResult2[PeerDataOperationRequestResponseMessagePeerDataOperationResult2["SUCCESS"] = 0] = "SUCCESS";
604
- PeerDataOperationRequestResponseMessagePeerDataOperationResult2[PeerDataOperationRequestResponseMessagePeerDataOperationResult2["NOT_AUTHORIZED"] = 1] = "NOT_AUTHORIZED";
605
- PeerDataOperationRequestResponseMessagePeerDataOperationResult2[PeerDataOperationRequestResponseMessagePeerDataOperationResult2["NOT_FOUND"] = 2] = "NOT_FOUND";
606
- PeerDataOperationRequestResponseMessagePeerDataOperationResult2[PeerDataOperationRequestResponseMessagePeerDataOperationResult2["THROTTLED"] = 3] = "THROTTLED";
607
- PeerDataOperationRequestResponseMessagePeerDataOperationResult2[PeerDataOperationRequestResponseMessagePeerDataOperationResult2["UNKNOWN_ERROR"] = 4] = "UNKNOWN_ERROR";
608
- return PeerDataOperationRequestResponseMessagePeerDataOperationResult2;
609
- })(PeerDataOperationRequestResponseMessagePeerDataOperationResult || {});
610
- function getMessageContent(message) {
611
- if (message.conversation) {
612
- return { type: "text", content: message.conversation };
613
- }
614
- if (message.extendedTextMessage) {
615
- return { type: "extendedText", content: message.extendedTextMessage };
616
- }
617
- if (message.imageMessage) {
618
- return { type: "image", content: message.imageMessage };
619
- }
620
- if (message.videoMessage) {
621
- return { type: "video", content: message.videoMessage };
622
- }
623
- if (message.audioMessage) {
624
- return { type: "audio", content: message.audioMessage };
625
- }
626
- if (message.documentMessage) {
627
- return { type: "document", content: message.documentMessage };
628
- }
629
- if (message.stickerMessage) {
630
- return { type: "sticker", content: message.stickerMessage };
631
- }
632
- if (message.locationMessage) {
633
- return { type: "location", content: message.locationMessage };
634
- }
635
- if (message.liveLocationMessage) {
636
- return { type: "liveLocation", content: message.liveLocationMessage };
637
- }
638
- if (message.contactMessage) {
639
- return { type: "contact", content: message.contactMessage };
640
- }
641
- if (message.contactsArrayMessage) {
642
- return { type: "contactsArray", content: message.contactsArrayMessage };
643
- }
644
- if (message.buttonsMessage) {
645
- return { type: "buttons", content: message.buttonsMessage };
646
- }
647
- if (message.listMessage) {
648
- return { type: "list", content: message.listMessage };
649
- }
650
- if (message.templateMessage) {
651
- return { type: "template", content: message.templateMessage };
652
- }
653
- if (message.buttonsResponseMessage) {
654
- return { type: "buttonsResponse", content: message.buttonsResponseMessage };
655
- }
656
- if (message.listResponseMessage) {
657
- return { type: "listResponse", content: message.listResponseMessage };
658
- }
659
- if (message.groupInviteMessage) {
660
- return { type: "groupInvite", content: message.groupInviteMessage };
661
- }
662
- if (message.pollCreationMessage) {
663
- return { type: "poll", content: message.pollCreationMessage };
664
- }
665
- if (message.pollUpdateMessage) {
666
- return { type: "pollUpdate", content: message.pollUpdateMessage };
667
- }
668
- if (message.reactionMessage) {
669
- return { type: "reaction", content: message.reactionMessage };
670
- }
671
- if (message.protocolMessage) {
672
- return { type: "protocol", content: message.protocolMessage };
673
- }
674
- if (message.ephemeralMessage) {
675
- return { type: "ephemeral", content: message.ephemeralMessage };
676
- }
677
- if (message.viewOnceMessage) {
678
- return { type: "viewOnce", content: message.viewOnceMessage };
679
- }
680
- return null;
681
- }
682
- var EventType = /* @__PURE__ */ ((EventType2) => {
683
- EventType2["MESSAGE"] = "Message";
684
- EventType2["RECEIPT"] = "Receipt";
685
- EventType2["PRESENCE"] = "Presence";
686
- EventType2["CHAT_PRESENCE"] = "ChatPresence";
687
- EventType2["CONNECTED"] = "Connected";
688
- EventType2["DISCONNECTED"] = "Disconnected";
689
- EventType2["LOGGED_OUT"] = "LoggedOut";
690
- EventType2["QR"] = "QR";
691
- EventType2["QR_SCANNED_WITHOUT_MULTIDEVICE"] = "QRScannedWithoutMultidevice";
692
- EventType2["PAIR_SUCCESS"] = "PairSuccess";
693
- EventType2["PAIR_ERROR"] = "PairError";
694
- EventType2["MANUAL_LOGIN_RECONNECT"] = "ManualLoginReconnect";
695
- EventType2["KEEP_ALIVE_RESTORED"] = "KeepAliveRestored";
696
- EventType2["KEEP_ALIVE_TIMEOUT"] = "KeepAliveTimeout";
697
- EventType2["GROUP_INFO"] = "GroupInfo";
698
- EventType2["JOINED_GROUP"] = "JoinedGroup";
699
- EventType2["CONTACT"] = "Contact";
700
- EventType2["PUSH_NAME"] = "PushName";
701
- EventType2["PUSH_NAME_SETTING"] = "PushNameSetting";
702
- EventType2["PICTURE"] = "Picture";
703
- EventType2["USER_ABOUT"] = "UserAbout";
704
- EventType2["USER_STATUS_MUTE"] = "UserStatusMute";
705
- EventType2["PRIVACY_SETTINGS"] = "PrivacySettings";
706
- EventType2["APP_STATE"] = "AppState";
707
- EventType2["APP_STATE_SYNC_COMPLETE"] = "AppStateSyncComplete";
708
- EventType2["HISTORY_SYNC"] = "HistorySync";
709
- EventType2["OFFLINE_SYNC_COMPLETED"] = "OfflineSyncCompleted";
710
- EventType2["OFFLINE_SYNC_PREVIEW"] = "OfflineSyncPreview";
711
- EventType2["IDENTITY_CHANGE"] = "IdentityChange";
712
- EventType2["ARCHIVE"] = "Archive";
713
- EventType2["UNARCHIVE_CHATS_SETTING"] = "UnarchiveChatsSetting";
714
- EventType2["CLEAR_CHAT"] = "ClearChat";
715
- EventType2["DELETE_CHAT"] = "DeleteChat";
716
- EventType2["DELETE_FOR_ME"] = "DeleteForMe";
717
- EventType2["MARK_CHAT_AS_READ"] = "MarkChatAsRead";
718
- EventType2["MUTE"] = "Mute";
719
- EventType2["PIN"] = "Pin";
720
- EventType2["STAR"] = "Star";
721
- EventType2["LABEL_ASSOCIATION_CHAT"] = "LabelAssociationChat";
722
- EventType2["LABEL_ASSOCIATION_MESSAGE"] = "LabelAssociationMessage";
723
- EventType2["LABEL_EDIT"] = "LabelEdit";
724
- EventType2["MEDIA_RETRY"] = "MediaRetry";
725
- EventType2["MEDIA_RETRY_ERROR"] = "MediaRetryError";
726
- EventType2["NEWSLETTER_JOIN"] = "NewsletterJoin";
727
- EventType2["NEWSLETTER_LEAVE"] = "NewsletterLeave";
728
- EventType2["NEWSLETTER_LIVE_UPDATE"] = "NewsletterLiveUpdate";
729
- EventType2["NEWSLETTER_MESSAGE_META"] = "NewsletterMessageMeta";
730
- EventType2["NEWSLETTER_MUTE_CHANGE"] = "NewsletterMuteChange";
731
- EventType2["UNDECRYPTABLE_MESSAGE"] = "UndecryptableMessage";
732
- EventType2["STREAM_ERROR"] = "StreamError";
733
- EventType2["STREAM_REPLACED"] = "StreamReplaced";
734
- EventType2["CONNECT_FAILURE"] = "ConnectFailure";
735
- EventType2["CLIENT_OUTDATED"] = "ClientOutdated";
736
- EventType2["TEMPORARY_BAN"] = "TemporaryBan";
737
- EventType2["CAT_REFRESH_ERROR"] = "CATRefreshError";
738
- EventType2["PERMANENT_DISCONNECT"] = "PermanentDisconnect";
739
- EventType2["BLOCKLIST"] = "Blocklist";
740
- EventType2["BLOCKLIST_ACTION"] = "BlocklistAction";
741
- EventType2["BLOCKLIST_CHANGE"] = "BlocklistChange";
742
- EventType2["BUSINESS_NAME"] = "BusinessName";
743
- EventType2["CALL_ACCEPT"] = "CallAccept";
744
- EventType2["CALL_OFFER"] = "CallOffer";
745
- EventType2["CALL_OFFER_NOTICE"] = "CallOfferNotice";
746
- EventType2["CALL_PRE_ACCEPT"] = "CallPreAccept";
747
- EventType2["CALL_REJECT"] = "CallReject";
748
- EventType2["CALL_RELAY_LATENCY"] = "CallRelayLatency";
749
- EventType2["CALL_TERMINATE"] = "CallTerminate";
750
- EventType2["CALL_TRANSPORT"] = "CallTransport";
751
- EventType2["UNKNOWN_CALL_EVENT"] = "UnknownCallEvent";
752
- EventType2["FB_MESSAGE"] = "FBMessage";
753
- return EventType2;
754
- })(EventType || {});
755
- var MessageStatus = /* @__PURE__ */ ((MessageStatus2) => {
756
- MessageStatus2["ERROR"] = "ERROR";
757
- MessageStatus2["PENDING"] = "PENDING";
758
- MessageStatus2["SERVER_ACK"] = "SERVER_ACK";
759
- MessageStatus2["DELIVERY_ACK"] = "DELIVERY_ACK";
760
- MessageStatus2["READ"] = "READ";
761
- MessageStatus2["PLAYED"] = "PLAYED";
762
- return MessageStatus2;
763
- })(MessageStatus || {});
764
- var ReceiptType = /* @__PURE__ */ ((ReceiptType2) => {
765
- ReceiptType2["UNKNOWN"] = "";
766
- ReceiptType2["DELIVERY"] = "delivery";
767
- ReceiptType2["READ"] = "read";
768
- ReceiptType2["READ_SELF"] = "read-self";
769
- ReceiptType2["PLAYED"] = "played";
770
- ReceiptType2["SENDER"] = "sender";
771
- ReceiptType2["INACTIVE"] = "inactive";
772
- ReceiptType2["PEER_MSG"] = "peer_msg";
773
- return ReceiptType2;
774
- })(ReceiptType || {});
775
- var DecryptFailMode = /* @__PURE__ */ ((DecryptFailMode2) => {
776
- DecryptFailMode2["UNAVAILABLE"] = "unavailable";
777
- DecryptFailMode2["DECRYPT_FAIL"] = "decrypt_fail";
778
- return DecryptFailMode2;
779
- })(DecryptFailMode || {});
780
- var UnavailableType = /* @__PURE__ */ ((UnavailableType2) => {
781
- UnavailableType2["UNKNOWN"] = "";
782
- UnavailableType2["VIEW_ONCE"] = "view_once";
783
- return UnavailableType2;
784
- })(UnavailableType || {});
785
- var ConnectFailureReason = /* @__PURE__ */ ((ConnectFailureReason2) => {
786
- ConnectFailureReason2[ConnectFailureReason2["SOCKET_OPEN_TIMEOUT"] = 4001] = "SOCKET_OPEN_TIMEOUT";
787
- ConnectFailureReason2[ConnectFailureReason2["SOCKET_PING_TIMEOUT"] = 4002] = "SOCKET_PING_TIMEOUT";
788
- ConnectFailureReason2[ConnectFailureReason2["SOCKET_PONG_TIMEOUT"] = 4003] = "SOCKET_PONG_TIMEOUT";
789
- ConnectFailureReason2[ConnectFailureReason2["UNKNOWN_LOGOUT"] = 4004] = "UNKNOWN_LOGOUT";
790
- ConnectFailureReason2[ConnectFailureReason2["BAD_MAC"] = 4005] = "BAD_MAC";
791
- ConnectFailureReason2[ConnectFailureReason2["INIT_TIMEOUT"] = 4006] = "INIT_TIMEOUT";
792
- ConnectFailureReason2[ConnectFailureReason2["MULTI_DEVICE_MISMATCH"] = 4007] = "MULTI_DEVICE_MISMATCH";
793
- ConnectFailureReason2[ConnectFailureReason2["MULTI_DEVICE_DISABLED"] = 4008] = "MULTI_DEVICE_DISABLED";
794
- ConnectFailureReason2[ConnectFailureReason2["TEMP_BANNED"] = 4009] = "TEMP_BANNED";
795
- ConnectFailureReason2[ConnectFailureReason2["CLIENT_OUTDATED"] = 4010] = "CLIENT_OUTDATED";
796
- ConnectFailureReason2[ConnectFailureReason2["STREAM_ERROR"] = 4011] = "STREAM_ERROR";
797
- ConnectFailureReason2[ConnectFailureReason2["DEVICE_GONE"] = 4012] = "DEVICE_GONE";
798
- ConnectFailureReason2[ConnectFailureReason2["IDENTITY_MISSING"] = 4013] = "IDENTITY_MISSING";
799
- ConnectFailureReason2[ConnectFailureReason2["RATE_LIMIT_HIT"] = 4014] = "RATE_LIMIT_HIT";
800
- ConnectFailureReason2[ConnectFailureReason2["MAIN_DEVICE_GONE"] = 4015] = "MAIN_DEVICE_GONE";
801
- return ConnectFailureReason2;
802
- })(ConnectFailureReason || {});
803
- var TempBanReason = /* @__PURE__ */ ((TempBanReason2) => {
804
- TempBanReason2[TempBanReason2["SENT_TO_TOO_MANY_PEOPLE"] = 101] = "SENT_TO_TOO_MANY_PEOPLE";
805
- TempBanReason2[TempBanReason2["BLOCKED_BY_USERS"] = 102] = "BLOCKED_BY_USERS";
806
- TempBanReason2[TempBanReason2["CREATED_TOO_MANY_GROUPS"] = 103] = "CREATED_TOO_MANY_GROUPS";
807
- TempBanReason2[TempBanReason2["SENT_TOO_MANY_SAME_MESSAGE"] = 104] = "SENT_TOO_MANY_SAME_MESSAGE";
808
- TempBanReason2[TempBanReason2["BROADCAST_LIST"] = 106] = "BROADCAST_LIST";
809
- return TempBanReason2;
810
- })(TempBanReason || {});
1
+ import { WuzapiClient, WuzapiClient as WuzapiClient2 } from "./wuzapi-client.js";
2
+ import { WuzapiError } from "./client.js";
3
+ import { BotPluginSearchProvider, BotPluginType, ButtonType, ButtonsMessageHeaderType, ButtonsResponseMessageType, ConnectFailureReason, DecryptFailMode, DisappearingModeInitiator, DisappearingModeTrigger, EventType, ExtendedTextMessageFontType, ExtendedTextMessageInviteLinkGroupType, ExtendedTextMessagePreviewType, HistorySyncNotificationHistorySyncType, InviteLinkGroupType, ListMessageListType, ListResponseMessageListType, MediaType, MessageStatus, PaymentBackgroundType, PeerDataOperationRequestResponseMessagePeerDataOperationResult, PeerDataOperationRequestType, ProtocolMessageType, ReceiptType, TempBanReason, UnavailableType, VideoAttribution, VideoSourceType, getMessageContent, hasBase64Media, hasBothMedia, hasS3Media } from "./types/index.js";
4
+ import { AdminModule } from "./modules/admin.js";
5
+ import { SessionModule } from "./modules/session.js";
6
+ import { UserModule } from "./modules/user.js";
7
+ import { ChatModule } from "./modules/chat.js";
8
+ import { GroupModule } from "./modules/group.js";
9
+ import { WebhookModule } from "./modules/webhook.js";
10
+ import { NewsletterModule } from "./modules/newsletter.js";
811
11
  export {
812
12
  AdminModule,
813
13
  BotPluginSearchProvider,
@@ -831,6 +31,7 @@ export {
831
31
  ListResponseMessageListType,
832
32
  MediaType,
833
33
  MessageStatus,
34
+ NewsletterModule,
834
35
  PaymentBackgroundType,
835
36
  PeerDataOperationRequestResponseMessagePeerDataOperationResult,
836
37
  PeerDataOperationRequestType,
@@ -845,7 +46,7 @@ export {
845
46
  WebhookModule,
846
47
  WuzapiClient,
847
48
  WuzapiError,
848
- WuzapiClient as default,
49
+ WuzapiClient2 as default,
849
50
  getMessageContent,
850
51
  hasBase64Media,
851
52
  hasBothMedia,