meta-cloud-api 1.6.1 → 1.7.1

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.
@@ -1243,7 +1243,7 @@ interface MediaClass {
1243
1243
  downloadMedia(mediaUrl: string): Promise<Blob>;
1244
1244
  }
1245
1245
  //#endregion
1246
- //#region src/core/webhook/types.d.ts
1246
+ //#region src/core/webhook/types/common.d.ts
1247
1247
  /**
1248
1248
  * WhatsApp contact information
1249
1249
  */
@@ -1316,6 +1316,8 @@ interface ReplyContext {
1316
1316
  from: string;
1317
1317
  id: string;
1318
1318
  }
1319
+ //#endregion
1320
+ //#region src/core/webhook/types/message.d.ts
1319
1321
  /**
1320
1322
  * Base message properties common to all message types
1321
1323
  */
@@ -1523,6 +1525,8 @@ type GroupMessage = {
1523
1525
  group_id: string;
1524
1526
  } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
1525
1527
  type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1528
+ //#endregion
1529
+ //#region src/core/webhook/types/status.d.ts
1526
1530
  interface StatusWebhook {
1527
1531
  id: string;
1528
1532
  status: 'sent' | 'delivered' | 'read' | 'failed';
@@ -1547,6 +1551,450 @@ interface StatusWebhook {
1547
1551
  };
1548
1552
  errors?: Array<WebhookError>;
1549
1553
  }
1554
+ //#endregion
1555
+ //#region src/core/webhook/types/account.d.ts
1556
+ /**
1557
+ * Account update event types
1558
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1559
+ */
1560
+ type AccountUpdateEvent = 'VERIFIED_ACCOUNT' | 'DISABLED_UPDATE' | 'ACCOUNT_VIOLATION' | 'ACCOUNT_RESTRICTION' | 'ACCOUNT_DELETED' | 'PARTNER_REMOVED' | 'PARTNER_APP_UNINSTALLED';
1561
+ /**
1562
+ * WABA ban state
1563
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--ban_info
1564
+ */
1565
+ type WabaBanState = 'SCHEDULE_FOR_DISABLE' | 'DISABLE' | 'REINSTATE';
1566
+ /**
1567
+ * Restriction types imposed on WABA
1568
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--restriction_info
1569
+ */
1570
+ type RestrictionType = 'RESTRICTION_ADD_PHONE_NUMBER_ACTION' | 'RESTRICTED_BIZ_INITIATED_MESSAGING' | 'RESTRICTED_CUSTOMER_INITIATED_MESSAGING';
1571
+ interface AccountUpdateBanInfo {
1572
+ waba_ban_state: WabaBanState;
1573
+ waba_ban_date?: number;
1574
+ }
1575
+ interface AccountUpdateViolationInfo {
1576
+ violation_type: string;
1577
+ }
1578
+ interface AccountUpdateRestrictionInfo {
1579
+ restriction_type: RestrictionType;
1580
+ expiration?: number;
1581
+ }
1582
+ interface AccountUpdateWabaInfo {
1583
+ waba_id: string;
1584
+ owner_business_id: string;
1585
+ partner_app_id?: string;
1586
+ }
1587
+ interface AccountUpdateValue {
1588
+ phone_number?: string;
1589
+ event: AccountUpdateEvent;
1590
+ ban_info?: AccountUpdateBanInfo;
1591
+ violation_info?: AccountUpdateViolationInfo;
1592
+ restriction_info?: AccountUpdateRestrictionInfo[];
1593
+ waba_info?: AccountUpdateWabaInfo;
1594
+ }
1595
+ interface AccountUpdateWebhookValue {
1596
+ field: 'account_update';
1597
+ value: AccountUpdateValue;
1598
+ }
1599
+ /**
1600
+ * Account review decision
1601
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--decision
1602
+ */
1603
+ type ReviewDecision = 'APPROVED' | 'REJECTED' | 'DEFERRED';
1604
+ interface AccountReviewUpdateValue {
1605
+ decision: ReviewDecision;
1606
+ }
1607
+ interface AccountReviewUpdateWebhookValue {
1608
+ field: 'account_review_update';
1609
+ value: AccountReviewUpdateValue;
1610
+ }
1611
+ /**
1612
+ * Entity type for alert
1613
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#account-alerts
1614
+ */
1615
+ type AlertEntityType = 'BUSINESS' | 'PHONE_NUMBER' | 'WABA';
1616
+ /**
1617
+ * Alert severity level
1618
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#account-alerts
1619
+ */
1620
+ type AlertSeverity = 'CRITICAL' | 'WARNING' | 'INFO';
1621
+ /**
1622
+ * Alert status
1623
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#account-alerts
1624
+ */
1625
+ type AlertStatus = 'ACTIVE' | 'RESOLVED';
1626
+ /**
1627
+ * Alert types for messaging limit increases
1628
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#account-alerts
1629
+ */
1630
+ type AlertType = 'INCREASED_CAPABILITIES_ELIGIBILITY_FAILED' | 'INCREASED_CAPABILITIES_ELIGIBILITY_DEFERRED' | 'INCREASED_CAPABILITIES_ELIGIBILITY_NEED_MORE_INFO';
1631
+ interface AccountAlertsValue {
1632
+ entity_type: AlertEntityType;
1633
+ entity_id: string;
1634
+ alert_severity: AlertSeverity;
1635
+ alert_status: AlertStatus;
1636
+ alert_type: AlertType;
1637
+ alert_description: string;
1638
+ }
1639
+ interface AccountAlertsWebhookValue {
1640
+ field: 'account_alerts';
1641
+ value: AccountAlertsValue;
1642
+ }
1643
+ //#endregion
1644
+ //#region src/core/webhook/types/business.d.ts
1645
+ /**
1646
+ * Business capability limits
1647
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#business-capability-updates
1648
+ */
1649
+ interface BusinessCapabilityUpdateValue {
1650
+ max_daily_conversation_per_phone?: number;
1651
+ max_phone_numbers_per_business?: number;
1652
+ max_phone_numbers_per_waba?: number;
1653
+ }
1654
+ interface BusinessCapabilityUpdateWebhookValue {
1655
+ field: 'business_capability_update';
1656
+ value: BusinessCapabilityUpdateValue;
1657
+ }
1658
+ //#endregion
1659
+ //#region src/core/webhook/types/phoneNumber.d.ts
1660
+ /**
1661
+ * Phone number name update decision
1662
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#phone-number-updates
1663
+ */
1664
+ type PhoneNumberDecision = 'APPROVED' | 'REJECTED' | 'DEFERRED';
1665
+ interface PhoneNumberNameUpdateValue {
1666
+ display_phone_number: string;
1667
+ decision: PhoneNumberDecision;
1668
+ requested_verified_name: string;
1669
+ rejection_reason: string | null;
1670
+ }
1671
+ interface PhoneNumberNameUpdateWebhookValue {
1672
+ field: 'phone_number_name_update';
1673
+ value: PhoneNumberNameUpdateValue;
1674
+ }
1675
+ /**
1676
+ * Phone number quality events
1677
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1678
+ */
1679
+ type PhoneNumberQualityEvent = 'FLAGGED' | 'UNFLAGGED' | 'UPGRADE' | 'DOWNGRADE' | 'ONBOARDING';
1680
+ /**
1681
+ * Messaging tier limits
1682
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--current_limit
1683
+ */
1684
+ type CurrentLimit = 'TIER_50' | 'TIER_250' | 'TIER_1K' | 'TIER_10K' | 'TIER_100K' | 'TIER_UNLIMITED';
1685
+ interface PhoneNumberQualityUpdateValue {
1686
+ display_phone_number: string;
1687
+ event: PhoneNumberQualityEvent;
1688
+ current_limit: CurrentLimit;
1689
+ }
1690
+ interface PhoneNumberQualityUpdateWebhookValue {
1691
+ field: 'phone_number_quality_update';
1692
+ value: PhoneNumberQualityUpdateValue;
1693
+ }
1694
+ //#endregion
1695
+ //#region src/core/webhook/types/template.d.ts
1696
+ /**
1697
+ * Message template status events
1698
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1699
+ */
1700
+ type TemplateStatusEvent = 'APPROVED' | 'REJECTED' | 'PENDING' | 'DISABLED' | 'REINSTATED' | 'IN_APPEAL' | 'FLAGGED' | 'PAUSED' | 'PENDING_DELETION';
1701
+ /**
1702
+ * Template rejection reasons
1703
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--reason
1704
+ */
1705
+ type TemplateRejectionReason = 'NONE' | 'ABUSIVE_CONTENT' | 'INCORRECT_CATEGORY' | 'INVALID_FORMAT' | 'SCAM';
1706
+ interface TemplateDisableInfo {
1707
+ disable_date: string;
1708
+ }
1709
+ interface TemplatePauseInfo {
1710
+ title: string;
1711
+ description: string;
1712
+ }
1713
+ interface MessageTemplateStatusUpdateValue {
1714
+ event: TemplateStatusEvent;
1715
+ message_template_id: number;
1716
+ message_template_name: string;
1717
+ message_template_language: string;
1718
+ reason: TemplateRejectionReason | null;
1719
+ disable_info?: TemplateDisableInfo;
1720
+ other_info?: TemplatePauseInfo;
1721
+ }
1722
+ interface MessageTemplateStatusUpdateWebhookValue {
1723
+ field: 'message_template_status_update';
1724
+ value: MessageTemplateStatusUpdateValue;
1725
+ }
1726
+ /**
1727
+ * Template categories
1728
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1729
+ */
1730
+ type TemplateCategory = 'MARKETING' | 'OTP' | 'TRANSACTIONAL' | 'AUTHENTICATION' | 'UTILITY';
1731
+ interface TemplateCategoryUpdateValue {
1732
+ message_template_id: number;
1733
+ message_template_name: string;
1734
+ message_template_language: string;
1735
+ previous_category: TemplateCategory;
1736
+ new_category: TemplateCategory;
1737
+ }
1738
+ interface TemplateCategoryUpdateWebhookValue {
1739
+ field: 'template_category_update';
1740
+ value: TemplateCategoryUpdateValue;
1741
+ }
1742
+ /**
1743
+ * Template quality scores
1744
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1745
+ */
1746
+ type TemplateQualityScore = 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
1747
+ interface MessageTemplateQualityUpdateValue {
1748
+ previous_quality_score: TemplateQualityScore;
1749
+ new_quality_score: TemplateQualityScore;
1750
+ message_template_id: number;
1751
+ message_template_name: string;
1752
+ message_template_language: string;
1753
+ }
1754
+ interface MessageTemplateQualityUpdateWebhookValue {
1755
+ field: 'message_template_quality_update';
1756
+ value: MessageTemplateQualityUpdateValue;
1757
+ }
1758
+ //#endregion
1759
+ //#region src/core/webhook/types/flows.d.ts
1760
+ /**
1761
+ * Flow event types
1762
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1763
+ */
1764
+ type FlowEvent = 'FLOW_STATUS_CHANGE' | 'FLOW_HEALTH_UPDATE' | 'FLOW_THROTTLED';
1765
+ /**
1766
+ * Flow status values
1767
+ * @see https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#statuses
1768
+ */
1769
+ type FlowStatus = 'DRAFT' | 'PUBLISHED' | 'DEPRECATED' | 'BLOCKED' | 'THROTTLED';
1770
+ /**
1771
+ * Flow alert state
1772
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--alert_state
1773
+ */
1774
+ type FlowAlertState = 'ACTIVE' | 'RESOLVED';
1775
+ /**
1776
+ * Flow endpoint request error
1777
+ */
1778
+ interface FlowEndpointRequestError {
1779
+ error_code: string;
1780
+ error_message: string;
1781
+ error_count: number;
1782
+ }
1783
+ /**
1784
+ * Flow webhook value
1785
+ */
1786
+ interface FlowsValue {
1787
+ event: FlowEvent;
1788
+ message?: string;
1789
+ flow_id: string;
1790
+ old_status?: FlowStatus;
1791
+ new_status?: FlowStatus;
1792
+ warning?: string;
1793
+ p90_latency?: number;
1794
+ p50_latency?: number;
1795
+ error_rate?: number;
1796
+ errors?: FlowEndpointRequestError[];
1797
+ requests_count?: number;
1798
+ availability?: number;
1799
+ threshold?: number;
1800
+ alert_state?: FlowAlertState;
1801
+ }
1802
+ interface FlowsWebhookValue {
1803
+ field: 'flows';
1804
+ value: FlowsValue;
1805
+ }
1806
+ //#endregion
1807
+ //#region src/core/webhook/types/security.d.ts
1808
+ /**
1809
+ * Two-step verification security events
1810
+ * @see https://developers.facebook.com/docs/whatsapp/business-management-api/webhooks/components#value--event
1811
+ */
1812
+ type SecurityEvent = 'PIN_CHANGED' | 'PIN_RESET_REQUEST' | 'PIN_RESET_SUCCESS';
1813
+ interface SecurityValue {
1814
+ event: SecurityEvent;
1815
+ requester?: string;
1816
+ }
1817
+ interface SecurityWebhookValue {
1818
+ field: 'security';
1819
+ value: SecurityValue;
1820
+ }
1821
+ //#endregion
1822
+ //#region src/core/webhook/types/history.d.ts
1823
+ /**
1824
+ * History sync metadata
1825
+ */
1826
+ interface HistorySyncMetadata {
1827
+ phase: number;
1828
+ chunk_order: number;
1829
+ progress: number;
1830
+ }
1831
+ /**
1832
+ * Reaction object in history
1833
+ */
1834
+ interface HistoryReaction {
1835
+ message_id: string;
1836
+ emoji: string;
1837
+ }
1838
+ /**
1839
+ * Message echo data (sent messages)
1840
+ */
1841
+ interface HistoryMessageEcho {
1842
+ from: string;
1843
+ to: string;
1844
+ id: string;
1845
+ timestamp: string;
1846
+ text?: {
1847
+ body: string;
1848
+ };
1849
+ interactive?: any;
1850
+ location?: any;
1851
+ image?: any;
1852
+ document?: any;
1853
+ voice?: any;
1854
+ audio?: any;
1855
+ video?: any;
1856
+ sticker?: any;
1857
+ button?: any;
1858
+ contacts?: any;
1859
+ reaction?: HistoryReaction;
1860
+ order?: any;
1861
+ biz_opaque_callback_data?: string;
1862
+ template?: any;
1863
+ }
1864
+ /**
1865
+ * History sync thread data
1866
+ */
1867
+ interface HistorySyncThread {
1868
+ id: string;
1869
+ messages: WhatsAppMessage[];
1870
+ }
1871
+ /**
1872
+ * History sync error data
1873
+ */
1874
+ interface HistorySyncError {
1875
+ message: string;
1876
+ error_data?: {
1877
+ details: string;
1878
+ };
1879
+ }
1880
+ /**
1881
+ * History sync data
1882
+ */
1883
+ interface HistorySyncData {
1884
+ metadata: HistorySyncMetadata;
1885
+ threads?: HistorySyncThread[];
1886
+ errors?: HistorySyncError[];
1887
+ }
1888
+ /**
1889
+ * History webhook value
1890
+ */
1891
+ interface HistoryValue {
1892
+ messaging_product: string;
1893
+ metadata: HistorySyncMetadata;
1894
+ history?: HistorySyncData[];
1895
+ messages?: WhatsAppMessage[];
1896
+ message_echoes?: HistoryMessageEcho[];
1897
+ }
1898
+ interface HistoryWebhookValue {
1899
+ field: 'history';
1900
+ value: HistoryValue;
1901
+ }
1902
+ //#endregion
1903
+ //#region src/core/webhook/types/messageEchoes.d.ts
1904
+ /**
1905
+ * Message echo error
1906
+ */
1907
+ interface MessageEchoError {
1908
+ message: string;
1909
+ error_data?: {
1910
+ details: string;
1911
+ };
1912
+ }
1913
+ /**
1914
+ * Message echo data (sent messages from business)
1915
+ */
1916
+ interface MessageEcho {
1917
+ from: string;
1918
+ to: string;
1919
+ id: string;
1920
+ timestamp: string;
1921
+ text?: {
1922
+ body: string;
1923
+ };
1924
+ interactive?: any;
1925
+ location?: any;
1926
+ image?: any;
1927
+ document?: any;
1928
+ voice?: any;
1929
+ audio?: any;
1930
+ video?: any;
1931
+ sticker?: any;
1932
+ button?: any;
1933
+ contacts?: any;
1934
+ reaction?: {
1935
+ message_id: string;
1936
+ emoji: string;
1937
+ };
1938
+ order?: any;
1939
+ biz_opaque_callback_data?: string;
1940
+ template?: any;
1941
+ system?: {
1942
+ type: string;
1943
+ };
1944
+ user_actions?: any[];
1945
+ }
1946
+ /**
1947
+ * SMB Message Echoes value
1948
+ */
1949
+ interface SmbMessageEchoesValue {
1950
+ metadata: WebhookMetadata;
1951
+ errors?: MessageEchoError[];
1952
+ message_echoes: MessageEcho[];
1953
+ }
1954
+ interface SmbMessageEchoesWebhookValue {
1955
+ field: 'smb_message_echoes';
1956
+ value: SmbMessageEchoesValue;
1957
+ }
1958
+ //#endregion
1959
+ //#region src/core/webhook/types/appStateSync.d.ts
1960
+ /**
1961
+ * Contact data in state sync
1962
+ */
1963
+ interface StateSyncContact {
1964
+ full_name: string;
1965
+ first_name: string;
1966
+ phone_number: string;
1967
+ }
1968
+ /**
1969
+ * State sync metadata
1970
+ */
1971
+ interface StateSyncMetadata {
1972
+ timestamp: string;
1973
+ version: number;
1974
+ }
1975
+ /**
1976
+ * State sync data
1977
+ */
1978
+ interface StateSyncData {
1979
+ type: string;
1980
+ contact: StateSyncContact;
1981
+ action: string;
1982
+ metadata: StateSyncMetadata;
1983
+ }
1984
+ /**
1985
+ * SMB App State Sync value
1986
+ */
1987
+ interface SmbAppStateSyncValue {
1988
+ messaging_product: string;
1989
+ metadata: WebhookMetadata;
1990
+ state_sync: StateSyncData[];
1991
+ }
1992
+ interface SmbAppStateSyncWebhookValue {
1993
+ field: 'smb_app_state_sync';
1994
+ value: SmbAppStateSyncValue;
1995
+ }
1996
+ //#endregion
1997
+ //#region src/core/webhook/types/index.d.ts
1550
1998
  /**
1551
1999
  * Webhook value for incoming messages
1552
2000
  */
@@ -1576,6 +2024,10 @@ interface ErrorWebhookValue {
1576
2024
  * Union type for all webhook value types
1577
2025
  */
1578
2026
  type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
2027
+ /**
2028
+ * Union type for all webhook field values
2029
+ */
2030
+ type WebhookFieldValue = AccountUpdateWebhookValue | AccountReviewUpdateWebhookValue | AccountAlertsWebhookValue | BusinessCapabilityUpdateWebhookValue | PhoneNumberNameUpdateWebhookValue | PhoneNumberQualityUpdateWebhookValue | MessageTemplateStatusUpdateWebhookValue | TemplateCategoryUpdateWebhookValue | MessageTemplateQualityUpdateWebhookValue | FlowsWebhookValue | SecurityWebhookValue | HistoryWebhookValue | SmbMessageEchoesWebhookValue | SmbAppStateSyncWebhookValue;
1579
2031
  interface WebhookPayload {
1580
2032
  object: 'whatsapp_business_account';
1581
2033
  entry: Array<{
@@ -1583,7 +2035,7 @@ interface WebhookPayload {
1583
2035
  changes: Array<{
1584
2036
  value: WebhookValue;
1585
2037
  field: 'messages';
1586
- }>;
2038
+ } | WebhookFieldValue>;
1587
2039
  }>;
1588
2040
  }
1589
2041
  /**
@@ -1595,23 +2047,23 @@ interface WebhookMessage {
1595
2047
  id: string;
1596
2048
  from: string;
1597
2049
  timestamp: string;
1598
- type: MessageTypesEnum;
2050
+ type: any;
1599
2051
  phoneNumberId: string;
1600
2052
  displayPhoneNumber: string;
1601
2053
  profileName: string;
1602
- text?: TextMessage['text'];
1603
- image?: ImageMessage['image'];
1604
- video?: VideoMessage['video'];
1605
- audio?: AudioMessage['audio'];
1606
- document?: DocumentMessage['document'];
1607
- sticker?: StickerMessage['sticker'];
1608
- location?: LocationMessage['location'];
1609
- contacts?: ContactsMessage['contacts'];
1610
- interactive?: InteractiveMessage['interactive'];
1611
- button?: ButtonMessage['button'];
1612
- order?: OrderMessage['order'];
1613
- system?: SystemMessage['system'];
1614
- reaction?: ReactionMessage['reaction'];
2054
+ text?: any;
2055
+ image?: any;
2056
+ video?: any;
2057
+ audio?: any;
2058
+ document?: any;
2059
+ sticker?: any;
2060
+ location?: any;
2061
+ contacts?: any;
2062
+ interactive?: any;
2063
+ button?: any;
2064
+ order?: any;
2065
+ system?: any;
2066
+ reaction?: any;
1615
2067
  statuses?: StatusWebhook;
1616
2068
  originalData: any;
1617
2069
  }