wuzapi 1.0.0 → 1.1.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 CHANGED
@@ -493,7 +493,7 @@ For detailed API documentation, refer to the [WuzAPI documentation](https://gith
493
493
 
494
494
  ```bash
495
495
  # Clone the repository
496
- git clone https://github.com/your-username/wuzapi.git
496
+ git clone https://github.com/gusnips/wuzapi-node.git
497
497
  cd wuzapi
498
498
 
499
499
  # Install dependencies
@@ -525,8 +525,8 @@ MIT License - see the [LICENSE](LICENSE) file for details.
525
525
  ## Support
526
526
 
527
527
  - 📚 [Documentation](https://github.com/asternic/wuzapi)
528
- - 🐛 [Issue Tracker](https://github.com/your-username/wuzapi/issues)
529
- - 💬 [Discussions](https://github.com/your-username/wuzapi/discussions)
528
+ - 🐛 [Issue Tracker](https://github.com/gusnips/wuzapi-node/issues)
529
+ - 💬 [Discussions](https://github.com/gusnips/wuzapi-node/discussions)
530
530
 
531
531
  ## Changelog
532
532
 
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { WuzapiConfig } from './types/common.js';
3
+ export declare class WuzapiError extends Error {
4
+ code: number;
5
+ details?: unknown;
6
+ constructor(code: number, message: string, details?: unknown);
7
+ }
8
+ export declare class BaseClient {
9
+ protected axios: AxiosInstance;
10
+ protected config: WuzapiConfig;
11
+ constructor(config: WuzapiConfig);
12
+ protected request<T>(method: "GET" | "POST" | "DELETE", endpoint: string, data?: unknown): Promise<T>;
13
+ protected get<T>(endpoint: string): Promise<T>;
14
+ protected post<T>(endpoint: string, data?: unknown): Promise<T>;
15
+ protected delete<T>(endpoint: string): Promise<T>;
16
+ }
@@ -0,0 +1,10 @@
1
+ export { WuzapiClient } from './wuzapi-client.js';
2
+ export { WuzapiError } from './client.js';
3
+ export * from './types/index.js';
4
+ export { AdminModule } from './modules/admin.js';
5
+ export { SessionModule } from './modules/session.js';
6
+ export { UserModule } from './modules/user.js';
7
+ export { ChatModule } from './modules/chat.js';
8
+ export { GroupModule } from './modules/group.js';
9
+ export { WebhookModule } from './modules/webhook.js';
10
+ export { WuzapiClient as default } from './wuzapi-client.js';
@@ -0,0 +1,16 @@
1
+ import { BaseClient } from '../client.js';
2
+ import { User, CreateUserRequest, CreateUserResponse, DeleteUserResponse } from '../types/admin.js';
3
+ export declare class AdminModule extends BaseClient {
4
+ /**
5
+ * List all users
6
+ */
7
+ listUsers(): Promise<User[]>;
8
+ /**
9
+ * Add a new user
10
+ */
11
+ addUser(user: CreateUserRequest): Promise<CreateUserResponse>;
12
+ /**
13
+ * Delete a user by ID
14
+ */
15
+ deleteUser(id: number): Promise<DeleteUserResponse>;
16
+ }
@@ -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 { ContextInfo } 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?: ContextInfo;
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?: ContextInfo;
25
+ }
26
+ export interface SendAudioRequest {
27
+ Phone: string;
28
+ Audio: string;
29
+ ContextInfo?: ContextInfo;
30
+ }
31
+ export interface SendImageRequest {
32
+ Phone: string;
33
+ Image: string;
34
+ Caption?: string;
35
+ ContextInfo?: ContextInfo;
36
+ }
37
+ export interface SendDocumentRequest {
38
+ Phone: string;
39
+ Document: string;
40
+ FileName: string;
41
+ ContextInfo?: ContextInfo;
42
+ }
43
+ export interface SendVideoRequest {
44
+ Phone: string;
45
+ Video: string;
46
+ Caption?: string;
47
+ JpegThumbnail?: string;
48
+ ContextInfo?: ContextInfo;
49
+ }
50
+ export interface SendStickerRequest {
51
+ Phone: string;
52
+ Sticker: string;
53
+ PngThumbnail?: string;
54
+ ContextInfo?: ContextInfo;
55
+ }
56
+ export interface SendLocationRequest {
57
+ Phone: string;
58
+ Latitude: number;
59
+ Longitude: number;
60
+ Name?: string;
61
+ ContextInfo?: ContextInfo;
62
+ }
63
+ export interface SendContactRequest {
64
+ Phone: string;
65
+ Name: string;
66
+ Vcard: string;
67
+ ContextInfo?: ContextInfo;
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 ContextInfo {
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
+ }
@@ -0,0 +1,76 @@
1
+ export interface GroupParticipant {
2
+ IsAdmin: boolean;
3
+ IsSuperAdmin: boolean;
4
+ JID: string;
5
+ }
6
+ export interface GroupInfo {
7
+ AnnounceVersionID: string;
8
+ DisappearingTimer: number;
9
+ GroupCreated: string;
10
+ IsAnnounce: boolean;
11
+ IsEphemeral: boolean;
12
+ IsLocked: boolean;
13
+ JID: string;
14
+ Name: string;
15
+ NameSetAt: string;
16
+ NameSetBy: string;
17
+ OwnerJID: string;
18
+ ParticipantVersionID: string;
19
+ Participants: GroupParticipant[];
20
+ Topic: string;
21
+ TopicID: string;
22
+ TopicSetAt: string;
23
+ TopicSetBy: string;
24
+ }
25
+ export interface GroupListResponse {
26
+ Groups: GroupInfo[];
27
+ }
28
+ export interface GroupInviteLinkRequest {
29
+ GroupJID: string;
30
+ }
31
+ export interface GroupInviteLinkResponse {
32
+ InviteLink: string;
33
+ }
34
+ export interface GroupInfoRequest {
35
+ GroupJID: string;
36
+ }
37
+ export interface GroupPhotoRequest {
38
+ GroupJID: string;
39
+ Image: string;
40
+ }
41
+ export interface GroupPhotoResponse {
42
+ Details: string;
43
+ PictureID: string;
44
+ }
45
+ export interface GroupNameRequest {
46
+ GroupJID: string;
47
+ Name: string;
48
+ }
49
+ export interface GroupNameResponse {
50
+ Details: string;
51
+ }
52
+ export interface GroupCreateRequest {
53
+ name: string;
54
+ participants: string[];
55
+ }
56
+ export type GroupCreateResponse = GroupInfo;
57
+ export interface GroupLockedRequest {
58
+ groupjid: string;
59
+ locked: boolean;
60
+ }
61
+ export interface GroupLockedResponse {
62
+ Details: string;
63
+ }
64
+ export interface GroupEphemeralRequest {
65
+ groupjid: string;
66
+ duration: "24h" | "7d" | "90d" | "off";
67
+ }
68
+ export interface GroupEphemeralResponse {
69
+ Details: string;
70
+ }
71
+ export interface GroupPhotoRemoveRequest {
72
+ groupjid: string;
73
+ }
74
+ export interface GroupPhotoRemoveResponse {
75
+ Details: string;
76
+ }
@@ -0,0 +1,7 @@
1
+ export * from './common.js';
2
+ export * from './admin.js';
3
+ export * from './session.js';
4
+ export * from './user.js';
5
+ export * from './chat.js';
6
+ export * from './group.js';
7
+ export * from './webhook.js';
@@ -0,0 +1,32 @@
1
+ import { S3Config } from './common.js';
2
+ export interface ConnectRequest {
3
+ Subscribe: string[];
4
+ Immediate?: boolean;
5
+ }
6
+ export interface ConnectResponse {
7
+ details: string;
8
+ events: string;
9
+ jid: string;
10
+ webhook: string;
11
+ }
12
+ export interface DisconnectResponse {
13
+ Details: string;
14
+ }
15
+ export interface LogoutResponse {
16
+ Details: string;
17
+ }
18
+ export interface StatusResponse {
19
+ Connected: boolean;
20
+ LoggedIn: boolean;
21
+ }
22
+ export interface QRCodeResponse {
23
+ QRCode: string;
24
+ }
25
+ export interface S3ConfigResponse extends S3Config {
26
+ accessKey: string;
27
+ }
28
+ export interface S3TestResponse {
29
+ Details: string;
30
+ Bucket: string;
31
+ Region: string;
32
+ }
@@ -0,0 +1,55 @@
1
+ export interface UserInfoRequest {
2
+ Phone: string[];
3
+ }
4
+ export interface VerifiedName {
5
+ Certificate: {
6
+ details: string;
7
+ signature: string;
8
+ };
9
+ Details: {
10
+ issuer: string;
11
+ serial: number;
12
+ verifiedName: string;
13
+ };
14
+ }
15
+ export interface UserInfo {
16
+ Devices: string[];
17
+ PictureID: string;
18
+ Status: string;
19
+ VerifiedName: VerifiedName | null;
20
+ }
21
+ export interface UserInfoResponse {
22
+ Users: Record<string, UserInfo>;
23
+ }
24
+ export interface UserCheckRequest {
25
+ Phone: string[];
26
+ }
27
+ export interface UserCheck {
28
+ IsInWhatsapp: boolean;
29
+ JID: string;
30
+ Query: string;
31
+ VerifiedName: string;
32
+ }
33
+ export interface UserCheckResponse {
34
+ Users: UserCheck[];
35
+ }
36
+ export interface UserAvatarRequest {
37
+ Phone: string;
38
+ Preview: boolean;
39
+ }
40
+ export interface UserAvatarResponse {
41
+ URL: string;
42
+ ID: string;
43
+ Type: string;
44
+ DirectPath: string;
45
+ }
46
+ export interface Contact {
47
+ BusinessName: string;
48
+ FirstName: string;
49
+ Found: boolean;
50
+ FullName: string;
51
+ PushName: string;
52
+ }
53
+ export interface ContactsResponse {
54
+ [jid: string]: Contact;
55
+ }
@@ -0,0 +1,10 @@
1
+ export interface SetWebhookRequest {
2
+ webhookURL: string;
3
+ }
4
+ export interface SetWebhookResponse {
5
+ webhook: string;
6
+ }
7
+ export interface GetWebhookResponse {
8
+ subscribe: string[];
9
+ webhook: string;
10
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,22 @@
1
+ import { WuzapiConfig } from './types/common.js';
2
+ import { AdminModule } from './modules/admin.js';
3
+ import { SessionModule } from './modules/session.js';
4
+ import { UserModule } from './modules/user.js';
5
+ import { ChatModule } from './modules/chat.js';
6
+ import { GroupModule } from './modules/group.js';
7
+ import { WebhookModule } from './modules/webhook.js';
8
+ export declare class WuzapiClient {
9
+ readonly admin: AdminModule;
10
+ readonly session: SessionModule;
11
+ readonly user: UserModule;
12
+ readonly chat: ChatModule;
13
+ readonly group: GroupModule;
14
+ readonly webhook: WebhookModule;
15
+ readonly users: UserModule;
16
+ readonly message: ChatModule;
17
+ constructor(config: WuzapiConfig);
18
+ /**
19
+ * Test connection to the API
20
+ */
21
+ ping(): Promise<boolean>;
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuzapi",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "TypeScript client library for WuzAPI WhatsApp API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "dev": "vite",
20
- "build": "tsc -p tsconfig.build.json && vite build",
20
+ "build": "vite build",
21
21
  "preview": "vite preview",
22
22
  "lint": "eslint src --ext .ts,.tsx",
23
23
  "lint:fix": "eslint src --ext .ts,.tsx --fix",
@@ -42,7 +42,7 @@
42
42
  "license": "MIT",
43
43
  "repository": {
44
44
  "type": "git",
45
- "url": "https://github.com/your-username/wuzapi.git"
45
+ "url": "https://github.com/gusnips/wuzapi-node.git"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^24.3.0",
@@ -50,7 +50,8 @@
50
50
  "@typescript-eslint/parser": "^8.41.0",
51
51
  "eslint": "^9.34.0",
52
52
  "typescript": "~5.8.3",
53
- "vite": "^7.1.2"
53
+ "vite": "^7.1.2",
54
+ "vite-plugin-dts": "^4.5.4"
54
55
  },
55
56
  "dependencies": {
56
57
  "axios": "^1.11.0"