meta-cloud-api 1.1.5 → 1.1.6

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.
Files changed (80) hide show
  1. package/dist/api/flow/types/common.d.ts +406 -0
  2. package/dist/api/flow/types/common.d.ts.map +1 -0
  3. package/dist/api/flow/types/common.js +51 -0
  4. package/dist/api/flow/types/common.js.map +1 -0
  5. package/dist/api/flow/types/index.d.ts +1 -0
  6. package/dist/api/flow/types/index.js +1 -0
  7. package/dist/api/media/types/common.d.ts +32 -0
  8. package/dist/api/media/types/common.d.ts.map +1 -0
  9. package/dist/api/media/types/index.d.ts +1 -0
  10. package/dist/api/messages/types/common.d.ts +99 -0
  11. package/dist/api/messages/types/common.d.ts.map +1 -0
  12. package/dist/api/messages/types/contact.d.ts +54 -0
  13. package/dist/api/messages/types/contact.d.ts.map +1 -0
  14. package/dist/api/messages/types/index.d.ts +8 -0
  15. package/dist/api/messages/types/interactive.d.ts +182 -0
  16. package/dist/api/messages/types/interactive.d.ts.map +1 -0
  17. package/dist/api/messages/types/location.d.ts +16 -0
  18. package/dist/api/messages/types/location.d.ts.map +1 -0
  19. package/dist/api/messages/types/media.d.ts +55 -0
  20. package/dist/api/messages/types/media.d.ts.map +1 -0
  21. package/dist/api/messages/types/reaction.d.ts +17 -0
  22. package/dist/api/messages/types/reaction.d.ts.map +1 -0
  23. package/dist/api/messages/types/template.d.ts +72 -0
  24. package/dist/api/messages/types/template.d.ts.map +1 -0
  25. package/dist/api/messages/types/text.d.ts +17 -0
  26. package/dist/api/messages/types/text.d.ts.map +1 -0
  27. package/dist/api/phone/types/common.d.ts +83 -0
  28. package/dist/api/phone/types/common.d.ts.map +1 -0
  29. package/dist/api/phone/types/index.d.ts +1 -0
  30. package/dist/api/profile/types/common.d.ts +149 -0
  31. package/dist/api/profile/types/common.d.ts.map +1 -0
  32. package/dist/api/profile/types/index.d.ts +2 -0
  33. package/dist/api/profile/types/upload.d.ts +73 -0
  34. package/dist/api/profile/types/upload.d.ts.map +1 -0
  35. package/dist/api/qrCode/types/common.d.ts +28 -0
  36. package/dist/api/qrCode/types/common.d.ts.map +1 -0
  37. package/dist/api/qrCode/types/index.d.ts +1 -0
  38. package/dist/api/template/types/common.d.ts +155 -0
  39. package/dist/api/template/types/common.d.ts.map +1 -0
  40. package/dist/api/template/types/factory.d.ts +202 -0
  41. package/dist/api/template/types/factory.d.ts.map +1 -0
  42. package/dist/api/template/types/index.d.ts +2 -0
  43. package/dist/api/waba/types/common.d.ts +122 -0
  44. package/dist/api/waba/types/common.d.ts.map +1 -0
  45. package/dist/api/waba/types/common.js +44 -0
  46. package/dist/api/waba/types/common.js.map +1 -0
  47. package/dist/api/waba/types/index.d.ts +1 -0
  48. package/dist/api/waba/types/index.js +1 -0
  49. package/dist/client.d.ts +25 -0
  50. package/dist/client.js +6 -0
  51. package/dist/core/webhook/types.d.ts +737 -0
  52. package/dist/core/webhook/types.d.ts.map +1 -0
  53. package/dist/enums.d.ts +1 -1
  54. package/dist/index.d.ts +2587 -2587
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -1
  57. package/dist/types/base.d.ts.map +1 -0
  58. package/dist/types/config.d.ts.map +1 -0
  59. package/dist/types/enums.d.ts +668 -0
  60. package/dist/types/enums.d.ts.map +1 -0
  61. package/dist/types/enums.js +681 -0
  62. package/dist/types/enums.js.map +1 -0
  63. package/dist/types/httpsClient.d.ts.map +1 -0
  64. package/dist/types/index.d.ts +24 -0
  65. package/dist/types/index.js +5 -0
  66. package/dist/types/logger.d.ts.map +1 -0
  67. package/dist/{request.d.ts → types/request.d.ts} +1 -1
  68. package/dist/types/request.d.ts.map +1 -0
  69. package/dist/utils/isMetaError.d.ts +23 -0
  70. package/dist/utils/isMetaError.d.ts.map +1 -0
  71. package/package.json +7 -1
  72. package/dist/base.d.ts.map +0 -1
  73. package/dist/config.d.ts.map +0 -1
  74. package/dist/httpsClient.d.ts.map +0 -1
  75. package/dist/logger.d.ts.map +0 -1
  76. package/dist/request.d.ts.map +0 -1
  77. /package/dist/{base.d.ts → types/base.d.ts} +0 -0
  78. /package/dist/{config.d.ts → types/config.d.ts} +0 -0
  79. /package/dist/{httpsClient.d.ts → types/httpsClient.d.ts} +0 -0
  80. /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
@@ -0,0 +1,737 @@
1
+ import { MessageTypesEnum } from "../../types/enums.js";
2
+
3
+ //#region src/core/webhook/types.d.ts
4
+ interface WebhookContact {
5
+ /**
6
+ * WhatsApp ID of the contact. Business can respond to this contact using this ID.
7
+ */
8
+ wa_id: string;
9
+ /**
10
+ * Additional unique, alphanumeric identifier for a WhatsApp user
11
+ */
12
+ user_id?: string;
13
+ /**
14
+ * Profile of Whatsapp user
15
+ */
16
+ profile: {
17
+ /**
18
+ * The display name of the contact
19
+ */
20
+ name: string;
21
+ };
22
+ }
23
+ /**
24
+ * Base message interface with common properties
25
+ */
26
+ interface BaseMessage {
27
+ id: string;
28
+ from: string;
29
+ timestamp: string;
30
+ type: MessageTypesEnum;
31
+ /**
32
+ * Context object, included when a user replies or interacts
33
+ */
34
+ context?: {
35
+ /**
36
+ * ID of the message
37
+ */
38
+ id?: string;
39
+ /**
40
+ * ID of the sender
41
+ */
42
+ from?: string;
43
+ /**
44
+ * ID of the message being replied to or interacted with
45
+ */
46
+ message_id: string;
47
+ /**
48
+ * ID of the forwarded message, if applicable
49
+ */
50
+ forwarded?: boolean;
51
+ /**
52
+ * Frequently forwarded status
53
+ */
54
+ frequently_forwarded?: boolean;
55
+ /**
56
+ * Original message information if the message was referred
57
+ */
58
+ referred_product?: {
59
+ /**
60
+ * Catalog ID
61
+ */
62
+ catalog_id: string;
63
+ /**
64
+ * Product ID
65
+ */
66
+ product_retailer_id: string;
67
+ };
68
+ };
69
+ /**
70
+ * Errors array, if the message had errors
71
+ */
72
+ errors?: Array<{
73
+ /**
74
+ * Error code
75
+ */
76
+ code: number;
77
+ /**
78
+ * Error title
79
+ */
80
+ title: string;
81
+ /**
82
+ * Error message
83
+ */
84
+ message: string;
85
+ /**
86
+ * Error details object
87
+ */
88
+ error_data?: {
89
+ /**
90
+ * Describes the error details
91
+ */
92
+ details: string;
93
+ };
94
+ }>;
95
+ }
96
+ /**
97
+ * Text message interface
98
+ */
99
+ interface TextMessage extends BaseMessage {
100
+ type: MessageTypesEnum.Text;
101
+ text: {
102
+ /**
103
+ * The text content of the message
104
+ */
105
+ body: string;
106
+ preview_url?: boolean;
107
+ };
108
+ }
109
+ /**
110
+ * Image message interface
111
+ */
112
+ interface ImageMessage extends BaseMessage {
113
+ type: MessageTypesEnum.Image;
114
+ image: {
115
+ /**
116
+ * The image caption (if provided)
117
+ */
118
+ caption?: string;
119
+ /**
120
+ * The SHA256 hash of the image
121
+ */
122
+ sha256?: string;
123
+ /**
124
+ * The ID for the image
125
+ */
126
+ id: string;
127
+ /**
128
+ * The MIME type of the image
129
+ */
130
+ mime_type: string;
131
+ };
132
+ }
133
+ /**
134
+ * Video message interface
135
+ */
136
+ interface VideoMessage extends BaseMessage {
137
+ type: MessageTypesEnum.Video;
138
+ video: {
139
+ /**
140
+ * The video caption (if provided)
141
+ */
142
+ caption?: string;
143
+ /**
144
+ * The SHA256 hash of the video
145
+ */
146
+ sha256?: string;
147
+ /**
148
+ * The ID for the video
149
+ */
150
+ id: string;
151
+ /**
152
+ * The MIME type of the video
153
+ */
154
+ mime_type: string;
155
+ };
156
+ }
157
+ /**
158
+ * Audio message interface
159
+ */
160
+ interface AudioMessage extends BaseMessage {
161
+ type: MessageTypesEnum.Audio;
162
+ audio: {
163
+ /**
164
+ * The ID for the audio file
165
+ */
166
+ id: string;
167
+ /**
168
+ * The MIME type of the audio file
169
+ */
170
+ mime_type: string;
171
+ /**
172
+ * Whether the audio is a voice message
173
+ */
174
+ voice?: boolean;
175
+ };
176
+ }
177
+ /**
178
+ * Document message interface
179
+ */
180
+ interface DocumentMessage extends BaseMessage {
181
+ type: MessageTypesEnum.Document;
182
+ document: {
183
+ /**
184
+ * The document caption (if provided)
185
+ */
186
+ caption?: string;
187
+ /**
188
+ * The document filename
189
+ */
190
+ filename: string;
191
+ /**
192
+ * The SHA256 hash of the document
193
+ */
194
+ sha256?: string;
195
+ /**
196
+ * The ID for the document
197
+ */
198
+ id: string;
199
+ /**
200
+ * The MIME type of the document
201
+ */
202
+ mime_type: string;
203
+ };
204
+ }
205
+ /**
206
+ * Sticker message interface
207
+ */
208
+ interface StickerMessage extends BaseMessage {
209
+ type: MessageTypesEnum.Sticker;
210
+ sticker: {
211
+ /**
212
+ * The ID for the sticker
213
+ */
214
+ id: string;
215
+ /**
216
+ * Whether this is an animated sticker
217
+ */
218
+ animated: boolean;
219
+ /**
220
+ * The MIME type of the sticker
221
+ */
222
+ mime_type: string;
223
+ };
224
+ }
225
+ /**
226
+ * Reaction message interface
227
+ */
228
+ interface ReactionMessage extends BaseMessage {
229
+ type: MessageTypesEnum.Reaction;
230
+ reaction: {
231
+ /**
232
+ * The ID of the message being reacted to
233
+ */
234
+ message_id: string;
235
+ /**
236
+ * Emoji used for the reaction
237
+ */
238
+ emoji: string;
239
+ };
240
+ }
241
+ /**
242
+ * Contacts message interface
243
+ */
244
+ interface ContactsMessage extends BaseMessage {
245
+ type: MessageTypesEnum.Contacts;
246
+ contacts: Array<{
247
+ /**
248
+ * The contact's name
249
+ */
250
+ name: {
251
+ /**
252
+ * The formatted name
253
+ */
254
+ formatted_name: string;
255
+ /**
256
+ * The first name
257
+ */
258
+ first_name?: string;
259
+ /**
260
+ * The last name
261
+ */
262
+ last_name?: string;
263
+ /**
264
+ * The middle name
265
+ */
266
+ middle_name?: string;
267
+ /**
268
+ * The suffix
269
+ */
270
+ suffix?: string;
271
+ /**
272
+ * The prefix
273
+ */
274
+ prefix?: string;
275
+ };
276
+ /**
277
+ * The contact's phone numbers
278
+ */
279
+ phones?: Array<{
280
+ phone: string;
281
+ type?: string;
282
+ wa_id?: string;
283
+ }>;
284
+ /**
285
+ * The contact's emails
286
+ */
287
+ emails?: Array<{
288
+ email: string;
289
+ type?: string;
290
+ }>;
291
+ /**
292
+ * The contact's addresses
293
+ */
294
+ addresses?: Array<{
295
+ street?: string;
296
+ city?: string;
297
+ state?: string;
298
+ zip?: string;
299
+ country?: string;
300
+ country_code?: string;
301
+ type?: string;
302
+ }>;
303
+ /**
304
+ * The contact's organizations
305
+ */
306
+ org?: {
307
+ company?: string;
308
+ department?: string;
309
+ title?: string;
310
+ };
311
+ /**
312
+ * The contact's URLs
313
+ */
314
+ urls?: Array<{
315
+ url: string;
316
+ type?: string;
317
+ }>;
318
+ /**
319
+ * The contact's birthday (YYYY-MM-DD format)
320
+ */
321
+ birthday?: string;
322
+ }>;
323
+ }
324
+ /**
325
+ * Location message interface
326
+ */
327
+ interface LocationMessage extends BaseMessage {
328
+ type: MessageTypesEnum.Location;
329
+ location: {
330
+ /**
331
+ * Latitude of the location
332
+ */
333
+ latitude: number;
334
+ /**
335
+ * Longitude of the location
336
+ */
337
+ longitude: number;
338
+ /**
339
+ * Name of the location
340
+ */
341
+ name?: string;
342
+ /**
343
+ * Address of the location
344
+ */
345
+ address?: string;
346
+ };
347
+ }
348
+ /**
349
+ * Interactive message interface
350
+ */
351
+ interface InteractiveMessage extends BaseMessage {
352
+ type: MessageTypesEnum.Interactive;
353
+ interactive: {
354
+ /**
355
+ * Type of the interactive message
356
+ * Can be: button_reply, list_reply, flow, nfm_reply, etc.
357
+ */
358
+ type: string;
359
+ /**
360
+ * ID for the button that was clicked
361
+ */
362
+ button_reply?: {
363
+ id: string;
364
+ title: string;
365
+ };
366
+ /**
367
+ * ID for the list item that was selected
368
+ */
369
+ list_reply?: {
370
+ id: string;
371
+ title: string;
372
+ description?: string;
373
+ };
374
+ /**
375
+ * NFM (No-Code Flow Message) reply data
376
+ */
377
+ nfm_reply?: {
378
+ /**
379
+ * Response data in JSON format
380
+ */
381
+ response_json: string;
382
+ /**
383
+ * Body text of the reply
384
+ */
385
+ body: string;
386
+ /**
387
+ * Name of the flow
388
+ */
389
+ name: string;
390
+ };
391
+ };
392
+ }
393
+ /**
394
+ * System message interface
395
+ */
396
+ interface SystemMessage extends BaseMessage {
397
+ type: MessageTypesEnum.System;
398
+ system: {
399
+ /**
400
+ * The type of system update
401
+ */
402
+ type: string;
403
+ /**
404
+ * User's identity if the update is a customer identity change
405
+ */
406
+ identity?: string;
407
+ /**
408
+ * Old and new phone numbers if the update is a phone number change
409
+ */
410
+ customer?: {
411
+ /**
412
+ * The previous phone number
413
+ */
414
+ previous_wa_id: string;
415
+ /**
416
+ * The new phone number
417
+ */
418
+ wa_id: string;
419
+ };
420
+ };
421
+ }
422
+ /**
423
+ * Order message interface
424
+ */
425
+ interface OrderMessage extends BaseMessage {
426
+ type: MessageTypesEnum.Order;
427
+ order: {
428
+ /**
429
+ * Catalog ID
430
+ */
431
+ catalog_id: string;
432
+ /**
433
+ * Product items in the order
434
+ */
435
+ product_items: Array<{
436
+ /**
437
+ * Product ID
438
+ */
439
+ product_retailer_id: string;
440
+ /**
441
+ * Quantity of the product
442
+ */
443
+ quantity: number;
444
+ /**
445
+ * Item price
446
+ */
447
+ item_price: number;
448
+ /**
449
+ * Currency code
450
+ */
451
+ currency: string;
452
+ }>;
453
+ /**
454
+ * Text message included with the order
455
+ */
456
+ text?: string;
457
+ };
458
+ }
459
+ /**
460
+ * Button message interface
461
+ */
462
+ interface ButtonMessage extends BaseMessage {
463
+ type: MessageTypesEnum.Button;
464
+ button: {
465
+ /**
466
+ * The payload for the button
467
+ */
468
+ payload: string;
469
+ /**
470
+ * Button text
471
+ */
472
+ text: string;
473
+ };
474
+ }
475
+ /**
476
+ * Union type for all message types
477
+ */
478
+ type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | ReactionMessage | ContactsMessage | LocationMessage | InteractiveMessage | SystemMessage | OrderMessage | ButtonMessage;
479
+ interface WebhookMessageValue {
480
+ /**
481
+ * The messaging product
482
+ */
483
+ messaging_product: string;
484
+ /**
485
+ * The metadata
486
+ */
487
+ metadata: {
488
+ /**
489
+ * The display phone number of the whatsapp business account
490
+ */
491
+ display_phone_number: string;
492
+ /**
493
+ * The phone number ID of the whatsapp business account
494
+ */
495
+ phone_number_id: string;
496
+ };
497
+ contacts?: Array<{
498
+ profile: {
499
+ /**
500
+ * The display name of the whatsapp user
501
+ */
502
+ name: string;
503
+ };
504
+ /**
505
+ * The whatsapp ID of the user
506
+ */
507
+ wa_id: string;
508
+ }>;
509
+ messages: Array<WhatsAppMessage>;
510
+ statuses?: Array<{
511
+ /**
512
+ * The ID of the message
513
+ */
514
+ id: string;
515
+ /**
516
+ * The status of the message
517
+ */
518
+ status: MessageStatus;
519
+ /**
520
+ * The timestamp of the message
521
+ */
522
+ timestamp: string;
523
+ /**
524
+ * The recipient ID ( phone number of the user )
525
+ */
526
+ recipient_id: string;
527
+ }>;
528
+ errors?: Array<{
529
+ /**
530
+ * The error code
531
+ */
532
+ code: number;
533
+ /**
534
+ * The error title
535
+ */
536
+ title: string;
537
+ /**
538
+ * The error data
539
+ */
540
+ error_data?: {
541
+ /**
542
+ * The error details
543
+ */
544
+ details: string;
545
+ };
546
+ }>;
547
+ }
548
+ /**
549
+ * Represents a message received through the webhook
550
+ * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
551
+ */
552
+ interface WebhookMessage {
553
+ /**
554
+ * The WhatsApp Business Account ID
555
+ */
556
+ wabaId: string;
557
+ /**
558
+ * The message ID
559
+ */
560
+ id: string;
561
+ /**
562
+ * The sender's phone number
563
+ */
564
+ from: string;
565
+ /**
566
+ * The timestamp of the message
567
+ */
568
+ timestamp: string;
569
+ /**
570
+ * The type of message (text, image, etc.)
571
+ */
572
+ type: MessageTypesEnum;
573
+ /**
574
+ * The phone number ID that received the message
575
+ */
576
+ phoneNumberId: string;
577
+ /**
578
+ * The display phone number that received the message
579
+ */
580
+ displayPhoneNumber: string;
581
+ /**
582
+ * The profile name of the sender
583
+ */
584
+ profileName: string;
585
+ text?: TextMessage['text'];
586
+ image?: ImageMessage['image'];
587
+ video?: VideoMessage['video'];
588
+ audio?: AudioMessage['audio'];
589
+ document?: DocumentMessage['document'];
590
+ sticker?: StickerMessage['sticker'];
591
+ location?: LocationMessage['location'];
592
+ contacts?: ContactsMessage['contacts'];
593
+ interactive?: InteractiveMessage['interactive'];
594
+ button?: ButtonMessage['button'];
595
+ order?: OrderMessage['order'];
596
+ system?: SystemMessage['system'];
597
+ reaction?: ReactionMessage['reaction'];
598
+ statuses?: {
599
+ /**
600
+ * Arbitrary string included in sent message
601
+ */
602
+ biz_opaque_callback_data?: string;
603
+ /**
604
+ * Information about the conversation
605
+ */
606
+ conversation?: {
607
+ /**
608
+ * Represents the ID of the conversation the given status notification belongs to
609
+ */
610
+ id: string;
611
+ /**
612
+ * Describes conversation category
613
+ */
614
+ origin: {
615
+ /**
616
+ * Indicates conversation category. This can also be referred to as a conversation entry point
617
+ * - authentication: Conversation opened by business sending template categorized as AUTHENTICATION
618
+ * - marketing: Conversation opened by business sending template categorized as MARKETING
619
+ * - utility: Conversation opened by business sending template categorized as UTILITY
620
+ * - service: Conversation opened by business replying to customer within service window
621
+ * - referral_conversion: Free entry point conversation
622
+ */
623
+ type: 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
624
+ };
625
+ /**
626
+ * Date when the conversation expires. Only present for messages with status 'sent'
627
+ */
628
+ expiration_timestamp?: string;
629
+ };
630
+ /**
631
+ * Array of error objects describing the error
632
+ */
633
+ errors?: Array<{
634
+ /**
635
+ * Error code
636
+ */
637
+ code: number;
638
+ /**
639
+ * Error code title
640
+ */
641
+ title: string;
642
+ /**
643
+ * Error code message
644
+ */
645
+ message: string;
646
+ /**
647
+ * Error details object
648
+ */
649
+ error_data?: {
650
+ /**
651
+ * Describes the error details
652
+ */
653
+ details: string;
654
+ };
655
+ }>;
656
+ /**
657
+ * The ID for the message that the business sent to a customer
658
+ */
659
+ id: string;
660
+ /**
661
+ * Pricing information for the message/conversation
662
+ */
663
+ pricing?: {
664
+ /**
665
+ * Indicates if the given message or conversation is billable
666
+ * @deprecated This field is deprecated. Visit the WhatsApp Changelog for more information.
667
+ */
668
+ billable?: boolean;
669
+ /**
670
+ * Indicates the conversation category:
671
+ * - authentication: Authentication conversation
672
+ * - authentication_international: Authentication-international conversation
673
+ * - marketing: Marketing conversation
674
+ * - utility: Utility conversation
675
+ * - service: Service conversation
676
+ * - referral_conversion: Free entry point conversation
677
+ */
678
+ category: 'authentication' | 'authentication_international' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
679
+ /**
680
+ * Type of pricing model used by the business. Current supported value is CBP
681
+ */
682
+ pricing_model: 'CBP';
683
+ };
684
+ /**
685
+ * The customer's WhatsApp ID. Business can respond to customer using this ID.
686
+ * This ID may not match the customer's phone number.
687
+ */
688
+ recipient_id: string;
689
+ /**
690
+ * Status of the message:
691
+ * - delivered: Message has been delivered
692
+ * - read: Message has been read by the customer
693
+ * - sent: Message has been sent to the customer
694
+ */
695
+ status: 'delivered' | 'read' | 'sent';
696
+ /**
697
+ * Unix timestamp for the status message
698
+ */
699
+ timestamp: string;
700
+ };
701
+ /**
702
+ * The original message data as received from the webhook
703
+ */
704
+ originalData: any;
705
+ }
706
+ /**
707
+ * Webhook event received from WhatsApp
708
+ */
709
+ interface WebhookEvent {
710
+ /**
711
+ * The field type of the event
712
+ */
713
+ field: string;
714
+ /**
715
+ * The event data
716
+ */
717
+ value: any;
718
+ /**
719
+ * The timestamp when the event was received
720
+ */
721
+ timestamp: number;
722
+ }
723
+ /**
724
+ * Message handler function type
725
+ */
726
+ type MessageHandler = (message: WebhookMessage) => void | Promise<void>;
727
+ /**
728
+ * Message status enum
729
+ */
730
+ declare enum MessageStatus {
731
+ DELIVERED = "delivered",
732
+ READ = "read",
733
+ SENT = "sent",
734
+ }
735
+ //#endregion
736
+ export { WebhookContact, WebhookEvent, WebhookMessage };
737
+ //# sourceMappingURL=types.d.ts.map