wuzapi 1.3.1 → 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.
@@ -1,40 +1,65 @@
1
1
  import { BaseClient } from '../client.js';
2
- import { GroupListResponse, GroupInviteLinkResponse, GroupInfo, GroupPhotoResponse, GroupNameResponse, GroupCreateResponse, GroupLockedResponse, GroupEphemeralResponse, GroupPhotoRemoveResponse } from '../types/group.js';
2
+ import { RequestOptions } from '../types/common.js';
3
+ import { GroupListResponse, GroupInviteLinkResponse, GroupInfo, GroupPhotoResponse, GroupNameResponse, GroupCreateResponse, GroupLockedResponse, GroupEphemeralResponse, GroupPhotoRemoveResponse, GroupLeaveResponse, GroupTopicResponse, GroupAnnounceResponse, GroupJoinResponse, GroupInviteInfoResponse, GroupUpdateParticipantsResponse } from '../types/group.js';
3
4
  export declare class GroupModule extends BaseClient {
4
5
  /**
5
6
  * List all subscribed groups
6
7
  */
7
- list(): Promise<GroupListResponse>;
8
+ list(options?: RequestOptions): Promise<GroupListResponse>;
8
9
  /**
9
10
  * Get group invite link
10
11
  */
11
- getInviteLink(groupJID: string): Promise<GroupInviteLinkResponse>;
12
+ getInviteLink(groupJID: string, options?: RequestOptions): Promise<GroupInviteLinkResponse>;
12
13
  /**
13
14
  * Get group information
14
15
  */
15
- getInfo(groupJID: string): Promise<GroupInfo>;
16
+ getInfo(groupJID: string, options?: RequestOptions): Promise<GroupInfo>;
16
17
  /**
17
18
  * Change group photo (JPEG only)
18
19
  */
19
- setPhoto(groupJID: string, image: string): Promise<GroupPhotoResponse>;
20
+ setPhoto(groupJID: string, image: string, options?: RequestOptions): Promise<GroupPhotoResponse>;
20
21
  /**
21
22
  * Change group name
22
23
  */
23
- setName(groupJID: string, name: string): Promise<GroupNameResponse>;
24
+ setName(groupJID: string, name: string, options?: RequestOptions): Promise<GroupNameResponse>;
24
25
  /**
25
26
  * Create a new group
26
27
  */
27
- create(name: string, participants: string[]): Promise<GroupCreateResponse>;
28
+ create(name: string, participants: string[], options?: RequestOptions): Promise<GroupCreateResponse>;
28
29
  /**
29
30
  * Set group locked status
30
31
  */
31
- setLocked(groupJID: string, locked: boolean): Promise<GroupLockedResponse>;
32
+ setLocked(groupJID: string, locked: boolean, options?: RequestOptions): Promise<GroupLockedResponse>;
32
33
  /**
33
34
  * Set disappearing messages timer
34
35
  */
35
- setEphemeral(groupJID: string, duration: "24h" | "7d" | "90d" | "off"): Promise<GroupEphemeralResponse>;
36
+ setEphemeral(groupJID: string, duration: "24h" | "7d" | "90d" | "off", options?: RequestOptions): Promise<GroupEphemeralResponse>;
36
37
  /**
37
38
  * Remove group photo
38
39
  */
39
- removePhoto(groupJID: string): Promise<GroupPhotoRemoveResponse>;
40
+ removePhoto(groupJID: string, options?: RequestOptions): Promise<GroupPhotoRemoveResponse>;
41
+ /**
42
+ * Leave a group
43
+ */
44
+ leave(groupJID: string, options?: RequestOptions): Promise<GroupLeaveResponse>;
45
+ /**
46
+ * Set group topic/description
47
+ */
48
+ setTopic(groupJID: string, topic: string, options?: RequestOptions): Promise<GroupTopicResponse>;
49
+ /**
50
+ * Set group announcement setting (only admins can send messages)
51
+ */
52
+ setAnnounce(groupJID: string, announce: boolean, options?: RequestOptions): Promise<GroupAnnounceResponse>;
53
+ /**
54
+ * Join a group using invite link
55
+ */
56
+ join(inviteLink: string, options?: RequestOptions): Promise<GroupJoinResponse>;
57
+ /**
58
+ * Get group invite information
59
+ */
60
+ getInviteInfo(inviteLink: string, options?: RequestOptions): Promise<GroupInviteInfoResponse>;
61
+ /**
62
+ * Update group participants (add/remove/promote/demote)
63
+ */
64
+ updateParticipants(groupJID: string, action: "add" | "remove" | "promote" | "demote", participants: string[], options?: RequestOptions): Promise<GroupUpdateParticipantsResponse>;
40
65
  }
@@ -0,0 +1,9 @@
1
+ import { BaseClient } from '../client.js';
2
+ import { RequestOptions } from '../types/common.js';
3
+ import { NewsletterListResponse } from '../types/newsletter.js';
4
+ export declare class NewsletterModule extends BaseClient {
5
+ /**
6
+ * List all subscribed newsletters
7
+ */
8
+ list(options?: RequestOptions): Promise<NewsletterListResponse>;
9
+ }
@@ -1,43 +1,55 @@
1
1
  import { BaseClient } from '../client.js';
2
- import { ConnectRequest, ConnectResponse, DisconnectResponse, LogoutResponse, StatusResponse, QRCodeResponse, S3ConfigResponse, S3TestResponse } from '../types/session.js';
3
- import { S3Config } from '../types/common.js';
2
+ import { ConnectRequest, ConnectResponse, DisconnectResponse, LogoutResponse, StatusResponse, QRCodeResponse, S3ConfigResponse, S3TestResponse, PairPhoneResponse, HistoryResponse, ProxyResponse } from '../types/session.js';
3
+ import { S3Config, RequestOptions } from '../types/common.js';
4
4
  export declare class SessionModule extends BaseClient {
5
5
  /**
6
6
  * Connect to WhatsApp servers
7
7
  */
8
- connect(options: ConnectRequest): Promise<ConnectResponse>;
8
+ connect(request: ConnectRequest, options?: RequestOptions): Promise<ConnectResponse>;
9
9
  /**
10
10
  * Disconnect from WhatsApp servers
11
11
  */
12
- disconnect(): Promise<DisconnectResponse>;
12
+ disconnect(options?: RequestOptions): Promise<DisconnectResponse>;
13
13
  /**
14
14
  * Logout and finish the session
15
15
  */
16
- logout(): Promise<LogoutResponse>;
16
+ logout(options?: RequestOptions): Promise<LogoutResponse>;
17
17
  /**
18
18
  * Get session status
19
19
  */
20
- getStatus(): Promise<StatusResponse>;
20
+ getStatus(options?: RequestOptions): Promise<StatusResponse>;
21
21
  /**
22
22
  * Get QR code for scanning
23
23
  */
24
- getQRCode(): Promise<QRCodeResponse>;
24
+ getQRCode(options?: RequestOptions): Promise<QRCodeResponse>;
25
25
  /**
26
26
  * Configure S3 storage
27
27
  */
28
- configureS3(config: S3Config): Promise<S3ConfigResponse>;
28
+ configureS3(config: S3Config, options?: RequestOptions): Promise<S3ConfigResponse>;
29
29
  /**
30
30
  * Get S3 configuration
31
31
  */
32
- getS3Config(): Promise<S3ConfigResponse>;
32
+ getS3Config(options?: RequestOptions): Promise<S3ConfigResponse>;
33
33
  /**
34
34
  * Test S3 connection
35
35
  */
36
- testS3(): Promise<S3TestResponse>;
36
+ testS3(options?: RequestOptions): Promise<S3TestResponse>;
37
37
  /**
38
38
  * Delete S3 configuration
39
39
  */
40
- deleteS3Config(): Promise<{
40
+ deleteS3Config(options?: RequestOptions): Promise<{
41
41
  Details: string;
42
42
  }>;
43
+ /**
44
+ * Pair phone using verification code
45
+ */
46
+ pairPhone(phone: string, code: string, options?: RequestOptions): Promise<PairPhoneResponse>;
47
+ /**
48
+ * Request history sync from WhatsApp servers
49
+ */
50
+ requestHistory(options?: RequestOptions): Promise<HistoryResponse>;
51
+ /**
52
+ * Set proxy configuration
53
+ */
54
+ setProxy(proxy: string, options?: RequestOptions): Promise<ProxyResponse>;
43
55
  }
@@ -1,20 +1,25 @@
1
1
  import { BaseClient } from '../client.js';
2
- import { UserInfoResponse, UserCheckResponse, UserAvatarResponse, ContactsResponse } from '../types/user.js';
2
+ import { RequestOptions } from '../types/common.js';
3
+ import { UserInfoResponse, UserCheckResponse, UserAvatarResponse, ContactsResponse, UserPresenceRequest } from '../types/user.js';
3
4
  export declare class UserModule extends BaseClient {
4
5
  /**
5
6
  * Get user details for specified phone numbers
6
7
  */
7
- getInfo(phones: string[]): Promise<UserInfoResponse>;
8
+ getInfo(phones: string[], options?: RequestOptions): Promise<UserInfoResponse>;
8
9
  /**
9
10
  * Check if phone numbers are registered WhatsApp users
10
11
  */
11
- check(phones: string[]): Promise<UserCheckResponse>;
12
+ check(phones: string[], options?: RequestOptions): Promise<UserCheckResponse>;
12
13
  /**
13
14
  * Get user avatar/profile picture
14
15
  */
15
- getAvatar(phone: string, preview?: boolean): Promise<UserAvatarResponse>;
16
+ getAvatar(phone: string, preview?: boolean, options?: RequestOptions): Promise<UserAvatarResponse>;
16
17
  /**
17
18
  * Get all contacts
18
19
  */
19
- getContacts(): Promise<ContactsResponse>;
20
+ getContacts(options?: RequestOptions): Promise<ContactsResponse>;
21
+ /**
22
+ * Send user presence (available/unavailable status)
23
+ */
24
+ sendPresence(request: UserPresenceRequest, options?: RequestOptions): Promise<void>;
20
25
  }
@@ -1,12 +1,21 @@
1
1
  import { BaseClient } from '../client.js';
2
- import { SetWebhookResponse, GetWebhookResponse } from '../types/webhook.js';
2
+ import { RequestOptions } from '../types/common.js';
3
+ import { SetWebhookResponse, GetWebhookResponse, UpdateWebhookResponse, DeleteWebhookResponse } from '../types/webhook.js';
3
4
  export declare class WebhookModule extends BaseClient {
4
5
  /**
5
6
  * Set webhook URL and events to subscribe to
6
7
  */
7
- setWebhook(webhookURL: string): Promise<SetWebhookResponse>;
8
+ setWebhook(webhookURL: string, options?: RequestOptions): Promise<SetWebhookResponse>;
8
9
  /**
9
10
  * Get current webhook configuration
10
11
  */
11
- getWebhook(): Promise<GetWebhookResponse>;
12
+ getWebhook(options?: RequestOptions): Promise<GetWebhookResponse>;
13
+ /**
14
+ * Update webhook URL
15
+ */
16
+ updateWebhook(webhookURL: string, options?: RequestOptions): Promise<UpdateWebhookResponse>;
17
+ /**
18
+ * Delete webhook configuration
19
+ */
20
+ deleteWebhook(options?: RequestOptions): Promise<DeleteWebhookResponse>;
12
21
  }
@@ -92,3 +92,58 @@ export interface DownloadMediaRequest {
92
92
  export interface DownloadMediaResponse {
93
93
  [key: string]: unknown;
94
94
  }
95
+ export interface DeleteMessageRequest {
96
+ Phone: string;
97
+ Id: string;
98
+ Remote?: boolean;
99
+ }
100
+ export interface DeleteMessageResponse {
101
+ Details: string;
102
+ }
103
+ export interface ChatButton {
104
+ ButtonId: string;
105
+ ButtonText: {
106
+ DisplayText: string;
107
+ };
108
+ Type: number;
109
+ }
110
+ export interface SendButtonsRequest {
111
+ Phone: string;
112
+ Body: string;
113
+ Footer?: string;
114
+ Buttons: ChatButton[];
115
+ ContextInfo?: SimpleContextInfo;
116
+ }
117
+ export interface ListItem {
118
+ Title: string;
119
+ Description?: string;
120
+ RowId: string;
121
+ }
122
+ export interface ListSection {
123
+ Title: string;
124
+ Rows: ListItem[];
125
+ }
126
+ export interface SendListRequest {
127
+ Phone: string;
128
+ Body: string;
129
+ Footer?: string;
130
+ Title: string;
131
+ ButtonText: string;
132
+ Sections: ListSection[];
133
+ ContextInfo?: SimpleContextInfo;
134
+ }
135
+ export interface ChatPollOption {
136
+ Name: string;
137
+ }
138
+ export interface SendPollRequest {
139
+ Phone: string;
140
+ Name: string;
141
+ Options: ChatPollOption[];
142
+ SelectableCount?: number;
143
+ ContextInfo?: SimpleContextInfo;
144
+ }
145
+ export interface EditMessageRequest {
146
+ Phone: string;
147
+ MessageId: string;
148
+ NewText: string;
149
+ }
@@ -1,6 +1,9 @@
1
1
  export interface WuzapiConfig {
2
2
  apiUrl: string;
3
- token: string;
3
+ token?: string;
4
+ }
5
+ export interface RequestOptions {
6
+ token?: string;
4
7
  }
5
8
  export interface WuzapiResponse<T = unknown> {
6
9
  code: number;
@@ -74,3 +74,55 @@ export interface GroupPhotoRemoveRequest {
74
74
  export interface GroupPhotoRemoveResponse {
75
75
  Details: string;
76
76
  }
77
+ export interface GroupLeaveRequest {
78
+ GroupJID: string;
79
+ }
80
+ export interface GroupLeaveResponse {
81
+ Details: string;
82
+ }
83
+ export interface GroupTopicRequest {
84
+ GroupJID: string;
85
+ Topic: string;
86
+ }
87
+ export interface GroupTopicResponse {
88
+ Details: string;
89
+ }
90
+ export interface GroupAnnounceRequest {
91
+ GroupJID: string;
92
+ Announce: boolean;
93
+ }
94
+ export interface GroupAnnounceResponse {
95
+ Details: string;
96
+ }
97
+ export interface GroupJoinRequest {
98
+ InviteLink: string;
99
+ }
100
+ export interface GroupJoinResponse {
101
+ GroupJID: string;
102
+ Details: string;
103
+ }
104
+ export interface GroupInviteInfoRequest {
105
+ InviteLink: string;
106
+ }
107
+ export interface GroupInviteInfoResponse {
108
+ GroupJID: string;
109
+ Name: string;
110
+ Description: string;
111
+ Subject: string;
112
+ Owner: string;
113
+ Creation: string;
114
+ ParticipantsCount: number;
115
+ }
116
+ export interface GroupUpdateParticipantsRequest {
117
+ GroupJID: string;
118
+ Action: "add" | "remove" | "promote" | "demote";
119
+ Participants: string[];
120
+ }
121
+ export interface ParticipantUpdate {
122
+ JID: string;
123
+ Status: string;
124
+ Code: number;
125
+ }
126
+ export interface GroupUpdateParticipantsResponse {
127
+ Updates: ParticipantUpdate[];
128
+ }
@@ -5,5 +5,6 @@ export * from './user.js';
5
5
  export * from './chat.js';
6
6
  export * from './group.js';
7
7
  export * from './webhook.js';
8
+ export * from './newsletter.js';
8
9
  export * from './message.js';
9
10
  export * from './events.js';
@@ -0,0 +1,17 @@
1
+ export interface Newsletter {
2
+ ID: string;
3
+ Name: string;
4
+ Description: string;
5
+ ThreadJID: string;
6
+ InviteCode: string;
7
+ CreationTime: number;
8
+ Handle: string;
9
+ State: string;
10
+ ViewerMetadata: {
11
+ View: string;
12
+ Mute: string;
13
+ };
14
+ }
15
+ export interface NewsletterListResponse {
16
+ Newsletters: Newsletter[];
17
+ }
@@ -30,3 +30,19 @@ export interface S3TestResponse {
30
30
  Bucket: string;
31
31
  Region: string;
32
32
  }
33
+ export interface PairPhoneRequest {
34
+ Phone: string;
35
+ Code: string;
36
+ }
37
+ export interface PairPhoneResponse {
38
+ Details: string;
39
+ }
40
+ export interface HistoryResponse {
41
+ Details: string;
42
+ }
43
+ export interface ProxyRequest {
44
+ Proxy: string;
45
+ }
46
+ export interface ProxyResponse {
47
+ Details: string;
48
+ }
@@ -53,3 +53,8 @@ export interface Contact {
53
53
  export interface ContactsResponse {
54
54
  [jid: string]: Contact;
55
55
  }
56
+ export interface UserPresenceRequest {
57
+ Phone: string;
58
+ State: "available" | "unavailable";
59
+ LastSeen?: number;
60
+ }
@@ -8,6 +8,15 @@ export interface GetWebhookResponse {
8
8
  subscribe: string[];
9
9
  webhook: string;
10
10
  }
11
+ export interface UpdateWebhookRequest {
12
+ webhookURL: string;
13
+ }
14
+ export interface UpdateWebhookResponse {
15
+ webhook: string;
16
+ }
17
+ export interface DeleteWebhookResponse {
18
+ Details: string;
19
+ }
11
20
  export interface S3MediaInfo {
12
21
  url: string;
13
22
  key: string;
@@ -1,10 +1,11 @@
1
- import { WuzapiConfig } from './types/common.js';
1
+ import { WuzapiConfig, RequestOptions } from './types/common.js';
2
2
  import { AdminModule } from './modules/admin.js';
3
3
  import { SessionModule } from './modules/session.js';
4
4
  import { UserModule } from './modules/user.js';
5
5
  import { ChatModule } from './modules/chat.js';
6
6
  import { GroupModule } from './modules/group.js';
7
7
  import { WebhookModule } from './modules/webhook.js';
8
+ import { NewsletterModule } from './modules/newsletter.js';
8
9
  export declare class WuzapiClient {
9
10
  readonly admin: AdminModule;
10
11
  readonly session: SessionModule;
@@ -12,11 +13,12 @@ export declare class WuzapiClient {
12
13
  readonly chat: ChatModule;
13
14
  readonly group: GroupModule;
14
15
  readonly webhook: WebhookModule;
16
+ readonly newsletter: NewsletterModule;
15
17
  readonly users: UserModule;
16
18
  readonly message: ChatModule;
17
19
  constructor(config: WuzapiConfig);
18
20
  /**
19
21
  * Test connection to the API
20
22
  */
21
- ping(): Promise<boolean>;
23
+ ping(options?: RequestOptions): Promise<boolean>;
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuzapi",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "TypeScript client library for WuzAPI WhatsApp API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",