wuzapi 1.0.1 → 1.2.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 +722 -1
- package/dist/client.d.ts +16 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +308 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/admin.d.ts +16 -0
- package/dist/modules/chat.d.ts +68 -0
- package/dist/modules/group.d.ts +40 -0
- package/dist/modules/session.d.ts +43 -0
- package/dist/modules/user.d.ts +20 -0
- package/dist/modules/webhook.d.ts +12 -0
- package/dist/types/admin.d.ts +27 -0
- package/dist/types/chat.d.ts +94 -0
- package/dist/types/common.d.ts +29 -0
- package/dist/types/events.d.ts +557 -0
- package/dist/types/group.d.ts +76 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/message.d.ts +799 -0
- package/dist/types/session.d.ts +32 -0
- package/dist/types/user.d.ts +55 -0
- package/dist/types/webhook.d.ts +10 -0
- package/dist/vite-env.d.ts +1 -0
- package/dist/wuzapi-client.d.ts +22 -0
- package/package.json +4 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BaseClient } from '../client.js';
|
|
2
|
+
import { SendMessageResponse, SendTextRequest, SendTemplateRequest, SendAudioRequest, SendImageRequest, SendDocumentRequest, SendVideoRequest, SendStickerRequest, SendLocationRequest, SendContactRequest, ChatPresenceRequest, MarkReadRequest, ReactRequest, DownloadMediaRequest, DownloadMediaResponse } from '../types/chat.js';
|
|
3
|
+
export declare class ChatModule extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Send a text message
|
|
6
|
+
*/
|
|
7
|
+
sendText(request: SendTextRequest): Promise<SendMessageResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Send a template message with buttons
|
|
10
|
+
*/
|
|
11
|
+
sendTemplate(request: SendTemplateRequest): Promise<SendMessageResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Send an audio message
|
|
14
|
+
*/
|
|
15
|
+
sendAudio(request: SendAudioRequest): Promise<SendMessageResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Send an image message
|
|
18
|
+
*/
|
|
19
|
+
sendImage(request: SendImageRequest): Promise<SendMessageResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Send a document message
|
|
22
|
+
*/
|
|
23
|
+
sendDocument(request: SendDocumentRequest): Promise<SendMessageResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Send a video message
|
|
26
|
+
*/
|
|
27
|
+
sendVideo(request: SendVideoRequest): Promise<SendMessageResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Send a sticker message
|
|
30
|
+
*/
|
|
31
|
+
sendSticker(request: SendStickerRequest): Promise<SendMessageResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Send a location message
|
|
34
|
+
*/
|
|
35
|
+
sendLocation(request: SendLocationRequest): Promise<SendMessageResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Send a contact message
|
|
38
|
+
*/
|
|
39
|
+
sendContact(request: SendContactRequest): Promise<SendMessageResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Send chat presence indication (typing indicator)
|
|
42
|
+
*/
|
|
43
|
+
sendPresence(request: ChatPresenceRequest): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Mark messages as read
|
|
46
|
+
*/
|
|
47
|
+
markRead(request: MarkReadRequest): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* React to a message
|
|
50
|
+
*/
|
|
51
|
+
react(request: ReactRequest): Promise<SendMessageResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Download an image from a message
|
|
54
|
+
*/
|
|
55
|
+
downloadImage(request: DownloadMediaRequest): Promise<DownloadMediaResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Download a video from a message
|
|
58
|
+
*/
|
|
59
|
+
downloadVideo(request: DownloadMediaRequest): Promise<DownloadMediaResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Download an audio from a message
|
|
62
|
+
*/
|
|
63
|
+
downloadAudio(request: DownloadMediaRequest): Promise<DownloadMediaResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Download a document from a message
|
|
66
|
+
*/
|
|
67
|
+
downloadDocument(request: DownloadMediaRequest): Promise<DownloadMediaResponse>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseClient } from '../client.js';
|
|
2
|
+
import { GroupListResponse, GroupInviteLinkResponse, GroupInfo, GroupPhotoResponse, GroupNameResponse, GroupCreateResponse, GroupLockedResponse, GroupEphemeralResponse, GroupPhotoRemoveResponse } from '../types/group.js';
|
|
3
|
+
export declare class GroupModule extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* List all subscribed groups
|
|
6
|
+
*/
|
|
7
|
+
list(): Promise<GroupListResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Get group invite link
|
|
10
|
+
*/
|
|
11
|
+
getInviteLink(groupJID: string): Promise<GroupInviteLinkResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Get group information
|
|
14
|
+
*/
|
|
15
|
+
getInfo(groupJID: string): Promise<GroupInfo>;
|
|
16
|
+
/**
|
|
17
|
+
* Change group photo (JPEG only)
|
|
18
|
+
*/
|
|
19
|
+
setPhoto(groupJID: string, image: string): Promise<GroupPhotoResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Change group name
|
|
22
|
+
*/
|
|
23
|
+
setName(groupJID: string, name: string): Promise<GroupNameResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new group
|
|
26
|
+
*/
|
|
27
|
+
create(name: string, participants: string[]): Promise<GroupCreateResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Set group locked status
|
|
30
|
+
*/
|
|
31
|
+
setLocked(groupJID: string, locked: boolean): Promise<GroupLockedResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Set disappearing messages timer
|
|
34
|
+
*/
|
|
35
|
+
setEphemeral(groupJID: string, duration: "24h" | "7d" | "90d" | "off"): Promise<GroupEphemeralResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Remove group photo
|
|
38
|
+
*/
|
|
39
|
+
removePhoto(groupJID: string): Promise<GroupPhotoRemoveResponse>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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';
|
|
4
|
+
export declare class SessionModule extends BaseClient {
|
|
5
|
+
/**
|
|
6
|
+
* Connect to WhatsApp servers
|
|
7
|
+
*/
|
|
8
|
+
connect(options: ConnectRequest): Promise<ConnectResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Disconnect from WhatsApp servers
|
|
11
|
+
*/
|
|
12
|
+
disconnect(): Promise<DisconnectResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Logout and finish the session
|
|
15
|
+
*/
|
|
16
|
+
logout(): Promise<LogoutResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Get session status
|
|
19
|
+
*/
|
|
20
|
+
getStatus(): Promise<StatusResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Get QR code for scanning
|
|
23
|
+
*/
|
|
24
|
+
getQRCode(): Promise<QRCodeResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Configure S3 storage
|
|
27
|
+
*/
|
|
28
|
+
configureS3(config: S3Config): Promise<S3ConfigResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Get S3 configuration
|
|
31
|
+
*/
|
|
32
|
+
getS3Config(): Promise<S3ConfigResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Test S3 connection
|
|
35
|
+
*/
|
|
36
|
+
testS3(): Promise<S3TestResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* Delete S3 configuration
|
|
39
|
+
*/
|
|
40
|
+
deleteS3Config(): Promise<{
|
|
41
|
+
Details: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseClient } from '../client.js';
|
|
2
|
+
import { UserInfoResponse, UserCheckResponse, UserAvatarResponse, ContactsResponse } from '../types/user.js';
|
|
3
|
+
export declare class UserModule extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Get user details for specified phone numbers
|
|
6
|
+
*/
|
|
7
|
+
getInfo(phones: string[]): Promise<UserInfoResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Check if phone numbers are registered WhatsApp users
|
|
10
|
+
*/
|
|
11
|
+
check(phones: string[]): Promise<UserCheckResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Get user avatar/profile picture
|
|
14
|
+
*/
|
|
15
|
+
getAvatar(phone: string, preview?: boolean): Promise<UserAvatarResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Get all contacts
|
|
18
|
+
*/
|
|
19
|
+
getContacts(): Promise<ContactsResponse>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseClient } from '../client.js';
|
|
2
|
+
import { SetWebhookResponse, GetWebhookResponse } from '../types/webhook.js';
|
|
3
|
+
export declare class WebhookModule extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Set webhook URL and events to subscribe to
|
|
6
|
+
*/
|
|
7
|
+
setWebhook(webhookURL: string): Promise<SetWebhookResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Get current webhook configuration
|
|
10
|
+
*/
|
|
11
|
+
getWebhook(): Promise<GetWebhookResponse>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ProxyConfig, S3Config } from './common.js';
|
|
2
|
+
export interface User {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
token: string;
|
|
6
|
+
webhook: string;
|
|
7
|
+
jid: string;
|
|
8
|
+
qrcode: string;
|
|
9
|
+
connected: boolean;
|
|
10
|
+
expiration: number;
|
|
11
|
+
events: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateUserRequest {
|
|
14
|
+
name: string;
|
|
15
|
+
token: string;
|
|
16
|
+
webhook?: string;
|
|
17
|
+
events: string;
|
|
18
|
+
expiration?: number;
|
|
19
|
+
proxyConfig?: ProxyConfig;
|
|
20
|
+
s3Config?: S3Config;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateUserResponse {
|
|
23
|
+
id: number;
|
|
24
|
+
}
|
|
25
|
+
export interface DeleteUserResponse {
|
|
26
|
+
Details: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SimpleContextInfo } from './common.js';
|
|
2
|
+
export interface SendMessageResponse {
|
|
3
|
+
Details: string;
|
|
4
|
+
Id: string;
|
|
5
|
+
Timestamp: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SendTextRequest {
|
|
8
|
+
Phone: string;
|
|
9
|
+
Body: string;
|
|
10
|
+
Id?: string;
|
|
11
|
+
ContextInfo?: SimpleContextInfo;
|
|
12
|
+
}
|
|
13
|
+
export interface TemplateButton {
|
|
14
|
+
DisplayText: string;
|
|
15
|
+
Type: "quickreply" | "url" | "call";
|
|
16
|
+
Url?: string;
|
|
17
|
+
PhoneNumber?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SendTemplateRequest {
|
|
20
|
+
Phone: string;
|
|
21
|
+
Content: string;
|
|
22
|
+
Footer?: string;
|
|
23
|
+
Buttons: TemplateButton[];
|
|
24
|
+
ContextInfo?: SimpleContextInfo;
|
|
25
|
+
}
|
|
26
|
+
export interface SendAudioRequest {
|
|
27
|
+
Phone: string;
|
|
28
|
+
Audio: string;
|
|
29
|
+
ContextInfo?: SimpleContextInfo;
|
|
30
|
+
}
|
|
31
|
+
export interface SendImageRequest {
|
|
32
|
+
Phone: string;
|
|
33
|
+
Image: string;
|
|
34
|
+
Caption?: string;
|
|
35
|
+
ContextInfo?: SimpleContextInfo;
|
|
36
|
+
}
|
|
37
|
+
export interface SendDocumentRequest {
|
|
38
|
+
Phone: string;
|
|
39
|
+
Document: string;
|
|
40
|
+
FileName: string;
|
|
41
|
+
ContextInfo?: SimpleContextInfo;
|
|
42
|
+
}
|
|
43
|
+
export interface SendVideoRequest {
|
|
44
|
+
Phone: string;
|
|
45
|
+
Video: string;
|
|
46
|
+
Caption?: string;
|
|
47
|
+
JpegThumbnail?: string;
|
|
48
|
+
ContextInfo?: SimpleContextInfo;
|
|
49
|
+
}
|
|
50
|
+
export interface SendStickerRequest {
|
|
51
|
+
Phone: string;
|
|
52
|
+
Sticker: string;
|
|
53
|
+
PngThumbnail?: string;
|
|
54
|
+
ContextInfo?: SimpleContextInfo;
|
|
55
|
+
}
|
|
56
|
+
export interface SendLocationRequest {
|
|
57
|
+
Phone: string;
|
|
58
|
+
Latitude: number;
|
|
59
|
+
Longitude: number;
|
|
60
|
+
Name?: string;
|
|
61
|
+
ContextInfo?: SimpleContextInfo;
|
|
62
|
+
}
|
|
63
|
+
export interface SendContactRequest {
|
|
64
|
+
Phone: string;
|
|
65
|
+
Name: string;
|
|
66
|
+
Vcard: string;
|
|
67
|
+
ContextInfo?: SimpleContextInfo;
|
|
68
|
+
}
|
|
69
|
+
export interface ChatPresenceRequest {
|
|
70
|
+
Phone: string;
|
|
71
|
+
State: "composing" | "paused";
|
|
72
|
+
Media?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface MarkReadRequest {
|
|
75
|
+
Id: string[];
|
|
76
|
+
Chat: string;
|
|
77
|
+
Sender?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ReactRequest {
|
|
80
|
+
Phone: string;
|
|
81
|
+
Body: string;
|
|
82
|
+
Id: string;
|
|
83
|
+
}
|
|
84
|
+
export interface DownloadMediaRequest {
|
|
85
|
+
Url: string;
|
|
86
|
+
MediaKey: string;
|
|
87
|
+
Mimetype: string;
|
|
88
|
+
FileSHA256: string;
|
|
89
|
+
FileLength: number;
|
|
90
|
+
FileEncSHA256?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface DownloadMediaResponse {
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface WuzapiConfig {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
token: string;
|
|
4
|
+
}
|
|
5
|
+
export interface WuzapiResponse<T = unknown> {
|
|
6
|
+
code: number;
|
|
7
|
+
data: T;
|
|
8
|
+
success: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SimpleContextInfo {
|
|
11
|
+
StanzaId: string;
|
|
12
|
+
Participant: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ProxyConfig {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
proxyURL: string;
|
|
17
|
+
}
|
|
18
|
+
export interface S3Config {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
endpoint: string;
|
|
21
|
+
region: string;
|
|
22
|
+
bucket: string;
|
|
23
|
+
accessKey: string;
|
|
24
|
+
secretKey: string;
|
|
25
|
+
pathStyle: boolean;
|
|
26
|
+
publicURL?: string;
|
|
27
|
+
mediaDelivery: "base64" | "s3" | "both";
|
|
28
|
+
retentionDays: number;
|
|
29
|
+
}
|