@expressms/smartapp-sdk 1.13.0-alpha.9 → 1.13.0

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 (49) 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 +10 -6
  6. package/build/main/lib/client/file.js +7 -3
  7. package/build/main/lib/client/index.d.ts +1 -1
  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 +1 -1
  18. package/build/main/types/bridge.d.ts +3 -1
  19. package/build/main/types/bridge.js +5 -4
  20. package/build/main/types/events.d.ts +8 -1
  21. package/build/main/types/events.js +10 -3
  22. package/build/main/types/express-disk.d.ts +15 -0
  23. package/build/main/types/express-disk.js +3 -0
  24. package/build/main/types/routing.js +2 -2
  25. package/build/main/types/storage.js +2 -2
  26. package/build/module/index.d.ts +2 -1
  27. package/build/module/index.js +3 -2
  28. package/build/module/lib/client/events.d.ts +6 -7
  29. package/build/module/lib/client/events.js +3 -4
  30. package/build/module/lib/client/file.d.ts +10 -6
  31. package/build/module/lib/client/file.js +7 -3
  32. package/build/module/lib/client/index.d.ts +1 -1
  33. package/build/module/lib/contacts/index.d.ts +48 -8
  34. package/build/module/lib/contacts/index.js +49 -9
  35. package/build/module/lib/devices/bluetooth.d.ts +1 -1
  36. package/build/module/lib/express-disk/index.d.ts +6 -0
  37. package/build/module/lib/express-disk/index.js +18 -0
  38. package/build/module/lib/index.d.ts +1 -2
  39. package/build/module/lib/index.js +2 -3
  40. package/build/module/lib/notification/index.js +1 -1
  41. package/build/module/lib/routing/index.d.ts +1 -1
  42. package/build/module/types/bridge.d.ts +3 -1
  43. package/build/module/types/bridge.js +2 -1
  44. package/build/module/types/events.d.ts +8 -1
  45. package/build/module/types/events.js +8 -1
  46. package/build/module/types/express-disk.d.ts +15 -0
  47. package/build/module/types/express-disk.js +2 -0
  48. package/build/umd/index.js +77 -2
  49. package/package.json +5 -3
@@ -2023,6 +2023,7 @@
2023
2023
  METHODS["WRITE_NFC_TAG"] = "write_nfc_tag";
2024
2024
  METHODS["ALLOW_IOS_SWIPE_NAVIGATION"] = "allow_ios_swipe_navigation";
2025
2025
  METHODS["HIDE_RECV_DATA"] = "hide_recv_data";
2026
+ METHODS["GET_EXPRESS_DISK_AUTH_CODE"] = "get_express_disk_auth_code";
2026
2027
  })(METHODS || (METHODS = {}));
2027
2028
  var STATUS;
2028
2029
  (function (STATUS) {
@@ -2057,6 +2058,13 @@
2057
2058
  SubscriptionEventType["SMARTAPP_LIST"] = "smartapp_list";
2058
2059
  SubscriptionEventType["IOS_SWIPE"] = "ios_swipe";
2059
2060
  })(SubscriptionEventType || (SubscriptionEventType = {}));
2061
+ var FILE_MEDIA_QUALITY;
2062
+ (function (FILE_MEDIA_QUALITY) {
2063
+ FILE_MEDIA_QUALITY["LOW"] = "low";
2064
+ FILE_MEDIA_QUALITY["MEDIUM"] = "medium";
2065
+ FILE_MEDIA_QUALITY["HIGH"] = "high";
2066
+ FILE_MEDIA_QUALITY["ORIGINAL"] = "original";
2067
+ })(FILE_MEDIA_QUALITY || (FILE_MEDIA_QUALITY = {}));
2060
2068
 
2061
2069
  const subscriptions = [];
2062
2070
  let bridgeEventListenerInstalled = false;
@@ -2442,9 +2450,10 @@
2442
2450
  * Upload single file with client
2443
2451
  * @param mimeType Mime type of allowed files
2444
2452
  * @param maxSize Max file size in bytes
2453
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2445
2454
  * @returns Promise that'll be fullfilled with file metadata on success, otherwise rejected with reason
2446
2455
  */
2447
- const uploadFile = async ({ mimeType, maxSize, }) => {
2456
+ const uploadFile = async ({ mimeType, maxSize, mediaQuality, }) => {
2448
2457
  if (!bridge)
2449
2458
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2450
2459
  const response = await bridge.sendClientEvent({
@@ -2452,6 +2461,7 @@
2452
2461
  params: {
2453
2462
  type: mimeType,
2454
2463
  maxSize,
2464
+ mediaQuality,
2455
2465
  },
2456
2466
  timeout: FILE_LOAD_TIMEOUT,
2457
2467
  });
@@ -2462,9 +2472,10 @@
2462
2472
  * @param mimeType Mime type of allowed files
2463
2473
  * @param maxSize Max file size in bytes
2464
2474
  * @param totalSize Total files size in bytes
2475
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2465
2476
  * @returns Promise that'll be fullfilled with files metadata on success, otherwise rejected with reason
2466
2477
  */
2467
- const uploadFiles = async ({ mimeType, maxSize, totalSize, }) => {
2478
+ const uploadFiles = async ({ mimeType, maxSize, totalSize, mediaQuality, }) => {
2468
2479
  if (!bridge)
2469
2480
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2470
2481
  const response = await bridge.sendClientEvent({
@@ -2473,12 +2484,18 @@
2473
2484
  type: mimeType,
2474
2485
  maxSize,
2475
2486
  totalSize,
2487
+ mediaQuality,
2476
2488
  },
2477
2489
  timeout: FILE_LOAD_TIMEOUT,
2478
2490
  });
2479
2491
  return response;
2480
2492
  };
2481
2493
 
2494
+ /**
2495
+ * Add a contact to local device phonebook.
2496
+ * @param params Object containing phone and name of the contact.
2497
+ * @returns A promise that resolves with the response, or undefined if bridge is not available.
2498
+ */
2482
2499
  const addContact = ({ phone, name }) => {
2483
2500
  return bridge?.sendClientEvent({
2484
2501
  method: METHODS.ADD_CONTACT,
@@ -2488,21 +2505,47 @@
2488
2505
  },
2489
2506
  });
2490
2507
  };
2508
+ /**
2509
+ * Get a contact by phone number.
2510
+ * @param params Object containing the phone number of the contact.
2511
+ * @returns A promise that resolves with the response, or undefined if bridge is not available.
2512
+ */
2491
2513
  const getContact = async ({ phone }) => {
2492
2514
  return bridge?.sendClientEvent({
2493
2515
  method: METHODS.GET_CONTACT,
2494
2516
  params: { phone },
2495
2517
  });
2496
2518
  };
2519
+ /**
2520
+ * Creates a personal chat with the specified HUID.
2521
+ * @param {Object} params
2522
+ * @param {string} params.huid - The HUID of the user to create a chat with.
2523
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2524
+ */
2497
2525
  const createPersonalChat = ({ huid }) => {
2498
2526
  return bridge?.sendClientEvent({
2499
2527
  method: METHODS.CREATE_PERSONAL_CHAT,
2500
2528
  params: { huid },
2501
2529
  });
2502
2530
  };
2531
+ /**
2532
+ * Opens a personal chat with the specified HUID.
2533
+ * @param {Object} params
2534
+ * @param {string} params.huid - The HUID of the user whose chat to open.
2535
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2536
+ */
2503
2537
  const openPersonalChat = ({ huid }) => {
2504
2538
  return createPersonalChat({ huid });
2505
2539
  };
2540
+ /**
2541
+ * Sends a message to a user or group chat.
2542
+ * @param {SendMessageMethodParams} params - The parameters for sending a message.
2543
+ * @param {string | null} [params.userHuid=null] - The HUID of the user to send the message to.
2544
+ * @param {string | null} [params.groupChatId=null] - The ID of the group chat to send the message to.
2545
+ * @param {string} [params.messageBody=''] - The body of the message.
2546
+ * @param {object} [params.messageMeta={}] - Additional metadata for the message.
2547
+ * @returns {Promise<any> | undefined} A promise that resolves with the result of the operation, or undefined if bridge is not available.
2548
+ */
2506
2549
  const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {}, }) => {
2507
2550
  return bridge?.sendClientEvent({
2508
2551
  method: METHODS.SEND_MESSAGE,
@@ -2516,6 +2559,12 @@
2516
2559
  },
2517
2560
  });
2518
2561
  };
2562
+ /**
2563
+ * Opens the contact card for the specified user HUID.
2564
+ * @param {Object} params
2565
+ * @param {string} params.userHuid - The HUID of the user whose contact card to open.
2566
+ * @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.
2567
+ */
2519
2568
  const openContactCard = ({ userHuid }) => {
2520
2569
  if (!userHuid)
2521
2570
  return;
@@ -2524,6 +2573,10 @@
2524
2573
  params: { userHuid }
2525
2574
  });
2526
2575
  };
2576
+ /**
2577
+ * Requests the self profile of the current user.
2578
+ * @returns {RequestSelfProfileResponse} The response containing the self profile information.
2579
+ */
2527
2580
  const requestSelfProfile = () => {
2528
2581
  return bridge?.sendClientEvent({
2529
2582
  method: METHODS.REQUEST_SELF_PROFILE,
@@ -2953,8 +3006,30 @@
2953
3006
  writeTag: writeTag
2954
3007
  });
2955
3008
 
3009
+ /**
3010
+ * Get auth code for eXpress Disk
3011
+ * @returns Promise that'll be fullfilled with `payload.auth` on success, otherwise rejected with reason
3012
+ */
3013
+ const getAuthCode = () => {
3014
+ if (!bridge)
3015
+ return Promise.reject(ERROR_CODES.NO_BRIDGE);
3016
+ return bridge
3017
+ .sendClientEvent({
3018
+ method: METHODS.GET_EXPRESS_DISK_AUTH_CODE,
3019
+ params: {},
3020
+ hide_recv_event_data: true,
3021
+ })
3022
+ .then(event => event);
3023
+ };
3024
+
3025
+ var index = /*#__PURE__*/Object.freeze({
3026
+ __proto__: null,
3027
+ getAuthCode: getAuthCode
3028
+ });
3029
+
2956
3030
  exports.Bluetooth = bluetooth;
2957
3031
  exports.Bridge = bridge;
3032
+ exports.ExpressDisk = index;
2958
3033
  exports.GPS = gps;
2959
3034
  exports.NFC = nfc;
2960
3035
  exports.addContact = addContact;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-sdk",
3
- "version": "1.13.0-alpha.9",
3
+ "version": "1.13.0",
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,7 +36,8 @@
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
43
  "@expressms/smartapp-bridge": "1.4.5"