@wppconnect/server 2.2.5 → 2.4.0

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 (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +24 -2
  3. package/dist/config/upload.js +2 -2
  4. package/dist/config.js +9 -4
  5. package/dist/controller/deviceController.js +23 -19
  6. package/dist/controller/groupController.js +29 -23
  7. package/dist/controller/messageController.js +242 -33
  8. package/dist/controller/newsletterController.js +196 -0
  9. package/dist/controller/orderController.js +14 -29
  10. package/dist/index.js +2 -2
  11. package/dist/mapper/index.js +2 -2
  12. package/dist/mapper/tagone-chat.js +3 -3
  13. package/dist/mapper/tagone-device.js +3 -3
  14. package/dist/mapper/tagone-message-document.js +3 -3
  15. package/dist/mapper/tagone-message-image.js +3 -3
  16. package/dist/mapper/tagone-message-location.js +3 -3
  17. package/dist/mapper/tagone-message-video.js +3 -3
  18. package/dist/mapper/tagone-message.js +3 -3
  19. package/dist/mapper/tagone-onack.js +3 -3
  20. package/dist/mapper/tagone-return.js +3 -3
  21. package/dist/middleware/auth.js +3 -3
  22. package/dist/middleware/instrumentation.js +2 -2
  23. package/dist/middleware/statusConnection.js +7 -3
  24. package/dist/routes/index.js +50 -5
  25. package/dist/swagger.json +571 -51
  26. package/dist/types/ServerOptions.js +1 -1
  27. package/dist/util/bufferutils.js +3 -3
  28. package/dist/util/createSessionUtil.js +9 -2
  29. package/dist/util/db/mongodb/db.js +3 -3
  30. package/dist/util/db/redis/db.js +3 -3
  31. package/dist/util/functions.js +26 -6
  32. package/dist/util/sessionUtil.js +3 -3
  33. package/dist/util/tokenStore/FileTokenStore/FileTokenStore.js +4 -4
  34. package/dist/util/tokenStore/factory.js +3 -3
  35. package/dist/util/tokenStore/fileTokenStory.js +3 -3
  36. package/dist/util/tokenStore/model/token.js +3 -3
  37. package/dist/util/tokenStore/mongodbTokenStory.js +3 -3
  38. package/dist/util/tokenStore/redisTokenStory.js +3 -3
  39. package/package.json +58 -58
package/dist/swagger.json CHANGED
@@ -586,7 +586,106 @@
586
586
  "bearerAuth": []
587
587
  }
588
588
  ],
589
- "requestBody": {}
589
+ "requestBody": {
590
+ "required": true,
591
+ "content": {
592
+ "application/json": {
593
+ "schema": {
594
+ "type": "object",
595
+ "properties": {
596
+ "phone": {
597
+ "type": "string"
598
+ },
599
+ "isGroup": {
600
+ "type": "boolean"
601
+ },
602
+ "isNewsletter": {
603
+ "type": "boolean"
604
+ },
605
+ "message": {
606
+ "type": "string"
607
+ },
608
+ "options": {
609
+ "type": "object"
610
+ }
611
+ }
612
+ },
613
+ "examples": {
614
+ "Send message to contact": {
615
+ "value": {
616
+ "phone": "5521999999999",
617
+ "isGroup": false,
618
+ "isNewsletter": false,
619
+ "message": "Hi from WPPConnect"
620
+ }
621
+ },
622
+ "Send message to group": {
623
+ "value": {
624
+ "phone": "8865623215244578",
625
+ "isGroup": true,
626
+ "message": "Hi from WPPConnect"
627
+ }
628
+ }
629
+ }
630
+ }
631
+ }
632
+ }
633
+ }
634
+ },
635
+ "/api/{session}/edit-message": {
636
+ "post": {
637
+ "tags": ["Messages"],
638
+ "description": "",
639
+ "parameters": [
640
+ {
641
+ "name": "session",
642
+ "in": "path",
643
+ "required": true,
644
+ "schema": {
645
+ "type": "string",
646
+ "example": "NERDWHATS_AMERICA"
647
+ }
648
+ }
649
+ ],
650
+ "responses": {
651
+ "default": {
652
+ "description": ""
653
+ }
654
+ },
655
+ "security": [
656
+ {
657
+ "bearerAuth": []
658
+ }
659
+ ],
660
+ "requestBody": {
661
+ "required": true,
662
+ "content": {
663
+ "application/json": {
664
+ "schema": {
665
+ "type": "object",
666
+ "properties": {
667
+ "id": {
668
+ "type": "string"
669
+ },
670
+ "newText": {
671
+ "type": "string"
672
+ },
673
+ "options": {
674
+ "type": "object"
675
+ }
676
+ }
677
+ },
678
+ "examples": {
679
+ "Edit a message": {
680
+ "value": {
681
+ "id": "true_5521999999999@c.us_3EB04FCAA1527EB6D9DEC8",
682
+ "newText": "New text for message"
683
+ }
684
+ }
685
+ }
686
+ }
687
+ }
688
+ }
590
689
  }
591
690
  },
592
691
  "/api/{session}/send-image": {
@@ -630,6 +729,9 @@
630
729
  "isGroup": {
631
730
  "type": "boolean"
632
731
  },
732
+ "isNewsletter": {
733
+ "type": "boolean"
734
+ },
633
735
  "filename": {
634
736
  "type": "string"
635
737
  },
@@ -646,6 +748,7 @@
646
748
  "value": {
647
749
  "phone": "5521999999999",
648
750
  "isGroup": false,
751
+ "isNewsletter": false,
649
752
  "filename": "file name lol",
650
753
  "caption": "caption for my file",
651
754
  "base64": "<base64> string"
@@ -881,6 +984,9 @@
881
984
  "isGroup": {
882
985
  "type": "boolean"
883
986
  },
987
+ "isNewsletter": {
988
+ "type": "boolean"
989
+ },
884
990
  "filename": {
885
991
  "type": "string"
886
992
  },
@@ -897,6 +1003,7 @@
897
1003
  "value": {
898
1004
  "phone": "5521999999999",
899
1005
  "isGroup": false,
1006
+ "isNewsletter": false,
900
1007
  "filename": "file name lol",
901
1008
  "caption": "caption for my file",
902
1009
  "base64": "<base64> string"
@@ -949,6 +1056,9 @@
949
1056
  "isGroup": {
950
1057
  "type": "boolean"
951
1058
  },
1059
+ "isNewsletter": {
1060
+ "type": "boolean"
1061
+ },
952
1062
  "filename": {
953
1063
  "type": "string"
954
1064
  },
@@ -965,6 +1075,7 @@
965
1075
  "value": {
966
1076
  "phone": "5521999999999",
967
1077
  "isGroup": false,
1078
+ "isNewsletter": false,
968
1079
  "filename": "file name lol",
969
1080
  "caption": "caption for my file",
970
1081
  "base64": "<base64> string"
@@ -1438,7 +1549,166 @@
1438
1549
  "bearerAuth": []
1439
1550
  }
1440
1551
  ],
1441
- "deprecated": true
1552
+ "requestBody": {
1553
+ "required": true,
1554
+ "content": {
1555
+ "application/json": {
1556
+ "schema": {
1557
+ "type": "object",
1558
+ "properties": {
1559
+ "phone": {
1560
+ "type": "string"
1561
+ },
1562
+ "isGroup": {
1563
+ "type": "boolean"
1564
+ },
1565
+ "description": {
1566
+ "type": "string"
1567
+ },
1568
+ "sections": {
1569
+ "type": "array"
1570
+ },
1571
+ "buttonText": {
1572
+ "type": "string"
1573
+ }
1574
+ }
1575
+ },
1576
+ "examples": {
1577
+ "Send list message": {
1578
+ "value": {
1579
+ "phone": "5521999999999",
1580
+ "isGroup": false,
1581
+ "description": "Desc for list",
1582
+ "buttonText": "Select a option",
1583
+ "sections": [
1584
+ {
1585
+ "title": "Section 1",
1586
+ "rows": [
1587
+ {
1588
+ "rowId": "my_custom_id",
1589
+ "title": "Test 1",
1590
+ "description": "Description 1"
1591
+ },
1592
+ {
1593
+ "rowId": "2",
1594
+ "title": "Test 2",
1595
+ "description": "Description 2"
1596
+ }
1597
+ ]
1598
+ }
1599
+ ]
1600
+ }
1601
+ }
1602
+ }
1603
+ }
1604
+ }
1605
+ }
1606
+ }
1607
+ },
1608
+ "/api/{session}/send-order-message": {
1609
+ "post": {
1610
+ "tags": ["Messages"],
1611
+ "description": "",
1612
+ "parameters": [
1613
+ {
1614
+ "name": "session",
1615
+ "in": "path",
1616
+ "required": true,
1617
+ "schema": {
1618
+ "type": "string",
1619
+ "example": "NERDWHATS_AMERICA"
1620
+ }
1621
+ }
1622
+ ],
1623
+ "responses": {
1624
+ "400": {
1625
+ "description": "Bad Request"
1626
+ }
1627
+ },
1628
+ "security": [
1629
+ {
1630
+ "bearerAuth": []
1631
+ }
1632
+ ],
1633
+ "requestBody": {
1634
+ "required": true,
1635
+ "content": {
1636
+ "application/json": {
1637
+ "schema": {
1638
+ "type": "object",
1639
+ "properties": {
1640
+ "phone": {
1641
+ "type": "string"
1642
+ },
1643
+ "isGroup": {
1644
+ "type": "boolean"
1645
+ },
1646
+ "items": {
1647
+ "type": "object"
1648
+ },
1649
+ "options": {
1650
+ "type": "object"
1651
+ }
1652
+ }
1653
+ },
1654
+ "examples": {
1655
+ "Send with custom items": {
1656
+ "value": {
1657
+ "phone": "5521999999999",
1658
+ "isGroup": false,
1659
+ "items": [
1660
+ {
1661
+ "type": "custom",
1662
+ "name": "Item test",
1663
+ "price": 120000,
1664
+ "qnt": 2
1665
+ },
1666
+ {
1667
+ "type": "custom",
1668
+ "name": "Item test 2",
1669
+ "price": 145000,
1670
+ "qnt": 2
1671
+ }
1672
+ ]
1673
+ }
1674
+ },
1675
+ "Send with product items": {
1676
+ "value": {
1677
+ "phone": "5521999999999",
1678
+ "isGroup": false,
1679
+ "items": [
1680
+ {
1681
+ "type": "product",
1682
+ "id": "37878774457",
1683
+ "price": 148000,
1684
+ "qnt": 2
1685
+ }
1686
+ ]
1687
+ }
1688
+ },
1689
+ "Send with custom items and options": {
1690
+ "value": {
1691
+ "phone": "5521999999999",
1692
+ "isGroup": false,
1693
+ "items": [
1694
+ {
1695
+ "type": "custom",
1696
+ "name": "Item test",
1697
+ "price": 120000,
1698
+ "qnt": 2
1699
+ }
1700
+ ],
1701
+ "options": {
1702
+ "tax": 10000,
1703
+ "shipping": 4000,
1704
+ "discount": 10000
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1709
+ }
1710
+ }
1711
+ }
1442
1712
  }
1443
1713
  },
1444
1714
  "/api/{session}/send-poll-message": {
@@ -1560,6 +1830,14 @@
1560
1830
  "example": "<groupId>"
1561
1831
  },
1562
1832
  "in": "query"
1833
+ },
1834
+ {
1835
+ "name": "wid",
1836
+ "schema": {
1837
+ "type": "string",
1838
+ "example": "5521999999999@c.us"
1839
+ },
1840
+ "in": "query"
1563
1841
  }
1564
1842
  ],
1565
1843
  "responses": {
@@ -1634,30 +1912,46 @@
1634
1912
  {
1635
1913
  "bearerAuth": []
1636
1914
  }
1637
- ],
1638
- "requestBody": {
1639
- "required": true,
1640
- "content": {
1641
- "application/json": {
1642
- "schema": {
1643
- "type": "object",
1644
- "properties": {
1645
- "groupId": {
1646
- "type": "string"
1647
- }
1648
- },
1649
- "required": ["groupId"]
1650
- },
1651
- "examples": {
1652
- "Default": {
1653
- "value": {
1654
- "groupId": "<groupId>"
1655
- }
1656
- }
1657
- }
1915
+ ]
1916
+ }
1917
+ },
1918
+ "/api/{session}/common-groups/{wid}": {
1919
+ "get": {
1920
+ "tags": ["Group"],
1921
+ "description": "",
1922
+ "parameters": [
1923
+ {
1924
+ "name": "session",
1925
+ "in": "path",
1926
+ "required": true,
1927
+ "schema": {
1928
+ "type": "string",
1929
+ "example": "NERDWHATS_AMERICA"
1930
+ }
1931
+ },
1932
+ {
1933
+ "name": "wid",
1934
+ "in": "path",
1935
+ "required": true,
1936
+ "schema": {
1937
+ "type": "string",
1938
+ "example": "5521999999999@c.us"
1658
1939
  }
1659
1940
  }
1660
- }
1941
+ ],
1942
+ "responses": {
1943
+ "200": {
1944
+ "description": "OK"
1945
+ },
1946
+ "500": {
1947
+ "description": "Internal Server Error"
1948
+ }
1949
+ },
1950
+ "security": [
1951
+ {
1952
+ "bearerAuth": []
1953
+ }
1954
+ ]
1661
1955
  }
1662
1956
  },
1663
1957
  "/api/{session}/group-admins/{groupId}": {
@@ -3675,6 +3969,9 @@
3675
3969
  "200": {
3676
3970
  "description": "OK"
3677
3971
  },
3972
+ "401": {
3973
+ "description": "Unauthorized"
3974
+ },
3678
3975
  "500": {
3679
3976
  "description": "Internal Server Error"
3680
3977
  }
@@ -3699,6 +3996,12 @@
3699
3996
  },
3700
3997
  "messageId": {
3701
3998
  "type": "string"
3999
+ },
4000
+ "onlyLocal": {
4001
+ "type": "boolean"
4002
+ },
4003
+ "deleteMediaInDevice": {
4004
+ "type": "boolean"
3702
4005
  }
3703
4006
  }
3704
4007
  },
@@ -3813,7 +4116,7 @@
3813
4116
  "isGroup": {
3814
4117
  "type": "boolean"
3815
4118
  },
3816
- "messageid": {
4119
+ "messageId": {
3817
4120
  "type": "string"
3818
4121
  }
3819
4122
  }
@@ -3823,7 +4126,7 @@
3823
4126
  "value": {
3824
4127
  "phone": "5521999999999",
3825
4128
  "isGroup": false,
3826
- "messageid": "<messageId>"
4129
+ "messageId": "<messageId>"
3827
4130
  }
3828
4131
  }
3829
4132
  }
@@ -6673,6 +6976,14 @@
6673
6976
  "type": "string",
6674
6977
  "example": "NERDWHATS_AMERICA"
6675
6978
  }
6979
+ },
6980
+ {
6981
+ "name": "phone",
6982
+ "in": "query",
6983
+ "schema": {
6984
+ "type": "string",
6985
+ "example": "5521999999999@c.us"
6986
+ }
6676
6987
  }
6677
6988
  ],
6678
6989
  "responses": {
@@ -6687,7 +6998,7 @@
6687
6998
  ]
6688
6999
  }
6689
7000
  },
6690
- "/api/{session}/get-order-by-messageId": {
7001
+ "/api/{session}/get-order-by-messageId/{messageId}": {
6691
7002
  "get": {
6692
7003
  "tags": ["Catalog & Bussiness"],
6693
7004
  "description": "",
@@ -6700,6 +7011,15 @@
6700
7011
  "type": "string",
6701
7012
  "example": "NERDWHATS_AMERICA"
6702
7013
  }
7014
+ },
7015
+ {
7016
+ "name": "messageId",
7017
+ "in": "path",
7018
+ "required": true,
7019
+ "schema": {
7020
+ "type": "string",
7021
+ "example": "true_5521999999999@c.us_3EB0E69ACC5B396B21F2FE"
7022
+ }
6703
7023
  }
6704
7024
  ],
6705
7025
  "responses": {
@@ -6711,30 +7031,7 @@
6711
7031
  {
6712
7032
  "bearerAuth": []
6713
7033
  }
6714
- ],
6715
- "requestBody": {
6716
- "required": true,
6717
- "content": {
6718
- "application/json": {
6719
- "schema": {
6720
- "type": "object",
6721
- "properties": {
6722
- "messageId": {
6723
- "type": "string"
6724
- }
6725
- },
6726
- "required": ["messageId"]
6727
- },
6728
- "examples": {
6729
- "Default": {
6730
- "value": {
6731
- "messageId": "<message_id>"
6732
- }
6733
- }
6734
- }
6735
- }
6736
- }
6737
- }
7034
+ ]
6738
7035
  }
6739
7036
  },
6740
7037
  "/api/{secretkey}/backup-sessions": {
@@ -7278,6 +7575,229 @@
7278
7575
  ]
7279
7576
  }
7280
7577
  },
7578
+ "/api/{session}/newsletter": {
7579
+ "post": {
7580
+ "tags": [],
7581
+ "description": "",
7582
+ "operationId": "createNewsletter",
7583
+ "parameters": [
7584
+ {
7585
+ "name": "session",
7586
+ "in": "path",
7587
+ "required": true,
7588
+ "schema": {
7589
+ "type": "string",
7590
+ "example": "NERDWHATS_AMERICA"
7591
+ }
7592
+ },
7593
+ {
7594
+ "name": "id",
7595
+ "schema": {
7596
+ "type": "string",
7597
+ "example": "<newsletter_id>"
7598
+ },
7599
+ "in": "query"
7600
+ }
7601
+ ],
7602
+ "responses": {
7603
+ "201": {
7604
+ "description": "Created"
7605
+ }
7606
+ },
7607
+ "security": [
7608
+ {
7609
+ "bearerAuth": []
7610
+ }
7611
+ ],
7612
+ "requestBody": {
7613
+ "required": true,
7614
+ "content": {
7615
+ "application/json": {
7616
+ "schema": {
7617
+ "type": "object",
7618
+ "properties": {
7619
+ "name": {
7620
+ "type": "string"
7621
+ },
7622
+ "description": {
7623
+ "type": "string"
7624
+ },
7625
+ "picture": {
7626
+ "type": "string"
7627
+ }
7628
+ }
7629
+ },
7630
+ "examples": {
7631
+ "Edit newsletter/channel": {
7632
+ "value": {
7633
+ "name": "New name of channel",
7634
+ "description": "New description of channel",
7635
+ "picture": "<new_base64_image> or send null"
7636
+ }
7637
+ },
7638
+ "Create newsletter/channel": {
7639
+ "value": {
7640
+ "name": "Name for your channel",
7641
+ "options": {
7642
+ "description": "Description of channel",
7643
+ "picture": "<base64_image>"
7644
+ }
7645
+ }
7646
+ }
7647
+ }
7648
+ }
7649
+ }
7650
+ }
7651
+ }
7652
+ },
7653
+ "/api/{session}/newsletter/{id}": {
7654
+ "put": {
7655
+ "tags": [],
7656
+ "description": "",
7657
+ "operationId": "editNewsletter",
7658
+ "parameters": [
7659
+ {
7660
+ "name": "session",
7661
+ "in": "path",
7662
+ "required": true,
7663
+ "schema": {
7664
+ "type": "string",
7665
+ "example": "NERDWHATS_AMERICA"
7666
+ }
7667
+ },
7668
+ {
7669
+ "name": "id",
7670
+ "in": "path",
7671
+ "required": true,
7672
+ "schema": {
7673
+ "type": "string",
7674
+ "example": "NEWSLETTER ID"
7675
+ }
7676
+ }
7677
+ ],
7678
+ "responses": {
7679
+ "201": {
7680
+ "description": "Created"
7681
+ }
7682
+ },
7683
+ "security": [
7684
+ {
7685
+ "bearerAuth": []
7686
+ }
7687
+ ],
7688
+ "requestBody": {
7689
+ "required": true,
7690
+ "content": {
7691
+ "application/json": {
7692
+ "schema": {
7693
+ "type": "object",
7694
+ "properties": {
7695
+ "name": {
7696
+ "type": "string"
7697
+ },
7698
+ "description": {
7699
+ "type": "string"
7700
+ },
7701
+ "picture": {
7702
+ "type": "string"
7703
+ }
7704
+ }
7705
+ },
7706
+ "examples": {
7707
+ "Edit newsletter/channel": {
7708
+ "value": {
7709
+ "name": "New name of channel",
7710
+ "description": "New description of channel",
7711
+ "picture": "<new_base64_image> or send null"
7712
+ }
7713
+ },
7714
+ "Create newsletter/channel": {
7715
+ "value": {
7716
+ "name": "Name for your channel",
7717
+ "options": {
7718
+ "description": "Description of channel",
7719
+ "picture": "<base64_image>"
7720
+ }
7721
+ }
7722
+ }
7723
+ }
7724
+ }
7725
+ }
7726
+ }
7727
+ },
7728
+ "delete": {
7729
+ "tags": [],
7730
+ "description": "",
7731
+ "operationId": "destroyNewsletter",
7732
+ "parameters": [
7733
+ {
7734
+ "name": "session",
7735
+ "in": "path",
7736
+ "required": true,
7737
+ "schema": {
7738
+ "type": "string",
7739
+ "example": "NERDWHATS_AMERICA"
7740
+ }
7741
+ },
7742
+ {
7743
+ "name": "id",
7744
+ "in": "path",
7745
+ "required": true,
7746
+ "schema": {
7747
+ "type": "string",
7748
+ "example": "NEWSLETTER ID"
7749
+ }
7750
+ }
7751
+ ],
7752
+ "responses": {
7753
+ "201": {
7754
+ "description": "Created"
7755
+ }
7756
+ },
7757
+ "security": [
7758
+ {
7759
+ "bearerAuth": []
7760
+ }
7761
+ ]
7762
+ }
7763
+ },
7764
+ "/api/{session}/mute-newsletter/{id}": {
7765
+ "post": {
7766
+ "tags": [],
7767
+ "description": "",
7768
+ "operationId": "muteNewsletter",
7769
+ "parameters": [
7770
+ {
7771
+ "name": "session",
7772
+ "in": "path",
7773
+ "required": true,
7774
+ "schema": {
7775
+ "type": "string",
7776
+ "example": "NERDWHATS_AMERICA"
7777
+ }
7778
+ },
7779
+ {
7780
+ "name": "id",
7781
+ "in": "path",
7782
+ "required": true,
7783
+ "schema": {
7784
+ "type": "string",
7785
+ "example": "NEWSLETTER ID"
7786
+ }
7787
+ }
7788
+ ],
7789
+ "responses": {
7790
+ "default": {
7791
+ "description": ""
7792
+ }
7793
+ },
7794
+ "security": [
7795
+ {
7796
+ "bearerAuth": []
7797
+ }
7798
+ ]
7799
+ }
7800
+ },
7281
7801
  "/api/{session}/chatwoot": {
7282
7802
  "post": {
7283
7803
  "tags": ["Misc"],