@expressms/smartapp-sdk 1.4.2-alpha.0 → 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.
- package/README.md +1 -651
- package/build/main/index.d.ts +2 -2
- package/build/main/index.js +6 -2
- package/build/main/lib/client/index.d.ts +1 -0
- package/build/main/lib/client/index.js +3 -2
- package/build/main/lib/client/storage.d.ts +33 -0
- package/build/main/lib/client/storage.js +73 -0
- package/build/main/lib/notification/index.js +2 -1
- package/build/main/types/bridge.d.ts +15 -1
- package/build/main/types/bridge.js +6 -1
- package/build/main/types/index.d.ts +1 -0
- package/build/main/types/index.js +2 -1
- package/build/main/types/storage.d.ts +17 -0
- package/build/main/types/storage.js +10 -0
- package/build/module/index.d.ts +2 -2
- package/build/module/index.js +3 -3
- package/build/module/lib/client/index.d.ts +1 -0
- package/build/module/lib/client/index.js +3 -2
- package/build/module/lib/client/storage.d.ts +33 -0
- package/build/module/lib/client/storage.js +64 -0
- package/build/module/lib/notification/index.js +2 -1
- package/build/module/types/bridge.d.ts +15 -1
- package/build/module/types/bridge.js +6 -1
- package/build/module/types/index.d.ts +1 -0
- package/build/module/types/index.js +2 -1
- package/build/module/types/storage.d.ts +17 -0
- package/build/module/types/storage.js +7 -0
- package/build/umd/index.js +79 -1
- package/package.json +1 -1
package/build/umd/index.js
CHANGED
|
@@ -1945,6 +1945,11 @@
|
|
|
1945
1945
|
METHODS["UNSUBSCRIBE_CLIENT_EVENTS"] = "unsubscribe_client_events";
|
|
1946
1946
|
METHODS["GET_CONNECTION_STATUS"] = "get_connection_status";
|
|
1947
1947
|
METHODS["CREATE_DEEPLINK"] = "create_deeplink";
|
|
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";
|
|
1948
1953
|
})(METHODS || (METHODS = {}));
|
|
1949
1954
|
var STATUS;
|
|
1950
1955
|
(function (STATUS) {
|
|
@@ -1968,6 +1973,13 @@
|
|
|
1968
1973
|
SubscriptionEventType["CONNECTION_STATUS"] = "connection_status";
|
|
1969
1974
|
})(SubscriptionEventType || (SubscriptionEventType = {}));
|
|
1970
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
|
+
|
|
1971
1983
|
const subscriptions = [];
|
|
1972
1984
|
let bridgeEventListenerInstalled = false;
|
|
1973
1985
|
const isAnySubscriptionsOfType = (eventType) => {
|
|
@@ -2036,6 +2048,67 @@
|
|
|
2036
2048
|
.then(() => successResponse);
|
|
2037
2049
|
};
|
|
2038
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
|
+
|
|
2039
2112
|
const openClientSettings = () => {
|
|
2040
2113
|
return bridge?.sendClientEvent({
|
|
2041
2114
|
method: METHODS.OPEN_CLIENT_SETTINGS,
|
|
@@ -2124,7 +2197,7 @@
|
|
|
2124
2197
|
if (!bridge)
|
|
2125
2198
|
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2126
2199
|
return await bridge.sendClientEvent({
|
|
2127
|
-
method: METHODS.
|
|
2200
|
+
method: METHODS.OPEN_CHAT_MESSAGE,
|
|
2128
2201
|
params: { groupChatId, syncId },
|
|
2129
2202
|
});
|
|
2130
2203
|
};
|
|
@@ -2206,6 +2279,7 @@
|
|
|
2206
2279
|
method: METHODS.NOTIFICATION,
|
|
2207
2280
|
params: {},
|
|
2208
2281
|
});
|
|
2282
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2209
2283
|
return bridge?.onReceive((event) => {
|
|
2210
2284
|
if (event?.type === METHODS.NOTIFICATION) {
|
|
2211
2285
|
handleNotification(response);
|
|
@@ -2254,6 +2328,10 @@
|
|
|
2254
2328
|
|
|
2255
2329
|
exports.Bridge = bridge;
|
|
2256
2330
|
exports.addContact = addContact;
|
|
2331
|
+
exports.clientStorageClear = clientStorageClear;
|
|
2332
|
+
exports.clientStorageGet = clientStorageGet;
|
|
2333
|
+
exports.clientStorageRemove = clientStorageRemove;
|
|
2334
|
+
exports.clientStorageSet = clientStorageSet;
|
|
2257
2335
|
exports.closeSmartApp = closeSmartApp;
|
|
2258
2336
|
exports.createDeeplink = createDeeplink;
|
|
2259
2337
|
exports.createPersonalChat = createPersonalChat;
|