@expressms/smartapp-sdk 1.1.7 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +161 -13
  2. package/build/main/index.d.ts +4 -4
  3. package/build/main/index.js +7 -2
  4. package/build/main/lib/client/index.d.ts +3 -2
  5. package/build/main/lib/client/index.js +10 -3
  6. package/build/main/lib/contacts/index.d.ts +6 -2
  7. package/build/main/lib/contacts/index.js +19 -3
  8. package/build/main/lib/index.d.ts +0 -3
  9. package/build/main/lib/index.js +1 -4
  10. package/build/main/lib/logging/index.d.ts +2 -4
  11. package/build/main/lib/logging/index.js +2 -6
  12. package/build/main/lib/notification/index.d.ts +0 -3
  13. package/build/main/lib/notification/index.js +1 -4
  14. package/build/main/lib/routing/index.d.ts +7 -12
  15. package/build/main/lib/routing/index.js +20 -21
  16. package/build/main/types/bridge.d.ts +17 -2
  17. package/build/main/types/bridge.js +8 -3
  18. package/build/main/types/contacts.d.ts +24 -0
  19. package/build/module/index.d.ts +4 -4
  20. package/build/module/index.js +5 -5
  21. package/build/module/lib/client/index.d.ts +3 -2
  22. package/build/module/lib/client/index.js +9 -3
  23. package/build/module/lib/contacts/index.d.ts +6 -2
  24. package/build/module/lib/contacts/index.js +18 -4
  25. package/build/module/lib/index.d.ts +0 -3
  26. package/build/module/lib/index.js +1 -4
  27. package/build/module/lib/logging/index.d.ts +2 -4
  28. package/build/module/lib/logging/index.js +2 -6
  29. package/build/module/lib/notification/index.d.ts +0 -3
  30. package/build/module/lib/notification/index.js +1 -4
  31. package/build/module/lib/routing/index.d.ts +7 -12
  32. package/build/module/lib/routing/index.js +19 -22
  33. package/build/module/types/bridge.d.ts +17 -2
  34. package/build/module/types/bridge.js +8 -3
  35. package/build/module/types/contacts.d.ts +24 -0
  36. package/build/umd/index.js +52 -35
  37. package/package.json +2 -2
@@ -1956,7 +1956,7 @@
1956
1956
  }
1957
1957
  }
1958
1958
 
1959
- const LIB_VERSION = "1.1.8";
1959
+ const LIB_VERSION = "1.1.9";
1960
1960
 
1961
1961
  const getBridge = () => {
1962
1962
  if (process.env.NODE_ENV === 'test')
@@ -1981,8 +1981,9 @@
1981
1981
  var METHODS;
1982
1982
  (function (METHODS) {
1983
1983
  METHODS["READY"] = "ready";
1984
- METHODS["ROUTING_CHANGED"] = "routing_changed";
1984
+ METHODS["ROUTING_CHANGED"] = "routing_changes";
1985
1985
  METHODS["BACK_PRESSED"] = "back_pressed";
1986
+ METHODS["MOVE_TO_ROOT"] = "move_to_root";
1986
1987
  METHODS["ADD_CONTACT"] = "add_contact";
1987
1988
  METHODS["GET_CONTACT"] = "get_contact";
1988
1989
  METHODS["CREATE_PERSONAL_CHAT"] = "create_personal_chat";
@@ -1992,8 +1993,12 @@
1992
1993
  METHODS["OPEN_CLIENT_SETTINGS"] = "open_client_settings";
1993
1994
  METHODS["GET_CHATS"] = "get_chats";
1994
1995
  METHODS["SEARCH_CORPORATE_PHONEBOOK"] = "search_corporate_phonebook";
1995
- METHODS["OPEN_GROUP_CHAT"] = "open_group_chat";
1996
1996
  METHODS["SEND_BOT_COMMAND"] = "send_bot_command";
1997
+ METHODS["OPEN_GROUP_CHAT"] = "open_group_chat";
1998
+ METHODS["OPEN_CONTACT_CARD"] = "open_contact_card";
1999
+ METHODS["REQUEST_LOCATION"] = "request_location";
2000
+ METHODS["REQUEST_SELF_PROFILE"] = "request_self_profile";
2001
+ METHODS["CLOSE_SMART_APP"] = "close_smart_app";
1997
2002
  })(METHODS || (METHODS = {}));
1998
2003
 
1999
2004
  var LOCATION;
@@ -2026,7 +2031,7 @@
2026
2031
  params: { groupChatId },
2027
2032
  });
2028
2033
  };
2029
- const sendBotCommand = ({ userHuid, body, data }) => {
2034
+ const sendBotCommand = ({ userHuid, body, data, }) => {
2030
2035
  if (typeof data !== 'object')
2031
2036
  return;
2032
2037
  return bridge?.sendClientEvent({
@@ -2040,6 +2045,12 @@
2040
2045
  },
2041
2046
  });
2042
2047
  };
2048
+ const requestLocation = () => {
2049
+ return bridge?.sendClientEvent({
2050
+ method: METHODS.REQUEST_LOCATION,
2051
+ params: {},
2052
+ });
2053
+ };
2043
2054
 
2044
2055
  const addContact = ({ phone, name }) => {
2045
2056
  return bridge?.sendClientEvent({
@@ -2062,7 +2073,7 @@
2062
2073
  params: { huid },
2063
2074
  });
2064
2075
  };
2065
- const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = "", messageMeta = {}, }) => {
2076
+ const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {}, }) => {
2066
2077
  return bridge?.sendClientEvent({
2067
2078
  method: METHODS.SEND_MESSAGE,
2068
2079
  params: {
@@ -2075,15 +2086,26 @@
2075
2086
  },
2076
2087
  });
2077
2088
  };
2089
+ const openContactCard = ({ userHuid }) => {
2090
+ if (!userHuid)
2091
+ return;
2092
+ return bridge?.sendClientEvent({
2093
+ method: METHODS.OPEN_CONTACT_CARD,
2094
+ params: { userHuid }
2095
+ });
2096
+ };
2097
+ const requestSelfProfile = () => {
2098
+ return bridge?.sendClientEvent({
2099
+ method: METHODS.REQUEST_SELF_PROFILE,
2100
+ params: {},
2101
+ });
2102
+ };
2078
2103
 
2079
2104
  const useQuery = () => {
2080
2105
  const urlSearchParams = new URLSearchParams(window.location.search);
2081
2106
  return Object.fromEntries(urlSearchParams.entries());
2082
2107
  };
2083
2108
 
2084
- /**
2085
- * @param timeout
2086
- */
2087
2109
  const bridgeSendReady = (timeout) => {
2088
2110
  const event = {
2089
2111
  method: METHODS.READY,
@@ -2092,21 +2114,14 @@
2092
2114
  return bridge?.sendClientEvent(timeout ? { ...event, timeout } : event);
2093
2115
  };
2094
2116
 
2095
- /**
2096
- * @param timeout
2097
- */
2098
2117
  const ready = async (timeout) => {
2099
2118
  const response = await bridgeSendReady(timeout);
2100
- const Bridge = bridge;
2101
2119
  const isLogsEnabled = response?.payload?.logsEnabled;
2102
2120
  if (isLogsEnabled)
2103
- Bridge?.enableLogs?.();
2121
+ bridge?.enableLogs?.();
2104
2122
  return response;
2105
2123
  };
2106
2124
 
2107
- /**
2108
- * @param handleNotification
2109
- */
2110
2125
  const onNotification = async (handleNotification) => {
2111
2126
  const response = await bridge?.sendClientEvent({
2112
2127
  method: METHODS.NOTIFICATION,
@@ -2119,9 +2134,6 @@
2119
2134
  });
2120
2135
  };
2121
2136
 
2122
- /**
2123
- * @param isRoot
2124
- */
2125
2137
  const routingChanged = (isRoot) => {
2126
2138
  return bridge?.sendClientEvent({
2127
2139
  method: METHODS.ROUTING_CHANGED,
@@ -2130,49 +2142,54 @@
2130
2142
  },
2131
2143
  });
2132
2144
  };
2133
- /**
2134
- * @param handleBackPressed
2135
- */
2136
2145
  const onBackPressed = (handleBackPressed) => {
2137
- return bridge?.onReceive((event) => {
2146
+ return bridge?.onReceive(event => {
2138
2147
  if (event.type === METHODS.BACK_PRESSED)
2139
2148
  handleBackPressed();
2140
2149
  });
2141
2150
  };
2142
- /**
2143
- * @param appId
2144
- * @param meta
2145
- */
2146
- const openSmartApp = (appId, meta) => {
2151
+ const openSmartApp = ({ appId, meta }) => {
2147
2152
  return bridge?.sendClientEvent({
2148
2153
  method: METHODS.OPEN_SMART_APP,
2149
- params: {
2150
- appId,
2151
- meta,
2152
- },
2154
+ params: meta ? { appId, meta } : { appId },
2155
+ });
2156
+ };
2157
+ const closeSmartApp = () => {
2158
+ return bridge?.sendClientEvent({
2159
+ method: METHODS.CLOSE_SMART_APP,
2160
+ params: {},
2161
+ });
2162
+ };
2163
+ const onMoveToRoot = (handleMoveToRoot) => {
2164
+ return bridge?.onReceive(event => {
2165
+ if (event.type === METHODS.MOVE_TO_ROOT)
2166
+ handleMoveToRoot();
2153
2167
  });
2154
2168
  };
2155
2169
  const exitSmartAppToCatalog = () => {
2156
2170
  return bridge?.sendClientEvent({
2157
2171
  method: METHODS.OPEN_SMART_APP,
2158
- params: {
2159
- appId: "",
2160
- },
2172
+ params: { appId: '' },
2161
2173
  });
2162
2174
  };
2163
2175
 
2164
2176
  exports.Bridge = bridge;
2165
2177
  exports.addContact = addContact;
2178
+ exports.closeSmartApp = closeSmartApp;
2166
2179
  exports.createPersonalChat = createPersonalChat;
2167
2180
  exports.exitSmartAppToCatalog = exitSmartAppToCatalog;
2168
2181
  exports.getChats = getChats;
2169
2182
  exports.getContact = getContact;
2170
2183
  exports.onBackPressed = onBackPressed;
2184
+ exports.onMoveToRoot = onMoveToRoot;
2171
2185
  exports.onNotification = onNotification;
2172
2186
  exports.openClientSettings = openClientSettings;
2187
+ exports.openContactCard = openContactCard;
2173
2188
  exports.openGroupChat = openGroupChat;
2174
2189
  exports.openSmartApp = openSmartApp;
2175
2190
  exports.ready = ready;
2191
+ exports.requestLocation = requestLocation;
2192
+ exports.requestSelfProfile = requestSelfProfile;
2176
2193
  exports.routingChanged = routingChanged;
2177
2194
  exports.searchCorporatePhonebook = searchCorporatePhonebook;
2178
2195
  exports.sendBotCommand = sendBotCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-sdk",
3
- "version": "1.1.7",
3
+ "version": "1.2.6",
4
4
  "description": "Smartapp SDK",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  "typescript": "^4.0.2"
39
39
  },
40
40
  "dependencies": {
41
- "@expressms/smartapp-bridge": "^1.1.8",
41
+ "@expressms/smartapp-bridge": "^1.1.9",
42
42
  "webpack-manifest-plugin": "2.2.0",
43
43
  "workbox-cacheable-response": "^6.5.4",
44
44
  "workbox-expiration": "^6.5.4",