meta-cloud-api 1.1.9 → 1.1.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.
@@ -180,9 +180,6 @@ interface UploadHandle {
180
180
  name: string;
181
181
  };
182
182
  }
183
- /**
184
- * Request parameters for creating upload session.
185
- */
186
183
  //#endregion
187
184
  //#region src/api/profile/types/common.d.ts
188
185
  /**
@@ -1197,610 +1194,210 @@ interface MediaClass {
1197
1194
  downloadMedia(mediaUrl: string): Promise<Blob>;
1198
1195
  }
1199
1196
  //#endregion
1200
- //#region src/api/flow/types/common.d.ts
1201
- /**
1202
- * Enum for Flow Status
1203
- */
1204
- declare enum FlowStatusEnum {
1205
- Draft = "DRAFT",
1206
- Published = "PUBLISHED",
1207
- Throttled = "THROTTLED",
1208
- Blocked = "BLOCKED",
1209
- Deprecated = "DEPRECATED",
1197
+ //#region src/core/webhook/types.d.ts
1198
+ interface WebhookContact {
1199
+ /**
1200
+ * WhatsApp ID of the contact. Business can respond to this contact using this ID.
1201
+ */
1202
+ wa_id: string;
1203
+ /**
1204
+ * Additional unique, alphanumeric identifier for a WhatsApp user
1205
+ */
1206
+ user_id?: string;
1207
+ /**
1208
+ * Profile of Whatsapp user
1209
+ */
1210
+ profile: {
1211
+ /**
1212
+ * The display name of the contact
1213
+ */
1214
+ name: string;
1215
+ };
1210
1216
  }
1211
1217
  /**
1212
- * Enum for Flow Categories
1218
+ * Base message interface with common properties
1213
1219
  */
1214
- declare enum FlowCategoryEnum {
1215
- SignUp = "SIGN_UP",
1216
- SignIn = "SIGN_IN",
1217
- AppointmentBooking = "APPOINTMENT_BOOKING",
1218
- LeadGeneration = "LEAD_GENERATION",
1219
- ContactUs = "CONTACT_US",
1220
- CustomerSupport = "CUSTOMER_SUPPORT",
1221
- Survey = "SURVEY",
1222
- Other = "OTHER",
1223
- }
1224
- declare enum FlowActionEnum {
1225
- INIT = "INIT",
1226
- BACK = "BACK",
1227
- DATA_EXCHANGE = "data_exchange",
1220
+ interface BaseMessage {
1221
+ id: string;
1222
+ from: string;
1223
+ timestamp: string;
1224
+ type: MessageTypesEnum;
1225
+ /**
1226
+ * Context object, included when a user replies or interacts
1227
+ */
1228
+ context?: {
1229
+ /**
1230
+ * ID of the message
1231
+ */
1232
+ id?: string;
1233
+ /**
1234
+ * ID of the sender
1235
+ */
1236
+ from?: string;
1237
+ /**
1238
+ * ID of the message being replied to or interacted with
1239
+ */
1240
+ message_id: string;
1241
+ /**
1242
+ * ID of the forwarded message, if applicable
1243
+ */
1244
+ forwarded?: boolean;
1245
+ /**
1246
+ * Frequently forwarded status
1247
+ */
1248
+ frequently_forwarded?: boolean;
1249
+ /**
1250
+ * Original message information if the message was referred
1251
+ */
1252
+ referred_product?: {
1253
+ /**
1254
+ * Catalog ID
1255
+ */
1256
+ catalog_id: string;
1257
+ /**
1258
+ * Product ID
1259
+ */
1260
+ product_retailer_id: string;
1261
+ };
1262
+ };
1263
+ /**
1264
+ * Errors array, if the message had errors
1265
+ */
1266
+ errors?: Array<{
1267
+ /**
1268
+ * Error code
1269
+ */
1270
+ code: number;
1271
+ /**
1272
+ * Error title
1273
+ */
1274
+ title: string;
1275
+ /**
1276
+ * Error message
1277
+ */
1278
+ message: string;
1279
+ /**
1280
+ * Error details object
1281
+ */
1282
+ error_data?: {
1283
+ /**
1284
+ * Describes the error details
1285
+ */
1286
+ details: string;
1287
+ };
1288
+ }>;
1228
1289
  }
1229
1290
  /**
1230
- * Enum for Flow Types in webhook handlers
1231
- * Used to register handlers for specific flow events
1291
+ * Text message interface
1232
1292
  */
1233
- declare enum FlowTypeEnum {
1234
- /** Health check/ping requests */
1235
- Ping = "ping",
1236
- /** Data exchange requests */
1237
- Change = "data_exchange",
1238
- /** Error notification requests */
1239
- Error = "error",
1240
- /** Match all flow action types */
1241
- All = "*",
1293
+ interface TextMessage extends BaseMessage {
1294
+ type: MessageTypesEnum.Text;
1295
+ text: {
1296
+ /**
1297
+ * The text content of the message
1298
+ */
1299
+ body: string;
1300
+ preview_url?: boolean;
1301
+ };
1242
1302
  }
1243
- type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];
1244
1303
  /**
1245
- * Flow Validation Error Pointer
1304
+ * Image message interface
1246
1305
  */
1247
- interface FlowValidationErrorPointer {
1248
- line_start: number;
1249
- line_end: number;
1250
- column_start: number;
1251
- column_end: number;
1252
- path: string;
1306
+ interface ImageMessage extends BaseMessage {
1307
+ type: MessageTypesEnum.Image;
1308
+ image: {
1309
+ /**
1310
+ * The image caption (if provided)
1311
+ */
1312
+ caption?: string;
1313
+ /**
1314
+ * The SHA256 hash of the image
1315
+ */
1316
+ sha256?: string;
1317
+ /**
1318
+ * The ID for the image
1319
+ */
1320
+ id: string;
1321
+ /**
1322
+ * The MIME type of the image
1323
+ */
1324
+ mime_type: string;
1325
+ };
1253
1326
  }
1254
1327
  /**
1255
- * Flow Validation Error
1328
+ * Video message interface
1256
1329
  */
1257
- interface FlowValidationError {
1258
- error: string;
1259
- error_type: string;
1260
- message: string;
1261
- line_start: number;
1262
- line_end: number;
1263
- column_start: number;
1264
- column_end: number;
1265
- pointers: FlowValidationErrorPointer[];
1330
+ interface VideoMessage extends BaseMessage {
1331
+ type: MessageTypesEnum.Video;
1332
+ video: {
1333
+ /**
1334
+ * The video caption (if provided)
1335
+ */
1336
+ caption?: string;
1337
+ /**
1338
+ * The SHA256 hash of the video
1339
+ */
1340
+ sha256?: string;
1341
+ /**
1342
+ * The ID for the video
1343
+ */
1344
+ id: string;
1345
+ /**
1346
+ * The MIME type of the video
1347
+ */
1348
+ mime_type: string;
1349
+ };
1266
1350
  }
1267
1351
  /**
1268
- * Flow Item
1352
+ * Audio message interface
1269
1353
  */
1270
- interface Flow {
1271
- id: string;
1272
- name: string;
1273
- status: FlowStatusEnum;
1274
- categories: FlowCategoryEnum[];
1275
- validation_errors: FlowValidationError[];
1354
+ interface AudioMessage extends BaseMessage {
1355
+ type: MessageTypesEnum.Audio;
1356
+ audio: {
1357
+ /**
1358
+ * The ID for the audio file
1359
+ */
1360
+ id: string;
1361
+ /**
1362
+ * The MIME type of the audio file
1363
+ */
1364
+ mime_type: string;
1365
+ /**
1366
+ * Whether the audio is a voice message
1367
+ */
1368
+ voice?: boolean;
1369
+ };
1276
1370
  }
1277
1371
  /**
1278
- * Pagination Cursors
1372
+ * Document message interface
1279
1373
  */
1280
- interface PaginationCursors {
1281
- before: string;
1282
- after: string;
1374
+ interface DocumentMessage extends BaseMessage {
1375
+ type: MessageTypesEnum.Document;
1376
+ document: {
1377
+ /**
1378
+ * The document caption (if provided)
1379
+ */
1380
+ caption?: string;
1381
+ /**
1382
+ * The document filename
1383
+ */
1384
+ filename: string;
1385
+ /**
1386
+ * The SHA256 hash of the document
1387
+ */
1388
+ sha256?: string;
1389
+ /**
1390
+ * The ID for the document
1391
+ */
1392
+ id: string;
1393
+ /**
1394
+ * The MIME type of the document
1395
+ */
1396
+ mime_type: string;
1397
+ };
1283
1398
  }
1284
1399
  /**
1285
- * Pagination Object
1286
- */
1287
- interface Pagination {
1288
- cursors: PaginationCursors;
1289
- }
1290
- /**
1291
- * Flows List Response
1292
- */
1293
- interface FlowsListResponse {
1294
- data: Flow[];
1295
- paging: Pagination;
1296
- }
1297
- /**
1298
- * Flow Asset
1299
- */
1300
- interface FlowAsset {
1301
- name: string;
1302
- asset_type: string;
1303
- download_url: string;
1304
- }
1305
- /**
1306
- * Flow Assets Response
1307
- */
1308
- interface FlowAssetsResponse {
1309
- data: FlowAsset[];
1310
- paging: Pagination;
1311
- }
1312
- /**
1313
- * Flow Preview
1314
- */
1315
- interface FlowPreview {
1316
- preview_url: string;
1317
- expires_at: string;
1318
- }
1319
- /**
1320
- * Flow Preview Response
1321
- */
1322
- interface FlowPreviewResponse {
1323
- preview: FlowPreview;
1324
- id: string;
1325
- }
1326
- /**
1327
- * Flow Migration Result
1328
- */
1329
- interface FlowMigrationResult {
1330
- source_name: string;
1331
- source_id: string;
1332
- migrated_id: string;
1333
- }
1334
- /**
1335
- * Flow Migration Failure
1336
- */
1337
- interface FlowMigrationFailure {
1338
- source_name: string;
1339
- error_code: string;
1340
- error_message: string;
1341
- }
1342
- /**
1343
- * Create Flow Response
1344
- */
1345
- interface CreateFlowResponse {
1346
- id: string;
1347
- success: boolean;
1348
- validation_errors?: FlowValidationError[];
1349
- }
1350
- /**
1351
- * Update Flow Response
1352
- */
1353
- interface UpdateFlowResponse {
1354
- success: boolean;
1355
- validation_errors?: FlowValidationError[];
1356
- }
1357
- /**
1358
- * Flow Migration Response
1359
- */
1360
- interface FlowMigrationResponse {
1361
- migrated_flows: FlowMigrationResult[];
1362
- failed_flows: FlowMigrationFailure[];
1363
- }
1364
- /**
1365
- * Validate Flow JSON Response
1366
- */
1367
- interface ValidateFlowJsonResponse {
1368
- valid: boolean;
1369
- success: boolean;
1370
- validation_errors?: FlowValidationError[];
1371
- }
1372
- /**
1373
- * WhatsApp Flow Endpoint - Encrypted Request Payload
1374
- * Represents the raw encrypted data received from WhatsApp
1375
- */
1376
- interface FlowEncryptedRequestPayload {
1377
- encrypted_aes_key: string;
1378
- encrypted_flow_data: string;
1379
- initial_vector: string;
1380
- }
1381
- /**
1382
- * WhatsApp Flow Endpoint - Decrypted Request Response
1383
- * Represents the successfully decrypted data and encryption keys
1384
- */
1385
- interface FlowDecryptedRequestResponse {
1386
- decryptedBody: any;
1387
- aesKeyBuffer: Buffer;
1388
- initialVectorBuffer: Buffer;
1389
- }
1390
- /**
1391
- * WhatsApp Flow Endpoint - HTTP Request with Body
1392
- * Represents an HTTP request with the encrypted payload
1393
- */
1394
- interface FlowHttpRequest extends IncomingMessage {
1395
- body: FlowEncryptedRequestPayload;
1396
- headers: IncomingHttpHeaders;
1397
- }
1398
- /**
1399
- * WhatsApp Flow Endpoint - Health Check Request
1400
- * Represents the structure of a health check request
1401
- */
1402
- interface FlowHealthCheckRequest {
1403
- action: 'ping';
1404
- version: '3.0';
1405
- }
1406
- /**
1407
- * WhatsApp Flow Endpoint - Health Check Response
1408
- * The expected response structure for health check requests
1409
- */
1410
- interface FlowHealthCheckResponse {
1411
- data: {
1412
- status: 'active';
1413
- };
1414
- }
1415
- /**
1416
- * WhatsApp Flow Endpoint - Data Exchange Request
1417
- * Represents the structure of a data exchange request
1418
- */
1419
- interface FlowDataExchangeRequest {
1420
- version: '3.0';
1421
- action: FlowActionEnum;
1422
- screen: string;
1423
- flow_token: string;
1424
- data?: Record<string, any> & {
1425
- error_message?: string;
1426
- };
1427
- }
1428
- /**
1429
- * WhatsApp Flow Endpoint - Data Exchange Response
1430
- * The expected response structure for data exchange requests
1431
- */
1432
- interface FlowDataExchangeResponse {
1433
- screen?: string;
1434
- data?: Record<string, any | {
1435
- error_message?: string;
1436
- }>;
1437
- }
1438
- /**
1439
- * WhatsApp Flow Endpoint - Success Screen Response
1440
- * The expected response structure for success screen requests
1441
- */
1442
- interface FlowSuccessScreenResponse {
1443
- screen: 'SUCCESS';
1444
- data: {
1445
- extension_message_response?: {
1446
- params?: {
1447
- flow_token: string;
1448
- [key: string]: string;
1449
- };
1450
- };
1451
- };
1452
- }
1453
- /**
1454
- * WhatsApp Flow Endpoint - Error Notification Request
1455
- * Represents the structure of an error notification request
1456
- */
1457
- interface FlowErrorNotificationRequest {
1458
- version: '3.0';
1459
- action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;
1460
- screen: string;
1461
- flow_token: string;
1462
- data: {
1463
- error: string;
1464
- error_message: string;
1465
- };
1466
- }
1467
- /**
1468
- * WhatsApp Flow Endpoint - Error Notification Response
1469
- * The expected response structure for error notification requests
1470
- */
1471
- interface FlowErrorNotificationResponse {
1472
- acknowledged: boolean;
1473
- }
1474
- /**
1475
- * WhatsApp Flow Endpoint - Comprehensive Request Object
1476
- * A combined type that includes all possible fields from different request types
1477
- * with all fields being optional for flexibility
1478
- */
1479
- interface FlowEndpointRequest {
1480
- version?: '3.0';
1481
- action?: 'ping' | FlowActionEnum;
1482
- screen?: string;
1483
- flow_token?: string;
1484
- data?: Record<string, any> & {
1485
- error_key?: string;
1486
- error_message?: string;
1487
- };
1488
- }
1489
- /**
1490
- * WhatsApp Flow Endpoint - Response
1491
- * Union type for all possible response types from a Flow endpoint
1492
- */
1493
- type FlowEndpointResponse = FlowHealthCheckResponse | FlowDataExchangeResponse | FlowErrorNotificationResponse | FlowSuccessScreenResponse;
1494
- interface FlowClass {
1495
- /**
1496
- * List Flows
1497
- *
1498
- * @param wabaId - The WABA ID
1499
- * @returns Promise with the list of flows
1500
- */
1501
- listFlows(wabaId: string): Promise<FlowsListResponse>;
1502
- /**
1503
- * Create Flow
1504
- *
1505
- * @param wabaId - The WABA ID
1506
- * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
1507
- * @returns Promise with the created flow ID
1508
- */
1509
- createFlow(wabaId: string, data: {
1510
- name: string;
1511
- categories?: FlowCategoryEnum[];
1512
- endpoint_uri?: string;
1513
- clone_flow_id?: string;
1514
- flow_json?: string;
1515
- publish?: boolean;
1516
- }): Promise<CreateFlowResponse>;
1517
- /**
1518
- * Get Flow
1519
- *
1520
- * @param flowId - The flow ID
1521
- * @param fields - Optional fields to return
1522
- * @param dateFormat - Optional date format
1523
- * @returns Promise with the flow details
1524
- */
1525
- getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
1526
- /**
1527
- * Update Flow Metadata
1528
- *
1529
- * @param flowId - The flow ID
1530
- * @param data - The flow metadata to update
1531
- * @returns Promise with the success status
1532
- */
1533
- updateFlowMetadata(flowId: string, data: {
1534
- name?: string;
1535
- categories?: FlowCategoryEnum[];
1536
- endpoint_uri?: string;
1537
- application_id?: string;
1538
- }): Promise<ResponseSuccess>;
1539
- /**
1540
- * Delete Flow
1541
- *
1542
- * @param flowId - The flow ID
1543
- * @returns Promise with the success status
1544
- */
1545
- deleteFlow(flowId: string): Promise<ResponseSuccess>;
1546
- /**
1547
- * List Assets (Get Flow JSON URL)
1548
- *
1549
- * @param flowId - The flow ID
1550
- * @returns Promise with the list of assets
1551
- */
1552
- listAssets(flowId: string): Promise<FlowAssetsResponse>;
1553
- /**
1554
- * Update Flow JSON
1555
- *
1556
- * @param flowId - The flow ID
1557
- * @param data - The asset data including asset_type, file, and name
1558
- * @returns Promise with the success status and validation errors
1559
- */
1560
- updateFlowJson(flowId: string, data: {
1561
- file: Blob | Buffer | object;
1562
- name?: string;
1563
- }): Promise<UpdateFlowResponse>;
1564
- /**
1565
- * Validate Flow JSON by attempting an update without publishing.
1566
- * This is a convenience method; the API doesn't have a dedicated validation endpoint.
1567
- *
1568
- * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
1569
- * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
1570
- * @returns Promise indicating if the JSON is valid and includes validation errors if any.
1571
- */
1572
- validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
1573
- /**
1574
- * Publish Flow
1575
- *
1576
- * @param flowId - The flow ID
1577
- * @returns Promise with the success status
1578
- */
1579
- publishFlow(flowId: string): Promise<ResponseSuccess>;
1580
- /**
1581
- * Deprecate Flow
1582
- *
1583
- * @param flowId - The flow ID
1584
- * @returns Promise with the success status
1585
- */
1586
- deprecateFlow(flowId: string): Promise<ResponseSuccess>;
1587
- /**
1588
- * Migrate Flows
1589
- *
1590
- * @param wabaId - The destination WABA ID
1591
- * @param data - The migration data including source_waba_id and optional source_flow_names
1592
- * @returns Promise with migration results
1593
- */
1594
- migrateFlows(wabaId: string, data: {
1595
- source_waba_id: string;
1596
- source_flow_names?: string[];
1597
- }): Promise<FlowMigrationResponse>;
1598
- }
1599
- //#endregion
1600
- //#region src/core/webhook/types.d.ts
1601
- interface WebhookContact {
1602
- /**
1603
- * WhatsApp ID of the contact. Business can respond to this contact using this ID.
1604
- */
1605
- wa_id: string;
1606
- /**
1607
- * Additional unique, alphanumeric identifier for a WhatsApp user
1608
- */
1609
- user_id?: string;
1610
- /**
1611
- * Profile of Whatsapp user
1612
- */
1613
- profile: {
1614
- /**
1615
- * The display name of the contact
1616
- */
1617
- name: string;
1618
- };
1619
- }
1620
- /**
1621
- * Base message interface with common properties
1622
- */
1623
- interface BaseMessage {
1624
- id: string;
1625
- from: string;
1626
- timestamp: string;
1627
- type: MessageTypesEnum;
1628
- /**
1629
- * Context object, included when a user replies or interacts
1630
- */
1631
- context?: {
1632
- /**
1633
- * ID of the message
1634
- */
1635
- id?: string;
1636
- /**
1637
- * ID of the sender
1638
- */
1639
- from?: string;
1640
- /**
1641
- * ID of the message being replied to or interacted with
1642
- */
1643
- message_id: string;
1644
- /**
1645
- * ID of the forwarded message, if applicable
1646
- */
1647
- forwarded?: boolean;
1648
- /**
1649
- * Frequently forwarded status
1650
- */
1651
- frequently_forwarded?: boolean;
1652
- /**
1653
- * Original message information if the message was referred
1654
- */
1655
- referred_product?: {
1656
- /**
1657
- * Catalog ID
1658
- */
1659
- catalog_id: string;
1660
- /**
1661
- * Product ID
1662
- */
1663
- product_retailer_id: string;
1664
- };
1665
- };
1666
- /**
1667
- * Errors array, if the message had errors
1668
- */
1669
- errors?: Array<{
1670
- /**
1671
- * Error code
1672
- */
1673
- code: number;
1674
- /**
1675
- * Error title
1676
- */
1677
- title: string;
1678
- /**
1679
- * Error message
1680
- */
1681
- message: string;
1682
- /**
1683
- * Error details object
1684
- */
1685
- error_data?: {
1686
- /**
1687
- * Describes the error details
1688
- */
1689
- details: string;
1690
- };
1691
- }>;
1692
- }
1693
- /**
1694
- * Text message interface
1695
- */
1696
- interface TextMessage extends BaseMessage {
1697
- type: MessageTypesEnum.Text;
1698
- text: {
1699
- /**
1700
- * The text content of the message
1701
- */
1702
- body: string;
1703
- preview_url?: boolean;
1704
- };
1705
- }
1706
- /**
1707
- * Image message interface
1708
- */
1709
- interface ImageMessage extends BaseMessage {
1710
- type: MessageTypesEnum.Image;
1711
- image: {
1712
- /**
1713
- * The image caption (if provided)
1714
- */
1715
- caption?: string;
1716
- /**
1717
- * The SHA256 hash of the image
1718
- */
1719
- sha256?: string;
1720
- /**
1721
- * The ID for the image
1722
- */
1723
- id: string;
1724
- /**
1725
- * The MIME type of the image
1726
- */
1727
- mime_type: string;
1728
- };
1729
- }
1730
- /**
1731
- * Video message interface
1732
- */
1733
- interface VideoMessage extends BaseMessage {
1734
- type: MessageTypesEnum.Video;
1735
- video: {
1736
- /**
1737
- * The video caption (if provided)
1738
- */
1739
- caption?: string;
1740
- /**
1741
- * The SHA256 hash of the video
1742
- */
1743
- sha256?: string;
1744
- /**
1745
- * The ID for the video
1746
- */
1747
- id: string;
1748
- /**
1749
- * The MIME type of the video
1750
- */
1751
- mime_type: string;
1752
- };
1753
- }
1754
- /**
1755
- * Audio message interface
1756
- */
1757
- interface AudioMessage extends BaseMessage {
1758
- type: MessageTypesEnum.Audio;
1759
- audio: {
1760
- /**
1761
- * The ID for the audio file
1762
- */
1763
- id: string;
1764
- /**
1765
- * The MIME type of the audio file
1766
- */
1767
- mime_type: string;
1768
- /**
1769
- * Whether the audio is a voice message
1770
- */
1771
- voice?: boolean;
1772
- };
1773
- }
1774
- /**
1775
- * Document message interface
1776
- */
1777
- interface DocumentMessage extends BaseMessage {
1778
- type: MessageTypesEnum.Document;
1779
- document: {
1780
- /**
1781
- * The document caption (if provided)
1782
- */
1783
- caption?: string;
1784
- /**
1785
- * The document filename
1786
- */
1787
- filename: string;
1788
- /**
1789
- * The SHA256 hash of the document
1790
- */
1791
- sha256?: string;
1792
- /**
1793
- * The ID for the document
1794
- */
1795
- id: string;
1796
- /**
1797
- * The MIME type of the document
1798
- */
1799
- mime_type: string;
1800
- };
1801
- }
1802
- /**
1803
- * Sticker message interface
1400
+ * Sticker message interface
1804
1401
  */
1805
1402
  interface StickerMessage extends BaseMessage {
1806
1403
  type: MessageTypesEnum.Sticker;
@@ -2069,10 +1666,6 @@ interface ButtonMessage extends BaseMessage {
2069
1666
  text: string;
2070
1667
  };
2071
1668
  }
2072
- /**
2073
- * Union type for all message types
2074
- */
2075
-
2076
1669
  /**
2077
1670
  * Represents a message received through the webhook
2078
1671
  * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
@@ -2226,218 +1819,609 @@ interface WebhookMessage {
2226
1819
  */
2227
1820
  timestamp: string;
2228
1821
  };
2229
- /**
2230
- * The original message data as received from the webhook
2231
- */
2232
- originalData: any;
1822
+ /**
1823
+ * The original message data as received from the webhook
1824
+ */
1825
+ originalData: any;
1826
+ }
1827
+ /**
1828
+ * Webhook event received from WhatsApp
1829
+ */
1830
+ interface WebhookEvent {
1831
+ /**
1832
+ * The field type of the event
1833
+ */
1834
+ field: string;
1835
+ /**
1836
+ * The event data
1837
+ */
1838
+ value: any;
1839
+ /**
1840
+ * The timestamp when the event was received
1841
+ */
1842
+ timestamp: number;
1843
+ }
1844
+ //#endregion
1845
+ //#region src/api/qrCode/types/common.d.ts
1846
+ type QrCodeResponse = {
1847
+ code: string;
1848
+ prefilled_message: string;
1849
+ deep_link_url: string;
1850
+ qr_image_url?: string;
1851
+ };
1852
+ type QrCodesResponse = ResponseData<QrCodeResponse[]>;
1853
+ type CreateQrCodeRequest = {
1854
+ prefilled_message: string;
1855
+ generate_qr_image?: 'SVG' | 'PNG';
1856
+ };
1857
+ type UpdateQrCodeRequest = {
1858
+ code: string;
1859
+ prefilled_message: string;
1860
+ };
1861
+ interface QrCodeClass {
1862
+ createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
1863
+ getQrCodes(): Promise<QrCodesResponse>;
1864
+ getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
1865
+ updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
1866
+ deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
1867
+ }
1868
+ //#endregion
1869
+ //#region src/api/waba/types/common.d.ts
1870
+ /**
1871
+ * WhatsApp Business Account subscription configuration
1872
+ */
1873
+ type WabaSubscription = {
1874
+ whatsapp_business_api_data: {
1875
+ id: string;
1876
+ link: string;
1877
+ name: string;
1878
+ category: string;
1879
+ };
1880
+ override_callback_uri?: string;
1881
+ };
1882
+ /**
1883
+ * Parameters for updating WABA subscription
1884
+ */
1885
+ interface UpdateWabaSubscription {
1886
+ override_callback_uri: string;
1887
+ verify_token: string;
1888
+ }
1889
+ /**
1890
+ * Response containing all WABA subscriptions
1891
+ */
1892
+ interface WabaSubscriptions {
1893
+ data: Array<WabaSubscription>;
1894
+ }
1895
+ /**
1896
+ * WABA account review status enumeration
1897
+ */
1898
+ declare enum WabaAccountReviewStatus {
1899
+ Approved = "APPROVED",
1900
+ Active = "ACTIVE",
1901
+ Inactive = "INACTIVE",
1902
+ Disabled = "DISABLED",
1903
+ }
1904
+ /**
1905
+ * WABA health status for message sending capability
1906
+ */
1907
+ declare enum WabaHealthStatusCanSendMessage {
1908
+ Blocked = "BLOCKED",
1909
+ Limited = "LIMITED",
1910
+ Available = "AVAILABLE",
1911
+ }
1912
+ /**
1913
+ * WABA account status enumeration
1914
+ */
1915
+ declare enum WabaAccountStatus {
1916
+ Approved = "APPROVED",
1917
+ Active = "ACTIVE",
1918
+ Inactive = "INACTIVE",
1919
+ Disabled = "DISABLED",
1920
+ }
1921
+ /**
1922
+ * Business verification status enumeration
1923
+ */
1924
+ declare enum WabaBusinessVerificationStatus {
1925
+ Verified = "verified",
1926
+ PendingSubmission = "pending_submission",
1927
+ Unverified = "unverified",
1928
+ Rejected = "rejected",
1929
+ }
1930
+ /**
1931
+ * WABA health status error details
1932
+ */
1933
+ interface WabaHealthStatusError {
1934
+ error_code?: number;
1935
+ error_description?: string;
1936
+ possible_solution?: string;
1937
+ }
1938
+ /**
1939
+ * WABA health status entity information
1940
+ */
1941
+ interface WabaHealthStatusEntity {
1942
+ entity_type?: string;
1943
+ id?: string;
1944
+ can_send_message?: string;
1945
+ errors?: WabaHealthStatusError[];
1946
+ }
1947
+ /**
1948
+ * Overall WABA health status
1949
+ */
1950
+ interface WabaHealthStatus {
1951
+ can_send_message?: WabaHealthStatusCanSendMessage;
1952
+ entities?: WabaHealthStatusEntity[];
1953
+ }
1954
+ /**
1955
+ * WhatsApp Business Account information
1956
+ */
1957
+ interface WabaAccount {
1958
+ account_review_status?: WabaAccountReviewStatus;
1959
+ id?: string;
1960
+ health_status?: WabaHealthStatus;
1961
+ status?: WabaAccountStatus;
1962
+ business_verification_status?: WabaBusinessVerificationStatus;
1963
+ message_template_namespace?: string;
1964
+ name?: string;
1965
+ ownership_type?: string;
1966
+ currency?: string;
1967
+ }
1968
+ /**
1969
+ * Available fields for WABA account queries
1970
+ */
1971
+ type WabaAccountFields = 'id' | 'name' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace';
1972
+ /**
1973
+ * Parameter type for specifying which WABA account fields to retrieve
1974
+ */
1975
+ type WabaAccountFieldsParam = WabaAccountFields[];
1976
+ /**
1977
+ * Interface defining all WABA API methods
1978
+ */
1979
+ interface WABAClass {
1980
+ getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
1981
+ getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
1982
+ updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
1983
+ unsubscribeFromWaba(): Promise<ResponseSuccess>;
1984
+ }
1985
+ //#endregion
1986
+ //#region src/api/registration/types/common.d.ts
1987
+ type RegistrationRequest = {
1988
+ messaging_product: 'whatsapp';
1989
+ pin: string;
1990
+ data_localization_region?: DataLocalizationRegionEnum;
1991
+ };
1992
+ interface RegistrationClass {
1993
+ register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
1994
+ deregister(): Promise<ResponseSuccess>;
1995
+ }
1996
+ //#endregion
1997
+ //#region src/api/twoStepVerification/types/common.d.ts
1998
+ type TwoStepVerificationRequest = {
1999
+ pin: string;
2000
+ };
2001
+ interface TwoStepVerificationClass {
2002
+ setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
2003
+ }
2004
+ //#endregion
2005
+ //#region src/api/encryption/types/publicKey.d.ts
2006
+ type EncryptionPublicKeyResponse = ResponseData<{
2007
+ business_public_key: string;
2008
+ business_public_key_signature_status: 'VALID' | 'MISMATCH';
2009
+ }>;
2010
+ //#endregion
2011
+ //#region src/utils/isMetaError.d.ts
2012
+ interface MetaError extends Error {
2013
+ error: {
2014
+ message: string;
2015
+ type: string;
2016
+ code: number;
2017
+ error_data?: {
2018
+ messaging_product: 'whatsapp';
2019
+ details: string;
2020
+ };
2021
+ error_subcode?: number;
2022
+ fbtrace_id: string;
2023
+ };
2233
2024
  }
2025
+ //#endregion
2026
+ //#region src/api/flow/types/common.d.ts
2234
2027
  /**
2235
- * Webhook event received from WhatsApp
2028
+ * Enum for Flow Status
2236
2029
  */
2237
- interface WebhookEvent {
2238
- /**
2239
- * The field type of the event
2240
- */
2241
- field: string;
2242
- /**
2243
- * The event data
2244
- */
2245
- value: any;
2246
- /**
2247
- * The timestamp when the event was received
2248
- */
2249
- timestamp: number;
2030
+ declare enum FlowStatusEnum {
2031
+ Draft = "DRAFT",
2032
+ Published = "PUBLISHED",
2033
+ Throttled = "THROTTLED",
2034
+ Blocked = "BLOCKED",
2035
+ Deprecated = "DEPRECATED",
2250
2036
  }
2251
2037
  /**
2252
- * Message status enum
2038
+ * Enum for Flow Categories
2253
2039
  */
2254
- //#endregion
2255
- //#region src/api/qrCode/types/common.d.ts
2256
- type QrCodeResponse = {
2257
- code: string;
2258
- prefilled_message: string;
2259
- deep_link_url: string;
2260
- qr_image_url?: string;
2261
- };
2262
- type QrCodesResponse = ResponseData<QrCodeResponse[]>;
2263
- type CreateQrCodeRequest = {
2264
- prefilled_message: string;
2265
- generate_qr_image?: 'SVG' | 'PNG';
2266
- };
2267
- type UpdateQrCodeRequest = {
2268
- code: string;
2269
- prefilled_message: string;
2270
- };
2271
- interface QrCodeClass {
2272
- createQrCode(request: CreateQrCodeRequest): Promise<QrCodeResponse>;
2273
- getQrCodes(): Promise<QrCodesResponse>;
2274
- getQrCode(qrCodeId: string): Promise<QrCodeResponse>;
2275
- updateQrCode(request: UpdateQrCodeRequest): Promise<QrCodeResponse>;
2276
- deleteQrCode(qrCodeId: string): Promise<ResponseSuccess>;
2040
+ declare enum FlowCategoryEnum {
2041
+ SignUp = "SIGN_UP",
2042
+ SignIn = "SIGN_IN",
2043
+ AppointmentBooking = "APPOINTMENT_BOOKING",
2044
+ LeadGeneration = "LEAD_GENERATION",
2045
+ ContactUs = "CONTACT_US",
2046
+ CustomerSupport = "CUSTOMER_SUPPORT",
2047
+ Survey = "SURVEY",
2048
+ Other = "OTHER",
2049
+ }
2050
+ declare enum FlowActionEnum {
2051
+ INIT = "INIT",
2052
+ BACK = "BACK",
2053
+ DATA_EXCHANGE = "data_exchange",
2277
2054
  }
2278
- //#endregion
2279
- //#region src/api/waba/types/common.d.ts
2280
2055
  /**
2281
- * WhatsApp Business Account subscription configuration
2056
+ * Enum for Flow Types in webhook handlers
2057
+ * Used to register handlers for specific flow events
2282
2058
  */
2283
- type WabaSubscription = {
2284
- whatsapp_business_api_data: {
2285
- id: string;
2286
- link: string;
2287
- name: string;
2288
- category: string;
2289
- };
2290
- override_callback_uri?: string;
2291
- };
2059
+ declare enum FlowTypeEnum {
2060
+ /** Health check/ping requests */
2061
+ Ping = "ping",
2062
+ /** Data exchange requests */
2063
+ Change = "data_exchange",
2064
+ /** Error notification requests */
2065
+ Error = "error",
2066
+ /** Match all flow action types */
2067
+ All = "*",
2068
+ }
2069
+ type FlowType = (typeof FlowTypeEnum)[keyof typeof FlowTypeEnum];
2292
2070
  /**
2293
- * Parameters for updating WABA subscription
2071
+ * Flow Validation Error Pointer
2294
2072
  */
2295
- interface UpdateWabaSubscription {
2296
- override_callback_uri: string;
2297
- verify_token: string;
2073
+ interface FlowValidationErrorPointer {
2074
+ line_start: number;
2075
+ line_end: number;
2076
+ column_start: number;
2077
+ column_end: number;
2078
+ path: string;
2298
2079
  }
2299
2080
  /**
2300
- * Response containing all WABA subscriptions
2081
+ * Flow Validation Error
2301
2082
  */
2302
- interface WabaSubscriptions {
2303
- data: Array<WabaSubscription>;
2083
+ interface FlowValidationError {
2084
+ error: string;
2085
+ error_type: string;
2086
+ message: string;
2087
+ line_start: number;
2088
+ line_end: number;
2089
+ column_start: number;
2090
+ column_end: number;
2091
+ pointers: FlowValidationErrorPointer[];
2304
2092
  }
2305
2093
  /**
2306
- * WABA account review status enumeration
2094
+ * Flow Item
2307
2095
  */
2308
- declare enum WabaAccountReviewStatus {
2309
- Approved = "APPROVED",
2310
- Active = "ACTIVE",
2311
- Inactive = "INACTIVE",
2312
- Disabled = "DISABLED",
2096
+ interface Flow {
2097
+ id: string;
2098
+ name: string;
2099
+ status: FlowStatusEnum;
2100
+ categories: FlowCategoryEnum[];
2101
+ validation_errors: FlowValidationError[];
2313
2102
  }
2314
2103
  /**
2315
- * WABA health status for message sending capability
2104
+ * Pagination Cursors
2316
2105
  */
2317
- declare enum WabaHealthStatusCanSendMessage {
2318
- Blocked = "BLOCKED",
2319
- Limited = "LIMITED",
2320
- Available = "AVAILABLE",
2106
+ interface PaginationCursors {
2107
+ before: string;
2108
+ after: string;
2321
2109
  }
2322
2110
  /**
2323
- * WABA account status enumeration
2111
+ * Pagination Object
2324
2112
  */
2325
- declare enum WabaAccountStatus {
2326
- Approved = "APPROVED",
2327
- Active = "ACTIVE",
2328
- Inactive = "INACTIVE",
2329
- Disabled = "DISABLED",
2113
+ interface Pagination {
2114
+ cursors: PaginationCursors;
2330
2115
  }
2331
2116
  /**
2332
- * Business verification status enumeration
2117
+ * Flows List Response
2333
2118
  */
2334
- declare enum WabaBusinessVerificationStatus {
2335
- Verified = "verified",
2336
- PendingSubmission = "pending_submission",
2337
- Unverified = "unverified",
2338
- Rejected = "rejected",
2119
+ interface FlowsListResponse {
2120
+ data: Flow[];
2121
+ paging: Pagination;
2122
+ }
2123
+ /**
2124
+ * Flow Asset
2125
+ */
2126
+ interface FlowAsset {
2127
+ name: string;
2128
+ asset_type: string;
2129
+ download_url: string;
2130
+ }
2131
+ /**
2132
+ * Flow Assets Response
2133
+ */
2134
+ interface FlowAssetsResponse {
2135
+ data: FlowAsset[];
2136
+ paging: Pagination;
2137
+ }
2138
+ /**
2139
+ * Flow Preview
2140
+ */
2141
+ interface FlowPreview {
2142
+ preview_url: string;
2143
+ expires_at: string;
2144
+ }
2145
+ /**
2146
+ * Flow Preview Response
2147
+ */
2148
+ interface FlowPreviewResponse {
2149
+ preview: FlowPreview;
2150
+ id: string;
2151
+ }
2152
+ /**
2153
+ * Flow Migration Result
2154
+ */
2155
+ interface FlowMigrationResult {
2156
+ source_name: string;
2157
+ source_id: string;
2158
+ migrated_id: string;
2159
+ }
2160
+ /**
2161
+ * Flow Migration Failure
2162
+ */
2163
+ interface FlowMigrationFailure {
2164
+ source_name: string;
2165
+ error_code: string;
2166
+ error_message: string;
2167
+ }
2168
+ /**
2169
+ * Create Flow Response
2170
+ */
2171
+ interface CreateFlowResponse {
2172
+ id: string;
2173
+ success: boolean;
2174
+ validation_errors?: FlowValidationError[];
2175
+ }
2176
+ /**
2177
+ * Update Flow Response
2178
+ */
2179
+ interface UpdateFlowResponse {
2180
+ success: boolean;
2181
+ validation_errors?: FlowValidationError[];
2182
+ }
2183
+ /**
2184
+ * Flow Migration Response
2185
+ */
2186
+ interface FlowMigrationResponse {
2187
+ migrated_flows: FlowMigrationResult[];
2188
+ failed_flows: FlowMigrationFailure[];
2189
+ }
2190
+ /**
2191
+ * Validate Flow JSON Response
2192
+ */
2193
+ interface ValidateFlowJsonResponse {
2194
+ valid: boolean;
2195
+ success: boolean;
2196
+ validation_errors?: FlowValidationError[];
2197
+ }
2198
+ /**
2199
+ * WhatsApp Flow Endpoint - Encrypted Request Payload
2200
+ * Represents the raw encrypted data received from WhatsApp
2201
+ */
2202
+ interface FlowEncryptedRequestPayload {
2203
+ encrypted_aes_key: string;
2204
+ encrypted_flow_data: string;
2205
+ initial_vector: string;
2206
+ }
2207
+ /**
2208
+ * WhatsApp Flow Endpoint - Decrypted Request Response
2209
+ * Represents the successfully decrypted data and encryption keys
2210
+ */
2211
+ interface FlowDecryptedRequestResponse {
2212
+ decryptedBody: any;
2213
+ aesKeyBuffer: Buffer;
2214
+ initialVectorBuffer: Buffer;
2215
+ }
2216
+ /**
2217
+ * WhatsApp Flow Endpoint - HTTP Request with Body
2218
+ * Represents an HTTP request with the encrypted payload
2219
+ */
2220
+ interface FlowHttpRequest extends IncomingMessage {
2221
+ body: FlowEncryptedRequestPayload;
2222
+ headers: IncomingHttpHeaders;
2339
2223
  }
2340
2224
  /**
2341
- * WABA health status error details
2225
+ * WhatsApp Flow Endpoint - Health Check Request
2226
+ * Represents the structure of a health check request
2342
2227
  */
2343
- interface WabaHealthStatusError {
2344
- error_code?: number;
2345
- error_description?: string;
2346
- possible_solution?: string;
2228
+ interface FlowHealthCheckRequest {
2229
+ action: 'ping';
2230
+ version: '3.0';
2347
2231
  }
2348
2232
  /**
2349
- * WABA health status entity information
2233
+ * WhatsApp Flow Endpoint - Health Check Response
2234
+ * The expected response structure for health check requests
2350
2235
  */
2351
- interface WabaHealthStatusEntity {
2352
- entity_type?: string;
2353
- id?: string;
2354
- can_send_message?: string;
2355
- errors?: WabaHealthStatusError[];
2236
+ interface FlowHealthCheckResponse {
2237
+ data: {
2238
+ status: 'active';
2239
+ };
2356
2240
  }
2357
2241
  /**
2358
- * Overall WABA health status
2242
+ * WhatsApp Flow Endpoint - Data Exchange Request
2243
+ * Represents the structure of a data exchange request
2359
2244
  */
2360
- interface WabaHealthStatus {
2361
- can_send_message?: WabaHealthStatusCanSendMessage;
2362
- entities?: WabaHealthStatusEntity[];
2245
+ interface FlowDataExchangeRequest {
2246
+ version: '3.0';
2247
+ action: FlowActionEnum;
2248
+ screen: string;
2249
+ flow_token: string;
2250
+ data?: Record<string, any> & {
2251
+ error_message?: string;
2252
+ };
2363
2253
  }
2364
2254
  /**
2365
- * WhatsApp Business Account information
2255
+ * WhatsApp Flow Endpoint - Data Exchange Response
2256
+ * The expected response structure for data exchange requests
2366
2257
  */
2367
- interface WabaAccount {
2368
- account_review_status?: WabaAccountReviewStatus;
2369
- id?: string;
2370
- health_status?: WabaHealthStatus;
2371
- status?: WabaAccountStatus;
2372
- business_verification_status?: WabaBusinessVerificationStatus;
2373
- message_template_namespace?: string;
2374
- name?: string;
2375
- ownership_type?: string;
2376
- currency?: string;
2258
+ interface FlowDataExchangeResponse {
2259
+ screen?: string;
2260
+ data?: Record<string, any | {
2261
+ error_message?: string;
2262
+ }>;
2377
2263
  }
2378
2264
  /**
2379
- * Available fields for WABA account queries
2265
+ * WhatsApp Flow Endpoint - Success Screen Response
2266
+ * The expected response structure for success screen requests
2380
2267
  */
2381
- type WabaAccountFields = 'id' | 'name' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace';
2268
+ interface FlowSuccessScreenResponse {
2269
+ screen: 'SUCCESS';
2270
+ data: {
2271
+ extension_message_response?: {
2272
+ params?: {
2273
+ flow_token: string;
2274
+ [key: string]: string;
2275
+ };
2276
+ };
2277
+ };
2278
+ }
2382
2279
  /**
2383
- * Parameter type for specifying which WABA account fields to retrieve
2280
+ * WhatsApp Flow Endpoint - Error Notification Request
2281
+ * Represents the structure of an error notification request
2384
2282
  */
2385
- type WabaAccountFieldsParam = WabaAccountFields[];
2283
+ interface FlowErrorNotificationRequest {
2284
+ version: '3.0';
2285
+ action: Exclude<FlowActionEnum, FlowActionEnum.BACK>;
2286
+ screen: string;
2287
+ flow_token: string;
2288
+ data: {
2289
+ error: string;
2290
+ error_message: string;
2291
+ };
2292
+ }
2386
2293
  /**
2387
- * Interface defining all WABA API methods
2294
+ * WhatsApp Flow Endpoint - Error Notification Response
2295
+ * The expected response structure for error notification requests
2388
2296
  */
2389
- interface WABAClass {
2390
- getWabaAccount(fields?: WabaAccountFieldsParam): Promise<WabaAccount>;
2391
- getAllWabaSubscriptions(): Promise<WabaSubscriptions>;
2392
- updateWabaSubscription(params: UpdateWabaSubscription): Promise<ResponseSuccess>;
2393
- unsubscribeFromWaba(): Promise<ResponseSuccess>;
2394
- }
2395
- //#endregion
2396
- //#region src/api/registration/types/common.d.ts
2397
- type RegistrationRequest = {
2398
- messaging_product: 'whatsapp';
2399
- pin: string;
2400
- data_localization_region?: DataLocalizationRegionEnum;
2401
- };
2402
- interface RegistrationClass {
2403
- register(pin: string, dataLocalizationRegion?: DataLocalizationRegionEnum): Promise<ResponseSuccess>;
2404
- deregister(): Promise<ResponseSuccess>;
2405
- }
2406
- //#endregion
2407
- //#region src/api/twoStepVerification/types/common.d.ts
2408
- type TwoStepVerificationRequest = {
2409
- pin: string;
2410
- };
2411
- interface TwoStepVerificationClass {
2412
- setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
2297
+ interface FlowErrorNotificationResponse {
2298
+ acknowledged: boolean;
2413
2299
  }
2414
- //#endregion
2415
- //#region src/api/encryption/types/publicKey.d.ts
2416
- type EncryptionPublicKeyResponse = ResponseData<{
2417
- business_public_key: string;
2418
- business_public_key_signature_status: 'VALID' | 'MISMATCH';
2419
- }>;
2420
- //#endregion
2421
- //#region src/utils/isMetaError.d.ts
2422
- interface MetaError extends Error {
2423
- error: {
2424
- message: string;
2425
- type: string;
2426
- code: number;
2427
- error_data?: {
2428
- messaging_product: 'whatsapp';
2429
- details: string;
2430
- };
2431
- error_subcode?: number;
2432
- fbtrace_id: string;
2300
+ /**
2301
+ * WhatsApp Flow Endpoint - Comprehensive Request Object
2302
+ * A combined type that includes all possible fields from different request types
2303
+ * with all fields being optional for flexibility
2304
+ */
2305
+ interface FlowEndpointRequest {
2306
+ version?: '3.0';
2307
+ action?: 'ping' | FlowActionEnum;
2308
+ screen?: string;
2309
+ flow_token?: string;
2310
+ data?: Record<string, any> & {
2311
+ error_key?: string;
2312
+ error_message?: string;
2433
2313
  };
2434
2314
  }
2435
2315
  /**
2436
- * Determines if the error is a Meta API error response
2437
- * @param error Any error object to check
2438
- * @returns Type guard indicating if error is a Meta API error
2316
+ * WhatsApp Flow Endpoint - Response
2317
+ * Union type for all possible response types from a Flow endpoint
2439
2318
  */
2440
-
2319
+ type FlowEndpointResponse = FlowHealthCheckResponse | FlowDataExchangeResponse | FlowErrorNotificationResponse | FlowSuccessScreenResponse;
2320
+ interface FlowClass {
2321
+ /**
2322
+ * List Flows
2323
+ *
2324
+ * @param wabaId - The WABA ID
2325
+ * @returns Promise with the list of flows
2326
+ */
2327
+ listFlows(wabaId: string): Promise<FlowsListResponse>;
2328
+ /**
2329
+ * Create Flow
2330
+ *
2331
+ * @param wabaId - The WABA ID
2332
+ * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id
2333
+ * @returns Promise with the created flow ID
2334
+ */
2335
+ createFlow(wabaId: string, data: {
2336
+ name: string;
2337
+ categories?: FlowCategoryEnum[];
2338
+ endpoint_uri?: string;
2339
+ clone_flow_id?: string;
2340
+ flow_json?: string;
2341
+ publish?: boolean;
2342
+ }): Promise<CreateFlowResponse>;
2343
+ /**
2344
+ * Get Flow
2345
+ *
2346
+ * @param flowId - The flow ID
2347
+ * @param fields - Optional fields to return
2348
+ * @param dateFormat - Optional date format
2349
+ * @returns Promise with the flow details
2350
+ */
2351
+ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
2352
+ /**
2353
+ * Update Flow Metadata
2354
+ *
2355
+ * @param flowId - The flow ID
2356
+ * @param data - The flow metadata to update
2357
+ * @returns Promise with the success status
2358
+ */
2359
+ updateFlowMetadata(flowId: string, data: {
2360
+ name?: string;
2361
+ categories?: FlowCategoryEnum[];
2362
+ endpoint_uri?: string;
2363
+ application_id?: string;
2364
+ }): Promise<ResponseSuccess>;
2365
+ /**
2366
+ * Delete Flow
2367
+ *
2368
+ * @param flowId - The flow ID
2369
+ * @returns Promise with the success status
2370
+ */
2371
+ deleteFlow(flowId: string): Promise<ResponseSuccess>;
2372
+ /**
2373
+ * List Assets (Get Flow JSON URL)
2374
+ *
2375
+ * @param flowId - The flow ID
2376
+ * @returns Promise with the list of assets
2377
+ */
2378
+ listAssets(flowId: string): Promise<FlowAssetsResponse>;
2379
+ /**
2380
+ * Update Flow JSON
2381
+ *
2382
+ * @param flowId - The flow ID
2383
+ * @param data - The asset data including asset_type, file, and name
2384
+ * @returns Promise with the success status and validation errors
2385
+ */
2386
+ updateFlowJson(flowId: string, data: {
2387
+ file: Blob | Buffer | object;
2388
+ name?: string;
2389
+ }): Promise<UpdateFlowResponse>;
2390
+ /**
2391
+ * Validate Flow JSON by attempting an update without publishing.
2392
+ * This is a convenience method; the API doesn't have a dedicated validation endpoint.
2393
+ *
2394
+ * @param flowId - The ID of the Flow (must exist, can be in DRAFT status).
2395
+ * @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
2396
+ * @returns Promise indicating if the JSON is valid and includes validation errors if any.
2397
+ */
2398
+ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
2399
+ /**
2400
+ * Publish Flow
2401
+ *
2402
+ * @param flowId - The flow ID
2403
+ * @returns Promise with the success status
2404
+ */
2405
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
2406
+ /**
2407
+ * Deprecate Flow
2408
+ *
2409
+ * @param flowId - The flow ID
2410
+ * @returns Promise with the success status
2411
+ */
2412
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
2413
+ /**
2414
+ * Migrate Flows
2415
+ *
2416
+ * @param wabaId - The destination WABA ID
2417
+ * @param data - The migration data including source_waba_id and optional source_flow_names
2418
+ * @returns Promise with migration results
2419
+ */
2420
+ migrateFlows(wabaId: string, data: {
2421
+ source_waba_id: string;
2422
+ source_flow_names?: string[];
2423
+ }): Promise<FlowMigrationResponse>;
2424
+ }
2441
2425
  //#endregion
2442
2426
  export { type AccountMode, type AudioMediaObject, type AuthenticationTemplateOptions, type BaseClass, type BodyOptions, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, type ButtonOptions, type CarouselCard, type CarouselOptions, type CatalogButton, type CatalogTemplateOptions, type CodeVerificationStatus, type ComponentTypes, type ContactObject, type CopyCodeButton, type CouponTemplateOptions, CreateFlowResponse, type CreateQrCodeRequest, type CurrencyParameter, type Cursors, type DateTimeParameter, type DocumentMediaObject, type EncryptionPublicKeyResponse, type Flow, FlowActionEnum, type FlowAsset, type FlowAssetsResponse, type FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type HeaderOptions, type HealthStatus, type HealthStatusEntity, type HttpsClientClass, type HttpsClientResponseClass, type ImageMediaObject, type InteractiveObject, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, type LocationObject, type LocationParameter, type LoggerInterface, type MPMButton, type MPMTemplateOptions, type MediaCardCarouselTemplateOptions, type MediaCarouselCard, MediaClass, type MediaParameter, MediaResponse, MediasResponse, type MessageRequestBody, type MessageRequestParams, type MessageTemplateObject, type MessagesClass, type MessagesResponse, type MessagingLimitTier, type MetaError, type OTPButton, type OTPTemplateOptions, type Pagination, type PaginationCursors, type Paging, type PhoneNumberButton, type PhoneNumberClass, type PhoneNumberResponse, type PhoneNumbersResponse, type PlatformType, type ProductCardCarouselTemplateOptions, type ProductCarouselCard, type ProductParameter, type ProductSection, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, type QualityRating, type QualityScore, type QuickReplyButton, type ReactionParams, type RegistrationClass, type RegistrationRequest, type RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, type SPMButton, type SPMTemplateOptions, type StatusParams, type StickerMediaObject, type TemplateBody, type TemplateButton, type TemplateButtons, type TemplateCarousel, type TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateLimitedTimeOffer, type TemplateOptions, type TemplateParameter, type TemplateRequestBody, type TemplateResponse, type TextMessageParams, type TextObject, type TextParameter, type Throughput, type ThroughputLevel, type TwoStepVerificationClass, type TwoStepVerificationParams, type TwoStepVerificationRequest, type URLButton, type UpdateBusinessProfileRequest, type UpdateFlowResponse, type UpdateQrCodeRequest, type UpdateWabaSubscription, UploadMediaResponse, type ValidateFlowJsonResponse, type VerifyCodeRequest, type VideoMediaObject, type WABAClass, type WabaAccount, type WabaAccountFields, type WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaBusinessVerificationStatus, type WabaConfigType, type WabaHealthStatus, WabaHealthStatusCanSendMessage, type WabaHealthStatusEntity, type WabaHealthStatusError, type WabaSubscription, type WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookMessage, type WhatsAppConfig };
2443
2427
  //# sourceMappingURL=index.d.ts.map