@expressms/smartapp-sdk 1.13.0-alpha.8 → 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 (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 +2 -1
  20. package/build/main/types/bridge.js +5 -4
  21. package/build/main/types/events.d.ts +7 -1
  22. package/build/main/types/events.js +9 -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 +2 -1
  45. package/build/module/types/bridge.js +2 -1
  46. package/build/module/types/events.d.ts +7 -1
  47. package/build/module/types/events.js +7 -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 +77 -2
  51. package/package.json +5 -3
@@ -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,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;
@@ -2413,6 +2420,7 @@
2413
2420
  const hideRecievedData = () => {
2414
2421
  if (!bridge)
2415
2422
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2423
+ bridge.hideRecvData();
2416
2424
  return bridge
2417
2425
  .sendClientEvent({
2418
2426
  method: METHODS.HIDE_RECV_DATA,
@@ -2441,9 +2449,10 @@
2441
2449
  * Upload single file with client
2442
2450
  * @param mimeType Mime type of allowed files
2443
2451
  * @param maxSize Max file size in bytes
2452
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2444
2453
  * @returns Promise that'll be fullfilled with file metadata on success, otherwise rejected with reason
2445
2454
  */
2446
- const uploadFile = async ({ mimeType, maxSize, }) => {
2455
+ const uploadFile = async ({ mimeType, maxSize, mediaQuality, }) => {
2447
2456
  if (!bridge)
2448
2457
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2449
2458
  const response = await bridge.sendClientEvent({
@@ -2451,6 +2460,7 @@
2451
2460
  params: {
2452
2461
  type: mimeType,
2453
2462
  maxSize,
2463
+ mediaQuality,
2454
2464
  },
2455
2465
  timeout: FILE_LOAD_TIMEOUT,
2456
2466
  });
@@ -2461,9 +2471,10 @@
2461
2471
  * @param mimeType Mime type of allowed files
2462
2472
  * @param maxSize Max file size in bytes
2463
2473
  * @param totalSize Total files size in bytes
2474
+ * @param mediaQuality File media quality (For example: low mediaQuality - high compression ratio on client)
2464
2475
  * @returns Promise that'll be fullfilled with files metadata on success, otherwise rejected with reason
2465
2476
  */
2466
- const uploadFiles = async ({ mimeType, maxSize, totalSize, }) => {
2477
+ const uploadFiles = async ({ mimeType, maxSize, totalSize, mediaQuality, }) => {
2467
2478
  if (!bridge)
2468
2479
  return Promise.reject(ERROR_CODES.NO_BRIDGE);
2469
2480
  const response = await bridge.sendClientEvent({
@@ -2472,12 +2483,18 @@
2472
2483
  type: mimeType,
2473
2484
  maxSize,
2474
2485
  totalSize,
2486
+ mediaQuality,
2475
2487
  },
2476
2488
  timeout: FILE_LOAD_TIMEOUT,
2477
2489
  });
2478
2490
  return response;
2479
2491
  };
2480
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
+ */
2481
2498
  const addContact = ({ phone, name }) => {
2482
2499
  return bridge?.sendClientEvent({
2483
2500
  method: METHODS.ADD_CONTACT,
@@ -2487,21 +2504,47 @@
2487
2504
  },
2488
2505
  });
2489
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
+ */
2490
2512
  const getContact = async ({ phone }) => {
2491
2513
  return bridge?.sendClientEvent({
2492
2514
  method: METHODS.GET_CONTACT,
2493
2515
  params: { phone },
2494
2516
  });
2495
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
+ */
2496
2524
  const createPersonalChat = ({ huid }) => {
2497
2525
  return bridge?.sendClientEvent({
2498
2526
  method: METHODS.CREATE_PERSONAL_CHAT,
2499
2527
  params: { huid },
2500
2528
  });
2501
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
+ */
2502
2536
  const openPersonalChat = ({ huid }) => {
2503
2537
  return createPersonalChat({ huid });
2504
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
+ */
2505
2548
  const sendMessage = ({ userHuid = null, groupChatId = null, messageBody = '', messageMeta = {}, }) => {
2506
2549
  return bridge?.sendClientEvent({
2507
2550
  method: METHODS.SEND_MESSAGE,
@@ -2515,6 +2558,12 @@
2515
2558
  },
2516
2559
  });
2517
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
+ */
2518
2567
  const openContactCard = ({ userHuid }) => {
2519
2568
  if (!userHuid)
2520
2569
  return;
@@ -2523,6 +2572,10 @@
2523
2572
  params: { userHuid }
2524
2573
  });
2525
2574
  };
2575
+ /**
2576
+ * Requests the self profile of the current user.
2577
+ * @returns {RequestSelfProfileResponse} The response containing the self profile information.
2578
+ */
2526
2579
  const requestSelfProfile = () => {
2527
2580
  return bridge?.sendClientEvent({
2528
2581
  method: METHODS.REQUEST_SELF_PROFILE,
@@ -2952,8 +3005,30 @@
2952
3005
  writeTag: writeTag
2953
3006
  });
2954
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
+
2955
3029
  exports.Bluetooth = bluetooth;
2956
3030
  exports.Bridge = bridge;
3031
+ exports.ExpressDisk = index;
2957
3032
  exports.GPS = gps;
2958
3033
  exports.NFC = nfc;
2959
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.8",
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"