@expressms/smartapp-sdk 1.11.0-alpha.0 → 1.11.0-alpha.10
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/build/main/index.d.ts +3 -3
- package/build/main/index.js +6 -3
- package/build/main/lib/client/file.d.ts +1 -7
- package/build/main/lib/client/file.js +2 -18
- package/build/main/lib/client/index.d.ts +26 -3
- package/build/main/lib/client/index.js +71 -4
- package/build/main/lib/client/storage.js +3 -1
- package/build/main/types/bridge.d.ts +6 -2
- package/build/main/types/bridge.js +5 -2
- package/build/main/types/client.d.ts +24 -9
- package/build/main/types/client.js +1 -8
- package/build/main/types/events.d.ts +11 -0
- package/build/main/types/events.js +12 -0
- package/build/main/types/index.d.ts +1 -0
- package/build/main/types/index.js +2 -1
- package/build/module/index.d.ts +3 -3
- package/build/module/index.js +4 -4
- package/build/module/lib/client/file.d.ts +1 -7
- package/build/module/lib/client/file.js +2 -17
- package/build/module/lib/client/index.d.ts +26 -3
- package/build/module/lib/client/index.js +67 -4
- package/build/module/lib/client/storage.js +3 -1
- package/build/module/types/bridge.d.ts +6 -2
- package/build/module/types/bridge.js +5 -2
- package/build/module/types/client.d.ts +24 -9
- package/build/module/types/client.js +2 -7
- package/build/module/types/events.d.ts +11 -0
- package/build/module/types/events.js +9 -0
- package/build/module/types/index.d.ts +1 -0
- package/build/module/types/index.js +2 -1
- package/build/umd/index.js +113 -45
- package/package.json +2 -2
package/build/umd/index.js
CHANGED
|
@@ -1428,8 +1428,9 @@
|
|
|
1428
1428
|
const { type, ...payload } = data;
|
|
1429
1429
|
const emitterType = ref || EVENT_TYPE.RECEIVE;
|
|
1430
1430
|
// const isRenameParamsEnabled = data.handler === HANDLER.BOTX ? this.isRenameParamsEnabledForBotx : true // TODO uncomment when client is ready
|
|
1431
|
-
const eventFiles = this.isRenameParamsEnabledForBotx
|
|
1432
|
-
files?.map((file) => snakeCaseToCamelCase(file))
|
|
1431
|
+
const eventFiles = this.isRenameParamsEnabledForBotx
|
|
1432
|
+
? files?.map((file) => snakeCaseToCamelCase(file))
|
|
1433
|
+
: files;
|
|
1433
1434
|
const event = {
|
|
1434
1435
|
ref,
|
|
1435
1436
|
type,
|
|
@@ -1471,8 +1472,7 @@
|
|
|
1471
1472
|
hide_send_event_data,
|
|
1472
1473
|
hide_recv_event_data,
|
|
1473
1474
|
};
|
|
1474
|
-
const eventFiles = isRenameParamsEnabled ?
|
|
1475
|
-
files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1475
|
+
const eventFiles = isRenameParamsEnabled ? files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1476
1476
|
const event = files ? { ...eventParams, files: eventFiles } : eventParams;
|
|
1477
1477
|
this.logSendEvent(event);
|
|
1478
1478
|
window.express.handleSmartAppEvent(JSON.stringify(event));
|
|
@@ -1546,8 +1546,15 @@
|
|
|
1546
1546
|
* @param timeout - Timeout in ms.
|
|
1547
1547
|
* @returns Promise.
|
|
1548
1548
|
*/
|
|
1549
|
-
sendClientEvent({ method, params, timeout }) {
|
|
1550
|
-
return this.sendEvent({
|
|
1549
|
+
sendClientEvent({ method, params, timeout, hide_send_event_data, hide_recv_event_data, }) {
|
|
1550
|
+
return this.sendEvent({
|
|
1551
|
+
handler: HANDLER.EXPRESS,
|
|
1552
|
+
method,
|
|
1553
|
+
params,
|
|
1554
|
+
timeout,
|
|
1555
|
+
hide_send_event_data,
|
|
1556
|
+
hide_recv_event_data,
|
|
1557
|
+
});
|
|
1551
1558
|
}
|
|
1552
1559
|
/**
|
|
1553
1560
|
* Enabling renaming event params from camelCase to snake_case and vice versa
|
|
@@ -1572,8 +1579,9 @@
|
|
|
1572
1579
|
console.log('Bridge ~ Disabled renaming event params from camelCase to snake_case and vice versa');
|
|
1573
1580
|
}
|
|
1574
1581
|
log(data) {
|
|
1575
|
-
if (
|
|
1576
|
-
|
|
1582
|
+
if (!this.hasCommunicationObject)
|
|
1583
|
+
return;
|
|
1584
|
+
if (!data || (typeof data !== 'string' && typeof data !== 'object'))
|
|
1577
1585
|
return;
|
|
1578
1586
|
window.express.handleSmartAppEvent(JSON.stringify({ 'SmartApp Log': data }, null, 2));
|
|
1579
1587
|
}
|
|
@@ -1602,8 +1610,9 @@
|
|
|
1602
1610
|
const { type, ...payload } = data;
|
|
1603
1611
|
const emitterType = ref || EVENT_TYPE.RECEIVE;
|
|
1604
1612
|
// const isRenameParamsEnabled = data.handler === HANDLER.BOTX ? this.isRenameParamsEnabledForBotx : true // TODO uncomment when client is ready
|
|
1605
|
-
const eventFiles = this.isRenameParamsEnabledForBotx
|
|
1606
|
-
files?.map((file) => snakeCaseToCamelCase(file))
|
|
1613
|
+
const eventFiles = this.isRenameParamsEnabledForBotx
|
|
1614
|
+
? files?.map((file) => snakeCaseToCamelCase(file))
|
|
1615
|
+
: files;
|
|
1607
1616
|
const event = {
|
|
1608
1617
|
ref,
|
|
1609
1618
|
type,
|
|
@@ -1644,8 +1653,7 @@
|
|
|
1644
1653
|
hide_send_event_data,
|
|
1645
1654
|
hide_recv_event_data,
|
|
1646
1655
|
};
|
|
1647
|
-
const eventFiles = isRenameParamsEnabled ?
|
|
1648
|
-
files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1656
|
+
const eventFiles = isRenameParamsEnabled ? files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1649
1657
|
const event = files ? { ...eventProps, files: eventFiles } : eventProps;
|
|
1650
1658
|
this.logSendEvent(event);
|
|
1651
1659
|
window.webkit.messageHandlers.express.postMessage(event);
|
|
@@ -1705,12 +1713,14 @@
|
|
|
1705
1713
|
* })
|
|
1706
1714
|
* ```
|
|
1707
1715
|
*/
|
|
1708
|
-
sendClientEvent({ method, params, timeout = RESPONSE_TIMEOUT, }) {
|
|
1716
|
+
sendClientEvent({ method, params, timeout = RESPONSE_TIMEOUT, hide_send_event_data, hide_recv_event_data, }) {
|
|
1709
1717
|
return this.sendEvent({
|
|
1710
1718
|
handler: HANDLER.EXPRESS,
|
|
1711
1719
|
method,
|
|
1712
1720
|
params,
|
|
1713
1721
|
timeout,
|
|
1722
|
+
hide_send_event_data,
|
|
1723
|
+
hide_recv_event_data,
|
|
1714
1724
|
});
|
|
1715
1725
|
}
|
|
1716
1726
|
/**
|
|
@@ -1770,8 +1780,7 @@
|
|
|
1770
1780
|
const isRenameParamsEnabled = this.isRenameParamsEnabledForBotx; // TODO fix when handler is passed
|
|
1771
1781
|
this.logRecvEvent(event.data);
|
|
1772
1782
|
const emitterType = ref || EVENT_TYPE.RECEIVE;
|
|
1773
|
-
const eventFiles = isRenameParamsEnabled ?
|
|
1774
|
-
files?.map((file) => snakeCaseToCamelCase(file)) : files;
|
|
1783
|
+
const eventFiles = isRenameParamsEnabled ? files?.map((file) => snakeCaseToCamelCase(file)) : files;
|
|
1775
1784
|
this.eventEmitter.emit(emitterType, {
|
|
1776
1785
|
ref,
|
|
1777
1786
|
type,
|
|
@@ -1809,8 +1818,7 @@
|
|
|
1809
1818
|
hide_send_event_data,
|
|
1810
1819
|
hide_recv_event_data,
|
|
1811
1820
|
};
|
|
1812
|
-
const eventFiles = isRenameParamsEnabled ?
|
|
1813
|
-
files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1821
|
+
const eventFiles = isRenameParamsEnabled ? files?.map((file) => camelCaseToSnakeCase(file)) : files;
|
|
1814
1822
|
const event = files ? { ...payload, files: eventFiles } : payload;
|
|
1815
1823
|
this.logSendEvent(event);
|
|
1816
1824
|
window.parent.postMessage({
|
|
@@ -1871,12 +1879,14 @@
|
|
|
1871
1879
|
* })
|
|
1872
1880
|
* ```
|
|
1873
1881
|
*/
|
|
1874
|
-
sendClientEvent({ method, params, timeout }) {
|
|
1882
|
+
sendClientEvent({ method, params, timeout, hide_send_event_data, hide_recv_event_data, }) {
|
|
1875
1883
|
return this.sendEvent({
|
|
1876
1884
|
handler: HANDLER.EXPRESS,
|
|
1877
1885
|
method,
|
|
1878
1886
|
params,
|
|
1879
1887
|
timeout,
|
|
1888
|
+
hide_send_event_data,
|
|
1889
|
+
hide_recv_event_data,
|
|
1880
1890
|
});
|
|
1881
1891
|
}
|
|
1882
1892
|
/**
|
|
@@ -1922,7 +1932,7 @@
|
|
|
1922
1932
|
}
|
|
1923
1933
|
}
|
|
1924
1934
|
|
|
1925
|
-
const LIB_VERSION = "1.4.0
|
|
1935
|
+
const LIB_VERSION = "1.4.0";
|
|
1926
1936
|
|
|
1927
1937
|
const getBridge = () => {
|
|
1928
1938
|
if (process.env.NODE_ENV === 'test')
|
|
@@ -1966,7 +1976,6 @@
|
|
|
1966
1976
|
METHODS["REQUEST_SELF_PROFILE"] = "request_self_profile";
|
|
1967
1977
|
METHODS["CLOSE_SMART_APP"] = "close_smart_app";
|
|
1968
1978
|
METHODS["OPEN_FILE"] = "open_file";
|
|
1969
|
-
METHODS["OPEN_FILES"] = "open_files";
|
|
1970
1979
|
METHODS["UPLOAD_FILE"] = "upload_file";
|
|
1971
1980
|
METHODS["UPLOAD_FILES"] = "upload_files";
|
|
1972
1981
|
METHODS["SUBSCRIBE_CLIENT_EVENTS"] = "subscribe_client_events";
|
|
@@ -1983,6 +1992,10 @@
|
|
|
1983
1992
|
METHODS["GET_UNREAD_COUNTER"] = "get_unread_counter";
|
|
1984
1993
|
METHODS["GET_LAYOUT_TYPE"] = "get_layout_type";
|
|
1985
1994
|
METHODS["CLEAN_CACHE"] = "clean_cache";
|
|
1995
|
+
METHODS["GET_APP_VISIBILITY"] = "get_app_visibility";
|
|
1996
|
+
METHODS["GET_SMARTAPP_LIST"] = "get_smartapp_list";
|
|
1997
|
+
METHODS["SET_WEB_RESOURCE_COOKIES"] = "set_web_resource_cookies";
|
|
1998
|
+
METHODS["SET_ALLOWED_NAVIGATION_DOMAINS"] = "set_allowed_navigation_domains";
|
|
1986
1999
|
})(METHODS || (METHODS = {}));
|
|
1987
2000
|
var STATUS;
|
|
1988
2001
|
(function (STATUS) {
|
|
@@ -2001,13 +2014,6 @@
|
|
|
2001
2014
|
LOCATION["NESTED"] = "nested";
|
|
2002
2015
|
})(LOCATION || (LOCATION = {}));
|
|
2003
2016
|
|
|
2004
|
-
var SubscriptionEventType;
|
|
2005
|
-
(function (SubscriptionEventType) {
|
|
2006
|
-
SubscriptionEventType["CONNECTION_STATUS"] = "connection_status";
|
|
2007
|
-
SubscriptionEventType["UNREAD_COUNTER_CHANGE"] = "unread_counter_change";
|
|
2008
|
-
SubscriptionEventType["LAYOUT_TYPE"] = "layout_type";
|
|
2009
|
-
})(SubscriptionEventType || (SubscriptionEventType = {}));
|
|
2010
|
-
|
|
2011
2017
|
var CLIENT_STORAGE_ERROR_CODES;
|
|
2012
2018
|
(function (CLIENT_STORAGE_ERROR_CODES) {
|
|
2013
2019
|
CLIENT_STORAGE_ERROR_CODES["keyNotFound"] = "key_not_found";
|
|
@@ -2015,6 +2021,15 @@
|
|
|
2015
2021
|
CLIENT_STORAGE_ERROR_CODES["storageLimitReached"] = "storage_limit_reached";
|
|
2016
2022
|
})(CLIENT_STORAGE_ERROR_CODES || (CLIENT_STORAGE_ERROR_CODES = {}));
|
|
2017
2023
|
|
|
2024
|
+
var SubscriptionEventType;
|
|
2025
|
+
(function (SubscriptionEventType) {
|
|
2026
|
+
SubscriptionEventType["CONNECTION_STATUS"] = "connection_status";
|
|
2027
|
+
SubscriptionEventType["UNREAD_COUNTER_CHANGE"] = "unread_counter_change";
|
|
2028
|
+
SubscriptionEventType["LAYOUT_TYPE"] = "layout_type";
|
|
2029
|
+
SubscriptionEventType["APP_VISIBILITY"] = "app_visibility";
|
|
2030
|
+
SubscriptionEventType["SMARTAPP_LIST"] = "smartapp_list";
|
|
2031
|
+
})(SubscriptionEventType || (SubscriptionEventType = {}));
|
|
2032
|
+
|
|
2018
2033
|
const subscriptions = [];
|
|
2019
2034
|
let bridgeEventListenerInstalled = false;
|
|
2020
2035
|
const composeResponse = (status, errorCode) => {
|
|
@@ -2120,6 +2135,7 @@
|
|
|
2120
2135
|
.sendClientEvent({
|
|
2121
2136
|
method: METHODS.CLIENT_STORAGE_GET,
|
|
2122
2137
|
params: { key },
|
|
2138
|
+
hide_recv_event_data: true
|
|
2123
2139
|
})
|
|
2124
2140
|
.then(event => {
|
|
2125
2141
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2151,6 +2167,7 @@
|
|
|
2151
2167
|
key,
|
|
2152
2168
|
value: serializedValue,
|
|
2153
2169
|
},
|
|
2170
|
+
hide_send_event_data: true,
|
|
2154
2171
|
})
|
|
2155
2172
|
.then(event => event);
|
|
2156
2173
|
};
|
|
@@ -2196,10 +2213,10 @@
|
|
|
2196
2213
|
params: { filter },
|
|
2197
2214
|
});
|
|
2198
2215
|
};
|
|
2199
|
-
const searchCorporatePhonebook = ({ filter = null }) => {
|
|
2216
|
+
const searchCorporatePhonebook = ({ filter = null, exactMatch }) => {
|
|
2200
2217
|
return bridge?.sendClientEvent({
|
|
2201
2218
|
method: METHODS.SEARCH_CORPORATE_PHONEBOOK,
|
|
2202
|
-
params: { filter },
|
|
2219
|
+
params: { filter, exactMatch },
|
|
2203
2220
|
});
|
|
2204
2221
|
};
|
|
2205
2222
|
const openGroupChat = ({ groupChatId }) => {
|
|
@@ -2339,6 +2356,69 @@
|
|
|
2339
2356
|
});
|
|
2340
2357
|
return response;
|
|
2341
2358
|
};
|
|
2359
|
+
/**
|
|
2360
|
+
* Get application window visibility
|
|
2361
|
+
* @returns Promise that'll be fullfilled, otherwise rejected with reason
|
|
2362
|
+
*/
|
|
2363
|
+
const getAppVisibility = () => {
|
|
2364
|
+
if (!bridge)
|
|
2365
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2366
|
+
return bridge
|
|
2367
|
+
.sendClientEvent({
|
|
2368
|
+
method: METHODS.GET_APP_VISIBILITY,
|
|
2369
|
+
params: {},
|
|
2370
|
+
})
|
|
2371
|
+
.then(event => event);
|
|
2372
|
+
};
|
|
2373
|
+
/**
|
|
2374
|
+
* Get SmartApp list
|
|
2375
|
+
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2376
|
+
*/
|
|
2377
|
+
const getSmartAppList = () => {
|
|
2378
|
+
if (!bridge)
|
|
2379
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2380
|
+
return bridge
|
|
2381
|
+
.sendClientEvent({
|
|
2382
|
+
method: METHODS.GET_SMARTAPP_LIST,
|
|
2383
|
+
params: {},
|
|
2384
|
+
})
|
|
2385
|
+
.then(event => event);
|
|
2386
|
+
};
|
|
2387
|
+
/**
|
|
2388
|
+
* Set cookies for web resouce. It's needed for SSO auth cases.
|
|
2389
|
+
* @param cookies List of cookie strings !with domains!
|
|
2390
|
+
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2391
|
+
*/
|
|
2392
|
+
const setWebResourceCookies = (cookies) => {
|
|
2393
|
+
if (!bridge)
|
|
2394
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2395
|
+
return bridge
|
|
2396
|
+
.sendClientEvent({
|
|
2397
|
+
method: METHODS.SET_WEB_RESOURCE_COOKIES,
|
|
2398
|
+
params: {
|
|
2399
|
+
cookies,
|
|
2400
|
+
},
|
|
2401
|
+
})
|
|
2402
|
+
.then(event => event);
|
|
2403
|
+
};
|
|
2404
|
+
/**
|
|
2405
|
+
* Allow WebView то open links inside, not in external browser
|
|
2406
|
+
* @param domains List domains without schema
|
|
2407
|
+
* @returns Promise that'll be fullfilled with SmartApp list on success, otherwise rejected with reason
|
|
2408
|
+
*/
|
|
2409
|
+
const setAllowedNavigationDomains = (domains) => {
|
|
2410
|
+
if (!bridge)
|
|
2411
|
+
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2412
|
+
return bridge
|
|
2413
|
+
.sendClientEvent({
|
|
2414
|
+
method: METHODS.SET_ALLOWED_NAVIGATION_DOMAINS,
|
|
2415
|
+
params: {
|
|
2416
|
+
domains,
|
|
2417
|
+
},
|
|
2418
|
+
timeout: 1000,
|
|
2419
|
+
})
|
|
2420
|
+
.then(event => event);
|
|
2421
|
+
};
|
|
2342
2422
|
|
|
2343
2423
|
const FILE_LOAD_TIMEOUT = 60 * 60 * 1000;
|
|
2344
2424
|
/**
|
|
@@ -2356,21 +2436,6 @@
|
|
|
2356
2436
|
});
|
|
2357
2437
|
return response;
|
|
2358
2438
|
};
|
|
2359
|
-
/**
|
|
2360
|
-
* Download file list with client
|
|
2361
|
-
* @param files Files list to be opened
|
|
2362
|
-
* @returns Promise that'll be fullfilled, otherwise rejected with reason
|
|
2363
|
-
*/
|
|
2364
|
-
const openFiles = async (files) => {
|
|
2365
|
-
if (!bridge)
|
|
2366
|
-
return Promise.reject(ERROR_CODES.NO_BRIDGE);
|
|
2367
|
-
const response = await bridge.sendClientEvent({
|
|
2368
|
-
method: METHODS.OPEN_FILES,
|
|
2369
|
-
params: files,
|
|
2370
|
-
timeout: FILE_LOAD_TIMEOUT,
|
|
2371
|
-
});
|
|
2372
|
-
return response;
|
|
2373
|
-
};
|
|
2374
2439
|
/**
|
|
2375
2440
|
* Upload single file with client
|
|
2376
2441
|
* @param mimeType Mime type of allowed files
|
|
@@ -2550,10 +2615,12 @@
|
|
|
2550
2615
|
exports.createDeeplink = createDeeplink;
|
|
2551
2616
|
exports.createPersonalChat = createPersonalChat;
|
|
2552
2617
|
exports.exitSmartAppToCatalog = exitSmartAppToCatalog;
|
|
2618
|
+
exports.getAppVisibility = getAppVisibility;
|
|
2553
2619
|
exports.getChats = getChats;
|
|
2554
2620
|
exports.getConnectionStatus = getConnectionStatus;
|
|
2555
2621
|
exports.getContact = getContact;
|
|
2556
2622
|
exports.getLayoutType = getLayoutType;
|
|
2623
|
+
exports.getSmartAppList = getSmartAppList;
|
|
2557
2624
|
exports.getUnreadCounter = getUnreadCounter;
|
|
2558
2625
|
exports.handleDeeplink = handleDeeplink;
|
|
2559
2626
|
exports.onBackPressed = onBackPressed;
|
|
@@ -2563,7 +2630,6 @@
|
|
|
2563
2630
|
exports.openClientSettings = openClientSettings;
|
|
2564
2631
|
exports.openContactCard = openContactCard;
|
|
2565
2632
|
exports.openFile = openFile;
|
|
2566
|
-
exports.openFiles = openFiles;
|
|
2567
2633
|
exports.openGroupChat = openGroupChat;
|
|
2568
2634
|
exports.openPersonalChat = openPersonalChat;
|
|
2569
2635
|
exports.openSmartApp = openSmartApp;
|
|
@@ -2575,6 +2641,8 @@
|
|
|
2575
2641
|
exports.searchLocalPhonebook = searchLocalPhonebook;
|
|
2576
2642
|
exports.sendBotCommand = sendBotCommand;
|
|
2577
2643
|
exports.sendMessage = sendMessage;
|
|
2644
|
+
exports.setAllowedNavigationDomains = setAllowedNavigationDomains;
|
|
2645
|
+
exports.setWebResourceCookies = setWebResourceCookies;
|
|
2578
2646
|
exports.subscribeClientEvents = subscribeClientEvents;
|
|
2579
2647
|
exports.unsubscribeClientEvents = unsubscribeClientEvents;
|
|
2580
2648
|
exports.uploadFile = uploadFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressms/smartapp-sdk",
|
|
3
|
-
"version": "1.11.0-alpha.
|
|
3
|
+
"version": "1.11.0-alpha.10",
|
|
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.9.5"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@expressms/smartapp-bridge": "1.4.0
|
|
41
|
+
"@expressms/smartapp-bridge": "1.4.0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"build/main",
|