wuzapi 1.2.0 → 1.4.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,12 +1,13 @@
1
1
  import { BaseClient } from '../client.js';
2
+ import { RequestOptions } from '../types/common.js';
2
3
  import { SetWebhookResponse, GetWebhookResponse } 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>;
12
13
  }
@@ -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;
@@ -1,4 +1,76 @@
1
1
  import { Message } from './message.js';
2
+ export declare enum EventType {
3
+ MESSAGE = "Message",
4
+ RECEIPT = "Receipt",
5
+ PRESENCE = "Presence",
6
+ CHAT_PRESENCE = "ChatPresence",
7
+ CONNECTED = "Connected",
8
+ DISCONNECTED = "Disconnected",
9
+ LOGGED_OUT = "LoggedOut",
10
+ QR = "QR",
11
+ QR_SCANNED_WITHOUT_MULTIDEVICE = "QRScannedWithoutMultidevice",
12
+ PAIR_SUCCESS = "PairSuccess",
13
+ PAIR_ERROR = "PairError",
14
+ MANUAL_LOGIN_RECONNECT = "ManualLoginReconnect",
15
+ KEEP_ALIVE_RESTORED = "KeepAliveRestored",
16
+ KEEP_ALIVE_TIMEOUT = "KeepAliveTimeout",
17
+ GROUP_INFO = "GroupInfo",
18
+ JOINED_GROUP = "JoinedGroup",
19
+ CONTACT = "Contact",
20
+ PUSH_NAME = "PushName",
21
+ PUSH_NAME_SETTING = "PushNameSetting",
22
+ PICTURE = "Picture",
23
+ USER_ABOUT = "UserAbout",
24
+ USER_STATUS_MUTE = "UserStatusMute",
25
+ PRIVACY_SETTINGS = "PrivacySettings",
26
+ APP_STATE = "AppState",
27
+ APP_STATE_SYNC_COMPLETE = "AppStateSyncComplete",
28
+ HISTORY_SYNC = "HistorySync",
29
+ OFFLINE_SYNC_COMPLETED = "OfflineSyncCompleted",
30
+ OFFLINE_SYNC_PREVIEW = "OfflineSyncPreview",
31
+ IDENTITY_CHANGE = "IdentityChange",
32
+ ARCHIVE = "Archive",
33
+ UNARCHIVE_CHATS_SETTING = "UnarchiveChatsSetting",
34
+ CLEAR_CHAT = "ClearChat",
35
+ DELETE_CHAT = "DeleteChat",
36
+ DELETE_FOR_ME = "DeleteForMe",
37
+ MARK_CHAT_AS_READ = "MarkChatAsRead",
38
+ MUTE = "Mute",
39
+ PIN = "Pin",
40
+ STAR = "Star",
41
+ LABEL_ASSOCIATION_CHAT = "LabelAssociationChat",
42
+ LABEL_ASSOCIATION_MESSAGE = "LabelAssociationMessage",
43
+ LABEL_EDIT = "LabelEdit",
44
+ MEDIA_RETRY = "MediaRetry",
45
+ MEDIA_RETRY_ERROR = "MediaRetryError",
46
+ NEWSLETTER_JOIN = "NewsletterJoin",
47
+ NEWSLETTER_LEAVE = "NewsletterLeave",
48
+ NEWSLETTER_LIVE_UPDATE = "NewsletterLiveUpdate",
49
+ NEWSLETTER_MESSAGE_META = "NewsletterMessageMeta",
50
+ NEWSLETTER_MUTE_CHANGE = "NewsletterMuteChange",
51
+ UNDECRYPTABLE_MESSAGE = "UndecryptableMessage",
52
+ STREAM_ERROR = "StreamError",
53
+ STREAM_REPLACED = "StreamReplaced",
54
+ CONNECT_FAILURE = "ConnectFailure",
55
+ CLIENT_OUTDATED = "ClientOutdated",
56
+ TEMPORARY_BAN = "TemporaryBan",
57
+ CAT_REFRESH_ERROR = "CATRefreshError",
58
+ PERMANENT_DISCONNECT = "PermanentDisconnect",
59
+ BLOCKLIST = "Blocklist",
60
+ BLOCKLIST_ACTION = "BlocklistAction",
61
+ BLOCKLIST_CHANGE = "BlocklistChange",
62
+ BUSINESS_NAME = "BusinessName",
63
+ CALL_ACCEPT = "CallAccept",
64
+ CALL_OFFER = "CallOffer",
65
+ CALL_OFFER_NOTICE = "CallOfferNotice",
66
+ CALL_PRE_ACCEPT = "CallPreAccept",
67
+ CALL_REJECT = "CallReject",
68
+ CALL_RELAY_LATENCY = "CallRelayLatency",
69
+ CALL_TERMINATE = "CallTerminate",
70
+ CALL_TRANSPORT = "CallTransport",
71
+ UNKNOWN_CALL_EVENT = "UnknownCallEvent",
72
+ FB_MESSAGE = "FBMessage"
73
+ }
2
74
  export interface WaBinaryNode {
3
75
  Tag: string;
4
76
  Attrs: Record<string, string>;
@@ -8,3 +8,39 @@ export interface GetWebhookResponse {
8
8
  subscribe: string[];
9
9
  webhook: string;
10
10
  }
11
+ export interface S3MediaInfo {
12
+ url: string;
13
+ key: string;
14
+ bucket: string;
15
+ size: number;
16
+ mimeType: string;
17
+ fileName: string;
18
+ }
19
+ export interface WebhookPayload<T = unknown> {
20
+ event: T;
21
+ s3?: S3MediaInfo;
22
+ base64?: string;
23
+ mimeType?: string;
24
+ fileName?: string;
25
+ }
26
+ export interface S3OnlyWebhookPayload<T = unknown> {
27
+ event: T;
28
+ s3: S3MediaInfo;
29
+ }
30
+ export interface Base64OnlyWebhookPayload<T = unknown> {
31
+ event: T;
32
+ base64: string;
33
+ mimeType: string;
34
+ fileName: string;
35
+ }
36
+ export interface BothMediaWebhookPayload<T = unknown> {
37
+ event: T;
38
+ s3: S3MediaInfo;
39
+ base64: string;
40
+ mimeType: string;
41
+ fileName: string;
42
+ }
43
+ export type AnyWebhookPayload<T = unknown> = WebhookPayload<T> | S3OnlyWebhookPayload<T> | Base64OnlyWebhookPayload<T> | BothMediaWebhookPayload<T>;
44
+ export declare function hasS3Media(payload: WebhookPayload): payload is S3OnlyWebhookPayload | BothMediaWebhookPayload;
45
+ export declare function hasBase64Media(payload: WebhookPayload): payload is Base64OnlyWebhookPayload | BothMediaWebhookPayload;
46
+ export declare function hasBothMedia(payload: WebhookPayload): payload is BothMediaWebhookPayload;
@@ -1,4 +1,4 @@
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';
@@ -18,5 +18,5 @@ export declare class WuzapiClient {
18
18
  /**
19
19
  * Test connection to the API
20
20
  */
21
- ping(): Promise<boolean>;
21
+ ping(options?: RequestOptions): Promise<boolean>;
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuzapi",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "TypeScript client library for WuzAPI WhatsApp API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",