@expressms/smartapp-sdk 1.13.0-alpha.1 → 1.13.0-alpha.11

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 (51) hide show
  1. package/build/main/index.d.ts +2 -1
  2. package/build/main/index.js +26 -2
  3. package/build/main/lib/client/events.d.ts +6 -7
  4. package/build/main/lib/client/events.js +1 -1
  5. package/build/main/lib/client/file.d.ts +3 -3
  6. package/build/main/lib/client/index.d.ts +7 -2
  7. package/build/main/lib/client/index.js +18 -2
  8. package/build/main/lib/contacts/index.d.ts +48 -8
  9. package/build/main/lib/contacts/index.js +44 -3
  10. package/build/main/lib/devices/bluetooth.d.ts +1 -1
  11. package/build/main/lib/devices/index.js +18 -8
  12. package/build/main/lib/express-disk/index.d.ts +6 -0
  13. package/build/main/lib/express-disk/index.js +25 -0
  14. package/build/main/lib/index.d.ts +1 -2
  15. package/build/main/lib/index.js +1 -1
  16. package/build/main/lib/notification/index.js +1 -1
  17. package/build/main/lib/routing/index.d.ts +5 -1
  18. package/build/main/lib/routing/index.js +19 -2
  19. package/build/main/types/bridge.d.ts +4 -1
  20. package/build/main/types/bridge.js +7 -4
  21. package/build/main/types/events.d.ts +4 -2
  22. package/build/main/types/events.js +3 -2
  23. package/build/main/types/express-disk.d.ts +15 -0
  24. package/build/main/types/express-disk.js +3 -0
  25. package/build/main/types/routing.js +2 -2
  26. package/build/main/types/storage.js +2 -2
  27. package/build/module/index.d.ts +2 -1
  28. package/build/module/index.js +3 -2
  29. package/build/module/lib/client/events.d.ts +6 -7
  30. package/build/module/lib/client/events.js +3 -4
  31. package/build/module/lib/client/file.d.ts +3 -3
  32. package/build/module/lib/client/index.d.ts +7 -2
  33. package/build/module/lib/client/index.js +17 -2
  34. package/build/module/lib/contacts/index.d.ts +48 -8
  35. package/build/module/lib/contacts/index.js +49 -9
  36. package/build/module/lib/devices/bluetooth.d.ts +1 -1
  37. package/build/module/lib/express-disk/index.d.ts +6 -0
  38. package/build/module/lib/express-disk/index.js +18 -0
  39. package/build/module/lib/index.d.ts +1 -2
  40. package/build/module/lib/index.js +2 -3
  41. package/build/module/lib/notification/index.js +1 -1
  42. package/build/module/lib/routing/index.d.ts +5 -1
  43. package/build/module/lib/routing/index.js +20 -3
  44. package/build/module/types/bridge.d.ts +4 -1
  45. package/build/module/types/bridge.js +4 -1
  46. package/build/module/types/events.d.ts +4 -2
  47. package/build/module/types/events.js +2 -1
  48. package/build/module/types/express-disk.d.ts +15 -0
  49. package/build/module/types/express-disk.js +2 -0
  50. package/build/umd/index.js +117 -3
  51. package/package.json +6 -4
@@ -1347,6 +1347,7 @@
1347
1347
  class Logger {
1348
1348
  logsEnabled;
1349
1349
  hideRecvLogPayload;
1350
+ hideRecvLogNullRefPayload = false;
1350
1351
  constructor() {
1351
1352
  this.logsEnabled = false;
1352
1353
  this.hideRecvLogPayload = new Map();
@@ -1395,11 +1396,11 @@
1395
1396
  console.log('Bridge ~ Outgoing event', JSON.stringify(logEvent, null, ' '));
1396
1397
  }
1397
1398
  logRecvEvent(event) {
1398
- const hideRecvLogPayload = !!this.hideRecvLogPayload.get(event.ref);
1399
+ const hideLogPayload = !!this.hideRecvLogPayload.get(event.ref) || (this.hideRecvLogNullRefPayload && !event.ref);
1399
1400
  this.hideRecvLogPayload.delete(event.ref);
1400
1401
  if (!this.logsEnabled)
1401
1402
  return;
1402
- const logEvent = hideRecvLogPayload
1403
+ const logEvent = hideLogPayload
1403
1404
  ? {
1404
1405
  ...event,
1405
1406
  data: DATA_MASK,
@@ -1407,6 +1408,16 @@
1407
1408
  : event;
1408
1409
  console.log('Bridge ~ Incoming event', JSON.stringify(logEvent, null, 2));
1409
1410
  }
1411
+ /**
1412
+ * Hide payload for null ref events (onReceive callback)
1413
+ *
1414
+ * ```js
1415
+ * bridge.hideRecvData()
1416
+ * ```
1417
+ */
1418
+ hideRecvData() {
1419
+ this.hideRecvLogNullRefPayload = true;
1420
+ }
1410
1421
  }
1411
1422
 
1412
1423
  class AndroidBridge extends Logger {
@@ -1632,6 +1643,7 @@
1632
1643
  * console.log('event', type, handler, payload)
1633
1644
  * })
1634
1645
  * ```
1646
+ * @param callback - Callback function.
1635
1647
  */
1636
1648
  onReceive(callback) {
1637
1649
  this.eventEmitter.on(EVENT_TYPE.RECEIVE, callback);
@@ -1799,6 +1811,7 @@
1799
1811
  * console.log('event', type, handler, payload)
1800
1812
  * })
1801
1813
  * ```
1814
+ * @param callback - Callback function.
1802
1815
  */
1803
1816
  onReceive(callback) {
1804
1817
  this.eventEmitter.on(EVENT_TYPE.RECEIVE, callback);
@@ -1932,7 +1945,7 @@
1932
1945
  }
1933
1946
  }
1934
1947
 
1935
- const LIB_VERSION = "1.4.0";
1948
+ const LIB_VERSION = "1.4.5";
1936
1949
 
1937
1950
  const getBridge = () => {
1938
1951
  if (process.env.NODE_ENV === 'test')
@@ -2008,6 +2021,9 @@
2008
2021
  METHODS["READ_BLE_GATT_CHARACTERISTIC"] = "read_ble_gatt_characteristic";
2009
2022
  METHODS["READ_NFC_TAG"] = "read_nfc_tag";
2010
2023
  METHODS["WRITE_NFC_TAG"] = "write_nfc_tag";
2024
+ METHODS["ALLOW_IOS_SWIPE_NAVIGATION"] = "allow_ios_swipe_navigation";
2025
+ METHODS["HIDE_RECV_DATA"] = "hide_recv_data";
2026
+ METHODS["GET_EXPRESS_DISK_AUTH_CODE"] = "get_express_disk_auth_code";
2011
2027
  })(METHODS || (METHODS = {}));
2012
2028
  var STATUS;
2013
2029
  (function (STATUS) {
@@ -2040,6 +2056,7 @@
2040
2056
  SubscriptionEventType["LAYOUT_TYPE"] = "layout_type";
2041
2057
  SubscriptionEventType["APP_VISIBILITY"] = "app_visibility";
2042
2058
  SubscriptionEventType["SMARTAPP_LIST"] = "smartapp_list";
2059
+ SubscriptionEventType["IOS_SWIPE"] = "ios_swipe";
2043
2060
  })(SubscriptionEventType || (SubscriptionEventType = {}));
2044
2061
 
2045
2062
  const subscriptions = [];
@@ -2390,6 +2407,21 @@
2390
2407
  })
2391
2408
  .then(event => event);
2392
2409
  };
2410
+ /**
2411
+ * Hide recieved data in logs
2412
+ * @returns Promise that'll be fullfilled
2413
+ */
2414
+ const hideRecievedData = () => {
2415
+ if (!bridge)
2416
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2417
+ bridge.hideRecvData();
2418
+ return bridge
2419
+ .sendClientEvent({
2420
+ method: METHODS.HIDE_RECV_DATA,
2421
+ params: {},
2422
+ })
2423
+ .then(event => event);
2424
+ };
2393
2425
 
2394
2426
  const FILE_LOAD_TIMEOUT = 60 * 60 * 1000;
2395
2427
  /**
@@ -2448,6 +2480,11 @@
2448
2480
  return response;
2449
2481
  };
2450
2482
 
2483
+ /**
2484
+ * Add a contact to local device phonebook.
2485
+ * @param params Object containing phone and name of the contact.
2486
+ * @returns A promise that resolves with the response, or undefined if bridge is not available.
2487
+ */
2451
2488
  const addContact = ({ phone, name }) => {
2452
2489
  return bridge?.sendClientEvent({
2453
2490
  method: METHODS.ADD_CONTACT,
@@ -2457,21 +2494,47 @@
2457
2494
  },
2458
2495
  });
2459
2496
  };
2497
+ /**
2498
+ * Get a contact by phone number.
2499
+ * @param params Object containing the phone number of the contact.
2500
+ * @returns A promise that resolves with the response, or undefined if bridge is not available.
2501
+ */
2460
2502
  const getContact = async ({ phone }) => {
2461
2503
  return bridge?.sendClientEvent({
2462
2504
  method: METHODS.GET_CONTACT,
2463
2505
  params: { phone },
2464
2506
  });
2465
2507
  };
2508
+ /**
2509
+ * Creates a personal chat with the specified HUID.
2510
+ * @param {Object} params
2511
+ * @param {string} params.huid - The HUID of the user to create a chat with.
2512
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2513
+ */
2466
2514
  const createPersonalChat = ({ huid }) => {
2467
2515
  return bridge?.sendClientEvent({
2468
2516
  method: METHODS.CREATE_PERSONAL_CHAT,
2469
2517
  params: { huid },
2470
2518
  });
2471
2519
  };
2520
+ /**
2521
+ * Opens a personal chat with the specified HUID.
2522
+ * @param {Object} params
2523
+ * @param {string} params.huid - The HUID of the user whose chat to open.
2524
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2525
+ */
2472
2526
  const openPersonalChat = ({ huid }) => {
2473
2527
  return createPersonalChat({ huid });
2474
2528
  };
2529
+ /**
2530
+ * Sends a message to a user or group chat.
2531
+ * @param {SendMessageMethodParams} params - The parameters for sending a message.
2532
+ * @param {string | null} [params.userHuid=null] - The HUID of the user to send the message to.
2533
+ * @param {string | null} [params.groupChatId=null] - The ID of the group chat to send the message to.
2534
+ * @param {string} [params.messageBody=''] - The body of the message.
2535
+ * @param {object} [params.messageMeta={}] - Additional metadata for the message.
2536
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2537
+ */
2475
2538
  const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {}, }) => {
2476
2539
  return bridge?.sendClientEvent({
2477
2540
  method: METHODS.SEND_MESSAGE,
@@ -2485,6 +2548,12 @@
2485
2548
  },
2486
2549
  });
2487
2550
  };
2551
+ /**
2552
+ * Opens the contact card for the specified user HUID.
2553
+ * @param {Object} params
2554
+ * @param {string} params.userHuid - The HUID of the user whose contact card to open.
2555
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available or userHuid is not provided.
2556
+ */
2488
2557
  const openContactCard = ({ userHuid }) => {
2489
2558
  if (!userHuid)
2490
2559
  return;
@@ -2493,6 +2562,10 @@
2493
2562
  params: { userHuid }
2494
2563
  });
2495
2564
  };
2565
+ /**
2566
+ * Requests the self profile of the current user.
2567
+ * @returns {RequestSelfProfileResponse} The response containing the self profile information.
2568
+ */
2496
2569
  const requestSelfProfile = () => {
2497
2570
  return bridge?.sendClientEvent({
2498
2571
  method: METHODS.REQUEST_SELF_PROFILE,
@@ -2585,6 +2658,23 @@
2585
2658
  params: { appId: '' },
2586
2659
  });
2587
2660
  };
2661
+ /**
2662
+ * Switch on/off swipe navigation in WkWebView
2663
+ * @param allowed Enable/disable navigation
2664
+ */
2665
+ const allowSwipeNavigation = (allowed) => {
2666
+ if (!bridge)
2667
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
2668
+ return bridge
2669
+ .sendClientEvent({
2670
+ method: METHODS.ALLOW_IOS_SWIPE_NAVIGATION,
2671
+ params: { allowed },
2672
+ })
2673
+ .then(event => event);
2674
+ };
2675
+ const iOS = {
2676
+ allowSwipeNavigation,
2677
+ };
2588
2678
 
2589
2679
  /**
2590
2680
  * Set cookies for web resouce. It's needed for SSO auth cases.
@@ -2905,8 +2995,30 @@
2905
2995
  writeTag: writeTag
2906
2996
  });
2907
2997
 
2998
+ /**
2999
+ * Get auth code for eXpress Disk
3000
+ * @returns Promise that'll be fullfilled with `payload.auth` on success, otherwise rejected with reason
3001
+ */
3002
+ const getAuthCode = () => {
3003
+ if (!bridge)
3004
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
3005
+ return bridge
3006
+ .sendClientEvent({
3007
+ method: METHODS.GET_EXPRESS_DISK_AUTH_CODE,
3008
+ params: {},
3009
+ hide_recv_event_data: true,
3010
+ })
3011
+ .then(event => event);
3012
+ };
3013
+
3014
+ var index = /*#__PURE__*/Object.freeze({
3015
+ __proto__: null,
3016
+ getAuthCode: getAuthCode
3017
+ });
3018
+
2908
3019
  exports.Bluetooth = bluetooth;
2909
3020
  exports.Bridge = bridge;
3021
+ exports.ExpressDisk = index;
2910
3022
  exports.GPS = gps;
2911
3023
  exports.NFC = nfc;
2912
3024
  exports.addContact = addContact;
@@ -2930,6 +3042,8 @@
2930
3042
  exports.getSmartAppList = getSmartAppList;
2931
3043
  exports.getUnreadCounter = getUnreadCounter;
2932
3044
  exports.handleDeeplink = handleDeeplink;
3045
+ exports.hideRecievedData = hideRecievedData;
3046
+ exports.iOS = iOS;
2933
3047
  exports.onBackPressed = onBackPressed;
2934
3048
  exports.onMoveToRoot = onMoveToRoot;
2935
3049
  exports.onNotification = onNotification;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-sdk",
3
- "version": "1.13.0-alpha.1",
3
+ "version": "1.13.0-alpha.11",
4
4
  "description": "Smartapp SDK",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "build:umd": "rollup -c",
11
11
  "build:main": "tsc -p tsconfig.json",
12
12
  "build:module": "tsc -p tsconfig.module.json",
13
- "test:lint": "eslint src --ext .ts",
13
+ "test": "tsc -p tsconfig.spec.json && vitest run",
14
+ "test:lint": "tsc -p tsconfig.spec.json && eslint src --ext .ts",
14
15
  "test:prettier": "prettier \"src/**/*.ts\" --list-different"
15
16
  },
16
17
  "repository": {
@@ -35,10 +36,11 @@
35
36
  "prettier": "^2.8.8",
36
37
  "rollup": "^2.79.1",
37
38
  "tslib": "^2.6.2",
38
- "typescript": "^4.9.5"
39
+ "typescript": "^5.4.5",
40
+ "vitest": "^1.6.0"
39
41
  },
40
42
  "dependencies": {
41
- "@expressms/smartapp-bridge": "1.4.0"
43
+ "@expressms/smartapp-bridge": "1.4.5"
42
44
  },
43
45
  "files": [
44
46
  "build/main",