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