wuzapi 1.4.0 → 1.5.0
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/README.md +513 -1217
- package/dist/client.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +160 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/admin.d.ts +8 -0
- package/dist/modules/chat.d.ts +21 -1
- package/dist/modules/group.d.ts +25 -1
- package/dist/modules/newsletter.d.ts +9 -0
- package/dist/modules/session.d.ts +13 -1
- package/dist/modules/user.d.ts +5 -1
- package/dist/modules/webhook.d.ts +9 -1
- package/dist/types/chat.d.ts +55 -0
- package/dist/types/group.d.ts +52 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/newsletter.d.ts +17 -0
- package/dist/types/session.d.ts +16 -0
- package/dist/types/user.d.ts +5 -0
- package/dist/types/webhook.d.ts +9 -0
- package/dist/wuzapi-client.d.ts +2 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -14,8 +14,9 @@ export declare class BaseClient {
|
|
|
14
14
|
* Throws an error if no token is available
|
|
15
15
|
*/
|
|
16
16
|
private resolveToken;
|
|
17
|
-
protected request<T>(method: "GET" | "POST" | "DELETE", endpoint: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
17
|
+
protected request<T>(method: "GET" | "POST" | "DELETE" | "PUT", endpoint: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
18
18
|
protected get<T>(endpoint: string, options?: RequestOptions): Promise<T>;
|
|
19
19
|
protected post<T>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
20
|
+
protected put<T>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
20
21
|
protected delete<T>(endpoint: string, options?: RequestOptions): Promise<T>;
|
|
21
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { UserModule } from './modules/user.js';
|
|
|
7
7
|
export { ChatModule } from './modules/chat.js';
|
|
8
8
|
export { GroupModule } from './modules/group.js';
|
|
9
9
|
export { WebhookModule } from './modules/webhook.js';
|
|
10
|
+
export { NewsletterModule } from './modules/newsletter.js';
|
|
10
11
|
export { WuzapiClient as default } from './wuzapi-client.js';
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,9 @@ class BaseClient {
|
|
|
77
77
|
async post(endpoint, data, options) {
|
|
78
78
|
return this.request("POST", endpoint, data, options);
|
|
79
79
|
}
|
|
80
|
+
async put(endpoint, data, options) {
|
|
81
|
+
return this.request("PUT", endpoint, data, options);
|
|
82
|
+
}
|
|
80
83
|
async delete(endpoint, options) {
|
|
81
84
|
return this.request("DELETE", endpoint, void 0, options);
|
|
82
85
|
}
|
|
@@ -94,12 +97,24 @@ class AdminModule extends BaseClient {
|
|
|
94
97
|
async addUser(user, options) {
|
|
95
98
|
return this.post("/admin/users", user, options);
|
|
96
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Get a specific user by ID
|
|
102
|
+
*/
|
|
103
|
+
async getUser(id, options) {
|
|
104
|
+
return this.get(`/admin/users/${id}`, options);
|
|
105
|
+
}
|
|
97
106
|
/**
|
|
98
107
|
* Delete a user by ID
|
|
99
108
|
*/
|
|
100
109
|
async deleteUser(id, options) {
|
|
101
110
|
return this.delete(`/admin/users/${id}`, options);
|
|
102
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Delete a user completely (full deletion) by ID
|
|
114
|
+
*/
|
|
115
|
+
async deleteUserComplete(id, options) {
|
|
116
|
+
return this.delete(`/admin/users/${id}/full`, options);
|
|
117
|
+
}
|
|
103
118
|
}
|
|
104
119
|
class SessionModule extends BaseClient {
|
|
105
120
|
/**
|
|
@@ -160,6 +175,26 @@ class SessionModule extends BaseClient {
|
|
|
160
175
|
async deleteS3Config(options) {
|
|
161
176
|
return this.delete("/session/s3/config", options);
|
|
162
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Pair phone using verification code
|
|
180
|
+
*/
|
|
181
|
+
async pairPhone(phone, code, options) {
|
|
182
|
+
const request = { Phone: phone, Code: code };
|
|
183
|
+
return this.post("/session/pairphone", request, options);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Request history sync from WhatsApp servers
|
|
187
|
+
*/
|
|
188
|
+
async requestHistory(options) {
|
|
189
|
+
return this.get("/session/history", options);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Set proxy configuration
|
|
193
|
+
*/
|
|
194
|
+
async setProxy(proxy, options) {
|
|
195
|
+
const request = { Proxy: proxy };
|
|
196
|
+
return this.post("/session/proxy", request, options);
|
|
197
|
+
}
|
|
163
198
|
}
|
|
164
199
|
class UserModule extends BaseClient {
|
|
165
200
|
/**
|
|
@@ -189,6 +224,12 @@ class UserModule extends BaseClient {
|
|
|
189
224
|
async getContacts(options) {
|
|
190
225
|
return this.get("/user/contacts", options);
|
|
191
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Send user presence (available/unavailable status)
|
|
229
|
+
*/
|
|
230
|
+
async sendPresence(request, options) {
|
|
231
|
+
await this.post("/user/presence", request, options);
|
|
232
|
+
}
|
|
192
233
|
}
|
|
193
234
|
class ChatModule extends BaseClient {
|
|
194
235
|
/**
|
|
@@ -323,6 +364,40 @@ class ChatModule extends BaseClient {
|
|
|
323
364
|
options
|
|
324
365
|
);
|
|
325
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Delete a message
|
|
369
|
+
*/
|
|
370
|
+
async deleteMessage(request, options) {
|
|
371
|
+
return this.post("/chat/delete", request, options);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Send interactive buttons message
|
|
375
|
+
*/
|
|
376
|
+
async sendButtons(request, options) {
|
|
377
|
+
return this.post(
|
|
378
|
+
"/chat/send/buttons",
|
|
379
|
+
request,
|
|
380
|
+
options
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Send list message
|
|
385
|
+
*/
|
|
386
|
+
async sendList(request, options) {
|
|
387
|
+
return this.post("/chat/send/list", request, options);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Send poll message
|
|
391
|
+
*/
|
|
392
|
+
async sendPoll(request, options) {
|
|
393
|
+
return this.post("/chat/send/poll", request, options);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Edit a message
|
|
397
|
+
*/
|
|
398
|
+
async editMessage(request, options) {
|
|
399
|
+
return this.post("/chat/send/edit", request, options);
|
|
400
|
+
}
|
|
326
401
|
}
|
|
327
402
|
class GroupModule extends BaseClient {
|
|
328
403
|
/**
|
|
@@ -399,6 +474,67 @@ class GroupModule extends BaseClient {
|
|
|
399
474
|
options
|
|
400
475
|
);
|
|
401
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Leave a group
|
|
479
|
+
*/
|
|
480
|
+
async leave(groupJID, options) {
|
|
481
|
+
const request = { GroupJID: groupJID };
|
|
482
|
+
return this.post("/group/leave", request, options);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Set group topic/description
|
|
486
|
+
*/
|
|
487
|
+
async setTopic(groupJID, topic, options) {
|
|
488
|
+
const request = { GroupJID: groupJID, Topic: topic };
|
|
489
|
+
return this.post("/group/topic", request, options);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Set group announcement setting (only admins can send messages)
|
|
493
|
+
*/
|
|
494
|
+
async setAnnounce(groupJID, announce, options) {
|
|
495
|
+
const request = {
|
|
496
|
+
GroupJID: groupJID,
|
|
497
|
+
Announce: announce
|
|
498
|
+
};
|
|
499
|
+
return this.post(
|
|
500
|
+
"/group/announce",
|
|
501
|
+
request,
|
|
502
|
+
options
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Join a group using invite link
|
|
507
|
+
*/
|
|
508
|
+
async join(inviteLink, options) {
|
|
509
|
+
const request = { InviteLink: inviteLink };
|
|
510
|
+
return this.post("/group/join", request, options);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Get group invite information
|
|
514
|
+
*/
|
|
515
|
+
async getInviteInfo(inviteLink, options) {
|
|
516
|
+
const request = { InviteLink: inviteLink };
|
|
517
|
+
return this.post(
|
|
518
|
+
"/group/inviteinfo",
|
|
519
|
+
request,
|
|
520
|
+
options
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Update group participants (add/remove/promote/demote)
|
|
525
|
+
*/
|
|
526
|
+
async updateParticipants(groupJID, action, participants, options) {
|
|
527
|
+
const request = {
|
|
528
|
+
GroupJID: groupJID,
|
|
529
|
+
Action: action,
|
|
530
|
+
Participants: participants
|
|
531
|
+
};
|
|
532
|
+
return this.post(
|
|
533
|
+
"/group/updateparticipants",
|
|
534
|
+
request,
|
|
535
|
+
options
|
|
536
|
+
);
|
|
537
|
+
}
|
|
402
538
|
}
|
|
403
539
|
class WebhookModule extends BaseClient {
|
|
404
540
|
/**
|
|
@@ -414,6 +550,27 @@ class WebhookModule extends BaseClient {
|
|
|
414
550
|
async getWebhook(options) {
|
|
415
551
|
return this.get("/webhook", options);
|
|
416
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Update webhook URL
|
|
555
|
+
*/
|
|
556
|
+
async updateWebhook(webhookURL, options) {
|
|
557
|
+
const request = { webhookURL };
|
|
558
|
+
return this.put("/webhook", request, options);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Delete webhook configuration
|
|
562
|
+
*/
|
|
563
|
+
async deleteWebhook(options) {
|
|
564
|
+
return this.delete("/webhook", options);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
class NewsletterModule extends BaseClient {
|
|
568
|
+
/**
|
|
569
|
+
* List all subscribed newsletters
|
|
570
|
+
*/
|
|
571
|
+
async list(options) {
|
|
572
|
+
return this.get("/newsletter/list", options);
|
|
573
|
+
}
|
|
417
574
|
}
|
|
418
575
|
class WuzapiClient {
|
|
419
576
|
admin;
|
|
@@ -422,6 +579,7 @@ class WuzapiClient {
|
|
|
422
579
|
chat;
|
|
423
580
|
group;
|
|
424
581
|
webhook;
|
|
582
|
+
newsletter;
|
|
425
583
|
// Legacy aliases for convenience
|
|
426
584
|
users;
|
|
427
585
|
message;
|
|
@@ -432,6 +590,7 @@ class WuzapiClient {
|
|
|
432
590
|
this.chat = new ChatModule(config);
|
|
433
591
|
this.group = new GroupModule(config);
|
|
434
592
|
this.webhook = new WebhookModule(config);
|
|
593
|
+
this.newsletter = new NewsletterModule(config);
|
|
435
594
|
this.users = this.user;
|
|
436
595
|
this.message = this.chat;
|
|
437
596
|
}
|
|
@@ -831,6 +990,7 @@ export {
|
|
|
831
990
|
ListResponseMessageListType,
|
|
832
991
|
MediaType,
|
|
833
992
|
MessageStatus,
|
|
993
|
+
NewsletterModule,
|
|
834
994
|
PaymentBackgroundType,
|
|
835
995
|
PeerDataOperationRequestResponseMessagePeerDataOperationResult,
|
|
836
996
|
PeerDataOperationRequestType,
|