@expressms/smartapp-sdk 1.13.0-alpha.8 → 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 (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 +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/client/index.js +2 -1
  9. package/build/main/lib/contacts/index.d.ts +48 -8
  10. package/build/main/lib/contacts/index.js +44 -3
  11. package/build/main/lib/devices/bluetooth.d.ts +1 -1
  12. package/build/main/lib/devices/index.js +18 -8
  13. package/build/main/lib/express-disk/index.d.ts +6 -0
  14. package/build/main/lib/express-disk/index.js +25 -0
  15. package/build/main/lib/index.d.ts +1 -2
  16. package/build/main/lib/index.js +1 -1
  17. package/build/main/lib/notification/index.js +1 -1
  18. package/build/main/lib/routing/index.d.ts +1 -1
  19. package/build/main/types/bridge.d.ts +3 -1
  20. package/build/main/types/bridge.js +5 -4
  21. package/build/main/types/events.d.ts +8 -1
  22. package/build/main/types/events.js +10 -3
  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 +10 -6
  32. package/build/module/lib/client/file.js +7 -3
  33. package/build/module/lib/client/index.d.ts +1 -1
  34. package/build/module/lib/client/index.js +2 -1
  35. package/build/module/lib/contacts/index.d.ts +48 -8
  36. package/build/module/lib/contacts/index.js +49 -9
  37. package/build/module/lib/devices/bluetooth.d.ts +1 -1
  38. package/build/module/lib/express-disk/index.d.ts +6 -0
  39. package/build/module/lib/express-disk/index.js +18 -0
  40. package/build/module/lib/index.d.ts +1 -2
  41. package/build/module/lib/index.js +2 -3
  42. package/build/module/lib/notification/index.js +1 -1
  43. package/build/module/lib/routing/index.d.ts +1 -1
  44. package/build/module/types/bridge.d.ts +3 -1
  45. package/build/module/types/bridge.js +2 -1
  46. package/build/module/types/events.d.ts +8 -1
  47. package/build/module/types/events.js +8 -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 +78 -2
  51. package/package.json +5 -3
@@ -7,4 +7,11 @@ export var SubscriptionEventType;
7
7
  SubscriptionEventType["SMARTAPP_LIST"] = "smartapp_list";
8
8
  SubscriptionEventType["IOS_SWIPE"] = "ios_swipe";
9
9
  })(SubscriptionEventType || (SubscriptionEventType = {}));
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3R5cGVzL2V2ZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQU4sSUFBWSxxQkFPWDtBQVBELFdBQVkscUJBQXFCO0lBQy9CLGdFQUF1QyxDQUFBO0lBQ3ZDLHdFQUErQyxDQUFBO0lBQy9DLG9EQUEyQixDQUFBO0lBQzNCLDBEQUFpQyxDQUFBO0lBQ2pDLHdEQUErQixDQUFBO0lBQy9CLGdEQUF1QixDQUFBO0FBQ3pCLENBQUMsRUFQVyxxQkFBcUIsS0FBckIscUJBQXFCLFFBT2hDIn0=
10
+ export var FILE_MEDIA_QUALITY;
11
+ (function (FILE_MEDIA_QUALITY) {
12
+ FILE_MEDIA_QUALITY["LOW"] = "low";
13
+ FILE_MEDIA_QUALITY["MEDIUM"] = "medium";
14
+ FILE_MEDIA_QUALITY["HIGH"] = "high";
15
+ FILE_MEDIA_QUALITY["ORIGINAL"] = "original";
16
+ })(FILE_MEDIA_QUALITY || (FILE_MEDIA_QUALITY = {}));
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3R5cGVzL2V2ZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQU4sSUFBWSxxQkFPWDtBQVBELFdBQVkscUJBQXFCO0lBQy9CLGdFQUF1QyxDQUFBO0lBQ3ZDLHdFQUErQyxDQUFBO0lBQy9DLG9EQUEyQixDQUFBO0lBQzNCLDBEQUFpQyxDQUFBO0lBQ2pDLHdEQUErQixDQUFBO0lBQy9CLGdEQUF1QixDQUFBO0FBQ3pCLENBQUMsRUFQVyxxQkFBcUIsS0FBckIscUJBQXFCLFFBT2hDO0FBU0QsTUFBTSxDQUFOLElBQVksa0JBS1g7QUFMRCxXQUFZLGtCQUFrQjtJQUM1QixpQ0FBVyxDQUFBO0lBQ1gsdUNBQWlCLENBQUE7SUFDakIsbUNBQWEsQ0FBQTtJQUNiLDJDQUFxQixDQUFBO0FBQ3ZCLENBQUMsRUFMVyxrQkFBa0IsS0FBbEIsa0JBQWtCLFFBSzdCIn0=
@@ -0,0 +1,15 @@
1
+ import { EmitterEventPayload } from '@expressms/smartapp-bridge/build/main/types/eventEmitter';
2
+ import { STATUS } from './bridge';
3
+ export interface GetAuthCodeResponse extends Omit<EmitterEventPayload, 'payload'> {
4
+ payload: {
5
+ status: STATUS;
6
+ errorCode?: string | null;
7
+ auth: {
8
+ diskHost: string;
9
+ code: string;
10
+ codeChallenge: null | string;
11
+ codeChallengeMethod: string;
12
+ expiresIn: number;
13
+ };
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwcmVzcy1kaXNrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3R5cGVzL2V4cHJlc3MtZGlzay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -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;
@@ -2413,6 +2421,7 @@
2413
2421
  const hideRecievedData = () => {
2414
2422
  if (!bridge)
2415
2423
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2424
+ bridge.hideRecvData();
2416
2425
  return bridge
2417
2426
  .sendClientEvent({
2418
2427
  method: METHODS.HIDE_RECV_DATA,
@@ -2441,9 +2450,10 @@
2441
2450
  * Upload single file with client
2442
2451
  * @param mimeType Mime type of allowed files
2443
2452
  * @param maxSize Max file size in bytes
2453
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2444
2454
  * @returns Promise that'll be fullfilled with file metadata on success, otherwise rejected with reason
2445
2455
  */
2446
- const uploadFile = async ({ mimeType, maxSize, }) => {
2456
+ const uploadFile = async ({ mimeType, maxSize, mediaQuality, }) => {
2447
2457
  if (!bridge)
2448
2458
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2449
2459
  const response = await bridge.sendClientEvent({
@@ -2451,6 +2461,7 @@
2451
2461
  params: {
2452
2462
  type: mimeType,
2453
2463
  maxSize,
2464
+ mediaQuality,
2454
2465
  },
2455
2466
  timeout: FILE_LOAD_TIMEOUT,
2456
2467
  });
@@ -2461,9 +2472,10 @@
2461
2472
  * @param mimeType Mime type of allowed files
2462
2473
  * @param maxSize Max file size in bytes
2463
2474
  * @param totalSize Total files size in bytes
2475
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2464
2476
  * @returns Promise that'll be fullfilled with files metadata on success, otherwise rejected with reason
2465
2477
  */
2466
- const uploadFiles = async ({ mimeType, maxSize, totalSize, }) => {
2478
+ const uploadFiles = async ({ mimeType, maxSize, totalSize, mediaQuality, }) => {
2467
2479
  if (!bridge)
2468
2480
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2469
2481
  const response = await bridge.sendClientEvent({
@@ -2472,12 +2484,18 @@
2472
2484
  type: mimeType,
2473
2485
  maxSize,
2474
2486
  totalSize,
2487
+ mediaQuality,
2475
2488
  },
2476
2489
  timeout: FILE_LOAD_TIMEOUT,
2477
2490
  });
2478
2491
  return response;
2479
2492
  };
2480
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
+ */
2481
2499
  const addContact = ({ phone, name }) => {
2482
2500
  return bridge?.sendClientEvent({
2483
2501
  method: METHODS.ADD_CONTACT,
@@ -2487,21 +2505,47 @@
2487
2505
  },
2488
2506
  });
2489
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
+ */
2490
2513
  const getContact = async ({ phone }) => {
2491
2514
  return bridge?.sendClientEvent({
2492
2515
  method: METHODS.GET_CONTACT,
2493
2516
  params: { phone },
2494
2517
  });
2495
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
+ */
2496
2525
  const createPersonalChat = ({ huid }) => {
2497
2526
  return bridge?.sendClientEvent({
2498
2527
  method: METHODS.CREATE_PERSONAL_CHAT,
2499
2528
  params: { huid },
2500
2529
  });
2501
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
+ */
2502
2537
  const openPersonalChat = ({ huid }) => {
2503
2538
  return createPersonalChat({ huid });
2504
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
+ */
2505
2549
  const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {}, }) => {
2506
2550
  return bridge?.sendClientEvent({
2507
2551
  method: METHODS.SEND_MESSAGE,
@@ -2515,6 +2559,12 @@
2515
2559
  },
2516
2560
  });
2517
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
+ */
2518
2568
  const openContactCard = ({ userHuid }) => {
2519
2569
  if (!userHuid)
2520
2570
  return;
@@ -2523,6 +2573,10 @@
2523
2573
  params: { userHuid }
2524
2574
  });
2525
2575
  };
2576
+ /**
2577
+ * Requests the self profile of the current user.
2578
+ * @returns {RequestSelfProfileResponse} The response containing the self profile information.
2579
+ */
2526
2580
  const requestSelfProfile = () => {
2527
2581
  return bridge?.sendClientEvent({
2528
2582
  method: METHODS.REQUEST_SELF_PROFILE,
@@ -2952,8 +3006,30 @@
2952
3006
  writeTag: writeTag
2953
3007
  });
2954
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
+
2955
3030
  exports.Bluetooth = bluetooth;
2956
3031
  exports.Bridge = bridge;
3032
+ exports.ExpressDisk = index;
2957
3033
  exports.GPS = gps;
2958
3034
  exports.NFC = nfc;
2959
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.8",
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"