meta-cloud-api 0.0.17 → 0.0.18

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.
@@ -24,7 +24,7 @@ declare class MessagesApi extends BaseAPI implements MessagesClass {
24
24
  * @param replyMessageId Optional message ID to reply to
25
25
  * @returns The formatted request body
26
26
  */
27
- bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, toNumber: string, replyMessageId?: string): MessageRequestBody<T>;
27
+ bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
28
28
  /**
29
29
  * Sends a request to the WhatsApp API
30
30
  * @param body The request body to send
@@ -34,83 +34,83 @@ declare class MessagesApi extends BaseAPI implements MessagesClass {
34
34
  /**
35
35
  * Sends an audio message via WhatsApp
36
36
  * @param body The audio media object
37
- * @param recipient Recipient's phone number
37
+ * @param to Recipient's phone number
38
38
  * @param replyMessageId Optional message ID to reply to
39
39
  * @returns Promise with the message response
40
40
  */
41
- audio(body: AudioMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
41
+ audio(body: AudioMediaObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
42
42
  /**
43
43
  * Sends a contact card via WhatsApp
44
44
  * @param body The contact object
45
- * @param recipient Recipient's phone number
45
+ * @param to Recipient's phone number
46
46
  * @param replyMessageId Optional message ID to reply to
47
47
  * @returns Promise with the message response
48
48
  */
49
- contacts(body: [ContactObject], recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
49
+ contacts(body: [ContactObject], to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
50
50
  /**
51
51
  * Sends a document via WhatsApp
52
52
  * @param body The document media object
53
- * @param recipient Recipient's phone number
53
+ * @param to Recipient's phone number
54
54
  * @param replyMessageId Optional message ID to reply to
55
55
  * @returns Promise with the message response
56
56
  */
57
- document(body: DocumentMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
57
+ document(body: DocumentMediaObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
58
58
  /**
59
59
  * Sends an image via WhatsApp
60
60
  * @param body The image media object
61
- * @param recipient Recipient's phone number
61
+ * @param to Recipient's phone number
62
62
  * @param replyMessageId Optional message ID to reply to
63
63
  * @returns Promise with the message response
64
64
  */
65
- image(body: ImageMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
65
+ image(body: ImageMediaObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
66
66
  /**
67
67
  * Sends an interactive message via WhatsApp
68
68
  * @param body The interactive object (buttons, lists, etc.)
69
- * @param recipient Recipient's phone number
69
+ * @param to Recipient's phone number
70
70
  * @param replyMessageId Optional message ID to reply to
71
71
  * @returns Promise with the message response
72
72
  */
73
- interactive(body: InteractiveObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
73
+ interactive(body: InteractiveObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
74
74
  /**
75
75
  * Sends a location via WhatsApp
76
76
  * @param body The location object with coordinates
77
- * @param recipient Recipient's phone number
77
+ * @param to Recipient's phone number
78
78
  * @param replyMessageId Optional message ID to reply to
79
79
  * @returns Promise with the message response
80
80
  */
81
- location(body: LocationObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
81
+ location(body: LocationObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
82
82
  /**
83
83
  * Sends a sticker via WhatsApp
84
84
  * @param body The sticker media object
85
- * @param recipient Recipient's phone number
85
+ * @param to Recipient's phone number
86
86
  * @param replyMessageId Optional message ID to reply to
87
87
  * @returns Promise with the message response
88
88
  */
89
- sticker(body: StickerMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
89
+ sticker(body: StickerMediaObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
90
90
  /**
91
91
  * Sends a template message via WhatsApp
92
92
  * @param body The message template object
93
- * @param recipient Recipient's phone number
93
+ * @param to Recipient's phone number
94
94
  * @param replyMessageId Optional message ID to reply to
95
95
  * @returns Promise with the message response
96
96
  */
97
- template(body: MessageTemplateObject<ComponentTypesEnum>, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
97
+ template(body: MessageTemplateObject<ComponentTypesEnum>, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
98
98
  /**
99
99
  * Sends a text message via WhatsApp
100
100
  * @param body The text object containing the message
101
- * @param recipient Recipient's phone number
101
+ * @param to Recipient's phone number
102
102
  * @param replyMessageId Optional message ID to reply to
103
103
  * @returns Promise with the message response
104
104
  */
105
- text(body: TextObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
105
+ text(body: TextObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
106
106
  /**
107
107
  * Sends a video via WhatsApp
108
108
  * @param body The video media object
109
- * @param recipient Recipient's phone number
109
+ * @param to Recipient's phone number
110
110
  * @param replyMessageId Optional message ID to reply to
111
111
  * @returns Promise with the message response
112
112
  */
113
- video(body: VideoMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
113
+ video(body: VideoMediaObject, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
114
114
  /**
115
115
  * Updates message status (used for read receipts and typing indicators)
116
116
  * @param body The status object
@@ -132,72 +132,72 @@ declare class MessagesApi extends BaseAPI implements MessagesClass {
132
132
  /**
133
133
  * Sends an interactive list message
134
134
  * @param body The list message content
135
- * @param recipient Recipient phone number
135
+ * @param to Recipient phone number
136
136
  * @param replyMessageId Optional message ID to reply to
137
137
  * @returns Promise with the response
138
138
  */
139
139
  interactiveList(body: InteractiveObject & {
140
140
  type: InteractiveTypesEnum.List;
141
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
141
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
142
142
  /**
143
143
  * Sends an interactive CTA URL message
144
144
  * @param body The CTA URL message content
145
- * @param recipient Recipient phone number
145
+ * @param to Recipient phone number
146
146
  * @param replyMessageId Optional message ID to reply to
147
147
  * @returns Promise with the response
148
148
  */
149
149
  interactiveCtaUrl(body: InteractiveObject & {
150
150
  type: InteractiveTypesEnum.CtaUrl;
151
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
151
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
152
152
  /**
153
153
  * Sends a location request message
154
154
  * @param body The location request message content
155
- * @param recipient Recipient phone number
155
+ * @param to Recipient phone number
156
156
  * @param replyMessageId Optional message ID to reply to
157
157
  * @returns Promise with the response
158
158
  */
159
159
  interactiveLocationRequest(body: InteractiveObject & {
160
160
  type: InteractiveTypesEnum.LocationRequest;
161
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
161
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
162
162
  /**
163
163
  * Sends an address message to request shipping address from the user
164
164
  * Note: This feature is only available for businesses based in India and their India customers
165
165
  * @param body The address message content
166
- * @param recipient Recipient phone number
166
+ * @param to Recipient phone number
167
167
  * @param replyMessageId Optional message ID to reply to
168
168
  * @returns Promise with the response
169
169
  */
170
170
  interactiveAddressMessage(body: InteractiveObject & {
171
171
  type: InteractiveTypesEnum.AddressMessage;
172
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
172
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
173
173
  /**
174
174
  * Sends an interactive reply buttons message
175
175
  * @param body The reply buttons message content
176
- * @param recipient Recipient phone number
176
+ * @param to Recipient phone number
177
177
  * @param replyMessageId Optional message ID to reply to
178
178
  * @returns Promise with the response
179
179
  */
180
180
  interactiveReplyButtons(body: InteractiveObject & {
181
181
  type: InteractiveTypesEnum.Button;
182
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
182
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
183
183
  /**
184
184
  * Sends an interactive Flow message
185
185
  * @param body The Flow message content
186
- * @param recipient Recipient phone number
186
+ * @param to Recipient phone number
187
187
  * @param replyMessageId Optional message ID to reply to
188
188
  * @returns Promise with the response
189
189
  */
190
190
  interactiveFlow(body: InteractiveObject & {
191
191
  type: InteractiveTypesEnum.Flow;
192
- }, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
192
+ }, to: string, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
193
193
  /**
194
194
  * Sends a reaction to a message (emoji response)
195
195
  * @param messageId ID of the message to react to
196
196
  * @param emoji The emoji to send as reaction (e.g. "😀", "❤️", "👍")
197
- * @param recipient Recipient phone number
197
+ * @param to Recipient phone number
198
198
  * @returns Promise with the response
199
199
  */
200
- reaction(messageId: string, emoji: string, recipient: number): Promise<RequesterResponseInterface<MessagesResponse>>;
200
+ reaction(messageId: string, emoji: string, to: string): Promise<RequesterResponseInterface<MessagesResponse>>;
201
201
  }
202
202
 
203
203
  export { type MessagePayloadType, MessagesApi as default };
@@ -1,2 +1,2 @@
1
- "use strict";var D=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var B=(S,t)=>{for(var i in t)D(S,i,{get:t[i],enumerable:!0})},U=(S,t,i,R)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of T(t))!M.call(S,A)&&A!==i&&D(S,A,{get:()=>t[A],enumerable:!(R=I(t,A))||R.enumerable});return S};var G=S=>U(D({},"__esModule",{value:!0}),S);var s={};B(s,{default:()=>N});module.exports=G(s);var p=class{name;debug;constructor(t,i=!1){this.name=t,this.debug=i}log(...t){if(this.debug){let i=`[ ${Date.now()} ]`;this.name&&(i+=` - ${this.name}`),console.log.apply(console,[i,": ",...t])}}error(...t){let i=`[ ${Date.now()} ] - ERROR`;this.name&&(i+=` - ${this.name}`),console.error.apply(console,[i,": ",...t])}warn(...t){let i=`[ ${Date.now()} ] - WARN`;this.name&&(i+=` - ${this.name}`),console.warn.apply(console,[i,": ",...t])}info(...t){let i=`[ ${Date.now()} ] - INFO`;this.name&&(i+=` - ${this.name}`),console.info.apply(console,[i,": ",...t])}};var a="BaseAPI",l=!1,e=new p(a,process.env.DEBUG==="true"||l),P=class{config;client;constructor(t,i){this.config=t,this.client=i,e.log("Initialized with HTTPSClient")}};var N=class extends P{commonMethod="POST";commonEndpoint="messages";constructor(t,i){super(t,i)}bodyBuilder(t,i,R,A){let O={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:t,[t]:i};return A&&(O.context={message_id:A}),O}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("audio",t,i.toString(),R)))}async contacts(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,i.toString(),R)))}async document(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("document",t,i.toString(),R)))}async image(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("image",t,i.toString(),R)))}async interactive(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async location(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("location",t,i.toString(),R)))}async sticker(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,i.toString(),R)))}async template(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("template",t,i.toString(),R)))}async text(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("text",t,i.toString(),R)))}async video(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("video",t,i.toString(),R)))}async status(t){let i={messaging_product:"whatsapp",...t};return this.send(JSON.stringify(i))}async markAsRead(t){return this.status({status:"read",message_id:t})}async showTypingIndicator(t){return this.status({status:"read",message_id:t,typing_indicator:{type:"text"}})}async interactiveList(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveCtaUrl(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveLocationRequest(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveAddressMessage(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveReplyButtons(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveFlow(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async reaction(t,i,R){let A={messaging_product:"whatsapp",recipient_type:"individual",to:R.toString(),type:"reaction",reaction:{message_id:t,emoji:i}};return this.send(JSON.stringify(A))}};
1
+ "use strict";var D=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var B=(A,t)=>{for(var i in t)D(A,i,{get:t[i],enumerable:!0})},U=(A,t,i,R)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of T(t))!M.call(A,S)&&S!==i&&D(A,S,{get:()=>t[S],enumerable:!(R=I(t,S))||R.enumerable});return A};var G=A=>U(D({},"__esModule",{value:!0}),A);var K={};B(K,{default:()=>N});module.exports=G(K);var p=class{name;debug;constructor(t,i=!1){this.name=t,this.debug=i}log(...t){if(this.debug){let i=`[ ${Date.now()} ]`;this.name&&(i+=` - ${this.name}`),console.log.apply(console,[i,": ",...t])}}error(...t){let i=`[ ${Date.now()} ] - ERROR`;this.name&&(i+=` - ${this.name}`),console.error.apply(console,[i,": ",...t])}warn(...t){let i=`[ ${Date.now()} ] - WARN`;this.name&&(i+=` - ${this.name}`),console.warn.apply(console,[i,": ",...t])}info(...t){let i=`[ ${Date.now()} ] - INFO`;this.name&&(i+=` - ${this.name}`),console.info.apply(console,[i,": ",...t])}};var s="BaseAPI",a=!1,l=new p(s,process.env.DEBUG==="true"||a),P=class{config;client;constructor(t,i){this.config=t,this.client=i,l.log("Initialized with HTTPSClient")}};var N=class extends P{commonMethod="POST";commonEndpoint="messages";constructor(t,i){super(t,i)}bodyBuilder(t,i,R,S){let O={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:t,[t]:i};return S&&(O.context={message_id:S}),O}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("audio",t,i,R)))}async contacts(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,i,R)))}async document(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("document",t,i,R)))}async image(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("image",t,i,R)))}async interactive(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async location(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("location",t,i,R)))}async sticker(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,i,R)))}async template(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("template",t,i,R)))}async text(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("text",t,i,R)))}async video(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("video",t,i,R)))}async status(t){let i={messaging_product:"whatsapp",...t};return this.send(JSON.stringify(i))}async markAsRead(t){return this.status({status:"read",message_id:t})}async showTypingIndicator(t){return this.status({status:"read",message_id:t,typing_indicator:{type:"text"}})}async interactiveList(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveCtaUrl(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveLocationRequest(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveAddressMessage(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveReplyButtons(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveFlow(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async reaction(t,i,R){let S={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:"reaction",reaction:{message_id:t,emoji:i}};return this.send(JSON.stringify(S))}};
2
2
  //# sourceMappingURL=messages.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/messages.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n InteractiveTypesEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n toNumber: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: toNumber,\n type: type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param recipient Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n recipient: number,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: recipient.toString(),\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,C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AK,KACR,KAAK,UAAU,KAAK,0BAA0CC,EAAMC,EAAU,SAAS,EAAGF,CAAc,CAAC,CAC7G,CACJ,CASA,MAAM,gBACFC,EACAC,EACAF,EACuD,CACvD,OAAO,KAAK,KACR,KAAK,UAAU,KAAK,0BAA0CC,EAAMC,EAAU,SAAS,EAAGF,CAAc,CAAC,CAC7G,CACJ,CASA,MAAM,SACFI,EACAC,EACAH,EACuD,CACvD,IAAMD,EAAO,CACT,kBAAmB,WACnB,eAAgB,aAChB,GAAIC,EAAU,SAAS,EACvB,KAAM,WACN,SAAU,CACN,WAAYE,EACZ,MAAOC,CACX,CACJ,EAEA,OAAO,KAAK,KAAK,KAAK,UAAUJ,CAAI,CAAC,CACzC,CACJ","names":["messages_exports","__export","MessagesApi","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","MessagesApi","BaseAPI","config","client","type","payload","toNumber","replyMessageId","body","recipient","bodyToSend","messageId","emoji"]}
1
+ {"version":3,"sources":["../../src/api/messages.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, to, replyMessageId)));\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param to Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n to: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: to,\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK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,WAAYI,EACZ,MAAOC,CACX,CACJ,EAEA,OAAO,KAAK,KAAK,KAAK,UAAUH,CAAI,CAAC,CACzC,CACJ","names":["messages_exports","__export","MessagesApi","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","MessagesApi","BaseAPI","config","client","type","payload","to","replyMessageId","body","bodyToSend","messageId","emoji"]}
@@ -1,2 +1,2 @@
1
- var S=class{name;debug;constructor(t,i=!1){this.name=t,this.debug=i}log(...t){if(this.debug){let i=`[ ${Date.now()} ]`;this.name&&(i+=` - ${this.name}`),console.log.apply(console,[i,": ",...t])}}error(...t){let i=`[ ${Date.now()} ] - ERROR`;this.name&&(i+=` - ${this.name}`),console.error.apply(console,[i,": ",...t])}warn(...t){let i=`[ ${Date.now()} ] - WARN`;this.name&&(i+=` - ${this.name}`),console.warn.apply(console,[i,": ",...t])}info(...t){let i=`[ ${Date.now()} ] - INFO`;this.name&&(i+=` - ${this.name}`),console.info.apply(console,[i,": ",...t])}};var O="BaseAPI",I=!1,T=new S(O,process.env.DEBUG==="true"||I),A=class{config;client;constructor(t,i){this.config=t,this.client=i,T.log("Initialized with HTTPSClient")}};var P=class extends A{commonMethod="POST";commonEndpoint="messages";constructor(t,i){super(t,i)}bodyBuilder(t,i,R,p){let D={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:t,[t]:i};return p&&(D.context={message_id:p}),D}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("audio",t,i.toString(),R)))}async contacts(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,i.toString(),R)))}async document(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("document",t,i.toString(),R)))}async image(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("image",t,i.toString(),R)))}async interactive(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async location(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("location",t,i.toString(),R)))}async sticker(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,i.toString(),R)))}async template(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("template",t,i.toString(),R)))}async text(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("text",t,i.toString(),R)))}async video(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("video",t,i.toString(),R)))}async status(t){let i={messaging_product:"whatsapp",...t};return this.send(JSON.stringify(i))}async markAsRead(t){return this.status({status:"read",message_id:t})}async showTypingIndicator(t){return this.status({status:"read",message_id:t,typing_indicator:{type:"text"}})}async interactiveList(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveCtaUrl(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveLocationRequest(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveAddressMessage(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveReplyButtons(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async interactiveFlow(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i.toString(),R)))}async reaction(t,i,R){let p={messaging_product:"whatsapp",recipient_type:"individual",to:R.toString(),type:"reaction",reaction:{message_id:t,emoji:i}};return this.send(JSON.stringify(p))}};export{P as default};
1
+ var A=class{name;debug;constructor(t,i=!1){this.name=t,this.debug=i}log(...t){if(this.debug){let i=`[ ${Date.now()} ]`;this.name&&(i+=` - ${this.name}`),console.log.apply(console,[i,": ",...t])}}error(...t){let i=`[ ${Date.now()} ] - ERROR`;this.name&&(i+=` - ${this.name}`),console.error.apply(console,[i,": ",...t])}warn(...t){let i=`[ ${Date.now()} ] - WARN`;this.name&&(i+=` - ${this.name}`),console.warn.apply(console,[i,": ",...t])}info(...t){let i=`[ ${Date.now()} ] - INFO`;this.name&&(i+=` - ${this.name}`),console.info.apply(console,[i,": ",...t])}};var O="BaseAPI",I=!1,T=new A(O,process.env.DEBUG==="true"||I),S=class{config;client;constructor(t,i){this.config=t,this.client=i,T.log("Initialized with HTTPSClient")}};var P=class extends S{commonMethod="POST";commonEndpoint="messages";constructor(t,i){super(t,i)}bodyBuilder(t,i,R,p){let D={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:t,[t]:i};return p&&(D.context={message_id:p}),D}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("audio",t,i,R)))}async contacts(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,i,R)))}async document(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("document",t,i,R)))}async image(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("image",t,i,R)))}async interactive(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async location(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("location",t,i,R)))}async sticker(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,i,R)))}async template(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("template",t,i,R)))}async text(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("text",t,i,R)))}async video(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("video",t,i,R)))}async status(t){let i={messaging_product:"whatsapp",...t};return this.send(JSON.stringify(i))}async markAsRead(t){return this.status({status:"read",message_id:t})}async showTypingIndicator(t){return this.status({status:"read",message_id:t,typing_indicator:{type:"text"}})}async interactiveList(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveCtaUrl(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveLocationRequest(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveAddressMessage(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveReplyButtons(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async interactiveFlow(t,i,R){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,i,R)))}async reaction(t,i,R){let p={messaging_product:"whatsapp",recipient_type:"individual",to:R,type:"reaction",reaction:{message_id:t,emoji:i}};return this.send(JSON.stringify(p))}};export{P as default};
2
2
  //# sourceMappingURL=messages.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/messages.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n InteractiveTypesEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n toNumber: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: toNumber,\n type: type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param recipient Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param recipient Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(\n JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, recipient.toString(), replyMessageId)),\n );\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param recipient Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n recipient: number,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: recipient.toString(),\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC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AAK,0BAA0CC,EAAMC,EAAU,SAAS,EAAGF,CAAc,CAAC,CAC7G,CACJ,CASA,MAAM,SACFI,EACAC,EACAH,EACuD,CACvD,IAAMD,EAAO,CACT,kBAAmB,WACnB,eAAgB,aAChB,GAAIC,EAAU,SAAS,EACvB,KAAM,WACN,SAAU,CACN,WAAYE,EACZ,MAAOC,CACX,CACJ,EAEA,OAAO,KAAK,KAAK,KAAK,UAAUJ,CAAI,CAAC,CACzC,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","MessagesApi","BaseAPI","config","client","type","payload","toNumber","replyMessageId","body","recipient","bodyToSend","messageId","emoji"]}
1
+ {"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/messages.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport {\n ComponentTypesEnum,\n HttpMethodsEnum,\n InteractiveTypesEnum,\n MessageTypesEnum,\n WabaConfigEnum,\n} from '../types/enums';\n\nimport * as m from '../types/messages';\nimport type { RequesterClass, RequesterResponseInterface } from '../types/request';\nimport BaseAPI from './base';\n\n/**\n * Maps each message type to its appropriate payload type\n */\nexport type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio\n ? m.AudioMediaObject\n : T extends MessageTypesEnum.Contacts\n ? [m.ContactObject]\n : T extends MessageTypesEnum.Document\n ? m.DocumentMediaObject\n : T extends MessageTypesEnum.Image\n ? m.ImageMediaObject\n : T extends MessageTypesEnum.Interactive\n ? m.InteractiveObject\n : T extends MessageTypesEnum.Location\n ? m.LocationObject\n : T extends MessageTypesEnum.Template\n ? m.MessageTemplateObject<ComponentTypesEnum>\n : T extends MessageTypesEnum.Sticker\n ? m.StickerMediaObject\n : T extends MessageTypesEnum.Text\n ? m.TextObject\n : T extends MessageTypesEnum.Video\n ? m.VideoMediaObject\n : T extends MessageTypesEnum.Reaction\n ? { message_id: string; emoji: string }\n : never;\n\nexport default class MessagesApi extends BaseAPI implements m.MessagesClass {\n private readonly commonMethod = HttpMethodsEnum.Post;\n private readonly commonEndpoint = 'messages';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Builds the request body for WhatsApp API messages\n * @param type The type of message to send\n * @param payload The message payload object\n * @param toNumber The recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns The formatted request body\n */\n bodyBuilder<T extends MessageTypesEnum>(\n type: T,\n payload: MessagePayloadType<T>,\n to: string,\n replyMessageId?: string,\n ) {\n const body: m.MessageRequestBody<T> = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n type,\n [type]: payload,\n };\n\n if (replyMessageId) body['context'] = { message_id: replyMessageId };\n\n return body;\n }\n\n /**\n * Sends a request to the WhatsApp API\n * @param body The request body to send\n * @returns Promise with the API response\n */\n private send(body: BodyInit | null): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.client.sendRequest(\n this.commonMethod,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.commonEndpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n body,\n );\n }\n\n /**\n * Sends an audio message via WhatsApp\n * @param body The audio media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async audio(\n body: m.AudioMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Audio, body, to, replyMessageId)));\n }\n\n /**\n * Sends a contact card via WhatsApp\n * @param body The contact object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async contacts(\n body: [m.ContactObject],\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Contacts, body, to, replyMessageId)));\n }\n\n /**\n * Sends a document via WhatsApp\n * @param body The document media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async document(\n body: m.DocumentMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Document, body, to, replyMessageId)));\n }\n\n /**\n * Sends an image via WhatsApp\n * @param body The image media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async image(\n body: m.ImageMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Image, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive message via WhatsApp\n * @param body The interactive object (buttons, lists, etc.)\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async interactive(\n body: m.InteractiveObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location via WhatsApp\n * @param body The location object with coordinates\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async location(\n body: m.LocationObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Location, body, to, replyMessageId)));\n }\n\n /**\n * Sends a sticker via WhatsApp\n * @param body The sticker media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async sticker(\n body: m.StickerMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Sticker, body, to, replyMessageId)));\n }\n\n /**\n * Sends a template message via WhatsApp\n * @param body The message template object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async template(\n body: m.MessageTemplateObject<ComponentTypesEnum>,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Template, body, to, replyMessageId)));\n }\n\n /**\n * Sends a text message via WhatsApp\n * @param body The text object containing the message\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async text(\n body: m.TextObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Text, body, to, replyMessageId)));\n }\n\n /**\n * Sends a video via WhatsApp\n * @param body The video media object\n * @param to Recipient's phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the message response\n */\n async video(\n body: m.VideoMediaObject,\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Video, body, to, replyMessageId)));\n }\n\n /**\n * Updates message status (used for read receipts and typing indicators)\n * @param body The status object\n * @returns Promise with the response\n */\n async status(body: m.StatusObject): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const bodyToSend = {\n messaging_product: 'whatsapp',\n ...body,\n };\n\n return this.send(JSON.stringify(bodyToSend));\n }\n\n /**\n * Marks a message as read in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async markAsRead(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n });\n }\n\n /**\n * Marks a message as read and shows a typing indicator in WhatsApp\n * @param messageId ID of the message to mark as read\n * @returns Promise with the response\n */\n async showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.status({\n status: 'read',\n message_id: messageId,\n typing_indicator: {\n type: 'text',\n },\n });\n }\n\n /**\n * Sends an interactive list message\n * @param body The list message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveList(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.List },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive CTA URL message\n * @param body The CTA URL message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveCtaUrl(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.CtaUrl },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a location request message\n * @param body The location request message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveLocationRequest(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.LocationRequest },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an address message to request shipping address from the user\n * Note: This feature is only available for businesses based in India and their India customers\n * @param body The address message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveAddressMessage(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.AddressMessage },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive reply buttons message\n * @param body The reply buttons message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveReplyButtons(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Button },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends an interactive Flow message\n * @param body The Flow message content\n * @param to Recipient phone number\n * @param replyMessageId Optional message ID to reply to\n * @returns Promise with the response\n */\n async interactiveFlow(\n body: m.InteractiveObject & { type: InteractiveTypesEnum.Flow },\n to: string,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n return this.send(JSON.stringify(this.bodyBuilder(MessageTypesEnum.Interactive, body, to, replyMessageId)));\n }\n\n /**\n * Sends a reaction to a message (emoji response)\n * @param messageId ID of the message to react to\n * @param emoji The emoji to send as reaction (e.g. \"😀\", \"❤️\", \"👍\")\n * @param to Recipient phone number\n * @returns Promise with the response\n */\n async reaction(\n messageId: string,\n emoji: string,\n to: string,\n ): Promise<RequesterResponseInterface<m.MessagesResponse>> {\n const body = {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to: to,\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji: emoji,\n },\n };\n\n return this.send(JSON.stringify(body));\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,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OAAO,KAAK,OAAO,CACf,OAAQ,OACR,WAAYA,EACZ,iBAAkB,CACd,KAAM,MACV,CACJ,CAAC,CACL,CASA,MAAM,gBACFF,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CASA,MAAM,kBACFC,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CASA,MAAM,2BACFC,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CAUA,MAAM,0BACFC,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CASA,MAAM,wBACFC,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CASA,MAAM,gBACFC,EACAF,EACAC,EACuD,CACvD,OAAO,KAAK,KAAK,KAAK,UAAU,KAAK,0BAA0CC,EAAMF,EAAIC,CAAc,CAAC,CAAC,CAC7G,CASA,MAAM,SACFG,EACAC,EACAL,EACuD,CACvD,IAAME,EAAO,CACT,kBAAmB,WACnB,eAAgB,aAChB,GAAIF,EACJ,KAAM,WACN,SAAU,CACN,WAAYI,EACZ,MAAOC,CACX,CACJ,EAEA,OAAO,KAAK,KAAK,KAAK,UAAUH,CAAI,CAAC,CACzC,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","MessagesApi","BaseAPI","config","client","type","payload","to","replyMessageId","body","bodyToSend","messageId","emoji"]}