meta-cloud-api 0.0.7 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/base.d.mts +1 -1
- package/dist/api/base.d.ts +1 -1
- package/dist/api/businessProfile.d.mts +1 -1
- package/dist/api/businessProfile.d.ts +1 -1
- package/dist/api/businessProfile.js +1 -1
- package/dist/api/encryption.d.mts +1 -1
- package/dist/api/encryption.d.ts +1 -1
- package/dist/api/encryption.js +1 -1
- package/dist/api/encryption.mjs +1 -1
- package/dist/api/flow.d.mts +1 -1
- package/dist/api/flow.d.ts +1 -1
- package/dist/api/flow.js +1 -1
- package/dist/api/flow.mjs +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/media.d.mts +1 -1
- package/dist/api/media.d.ts +1 -1
- package/dist/api/media.js +1 -1
- package/dist/api/messages.d.mts +179 -3
- package/dist/api/messages.d.ts +179 -3
- package/dist/api/messages.js +1 -1
- package/dist/api/messages.js.map +1 -1
- package/dist/api/messages.mjs +1 -1
- package/dist/api/messages.mjs.map +1 -1
- package/dist/api/phoneNumber.d.mts +1 -1
- package/dist/api/phoneNumber.d.ts +1 -1
- package/dist/api/phoneNumber.js +1 -1
- package/dist/api/phoneNumber.mjs +1 -1
- package/dist/api/qrCode.d.mts +1 -1
- package/dist/api/qrCode.d.ts +1 -1
- package/dist/api/qrCode.js +1 -1
- package/dist/api/qrCode.mjs +1 -1
- package/dist/api/registration.d.mts +1 -1
- package/dist/api/registration.d.ts +1 -1
- package/dist/api/registration.js +1 -1
- package/dist/api/registration.mjs +1 -1
- package/dist/api/template.d.mts +1 -1
- package/dist/api/template.d.ts +1 -1
- package/dist/api/template.js +1 -1
- package/dist/api/template.mjs +1 -1
- package/dist/api/twoStepVerification.d.mts +1 -1
- package/dist/api/twoStepVerification.d.ts +1 -1
- package/dist/api/twoStepVerification.js +1 -1
- package/dist/api/waba.d.mts +1 -1
- package/dist/api/waba.d.ts +1 -1
- package/dist/api/waba.js +1 -1
- package/dist/api/waba.mjs +1 -1
- package/dist/{enums-Dn5Y1Nom.d.mts → enums-DLut7LZL.d.mts} +5 -1
- package/dist/{enums-Dn5Y1Nom.d.ts → enums-DLut7LZL.d.ts} +5 -1
- package/dist/httpsClient.d.mts +1 -1
- package/dist/httpsClient.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/request.d.mts +1 -1
- package/dist/request.d.ts +1 -1
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -1
- package/dist/request.mjs +1 -1
- package/dist/request.mjs.map +1 -1
- package/dist/types/base.d.mts +1 -1
- package/dist/types/base.d.ts +1 -1
- package/dist/types/businessProfile.d.mts +1 -1
- package/dist/types/businessProfile.d.ts +1 -1
- package/dist/types/config.d.mts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/encryption.d.mts +1 -1
- package/dist/types/encryption.d.ts +1 -1
- package/dist/types/enums.d.mts +1 -1
- package/dist/types/enums.d.ts +1 -1
- package/dist/types/enums.js +1 -1
- package/dist/types/enums.js.map +1 -1
- package/dist/types/enums.mjs +1 -1
- package/dist/types/enums.mjs.map +1 -1
- package/dist/types/flow.d.mts +1 -1
- package/dist/types/flow.d.ts +1 -1
- package/dist/types/httpsClient.d.mts +1 -1
- package/dist/types/httpsClient.d.ts +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/media.d.mts +1 -1
- package/dist/types/media.d.ts +1 -1
- package/dist/types/messages.d.mts +244 -3
- package/dist/types/messages.d.ts +244 -3
- package/dist/types/messages.js +1 -1
- package/dist/types/messages.js.map +1 -1
- package/dist/types/phoneNumber.d.mts +1 -1
- package/dist/types/phoneNumber.d.ts +1 -1
- package/dist/types/qrCode.d.mts +1 -1
- package/dist/types/qrCode.d.ts +1 -1
- package/dist/types/registration.d.mts +1 -1
- package/dist/types/registration.d.ts +1 -1
- package/dist/types/request.d.mts +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/template.d.mts +1 -1
- package/dist/types/template.d.ts +1 -1
- package/dist/types/twoStepVerification.d.mts +1 -1
- package/dist/types/twoStepVerification.d.ts +1 -1
- package/dist/types/waba.d.mts +1 -1
- package/dist/types/waba.d.ts +1 -1
- package/dist/types/whatsapp.d.mts +1 -1
- package/dist/types/whatsapp.d.ts +1 -1
- package/dist/utils/importConfig.d.mts +1 -1
- package/dist/utils/importConfig.d.ts +1 -1
- package/dist/utils/importConfig.js +1 -1
- package/dist/utils/importConfig.js.map +1 -1
- package/dist/utils/importConfig.mjs +1 -1
- package/dist/utils/importConfig.mjs.map +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/whatsapp.d.mts +1 -1
- package/dist/whatsapp.d.ts +1 -1
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +1 -1
package/dist/types/messages.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClass } from './base.js';
|
|
2
|
-
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-
|
|
2
|
+
import { I as InteractiveTypesEnum, b as ComponentTypesEnum, L as LanguagesEnum, P as ParametersTypesEnum, i as CurrencyCodesEnum, B as ButtonTypesEnum, a as ButtonPositionEnum, M as MessageTypesEnum } from '../enums-DLut7LZL.js';
|
|
3
3
|
import { RequesterResponseInterface, GeneralRequestBody } from './request.js';
|
|
4
4
|
import './config.js';
|
|
5
5
|
|
|
@@ -21,6 +21,10 @@ type GeneralMessageBody = GeneralRequestBody & {
|
|
|
21
21
|
type StatusObject = {
|
|
22
22
|
status: 'read';
|
|
23
23
|
message_id: string;
|
|
24
|
+
typing_indicator?: TypingIndicatorObject;
|
|
25
|
+
};
|
|
26
|
+
type TypingIndicatorObject = {
|
|
27
|
+
type: 'text';
|
|
24
28
|
};
|
|
25
29
|
type StatusRequestBody = GeneralMessageBody & StatusObject;
|
|
26
30
|
type ConTextObject = {
|
|
@@ -193,7 +197,88 @@ type ProductListInteractiveObject = {
|
|
|
193
197
|
header: HeaderObject;
|
|
194
198
|
action: ActionObject;
|
|
195
199
|
};
|
|
196
|
-
type
|
|
200
|
+
type CtaUrlParameters = {
|
|
201
|
+
display_text: string;
|
|
202
|
+
url: string;
|
|
203
|
+
};
|
|
204
|
+
type CtaUrlActionObject = {
|
|
205
|
+
name: 'cta_url';
|
|
206
|
+
parameters: CtaUrlParameters;
|
|
207
|
+
};
|
|
208
|
+
type CtaUrlInteractiveObject = {
|
|
209
|
+
type: InteractiveTypesEnum.CtaUrl;
|
|
210
|
+
body?: SimpleTextObject;
|
|
211
|
+
footer?: SimpleTextObject;
|
|
212
|
+
header?: HeaderObject;
|
|
213
|
+
action: CtaUrlActionObject;
|
|
214
|
+
};
|
|
215
|
+
type LocationRequestActionObject = {
|
|
216
|
+
name: 'send_location';
|
|
217
|
+
};
|
|
218
|
+
type LocationRequestInteractiveObject = {
|
|
219
|
+
type: InteractiveTypesEnum.LocationRequest;
|
|
220
|
+
body: SimpleTextObject;
|
|
221
|
+
footer?: SimpleTextObject;
|
|
222
|
+
header?: HeaderObject;
|
|
223
|
+
action: LocationRequestActionObject;
|
|
224
|
+
};
|
|
225
|
+
type AddressValues = {
|
|
226
|
+
name?: string;
|
|
227
|
+
phone_number?: string;
|
|
228
|
+
in_pin_code?: string;
|
|
229
|
+
house_number?: string;
|
|
230
|
+
floor_number?: string;
|
|
231
|
+
tower_number?: string;
|
|
232
|
+
building_name?: string;
|
|
233
|
+
address?: string;
|
|
234
|
+
landmark_area?: string;
|
|
235
|
+
city?: string;
|
|
236
|
+
state?: string;
|
|
237
|
+
};
|
|
238
|
+
type SavedAddress = {
|
|
239
|
+
id: string;
|
|
240
|
+
value: AddressValues;
|
|
241
|
+
};
|
|
242
|
+
type ValidationErrors = {
|
|
243
|
+
[key in keyof AddressValues]?: string;
|
|
244
|
+
};
|
|
245
|
+
type AddressMessageParameters = {
|
|
246
|
+
country: string;
|
|
247
|
+
values?: AddressValues;
|
|
248
|
+
saved_addresses?: SavedAddress[];
|
|
249
|
+
validation_errors?: ValidationErrors;
|
|
250
|
+
};
|
|
251
|
+
type AddressMessageActionObject = {
|
|
252
|
+
name: 'address_message';
|
|
253
|
+
parameters: AddressMessageParameters;
|
|
254
|
+
};
|
|
255
|
+
type AddressMessageInteractiveObject = {
|
|
256
|
+
type: InteractiveTypesEnum.AddressMessage;
|
|
257
|
+
body: SimpleTextObject;
|
|
258
|
+
footer?: SimpleTextObject;
|
|
259
|
+
header?: HeaderObject;
|
|
260
|
+
action: AddressMessageActionObject;
|
|
261
|
+
};
|
|
262
|
+
type FlowParameters = {
|
|
263
|
+
flow_token: string;
|
|
264
|
+
flow_id?: string;
|
|
265
|
+
flow_cta?: string;
|
|
266
|
+
screen?: string;
|
|
267
|
+
mode?: 'fullscreen' | 'drawer';
|
|
268
|
+
data?: Record<string, string>;
|
|
269
|
+
};
|
|
270
|
+
type FlowActionObject = {
|
|
271
|
+
name: 'flow';
|
|
272
|
+
parameters: FlowParameters;
|
|
273
|
+
};
|
|
274
|
+
type FlowInteractiveObject = {
|
|
275
|
+
type: InteractiveTypesEnum.Flow;
|
|
276
|
+
body: SimpleTextObject;
|
|
277
|
+
footer?: SimpleTextObject;
|
|
278
|
+
header?: HeaderObject;
|
|
279
|
+
action: FlowActionObject;
|
|
280
|
+
};
|
|
281
|
+
type InteractiveObject = ButtonInteractiveObject | ListInteractiveObject | ProductInteractiveObject | ProductListInteractiveObject | CtaUrlInteractiveObject | LocationRequestInteractiveObject | AddressMessageInteractiveObject | FlowInteractiveObject;
|
|
197
282
|
type InteractiveMessageRequestBody = MessageRequestBody<MessageTypesEnum.Interactive> & {
|
|
198
283
|
[MessageTypesEnum.Interactive]: InteractiveObject;
|
|
199
284
|
};
|
|
@@ -306,17 +391,173 @@ type MessagesResponse = GeneralMessageBody & {
|
|
|
306
391
|
];
|
|
307
392
|
};
|
|
308
393
|
declare class MessagesClass extends BaseClass {
|
|
394
|
+
/**
|
|
395
|
+
* Sends an audio message via WhatsApp
|
|
396
|
+
* @param body The audio media object
|
|
397
|
+
* @param recipient Recipient's phone number
|
|
398
|
+
* @param replyMessageId Optional message ID to reply to
|
|
399
|
+
* @returns Promise with the message response
|
|
400
|
+
*/
|
|
309
401
|
audio(body: AudioMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
402
|
+
/**
|
|
403
|
+
* Sends a contact card via WhatsApp
|
|
404
|
+
* @param body The contact object
|
|
405
|
+
* @param recipient Recipient's phone number
|
|
406
|
+
* @param replyMessageId Optional message ID to reply to
|
|
407
|
+
* @returns Promise with the message response
|
|
408
|
+
*/
|
|
310
409
|
contacts(body: [ContactObject], recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
410
|
+
/**
|
|
411
|
+
* Sends a document via WhatsApp
|
|
412
|
+
* @param body The document media object
|
|
413
|
+
* @param recipient Recipient's phone number
|
|
414
|
+
* @param replyMessageId Optional message ID to reply to
|
|
415
|
+
* @returns Promise with the message response
|
|
416
|
+
*/
|
|
311
417
|
document(body: DocumentMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
418
|
+
/**
|
|
419
|
+
* Sends an image via WhatsApp
|
|
420
|
+
* @param body The image media object
|
|
421
|
+
* @param recipient Recipient's phone number
|
|
422
|
+
* @param replyMessageId Optional message ID to reply to
|
|
423
|
+
* @returns Promise with the message response
|
|
424
|
+
*/
|
|
312
425
|
image(body: ImageMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
426
|
+
/**
|
|
427
|
+
* Sends an interactive message via WhatsApp
|
|
428
|
+
* @param body The interactive object (buttons, lists, etc.)
|
|
429
|
+
* @param recipient Recipient's phone number
|
|
430
|
+
* @param replyMessageId Optional message ID to reply to
|
|
431
|
+
* @returns Promise with the message response
|
|
432
|
+
*/
|
|
313
433
|
interactive(body: InteractiveObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
434
|
+
/**
|
|
435
|
+
* Sends a location via WhatsApp
|
|
436
|
+
* @param body The location object with coordinates
|
|
437
|
+
* @param recipient Recipient's phone number
|
|
438
|
+
* @param replyMessageId Optional message ID to reply to
|
|
439
|
+
* @returns Promise with the message response
|
|
440
|
+
*/
|
|
314
441
|
location(body: LocationObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
442
|
+
/**
|
|
443
|
+
* Updates message status (used for read receipts and typing indicators)
|
|
444
|
+
* @param body The status object
|
|
445
|
+
* @returns Promise with the response
|
|
446
|
+
*/
|
|
315
447
|
status(body: StatusObject): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
448
|
+
/**
|
|
449
|
+
* Sends a sticker via WhatsApp
|
|
450
|
+
* @param body The sticker media object
|
|
451
|
+
* @param recipient Recipient's phone number
|
|
452
|
+
* @param replyMessageId Optional message ID to reply to
|
|
453
|
+
* @returns Promise with the message response
|
|
454
|
+
*/
|
|
316
455
|
sticker(body: StickerMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
456
|
+
/**
|
|
457
|
+
* Sends a template message via WhatsApp
|
|
458
|
+
* @param body The message template object
|
|
459
|
+
* @param recipient Recipient's phone number
|
|
460
|
+
* @param replyMessageId Optional message ID to reply to
|
|
461
|
+
* @returns Promise with the message response
|
|
462
|
+
*/
|
|
317
463
|
template(body: MessageTemplateObject<ComponentTypesEnum>, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
464
|
+
/**
|
|
465
|
+
* Sends a text message via WhatsApp
|
|
466
|
+
* @param body The text object containing the message
|
|
467
|
+
* @param recipient Recipient's phone number
|
|
468
|
+
* @param replyMessageId Optional message ID to reply to
|
|
469
|
+
* @returns Promise with the message response
|
|
470
|
+
*/
|
|
318
471
|
text(body: TextObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
472
|
+
/**
|
|
473
|
+
* Sends a video via WhatsApp
|
|
474
|
+
* @param body The video media object
|
|
475
|
+
* @param recipient Recipient's phone number
|
|
476
|
+
* @param replyMessageId Optional message ID to reply to
|
|
477
|
+
* @returns Promise with the message response
|
|
478
|
+
*/
|
|
319
479
|
video(body: VideoMediaObject, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
480
|
+
/**
|
|
481
|
+
* Marks a message as read in WhatsApp
|
|
482
|
+
* @param messageId ID of the message to mark as read
|
|
483
|
+
* @returns Promise with the response
|
|
484
|
+
*/
|
|
485
|
+
markAsRead(messageId: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
486
|
+
/**
|
|
487
|
+
* Marks a message as read and shows a typing indicator in WhatsApp
|
|
488
|
+
* @param messageId ID of the message to mark as read
|
|
489
|
+
* @returns Promise with the response
|
|
490
|
+
*/
|
|
491
|
+
showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
492
|
+
/**
|
|
493
|
+
* Sends an interactive list message
|
|
494
|
+
* @param body The list message content
|
|
495
|
+
* @param recipient Recipient phone number
|
|
496
|
+
* @param replyMessageId Optional message ID to reply to
|
|
497
|
+
* @returns Promise with the response
|
|
498
|
+
*/
|
|
499
|
+
interactiveList(body: InteractiveObject & {
|
|
500
|
+
type: 'list';
|
|
501
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
502
|
+
/**
|
|
503
|
+
* Sends an interactive CTA URL message
|
|
504
|
+
* @param body The CTA URL message content
|
|
505
|
+
* @param recipient Recipient phone number
|
|
506
|
+
* @param replyMessageId Optional message ID to reply to
|
|
507
|
+
* @returns Promise with the response
|
|
508
|
+
*/
|
|
509
|
+
interactiveCtaUrl(body: InteractiveObject & {
|
|
510
|
+
type: 'cta_url';
|
|
511
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
512
|
+
/**
|
|
513
|
+
* Sends a location request message
|
|
514
|
+
* @param body The location request message content
|
|
515
|
+
* @param recipient Recipient phone number
|
|
516
|
+
* @param replyMessageId Optional message ID to reply to
|
|
517
|
+
* @returns Promise with the response
|
|
518
|
+
*/
|
|
519
|
+
interactiveLocationRequest(body: InteractiveObject & {
|
|
520
|
+
type: 'location_request_message';
|
|
521
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
522
|
+
/**
|
|
523
|
+
* Sends an address message to request shipping address from the user
|
|
524
|
+
* Note: This feature is only available for businesses based in India and their India customers
|
|
525
|
+
* @param body The address message content
|
|
526
|
+
* @param recipient Recipient phone number
|
|
527
|
+
* @param replyMessageId Optional message ID to reply to
|
|
528
|
+
* @returns Promise with the response
|
|
529
|
+
*/
|
|
530
|
+
interactiveAddressMessage(body: InteractiveObject & {
|
|
531
|
+
type: 'address_message';
|
|
532
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
533
|
+
/**
|
|
534
|
+
* Sends an interactive reply buttons message
|
|
535
|
+
* @param body The reply buttons message content
|
|
536
|
+
* @param recipient Recipient phone number
|
|
537
|
+
* @param replyMessageId Optional message ID to reply to
|
|
538
|
+
* @returns Promise with the response
|
|
539
|
+
*/
|
|
540
|
+
interactiveReplyButtons(body: InteractiveObject & {
|
|
541
|
+
type: 'button';
|
|
542
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
543
|
+
/**
|
|
544
|
+
* Sends a reaction to a message (emoji response)
|
|
545
|
+
* @param messageId ID of the message to react to
|
|
546
|
+
* @param emoji The emoji to send as reaction (e.g. "😀", "❤️", "👍")
|
|
547
|
+
* @param recipient Recipient phone number
|
|
548
|
+
* @returns Promise with the response
|
|
549
|
+
*/
|
|
550
|
+
reaction(messageId: string, emoji: string, recipient: number): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
551
|
+
/**
|
|
552
|
+
* Sends an interactive Flow message
|
|
553
|
+
* @param body The Flow message content
|
|
554
|
+
* @param recipient Recipient phone number
|
|
555
|
+
* @param replyMessageId Optional message ID to reply to
|
|
556
|
+
* @returns Promise with the response
|
|
557
|
+
*/
|
|
558
|
+
interactiveFlow(body: InteractiveObject & {
|
|
559
|
+
type: 'flow';
|
|
560
|
+
}, recipient: number, replyMessageId?: string): Promise<RequesterResponseInterface<MessagesResponse>>;
|
|
320
561
|
}
|
|
321
562
|
|
|
322
|
-
export { type AudioMediaObject, type AudioMessageRequestBody, type ContactObject, type ContactsMessageRequestBody, type DocumentMediaObject, type DocumentMessageRequestBody, type GeneralMessageBody, type ImageMediaObject, type ImageMessageRequestBody, type InteractiveMessageRequestBody, type InteractiveObject, type LocationMessageRequestBody, type LocationObject, type MessageRequestBody, type MessageTemplateObject, type MessageTemplateRequestBody, MessagesClass, type MessagesResponse, type ReactionMessageRequestBody, type StatusObject, type StatusRequestBody, type StickerMediaObject, type StickerMessageRequestBody, type TextMessageRequestBody, type TextObject, type VideoMediaObject, type VideoMessageRequestBody };
|
|
563
|
+
export { type AudioMediaObject, type AudioMessageRequestBody, type ContactObject, type ContactsMessageRequestBody, type DocumentMediaObject, type DocumentMessageRequestBody, type GeneralMessageBody, type ImageMediaObject, type ImageMessageRequestBody, type InteractiveMessageRequestBody, type InteractiveObject, type LocationMessageRequestBody, type LocationObject, type MessageRequestBody, type MessageTemplateObject, type MessageTemplateRequestBody, MessagesClass, type MessagesResponse, type ReactionMessageRequestBody, type StatusObject, type StatusRequestBody, type StickerMediaObject, type StickerMessageRequestBody, type TextMessageRequestBody, type TextObject, type TypingIndicatorObject, type VideoMediaObject, type VideoMessageRequestBody };
|
package/dist/types/messages.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of o(e))!c.call(t,s)&&s!==a&&n(t,s,{get:()=>e[s],enumerable:!(r=i(e,s))||r.enumerable});return t};var d=t=>p(n({},"__esModule",{value:!0}),t);var m={};module.exports=d(m);
|
|
2
2
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/messages.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { BaseClass } from './base';\nimport {\n MessageTypesEnum,\n ComponentTypesEnum,\n LanguagesEnum,\n ParametersTypesEnum,\n CurrencyCodesEnum,\n ButtonTypesEnum,\n ButtonPositionEnum,\n InteractiveTypesEnum,\n} from './enums';\nimport { GeneralRequestBody, RequesterResponseInterface } from './request';\n\nexport type GeneralMessageBody = GeneralRequestBody & {\n /**\n * The Meta messaging product name.\n * @default 'whatsapp'\n */\n messaging_product: 'whatsapp';\n};\n\nexport type StatusObject = {\n status: 'read';\n message_id: string;\n};\n\nexport type StatusRequestBody = GeneralMessageBody & StatusObject;\n\ntype ConTextObject = {\n message_id: string;\n};\n\nexport type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {\n recipient_type?: string;\n to: string;\n context?: ConTextObject;\n type?: T;\n};\n\ntype MetaAudioMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedAudioMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type AudioMediaObject = MetaAudioMediaObject | HostedAudioMediaObject;\n\nexport type AudioMessageRequestBody = MessageRequestBody<MessageTypesEnum.Audio> & {\n [MessageTypesEnum.Audio]: [AudioMediaObject];\n};\n\ntype AddressesObject = {\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype EmailObject = {\n email?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype NameObject = {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n};\n\ntype OrgObject = {\n company?: string;\n department?: string;\n title?: string;\n};\n\ntype PhoneObject = {\n phone?: 'PHONE_NUMBER';\n type?: 'CELL' | 'MAIN' | 'IPHONE' | 'HOME' | 'WORK' | string;\n wa_id?: string;\n};\n\ntype URLObject = {\n url?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\nexport type ContactObject = {\n addresses?: AddressesObject[];\n birthday?: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;\n emails?: EmailObject[];\n name: NameObject;\n org?: OrgObject;\n phones?: PhoneObject[];\n urls?: URLObject[];\n};\n\nexport type ContactsMessageRequestBody = MessageRequestBody<MessageTypesEnum.Contacts> & {\n [MessageTypesEnum.Contacts]: [ContactObject];\n};\n\ntype MetaDocumentMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n filename?: string;\n};\n\ntype HostedDocumentMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n filename?: string;\n};\n\nexport type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject;\n\nexport type DocumentMessageRequestBody = MessageRequestBody<MessageTypesEnum.Document> & {\n [MessageTypesEnum.Document]: [DocumentMediaObject];\n};\n\ntype MetaImageMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype HostedImageMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject;\n\nexport type ImageMessageRequestBody = MessageRequestBody<MessageTypesEnum.Image> & {\n [MessageTypesEnum.Image]: [ImageMediaObject];\n};\n\ntype ProductObject = {\n product_retailer_id: string;\n};\n\ntype SimpleTextObject = {\n text: string;\n};\n\ntype RowObject = {\n id: string;\n title: string;\n description?: string;\n};\n\ntype MultiProductSectionObject = {\n product_items: ProductObject[];\n rows?: never;\n title?: string;\n};\n\ntype ListSectionObject = {\n product_items?: never;\n rows: RowObject[];\n title?: string;\n};\n\ntype SectionObject = MultiProductSectionObject | ListSectionObject;\n\ntype ButtonObject = {\n title: string;\n id: string;\n};\n\ntype ReplyButtonObject = {\n type: 'reply';\n reply: ButtonObject;\n};\n\ntype ActionObject = {\n button?: string;\n buttons?: ReplyButtonObject[];\n catalog_id?: string;\n product_retailer_id?: string;\n sections?: SectionObject;\n};\n\ntype HeaderObject = {\n type: 'document' | 'image' | 'text' | 'video';\n document?: DocumentMediaObject;\n image?: ImageMediaObject;\n text?: string;\n video?: VideoMediaObject;\n};\n\ntype ButtonInteractiveObject = {\n type: InteractiveTypesEnum.Button;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ListInteractiveObject = {\n type: InteractiveTypesEnum.List;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductInteractiveObject = {\n type: InteractiveTypesEnum.Product;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductListInteractiveObject = {\n type: InteractiveTypesEnum.ProductList;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header: HeaderObject;\n action: ActionObject;\n};\n\nexport type InteractiveObject =\n | ButtonInteractiveObject\n | ListInteractiveObject\n | ProductInteractiveObject\n | ProductListInteractiveObject;\n\nexport type InteractiveMessageRequestBody = MessageRequestBody<MessageTypesEnum.Interactive> & {\n [MessageTypesEnum.Interactive]: InteractiveObject;\n};\n\ntype MetaStickerMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedStickerMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type StickerMediaObject = MetaStickerMediaObject | HostedStickerMediaObject;\n\nexport type StickerMessageRequestBody = MessageRequestBody<MessageTypesEnum.Sticker> & {\n [MessageTypesEnum.Sticker]: [StickerMediaObject];\n};\n\ntype ReActionObject = {\n message_id: string;\n emoji: string;\n};\n\nexport type ReactionMessageRequestBody = MessageRequestBody<MessageTypesEnum.Reaction> & ReActionObject;\n\nexport type TextObject = {\n body: string;\n preview_url?: boolean;\n};\n\nexport type TextMessageRequestBody = MessageRequestBody<MessageTypesEnum.Text> & {\n [MessageTypesEnum.Text]: [TextObject];\n};\n\ntype MetaHostedVideoMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype SelfHostedVideoMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type VideoMediaObject = MetaHostedVideoMediaObject | SelfHostedVideoMediaObject;\n\nexport type VideoMessageRequestBody = MessageRequestBody<MessageTypesEnum.Video> & {\n [MessageTypesEnum.Video]: [VideoMediaObject];\n};\n\ntype LanguageObject = {\n policy: 'deterministic';\n code: LanguagesEnum;\n};\n\ntype ParametersObject<T extends ParametersTypesEnum> = {\n type: T;\n};\n\ntype TextParametersObject = ParametersObject<ParametersTypesEnum.Text> & SimpleTextObject;\n\ntype CurrencyObject = {\n fallback_value: string;\n code: CurrencyCodesEnum;\n amount_1000: number;\n};\n\ntype CurrencyParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n currency: CurrencyObject;\n};\n\ntype DateTimeObject = {\n fallback_value: string;\n};\n\ntype DateTimeParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n date_time: DateTimeObject;\n};\n\ntype DocumentParametersObject = ParametersObject<ParametersTypesEnum.Document> & DocumentMediaObject;\n\ntype ImageParametersObject = ParametersObject<ParametersTypesEnum.Image> & ImageMediaObject;\n\ntype VideoParametersObject = ParametersObject<ParametersTypesEnum.Video> & VideoMediaObject;\n\ntype QuickReplyButtonParametersObject = {\n type: ParametersTypesEnum.Payload;\n payload: string;\n};\n\ntype URLButtonParametersObject = SimpleTextObject & {\n type: ParametersTypesEnum.Text;\n};\n\ntype ButtonParameterObject = QuickReplyButtonParametersObject | URLButtonParametersObject;\n\ntype ComponentObject<T extends ComponentTypesEnum> = {\n type: T;\n parameters: (\n | CurrencyParametersObject\n | DateTimeParametersObject\n | DocumentParametersObject\n | ImageParametersObject\n | TextParametersObject\n | VideoParametersObject\n )[];\n};\n\ntype ButtonComponentObject = ComponentObject<ComponentTypesEnum.Button> & {\n parameters: ButtonParameterObject;\n sub_type: ButtonTypesEnum;\n index: ButtonPositionEnum;\n};\n\nexport type MessageTemplateObject<T extends ComponentTypesEnum> = {\n name: string;\n language: LanguageObject;\n components?: (ComponentObject<T> | ButtonComponentObject)[];\n};\n\nexport type MessageTemplateRequestBody<T extends ComponentTypesEnum> = MessageRequestBody<MessageTypesEnum.Template> &\n MessageTemplateObject<T>;\n\nexport type LocationObject = {\n longitude: number;\n latitude: number;\n name?: string;\n address?: string;\n};\n\nexport type LocationMessageRequestBody = MessageRequestBody<MessageTypesEnum.Location> & {\n [MessageTypesEnum.Location]: [LocationObject];\n};\n\nexport type MessagesResponse = GeneralMessageBody & {\n contacts: [\n {\n input: string;\n wa_id: string;\n },\n ];\n messages: [\n {\n id: string;\n },\n ];\n};\n\nexport declare class MessagesClass extends BaseClass {\n audio(\n body: AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n contacts(\n body: [ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n document(\n body: DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n image(\n body: ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n interactive(\n body: InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n location(\n body: LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n status(body: StatusObject): Promise<RequesterResponseInterface<MessagesResponse>>;\n sticker(\n body: StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n template(\n body: MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n text(\n body: TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n video(\n body: VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["messages_exports","__toCommonJS"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/messages.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { BaseClass } from './base';\nimport {\n MessageTypesEnum,\n ComponentTypesEnum,\n LanguagesEnum,\n ParametersTypesEnum,\n CurrencyCodesEnum,\n ButtonTypesEnum,\n ButtonPositionEnum,\n InteractiveTypesEnum,\n} from './enums';\nimport { GeneralRequestBody, RequesterResponseInterface } from './request';\n\nexport type GeneralMessageBody = GeneralRequestBody & {\n /**\n * The Meta messaging product name.\n * @default 'whatsapp'\n */\n messaging_product: 'whatsapp';\n};\n\nexport type StatusObject = {\n status: 'read';\n message_id: string;\n typing_indicator?: TypingIndicatorObject;\n};\n\nexport type TypingIndicatorObject = {\n type: 'text';\n};\n\nexport type StatusRequestBody = GeneralMessageBody & StatusObject;\n\ntype ConTextObject = {\n message_id: string;\n};\n\nexport type MessageRequestBody<T extends MessageTypesEnum> = GeneralMessageBody & {\n recipient_type?: string;\n to: string;\n context?: ConTextObject;\n type?: T;\n};\n\ntype MetaAudioMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedAudioMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type AudioMediaObject = MetaAudioMediaObject | HostedAudioMediaObject;\n\nexport type AudioMessageRequestBody = MessageRequestBody<MessageTypesEnum.Audio> & {\n [MessageTypesEnum.Audio]: [AudioMediaObject];\n};\n\ntype AddressesObject = {\n street?: string;\n city?: string;\n state?: string;\n zip?: string;\n country?: string;\n country_code?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype EmailObject = {\n email?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\ntype NameObject = {\n formatted_name: string;\n first_name?: string;\n last_name?: string;\n middle_name?: string;\n suffix?: string;\n prefix?: string;\n};\n\ntype OrgObject = {\n company?: string;\n department?: string;\n title?: string;\n};\n\ntype PhoneObject = {\n phone?: 'PHONE_NUMBER';\n type?: 'CELL' | 'MAIN' | 'IPHONE' | 'HOME' | 'WORK' | string;\n wa_id?: string;\n};\n\ntype URLObject = {\n url?: string;\n type?: 'HOME' | 'WORK' | string;\n};\n\nexport type ContactObject = {\n addresses?: AddressesObject[];\n birthday?: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;\n emails?: EmailObject[];\n name: NameObject;\n org?: OrgObject;\n phones?: PhoneObject[];\n urls?: URLObject[];\n};\n\nexport type ContactsMessageRequestBody = MessageRequestBody<MessageTypesEnum.Contacts> & {\n [MessageTypesEnum.Contacts]: [ContactObject];\n};\n\ntype MetaDocumentMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n filename?: string;\n};\n\ntype HostedDocumentMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n filename?: string;\n};\n\nexport type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject;\n\nexport type DocumentMessageRequestBody = MessageRequestBody<MessageTypesEnum.Document> & {\n [MessageTypesEnum.Document]: [DocumentMediaObject];\n};\n\ntype MetaImageMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype HostedImageMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject;\n\nexport type ImageMessageRequestBody = MessageRequestBody<MessageTypesEnum.Image> & {\n [MessageTypesEnum.Image]: [ImageMediaObject];\n};\n\ntype ProductObject = {\n product_retailer_id: string;\n};\n\ntype SimpleTextObject = {\n text: string;\n};\n\ntype RowObject = {\n id: string;\n title: string;\n description?: string;\n};\n\ntype MultiProductSectionObject = {\n product_items: ProductObject[];\n rows?: never;\n title?: string;\n};\n\ntype ListSectionObject = {\n product_items?: never;\n rows: RowObject[];\n title?: string;\n};\n\ntype SectionObject = MultiProductSectionObject | ListSectionObject;\n\ntype ButtonObject = {\n title: string;\n id: string;\n};\n\ntype ReplyButtonObject = {\n type: 'reply';\n reply: ButtonObject;\n};\n\ntype ActionObject = {\n button?: string;\n buttons?: ReplyButtonObject[];\n catalog_id?: string;\n product_retailer_id?: string;\n sections?: SectionObject;\n};\n\ntype HeaderObject = {\n type: 'document' | 'image' | 'text' | 'video';\n document?: DocumentMediaObject;\n image?: ImageMediaObject;\n text?: string;\n video?: VideoMediaObject;\n};\n\ntype ButtonInteractiveObject = {\n type: InteractiveTypesEnum.Button;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ListInteractiveObject = {\n type: InteractiveTypesEnum.List;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductInteractiveObject = {\n type: InteractiveTypesEnum.Product;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: ActionObject;\n};\n\ntype ProductListInteractiveObject = {\n type: InteractiveTypesEnum.ProductList;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header: HeaderObject;\n action: ActionObject;\n};\n\ntype CtaUrlParameters = {\n display_text: string;\n url: string;\n};\n\ntype CtaUrlActionObject = {\n name: 'cta_url';\n parameters: CtaUrlParameters;\n};\n\ntype CtaUrlInteractiveObject = {\n type: InteractiveTypesEnum.CtaUrl;\n body?: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: CtaUrlActionObject;\n};\n\ntype LocationRequestActionObject = {\n name: 'send_location';\n};\n\ntype LocationRequestInteractiveObject = {\n type: InteractiveTypesEnum.LocationRequest;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: LocationRequestActionObject;\n};\n\n// Address message types\ntype AddressValues = {\n name?: string;\n phone_number?: string;\n in_pin_code?: string;\n house_number?: string;\n floor_number?: string;\n tower_number?: string;\n building_name?: string;\n address?: string;\n landmark_area?: string;\n city?: string;\n state?: string;\n};\n\ntype SavedAddress = {\n id: string;\n value: AddressValues;\n};\n\ntype ValidationErrors = {\n [key in keyof AddressValues]?: string;\n};\n\ntype AddressMessageParameters = {\n country: string; // ISO country code, e.g., \"IN\" for India\n values?: AddressValues;\n saved_addresses?: SavedAddress[];\n validation_errors?: ValidationErrors;\n};\n\ntype AddressMessageActionObject = {\n name: 'address_message';\n parameters: AddressMessageParameters;\n};\n\ntype AddressMessageInteractiveObject = {\n type: InteractiveTypesEnum.AddressMessage;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: AddressMessageActionObject;\n};\n\n// Flow message types\ntype FlowParameters = {\n flow_token: string;\n flow_id?: string;\n flow_cta?: string;\n screen?: string;\n mode?: 'fullscreen' | 'drawer';\n data?: Record<string, string>;\n};\n\ntype FlowActionObject = {\n name: 'flow';\n parameters: FlowParameters;\n};\n\ntype FlowInteractiveObject = {\n type: InteractiveTypesEnum.Flow;\n body: SimpleTextObject;\n footer?: SimpleTextObject;\n header?: HeaderObject;\n action: FlowActionObject;\n};\n\n// Update InteractiveObject type\nexport type InteractiveObject =\n | ButtonInteractiveObject\n | ListInteractiveObject\n | ProductInteractiveObject\n | ProductListInteractiveObject\n | CtaUrlInteractiveObject\n | LocationRequestInteractiveObject\n | AddressMessageInteractiveObject\n | FlowInteractiveObject;\n\nexport type InteractiveMessageRequestBody = MessageRequestBody<MessageTypesEnum.Interactive> & {\n [MessageTypesEnum.Interactive]: InteractiveObject;\n};\n\ntype MetaStickerMediaObject = {\n id: string;\n link?: never;\n};\n\ntype HostedStickerMediaObject = {\n id?: never;\n link: string;\n};\n\nexport type StickerMediaObject = MetaStickerMediaObject | HostedStickerMediaObject;\n\nexport type StickerMessageRequestBody = MessageRequestBody<MessageTypesEnum.Sticker> & {\n [MessageTypesEnum.Sticker]: [StickerMediaObject];\n};\n\ntype ReActionObject = {\n message_id: string;\n emoji: string;\n};\n\nexport type ReactionMessageRequestBody = MessageRequestBody<MessageTypesEnum.Reaction> & ReActionObject;\n\nexport type TextObject = {\n body: string;\n preview_url?: boolean;\n};\n\nexport type TextMessageRequestBody = MessageRequestBody<MessageTypesEnum.Text> & {\n [MessageTypesEnum.Text]: [TextObject];\n};\n\ntype MetaHostedVideoMediaObject = {\n id: string;\n link?: never;\n caption?: string;\n};\n\ntype SelfHostedVideoMediaObject = {\n id?: never;\n link: string;\n caption?: string;\n};\n\nexport type VideoMediaObject = MetaHostedVideoMediaObject | SelfHostedVideoMediaObject;\n\nexport type VideoMessageRequestBody = MessageRequestBody<MessageTypesEnum.Video> & {\n [MessageTypesEnum.Video]: [VideoMediaObject];\n};\n\ntype LanguageObject = {\n policy: 'deterministic';\n code: LanguagesEnum;\n};\n\ntype ParametersObject<T extends ParametersTypesEnum> = {\n type: T;\n};\n\ntype TextParametersObject = ParametersObject<ParametersTypesEnum.Text> & SimpleTextObject;\n\ntype CurrencyObject = {\n fallback_value: string;\n code: CurrencyCodesEnum;\n amount_1000: number;\n};\n\ntype CurrencyParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n currency: CurrencyObject;\n};\n\ntype DateTimeObject = {\n fallback_value: string;\n};\n\ntype DateTimeParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {\n date_time: DateTimeObject;\n};\n\ntype DocumentParametersObject = ParametersObject<ParametersTypesEnum.Document> & DocumentMediaObject;\n\ntype ImageParametersObject = ParametersObject<ParametersTypesEnum.Image> & ImageMediaObject;\n\ntype VideoParametersObject = ParametersObject<ParametersTypesEnum.Video> & VideoMediaObject;\n\ntype QuickReplyButtonParametersObject = {\n type: ParametersTypesEnum.Payload;\n payload: string;\n};\n\ntype URLButtonParametersObject = SimpleTextObject & {\n type: ParametersTypesEnum.Text;\n};\n\ntype ButtonParameterObject = QuickReplyButtonParametersObject | URLButtonParametersObject;\n\ntype ComponentObject<T extends ComponentTypesEnum> = {\n type: T;\n parameters: (\n | CurrencyParametersObject\n | DateTimeParametersObject\n | DocumentParametersObject\n | ImageParametersObject\n | TextParametersObject\n | VideoParametersObject\n )[];\n};\n\ntype ButtonComponentObject = ComponentObject<ComponentTypesEnum.Button> & {\n parameters: ButtonParameterObject;\n sub_type: ButtonTypesEnum;\n index: ButtonPositionEnum;\n};\n\nexport type MessageTemplateObject<T extends ComponentTypesEnum> = {\n name: string;\n language: LanguageObject;\n components?: (ComponentObject<T> | ButtonComponentObject)[];\n};\n\nexport type MessageTemplateRequestBody<T extends ComponentTypesEnum> = MessageRequestBody<MessageTypesEnum.Template> &\n MessageTemplateObject<T>;\n\nexport type LocationObject = {\n longitude: number;\n latitude: number;\n name?: string;\n address?: string;\n};\n\nexport type LocationMessageRequestBody = MessageRequestBody<MessageTypesEnum.Location> & {\n [MessageTypesEnum.Location]: [LocationObject];\n};\n\nexport type MessagesResponse = GeneralMessageBody & {\n contacts: [\n {\n input: string;\n wa_id: string;\n },\n ];\n messages: [\n {\n id: string;\n },\n ];\n};\n\nexport declare class MessagesClass extends BaseClass {\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 audio(\n body: AudioMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 contacts(\n body: [ContactObject],\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 document(\n body: DocumentMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 image(\n body: ImageMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactive(\n body: InteractiveObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 location(\n body: LocationObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 status(body: StatusObject): Promise<RequesterResponseInterface<MessagesResponse>>;\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 sticker(\n body: StickerMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 template(\n body: MessageTemplateObject<ComponentTypesEnum>,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 text(\n body: TextObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 video(\n body: VideoMediaObject,\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n\n // New methods\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 markAsRead(messageId: string): Promise<RequesterResponseInterface<MessagesResponse>>;\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 showTypingIndicator(messageId: string): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveList(\n body: InteractiveObject & { type: 'list' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveCtaUrl(\n body: InteractiveObject & { type: 'cta_url' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveLocationRequest(\n body: InteractiveObject & { type: 'location_request_message' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveAddressMessage(\n body: InteractiveObject & { type: 'address_message' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveReplyButtons(\n body: InteractiveObject & { type: 'button' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 reaction(\n messageId: string,\n emoji: string,\n recipient: number,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\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 interactiveFlow(\n body: InteractiveObject & { type: 'flow' },\n recipient: number,\n replyMessageId?: string,\n ): Promise<RequesterResponseInterface<MessagesResponse>>;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["messages_exports","__toCommonJS"]}
|
package/dist/types/qrCode.d.mts
CHANGED
package/dist/types/qrCode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequesterResponseInterface, ResponseSuccess } from './request.mjs';
|
|
2
|
-
import { j as DataLocalizationRegionEnum } from '../enums-
|
|
2
|
+
import { j as DataLocalizationRegionEnum } from '../enums-DLut7LZL.mjs';
|
|
3
3
|
|
|
4
4
|
type RegistrationRequest = {
|
|
5
5
|
messaging_product: 'whatsapp';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequesterResponseInterface, ResponseSuccess } from './request.js';
|
|
2
|
-
import { j as DataLocalizationRegionEnum } from '../enums-
|
|
2
|
+
import { j as DataLocalizationRegionEnum } from '../enums-DLut7LZL.js';
|
|
3
3
|
|
|
4
4
|
type RegistrationRequest = {
|
|
5
5
|
messaging_product: 'whatsapp';
|
package/dist/types/request.d.mts
CHANGED
package/dist/types/request.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-DLut7LZL.mjs';
|
|
2
2
|
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.mjs';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
package/dist/types/template.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-
|
|
1
|
+
import { L as LanguagesEnum, C as CategoryEnum, T as TemplateStatusEnum } from '../enums-DLut7LZL.js';
|
|
2
2
|
import { RequesterResponseInterface, GeneralRequestBody, ResponseSuccess, ResponsePagination } from './request.js';
|
|
3
3
|
|
|
4
4
|
type TemplateFormat = 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION';
|
package/dist/types/waba.d.mts
CHANGED
package/dist/types/waba.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { RegistrationClass } from './registration.mjs';
|
|
|
9
9
|
import { TemplateClass } from './template.mjs';
|
|
10
10
|
import { TwoStepVerificationClass } from './twoStepVerification.mjs';
|
|
11
11
|
import { WABAClass } from './waba.mjs';
|
|
12
|
-
import '../enums-
|
|
12
|
+
import '../enums-DLut7LZL.mjs';
|
|
13
13
|
import './request.mjs';
|
|
14
14
|
import './base.mjs';
|
|
15
15
|
import './config.mjs';
|
package/dist/types/whatsapp.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { RegistrationClass } from './registration.js';
|
|
|
9
9
|
import { TemplateClass } from './template.js';
|
|
10
10
|
import { TwoStepVerificationClass } from './twoStepVerification.js';
|
|
11
11
|
import { WABAClass } from './waba.js';
|
|
12
|
-
import '../enums-
|
|
12
|
+
import '../enums-DLut7LZL.js';
|
|
13
13
|
import './request.js';
|
|
14
14
|
import './base.js';
|
|
15
15
|
import './config.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WhatsAppConfig } from '../types/whatsapp.mjs';
|
|
2
2
|
import { WabaConfigType } from '../types/config.mjs';
|
|
3
3
|
import '../types/businessProfile.mjs';
|
|
4
|
-
import '../enums-
|
|
4
|
+
import '../enums-DLut7LZL.mjs';
|
|
5
5
|
import '../types/request.mjs';
|
|
6
6
|
import '../types/encryption.mjs';
|
|
7
7
|
import '../types/flow.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WhatsAppConfig } from '../types/whatsapp.js';
|
|
2
2
|
import { WabaConfigType } from '../types/config.js';
|
|
3
3
|
import '../types/businessProfile.js';
|
|
4
|
-
import '../enums-
|
|
4
|
+
import '../enums-DLut7LZL.js';
|
|
5
5
|
import '../types/request.js';
|
|
6
6
|
import '../types/encryption.js';
|
|
7
7
|
import '../types/flow.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var B=(S,A)=>{for(var R in A)P(S,R,{get:A[R],enumerable:!0})},G=(S,A,R,U)=>{if(A&&typeof A=="object"||typeof A=="function")for(let D of O(A))!_.call(S,D)&&D!==R&&P(S,D,{get:()=>A[D],enumerable:!(U=I(A,D))||U.enumerable});return S};var T=S=>G(P({},"__esModule",{value:!0}),S);var X={};B(X,{importConfig:()=>l});module.exports=T(X);var N=class{name;debug;constructor(A,R=!1){this.name=A,this.debug=R}log(...A){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...A])}}error(...A){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...A])}warn(...A){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...A])}info(...A){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...A])}};var K="UTILS",M=!1,t=new N(K,process.env.DEBUG==="true"||M),i="graph.facebook.com",p=3e3,F=30,H=2e4,L=S=>{if(!process.env.WA_PHONE_NUMBER_ID&&!S?.phoneNumberId)throw t.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!S?.accessToken)throw t.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},l=S=>{L(S);let A={WA_BASE_URL:process.env.WA_BASE_URL||i,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:S?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:S?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||p,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||F,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||H,DEBUG:process.env.DEBUG==="true"};return t.log(`Configuration loaded for App Id ${A.M4D_APP_ID}`),A};0&&(module.exports={importConfig});
|
|
2
2
|
//# sourceMappingURL=importConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !config?.phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !config?.phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.BaseURL]: process.env.WA_BASE_URL || DEFAULT_BASE_URL,\n [WabaConfigEnum.AppId]: process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || parseInt(process.env.WA_PHONE_NUMBER_ID || ''),\n [WabaConfigEnum.BusinessAcctId]: process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]: process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]: parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') || DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]: parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\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"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,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,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,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,EDxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAmB,qBACnBC,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,oBAAiC,CAACA,GAAQ,cACvD,MAAAP,EAAO,IAAI,iGAAiG,EACtG,IAAI,MAAM,0CAA0C,EAG9D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACO,GAAQ,YACrD,MAAAP,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaQ,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,YAAyB,QAAQ,IAAI,aAAeR,EACpD,WAAuB,QAAQ,IAAI,YAAc,GACjD,eAA2B,QAAQ,IAAI,gBAAkB,GACzD,mBAA+BO,GAAa,eAAiB,SAAS,QAAQ,IAAI,oBAAsB,EAAE,EAC1G,uBAAgC,QAAQ,IAAI,wBAA0B,GACtE,kBAA4B,QAAQ,IAAI,mBAAqB,GAC7D,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiC,QAAQ,IAAI,kBAAoB,GACjE,2BAA0C,QAAQ,IAAI,4BAA8B,GACpF,cAA8B,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC3E,uBACG,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GAAKC,EACzD,gBAAgC,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKC,EAC/E,MAAuB,QAAQ,IAAI,QAAU,MAClD,EAEA,OAAAL,EAAO,IAAI,mCAAmCU,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["importConfig_exports","__export","importConfig","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_BASE_URL","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var D=class{name;debug;constructor(R,A=!1){this.name=R,this.debug=A}log(...R){if(this.debug){let A=`[ ${Date.now()} ]`;this.name&&(A+=` - ${this.name}`),console.log.apply(console,[A,": ",...R])}}error(...R){let A=`[ ${Date.now()} ] - ERROR`;this.name&&(A+=` - ${this.name}`),console.error.apply(console,[A,": ",...R])}warn(...R){let A=`[ ${Date.now()} ] - WARN`;this.name&&(A+=` - ${this.name}`),console.warn.apply(console,[A,": ",...R])}info(...R){let A=`[ ${Date.now()} ] - INFO`;this.name&&(A+=` - ${this.name}`),console.info.apply(console,[A,": ",...R])}};var
|
|
1
|
+
var D=class{name;debug;constructor(R,A=!1){this.name=R,this.debug=A}log(...R){if(this.debug){let A=`[ ${Date.now()} ]`;this.name&&(A+=` - ${this.name}`),console.log.apply(console,[A,": ",...R])}}error(...R){let A=`[ ${Date.now()} ] - ERROR`;this.name&&(A+=` - ${this.name}`),console.error.apply(console,[A,": ",...R])}warn(...R){let A=`[ ${Date.now()} ] - WARN`;this.name&&(A+=` - ${this.name}`),console.warn.apply(console,[A,": ",...R])}info(...R){let A=`[ ${Date.now()} ] - INFO`;this.name&&(A+=` - ${this.name}`),console.info.apply(console,[A,": ",...R])}};var P="UTILS",t=!1,N=new D(P,process.env.DEBUG==="true"||t),U="graph.facebook.com",I=3e3,O=30,_=2e4,B=S=>{if(!process.env.WA_PHONE_NUMBER_ID&&!S?.phoneNumberId)throw N.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!S?.accessToken)throw N.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},p=S=>{B(S);let R={WA_BASE_URL:process.env.WA_BASE_URL||U,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:S?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:S?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||I,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||O,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||_,DEBUG:process.env.DEBUG==="true"};return N.log(`Configuration loaded for App Id ${R.M4D_APP_ID}`),R};export{p as importConfig};
|
|
2
2
|
//# sourceMappingURL=importConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.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 { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !config?.phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.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 { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_BASE_URL = 'graph.facebook.com';\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.PhoneNumberId] && !config?.phoneNumberId) {\n LOGGER.log(`Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined.`);\n throw new Error('Missing WhatsApp sender phone number Id.');\n }\n\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.BaseURL]: process.env.WA_BASE_URL || DEFAULT_BASE_URL,\n [WabaConfigEnum.AppId]: process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || parseInt(process.env.WA_PHONE_NUMBER_ID || ''),\n [WabaConfigEnum.BusinessAcctId]: process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]: process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]: parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') || DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]: parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: process.env.DEBUG === 'true',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\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,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAmB,qBACnBC,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,oBAAiC,CAACA,GAAQ,cACvD,MAAAP,EAAO,IAAI,iGAAiG,EACtG,IAAI,MAAM,0CAA0C,EAG9D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACO,GAAQ,YACrD,MAAAP,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaQ,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,YAAyB,QAAQ,IAAI,aAAeR,EACpD,WAAuB,QAAQ,IAAI,YAAc,GACjD,eAA2B,QAAQ,IAAI,gBAAkB,GACzD,mBAA+BO,GAAa,eAAiB,SAAS,QAAQ,IAAI,oBAAsB,EAAE,EAC1G,uBAAgC,QAAQ,IAAI,wBAA0B,GACtE,kBAA4B,QAAQ,IAAI,mBAAqB,GAC7D,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiC,QAAQ,IAAI,kBAAoB,GACjE,2BAA0C,QAAQ,IAAI,4BAA8B,GACpF,cAA8B,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC3E,uBACG,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GAAKC,EACzD,gBAAgC,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKC,EAC/E,MAAuB,QAAQ,IAAI,QAAU,MAClD,EAEA,OAAAL,EAAO,IAAI,mCAAmCU,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_BASE_URL","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|