@expressms/smartapp-sdk 1.0.5 → 1.0.7

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 (40) hide show
  1. package/README.md +251 -50
  2. package/build/main/index.d.ts +8 -7
  3. package/build/main/index.js +5 -2
  4. package/build/main/lib/client/index.d.ts +8 -0
  5. package/build/main/lib/client/index.js +26 -0
  6. package/build/main/lib/contacts/index.d.ts +20 -4
  7. package/build/main/lib/contacts/index.js +26 -6
  8. package/build/main/lib/index.d.ts +5 -2
  9. package/build/main/lib/index.js +5 -2
  10. package/build/main/lib/logging/index.d.ts +5 -7
  11. package/build/main/lib/logging/index.js +4 -1
  12. package/build/main/lib/notification/index.d.ts +3 -0
  13. package/build/main/lib/notification/index.js +6 -2
  14. package/build/main/lib/routing/index.d.ts +14 -4
  15. package/build/main/lib/routing/index.js +18 -8
  16. package/build/main/types/bridge.d.ts +4 -2
  17. package/build/main/types/bridge.js +4 -2
  18. package/build/main/types/contacts.d.ts +1 -1
  19. package/build/main/types/index.d.ts +2 -2
  20. package/build/module/index.d.ts +8 -7
  21. package/build/module/index.js +9 -8
  22. package/build/module/lib/client/index.d.ts +8 -0
  23. package/build/module/lib/client/index.js +19 -0
  24. package/build/module/lib/contacts/index.d.ts +20 -4
  25. package/build/module/lib/contacts/index.js +28 -8
  26. package/build/module/lib/index.d.ts +5 -2
  27. package/build/module/lib/index.js +8 -5
  28. package/build/module/lib/logging/index.d.ts +5 -7
  29. package/build/module/lib/logging/index.js +7 -4
  30. package/build/module/lib/notification/index.d.ts +3 -0
  31. package/build/module/lib/notification/index.js +8 -4
  32. package/build/module/lib/routing/index.d.ts +14 -4
  33. package/build/module/lib/routing/index.js +20 -10
  34. package/build/module/types/bridge.d.ts +4 -2
  35. package/build/module/types/bridge.js +4 -2
  36. package/build/module/types/contacts.d.ts +1 -1
  37. package/build/module/types/index.d.ts +2 -2
  38. package/build/module/types/index.js +2 -2
  39. package/build/umd/index.js +75 -15
  40. package/package.json +1 -1
@@ -1953,7 +1953,7 @@
1953
1953
  var METHODS;
1954
1954
  (function (METHODS) {
1955
1955
  METHODS["READY"] = "ready";
1956
- METHODS["ROUTING_CHANGED"] = "routing_changes";
1956
+ METHODS["ROUTING_CHANGED"] = "routing_changed";
1957
1957
  METHODS["BACK_PRESSED"] = "back_pressed";
1958
1958
  METHODS["ADD_CONTACT"] = "add_contact";
1959
1959
  METHODS["GET_CONTACT"] = "get_contact";
@@ -1961,6 +1961,8 @@
1961
1961
  METHODS["SEND_MESSAGE"] = "send_message";
1962
1962
  METHODS["NOTIFICATION"] = "notification";
1963
1963
  METHODS["OPEN_SMART_APP"] = "open_smart_app";
1964
+ METHODS["OPEN_CLIENT_SETTINGS"] = "open_client_settings";
1965
+ METHODS["GET_CHATS"] = "get_chats";
1964
1966
  })(METHODS || (METHODS = {}));
1965
1967
 
1966
1968
  var LOCATION;
@@ -1969,7 +1971,27 @@
1969
1971
  LOCATION["NESTED"] = "nested";
1970
1972
  })(LOCATION || (LOCATION = {}));
1971
1973
 
1972
- const addContact = async ({ phone, name }) => {
1974
+ const openClientSettings = () => {
1975
+ return bridge?.sendClientEvent({
1976
+ method: METHODS.OPEN_CLIENT_SETTINGS,
1977
+ params: {},
1978
+ });
1979
+ };
1980
+ /**
1981
+ * @param filter
1982
+ */
1983
+ const getChats = ({ filter = null }) => {
1984
+ return bridge?.sendClientEvent({
1985
+ method: METHODS.GET_CHATS,
1986
+ params: { filter },
1987
+ });
1988
+ };
1989
+
1990
+ /**
1991
+ * @param phone
1992
+ * @param name
1993
+ */
1994
+ const addContact = ({ phone, name }) => {
1973
1995
  return bridge?.sendClientEvent({
1974
1996
  method: METHODS.ADD_CONTACT,
1975
1997
  params: {
@@ -1978,25 +2000,41 @@
1978
2000
  },
1979
2001
  });
1980
2002
  };
2003
+ /**
2004
+ * @param phone
2005
+ */
1981
2006
  const getContact = async ({ phone }) => {
1982
2007
  return bridge?.sendClientEvent({
1983
2008
  method: METHODS.GET_CONTACT,
1984
2009
  params: { phone },
1985
2010
  });
1986
2011
  };
1987
- const createPersonalChat = async ({ huid }) => {
2012
+ /**
2013
+ * @param huid
2014
+ */
2015
+ const createPersonalChat = ({ huid }) => {
1988
2016
  return bridge?.sendClientEvent({
1989
2017
  method: METHODS.CREATE_PERSONAL_CHAT,
1990
2018
  params: { huid },
1991
2019
  });
1992
2020
  };
1993
- const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {} }) => {
2021
+ /**
2022
+ * @param userHuid
2023
+ * @param groupChatId
2024
+ * @param messageBody
2025
+ * @param messageMeta
2026
+ */
2027
+ const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = "", messageMeta = {}, }) => {
1994
2028
  return bridge?.sendClientEvent({
1995
2029
  method: METHODS.SEND_MESSAGE,
1996
- params: { userHuid, groupChatId, message: {
2030
+ params: {
2031
+ userHuid,
2032
+ groupChatId,
2033
+ message: {
1997
2034
  body: messageBody,
1998
2035
  meta: messageMeta,
1999
- } },
2036
+ },
2037
+ },
2000
2038
  });
2001
2039
  };
2002
2040
 
@@ -2005,7 +2043,10 @@
2005
2043
  return Object.fromEntries(urlSearchParams.entries());
2006
2044
  };
2007
2045
 
2008
- const bridgeSendReady = async (timeout) => {
2046
+ /**
2047
+ * @param timeout
2048
+ */
2049
+ const bridgeSendReady = (timeout) => {
2009
2050
  const event = {
2010
2051
  method: METHODS.READY,
2011
2052
  params: {},
@@ -2013,6 +2054,9 @@
2013
2054
  return bridge?.sendClientEvent(timeout ? { ...event, timeout } : event);
2014
2055
  };
2015
2056
 
2057
+ /**
2058
+ * @param timeout
2059
+ */
2016
2060
  const ready = async (timeout) => {
2017
2061
  const response = await bridgeSendReady(timeout);
2018
2062
  const Bridge = bridge;
@@ -2022,18 +2066,25 @@
2022
2066
  return response;
2023
2067
  };
2024
2068
 
2069
+ /**
2070
+ * @param handleNotification
2071
+ */
2025
2072
  const onNotification = async (handleNotification) => {
2026
2073
  const response = await bridge?.sendClientEvent({
2027
2074
  method: METHODS.NOTIFICATION,
2028
2075
  params: {},
2029
2076
  });
2030
2077
  return bridge?.onReceive((event) => {
2031
- if (event.type === METHODS.NOTIFICATION)
2078
+ if (event?.type === METHODS.NOTIFICATION) {
2032
2079
  handleNotification(response);
2080
+ }
2033
2081
  });
2034
2082
  };
2035
2083
 
2036
- const routingChanged = async (isRoot) => {
2084
+ /**
2085
+ * @param isRoot
2086
+ */
2087
+ const routingChanged = (isRoot) => {
2037
2088
  return bridge?.sendClientEvent({
2038
2089
  method: METHODS.ROUTING_CHANGED,
2039
2090
  params: {
@@ -2041,27 +2092,34 @@
2041
2092
  },
2042
2093
  });
2043
2094
  };
2044
- const onBackPressed = async (handleBackPressed) => {
2095
+ /**
2096
+ * @param handleBackPressed
2097
+ */
2098
+ const onBackPressed = (handleBackPressed) => {
2045
2099
  return bridge?.onReceive((event) => {
2046
2100
  if (event.type === METHODS.BACK_PRESSED)
2047
2101
  handleBackPressed();
2048
2102
  });
2049
2103
  };
2050
- const openSmartApp = async (appId, meta) => {
2104
+ /**
2105
+ * @param appId
2106
+ * @param meta
2107
+ */
2108
+ const openSmartApp = (appId, meta) => {
2051
2109
  return bridge?.sendClientEvent({
2052
2110
  method: METHODS.OPEN_SMART_APP,
2053
2111
  params: {
2054
2112
  appId,
2055
2113
  meta,
2056
- }
2114
+ },
2057
2115
  });
2058
2116
  };
2059
- const exitSmartAppToCatalog = async () => {
2117
+ const exitSmartAppToCatalog = () => {
2060
2118
  return bridge?.sendClientEvent({
2061
2119
  method: METHODS.OPEN_SMART_APP,
2062
2120
  params: {
2063
- appId: ''
2064
- }
2121
+ appId: "",
2122
+ },
2065
2123
  });
2066
2124
  };
2067
2125
 
@@ -2069,9 +2127,11 @@
2069
2127
  exports.addContact = addContact;
2070
2128
  exports.createPersonalChat = createPersonalChat;
2071
2129
  exports.exitSmartAppToCatalog = exitSmartAppToCatalog;
2130
+ exports.getChats = getChats;
2072
2131
  exports.getContact = getContact;
2073
2132
  exports.onBackPressed = onBackPressed;
2074
2133
  exports.onNotification = onNotification;
2134
+ exports.openClientSettings = openClientSettings;
2075
2135
  exports.openSmartApp = openSmartApp;
2076
2136
  exports.ready = ready;
2077
2137
  exports.routingChanged = routingChanged;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Smartapp SDK",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",