@expressms/smartapp-sdk 1.4.2-alpha.1 → 1.5.0-alpha.3

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.
@@ -1946,6 +1946,10 @@
1946
1946
  METHODS["GET_CONNECTION_STATUS"] = "get_connection_status";
1947
1947
  METHODS["CREATE_DEEPLINK"] = "create_deeplink";
1948
1948
  METHODS["OPEN_CHAT_MESSAGE"] = "open_chat_message";
1949
+ METHODS["CLIENT_STORAGE_GET"] = "client_storage_get";
1950
+ METHODS["CLIENT_STORAGE_SET"] = "client_storage_set";
1951
+ METHODS["CLIENT_STORAGE_REMOVE"] = "client_storage_remove";
1952
+ METHODS["CLIENT_STORAGE_CLEAR"] = "client_storage_clear";
1949
1953
  })(METHODS || (METHODS = {}));
1950
1954
  var STATUS;
1951
1955
  (function (STATUS) {
@@ -1969,6 +1973,13 @@
1969
1973
  SubscriptionEventType["CONNECTION_STATUS"] = "connection_status";
1970
1974
  })(SubscriptionEventType || (SubscriptionEventType = {}));
1971
1975
 
1976
+ var CLIENT_STORAGE_ERROR_CODES;
1977
+ (function (CLIENT_STORAGE_ERROR_CODES) {
1978
+ CLIENT_STORAGE_ERROR_CODES["keyNotFound"] = "key_not_found";
1979
+ CLIENT_STORAGE_ERROR_CODES["valueSizeExceeded"] = "value_size_exceeded";
1980
+ CLIENT_STORAGE_ERROR_CODES["storageLimitReached"] = "storage_limit_reached";
1981
+ })(CLIENT_STORAGE_ERROR_CODES || (CLIENT_STORAGE_ERROR_CODES = {}));
1982
+
1972
1983
  const subscriptions = [];
1973
1984
  let bridgeEventListenerInstalled = false;
1974
1985
  const isAnySubscriptionsOfType = (eventType) => {
@@ -2037,6 +2048,67 @@
2037
2048
  .then(() => successResponse);
2038
2049
  };
2039
2050
 
2051
+ /**
2052
+ * Get value for key from client storage
2053
+ * @param key Key
2054
+ * @returns Promise that'll be fullfilled with `response.data.value` on success, otherwise rejected with reason
2055
+ */
2056
+ const clientStorageGet = ({ key }) => {
2057
+ if (!bridge)
2058
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2059
+ return bridge
2060
+ .sendClientEvent({
2061
+ method: METHODS.CLIENT_STORAGE_GET,
2062
+ params: { key },
2063
+ })
2064
+ .then(event => event);
2065
+ };
2066
+ /**
2067
+ * Save value in client storage
2068
+ * @param key Key
2069
+ * @param value Data to be stored
2070
+ * @returns Promise that'll be fullfilled on success or rejected with reason
2071
+ */
2072
+ const clientStorageSet = ({ key, value }) => {
2073
+ if (!bridge)
2074
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2075
+ return bridge
2076
+ .sendClientEvent({
2077
+ method: METHODS.CLIENT_STORAGE_SET,
2078
+ params: { key, value },
2079
+ })
2080
+ .then(event => event);
2081
+ };
2082
+ /**
2083
+ * Remove record from client storage
2084
+ * @param key Key
2085
+ * @returns Promise that'll be fullfilled on success or rejected with reason
2086
+ */
2087
+ const clientStorageRemove = ({ key }) => {
2088
+ if (!bridge)
2089
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2090
+ return bridge
2091
+ .sendClientEvent({
2092
+ method: METHODS.CLIENT_STORAGE_REMOVE,
2093
+ params: { key },
2094
+ })
2095
+ .then(event => event);
2096
+ };
2097
+ /**
2098
+ * Clear all records from client storage
2099
+ * @returns Promise that'll be fullfilled on success or rejected with reason
2100
+ */
2101
+ const clientStorageClear = () => {
2102
+ if (!bridge)
2103
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2104
+ return bridge
2105
+ .sendClientEvent({
2106
+ method: METHODS.CLIENT_STORAGE_CLEAR,
2107
+ params: {},
2108
+ })
2109
+ .then(event => event);
2110
+ };
2111
+
2040
2112
  const openClientSettings = () => {
2041
2113
  return bridge?.sendClientEvent({
2042
2114
  method: METHODS.OPEN_CLIENT_SETTINGS,
@@ -2207,6 +2279,7 @@
2207
2279
  method: METHODS.NOTIFICATION,
2208
2280
  params: {},
2209
2281
  });
2282
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2210
2283
  return bridge?.onReceive((event) => {
2211
2284
  if (event?.type === METHODS.NOTIFICATION) {
2212
2285
  handleNotification(response);
@@ -2255,6 +2328,10 @@
2255
2328
 
2256
2329
  exports.Bridge = bridge;
2257
2330
  exports.addContact = addContact;
2331
+ exports.clientStorageClear = clientStorageClear;
2332
+ exports.clientStorageGet = clientStorageGet;
2333
+ exports.clientStorageRemove = clientStorageRemove;
2334
+ exports.clientStorageSet = clientStorageSet;
2258
2335
  exports.closeSmartApp = closeSmartApp;
2259
2336
  exports.createDeeplink = createDeeplink;
2260
2337
  exports.createPersonalChat = createPersonalChat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-sdk",
3
- "version": "1.4.2-alpha.1",
3
+ "version": "1.5.0-alpha.3",
4
4
  "description": "Smartapp SDK",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",