@pitcher/js-api 1.22.0-alpha.5 → 1.22.0-beta.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 (187) hide show
  1. package/js-api.esm.js +693 -184
  2. package/js-api.esm.js.map +1 -1
  3. package/js-api.umd.min.js +10 -10
  4. package/js-api.umd.min.js.map +1 -1
  5. package/lib/api/canvases/canvases.queries.d.ts +5 -5
  6. package/lib/apps/browser/stores/api.d.ts +215 -84
  7. package/lib/apps/browser/stores/app.d.ts +7 -26
  8. package/lib/apps/browser/stores/upload.d.ts +34 -24
  9. package/lib/apps/browser/util/file.d.ts +2 -2
  10. package/lib/apps/canvas-builder/composables/useCanvas.d.ts +550 -460
  11. package/lib/apps/canvas-builder/composables/useCanvasExit.d.ts +3 -0
  12. package/lib/apps/canvas-builder/composables/useCanvasHistory.d.ts +86 -74
  13. package/lib/apps/canvas-builder/composables/useCanvasHooks.d.ts +4 -4
  14. package/lib/apps/canvas-builder/composables/useCanvasPages.d.ts +3 -3
  15. package/lib/apps/canvas-builder/composables/useCanvasSectionOverrides.d.ts +3 -3
  16. package/lib/apps/canvas-builder/composables/useCanvasTheme.d.ts +24 -17
  17. package/lib/apps/canvas-builder/composables/useCanvasVisibility.d.ts +2 -2
  18. package/lib/apps/canvas-builder/composables/useCollapsibles.d.ts +3 -3
  19. package/lib/apps/canvas-builder/composables/useComponentPermissions.d.ts +2 -2
  20. package/lib/apps/canvas-builder/composables/useContentSelector.d.ts +6 -4
  21. package/lib/apps/canvas-builder/composables/useInstalledEmbeddables.d.ts +15 -0
  22. package/lib/apps/canvas-builder/composables/useRecommendations.d.ts +6 -5
  23. package/lib/apps/canvas-builder/composables/useSectionPopularity.d.ts +2 -2
  24. package/lib/apps/canvas-builder/types/canvas.d.ts +19 -18
  25. package/lib/apps/canvas-builder/types/recommendations.types.d.ts +3 -3
  26. package/lib/apps/canvas-builder/util/canvas.util.d.ts +5 -4
  27. package/lib/apps/canvas-selector/appTypes.d.ts +9 -0
  28. package/lib/apps/content-selector/appTypes.d.ts +1 -0
  29. package/lib/apps/content-selector/stores/app.d.ts +8 -1
  30. package/lib/components/CFileViewer/CFileViewer.use.d.ts +2 -4
  31. package/lib/components/CFileViewer/CFileViewerFullScreen.use.d.ts +1 -1
  32. package/lib/components/canvases/CanvasesManagementBulk.use.d.ts +5 -5
  33. package/lib/components/filters/filter.util.d.ts +1 -1
  34. package/lib/components/savedCanvases/CSavedCanvasesManagementShareCanvas.use.d.ts +5 -3
  35. package/lib/composables/instanceTagsActions.use.d.ts +14 -0
  36. package/lib/composables/recentFiles.use.d.ts +1 -1
  37. package/lib/composables/suggestedTags.use.d.ts +3 -0
  38. package/lib/composables/tableColumnsSettings.use.d.ts +25 -0
  39. package/lib/composables/useCanvasOverlay.d.ts +20 -0
  40. package/lib/composables/useCanvasTablesPagination.d.ts +13 -0
  41. package/lib/composables/useConfirmation.d.ts +1 -0
  42. package/lib/composables/useElementHeightResize.d.ts +5 -0
  43. package/lib/composables/useFiles.d.ts +11 -0
  44. package/lib/composables/useWindowEvents.d.ts +1 -1
  45. package/lib/constants/pitcherSettings.const.d.ts +4 -0
  46. package/lib/main.lib.d.ts +31 -21
  47. package/lib/sdk/api/HighLevelApi.d.ts +112 -14
  48. package/lib/sdk/api/modules/admin/canvas.admin.d.ts +53 -15
  49. package/lib/sdk/api/modules/admin/env.admin.d.ts +3 -2
  50. package/lib/sdk/api/modules/admin/files.admin.d.ts +43 -4
  51. package/lib/sdk/api/modules/admin/index.d.ts +53 -5
  52. package/lib/sdk/api/modules/admin/metadataTemplates.admin.d.ts +1 -2
  53. package/lib/sdk/api/modules/admin/types.admin.d.ts +132 -3
  54. package/lib/sdk/api/modules/canvas.d.ts +12 -14
  55. package/lib/sdk/api/modules/dsr/env.dsr.d.ts +4 -3
  56. package/lib/sdk/api/modules/dsr/index.d.ts +14 -3
  57. package/lib/sdk/api/modules/dsr/loading.dsr.d.ts +7 -1
  58. package/lib/sdk/api/modules/env.d.ts +16 -0
  59. package/lib/sdk/api/modules/favorites.d.ts +9 -0
  60. package/lib/sdk/api/modules/feedback.d.ts +3 -0
  61. package/lib/sdk/api/modules/files.d.ts +7 -4
  62. package/lib/sdk/api/modules/folders.d.ts +29 -0
  63. package/lib/sdk/api/modules/open.d.ts +6 -0
  64. package/lib/sdk/api/modules/sync.d.ts +1 -2
  65. package/lib/sdk/api/modules/ui/app-errors.ui.d.ts +13 -1
  66. package/lib/sdk/api/modules/ui/canvas.ui.d.ts +102 -8
  67. package/lib/sdk/api/modules/ui/content.ui.d.ts +52 -2
  68. package/lib/sdk/api/modules/ui/index.d.ts +150 -13
  69. package/lib/sdk/api/modules/ui/loading.ui.d.ts +9 -1
  70. package/lib/sdk/api/modules/ui/location.ui.d.ts +18 -1
  71. package/lib/sdk/api/modules/ui/post-call.ui.d.ts +35 -4
  72. package/lib/sdk/api/modules/ui/types.ui.d.ts +86 -8
  73. package/lib/sdk/api/modules/users.d.ts +6 -1
  74. package/lib/sdk/api/onlineRestApiHandlers.d.ts +4 -0
  75. package/lib/sdk/interfaces.d.ts +124 -3
  76. package/lib/sdk/main.d.ts +297 -151
  77. package/lib/sdk/payload.types.d.ts +134 -2
  78. package/lib/sdk/utils/httpFetch.d.ts +15 -0
  79. package/lib/sdk/utils/object.d.ts +1 -0
  80. package/lib/sdk/utils/object.spec.d.ts +1 -0
  81. package/lib/theme/light.d.ts +12 -0
  82. package/lib/types/app.d.ts +11 -0
  83. package/lib/types/call.d.ts +4 -3
  84. package/lib/types/files.d.ts +27 -1
  85. package/lib/types/filter.d.ts +5 -0
  86. package/lib/types/instance.types.d.ts +18 -0
  87. package/lib/types/{instanceSettings.d.ts → instanceSettings.types.d.ts} +10 -2
  88. package/lib/types/launchDarkly.types.d.ts +4 -4
  89. package/lib/types/organization.types.d.ts +2 -2
  90. package/lib/types/organizationSettings.types.d.ts +4 -0
  91. package/lib/types/recentFiles.types.d.ts +4 -1
  92. package/lib/types/users.d.ts +13 -0
  93. package/lib/util/fullscreen.util.d.ts +1 -1
  94. package/lib/util/string.d.ts +1 -0
  95. package/package.json +1 -1
  96. package/types/openapi/index.d.ts +23 -17
  97. package/types/openapi/models/AccessTypeEnum.d.ts +3 -1
  98. package/types/openapi/models/App.d.ts +1 -0
  99. package/types/openapi/models/AppRelease.d.ts +1 -0
  100. package/types/openapi/models/AppsDBEntry.d.ts +4 -0
  101. package/types/openapi/models/AppsDBEntryRequest.d.ts +3 -0
  102. package/types/openapi/models/Canvas.d.ts +10 -15
  103. package/types/openapi/models/CanvasCreate.d.ts +14 -12
  104. package/types/openapi/models/CanvasCreateRequest.d.ts +6 -5
  105. package/types/openapi/models/CanvasRecommendedFile.d.ts +6 -0
  106. package/types/openapi/models/CanvasRetrieve.d.ts +15 -13
  107. package/types/openapi/models/CanvasSection.d.ts +5 -2
  108. package/types/openapi/models/CanvasUpdate.d.ts +14 -12
  109. package/types/openapi/models/CanvasUpdateRequest.d.ts +5 -4
  110. package/types/openapi/models/CollaborationRoleEnum.d.ts +0 -4
  111. package/types/openapi/models/ContentDistributionGroupCreate.d.ts +1 -0
  112. package/types/openapi/models/DeletedApp.d.ts +1 -0
  113. package/types/openapi/models/{CanvasList.d.ts → DeletedCanvas.d.ts} +13 -9
  114. package/types/openapi/models/DeletedContentDistributionGroup.d.ts +1 -0
  115. package/types/openapi/models/DeletedEnvironment.d.ts +1 -0
  116. package/types/openapi/models/DeletedFavorite.d.ts +1 -0
  117. package/types/openapi/models/DeletedFile.d.ts +6 -0
  118. package/types/openapi/models/DeletedFolder.d.ts +4 -3
  119. package/types/openapi/models/DeletedInstance.d.ts +1 -0
  120. package/types/openapi/models/DeletedInstanceAssignmentGroup.d.ts +1 -0
  121. package/types/openapi/models/DeletedMetadataTemplate.d.ts +1 -0
  122. package/types/openapi/models/DeletedRegion.d.ts +1 -0
  123. package/types/openapi/models/Environment.d.ts +1 -0
  124. package/types/openapi/models/Favorite.d.ts +1 -0
  125. package/types/openapi/models/File.d.ts +6 -0
  126. package/types/openapi/models/FileCreate.d.ts +8 -0
  127. package/types/openapi/models/FileCreateRequest.d.ts +3 -0
  128. package/types/openapi/models/FilePermission.d.ts +4 -0
  129. package/types/openapi/models/FilePermissionRequest.d.ts +4 -0
  130. package/types/openapi/models/FileRetrieve.d.ts +8 -0
  131. package/types/openapi/models/FileRevision.d.ts +8 -0
  132. package/types/openapi/models/FileRevisionRequest.d.ts +3 -0
  133. package/types/openapi/models/FileUpdate.d.ts +8 -0
  134. package/types/openapi/models/FileUpdateRequest.d.ts +3 -0
  135. package/types/openapi/models/FileVersion.d.ts +5 -0
  136. package/types/openapi/models/Folder.d.ts +4 -3
  137. package/types/openapi/models/FolderCanvas.d.ts +11 -0
  138. package/types/openapi/models/FolderCreate.d.ts +8 -7
  139. package/types/openapi/models/FolderCreateRequest.d.ts +4 -2
  140. package/types/openapi/models/FolderFile.d.ts +3 -0
  141. package/types/openapi/models/FolderFolder.d.ts +5 -1
  142. package/types/openapi/models/FolderRetrieve.d.ts +8 -8
  143. package/types/openapi/models/FolderRule.d.ts +7 -0
  144. package/types/openapi/models/FolderRuleRequest.d.ts +7 -0
  145. package/types/openapi/models/FolderUpdate.d.ts +8 -8
  146. package/types/openapi/models/FolderUpdateRequest.d.ts +3 -0
  147. package/types/openapi/models/Instance.d.ts +1 -0
  148. package/types/openapi/models/InstanceUpdate.d.ts +1 -0
  149. package/types/openapi/models/MetadataTemplate.d.ts +1 -0
  150. package/types/openapi/models/OfflineSyncFolder.d.ts +17 -0
  151. package/types/openapi/models/OperatorEnum.d.ts +64 -0
  152. package/types/openapi/models/PaginatedCanvasList.d.ts +8 -0
  153. package/types/openapi/models/PaginatedFileRevisionList.d.ts +8 -0
  154. package/types/openapi/models/PaginatedOfflineSyncFolderList.d.ts +8 -0
  155. package/types/openapi/models/PatchedCanvasUpdateRequest.d.ts +5 -4
  156. package/types/openapi/models/PatchedFileRequest.d.ts +3 -0
  157. package/types/openapi/models/PatchedFileRevisionRequest.d.ts +3 -0
  158. package/types/openapi/models/PatchedFileUpdateRequest.d.ts +3 -0
  159. package/types/openapi/models/PatchedFolderUpdateRequest.d.ts +3 -0
  160. package/types/openapi/models/Region.d.ts +1 -0
  161. package/types/openapi/models/SearchFile.d.ts +3 -0
  162. package/types/openapi/models/SharedLink.d.ts +6 -5
  163. package/types/openapi/models/SharedLinkCanvas.d.ts +11 -0
  164. package/types/openapi/models/SharedLinkCanvasRequest.d.ts +8 -0
  165. package/types/openapi/models/SharedLinkCreate.d.ts +6 -5
  166. package/types/openapi/models/{SharedLinkInstanceSerialzier.d.ts → SharedLinkInstance.d.ts} +1 -1
  167. package/types/openapi/models/SharedLinkInstanceRequest.d.ts +5 -0
  168. package/types/openapi/models/{SharedLinkOrganizationSerialzier.d.ts → SharedLinkOrganization.d.ts} +1 -1
  169. package/types/openapi/models/SharedLinkOrganizationRequest.d.ts +6 -0
  170. package/lib/apps/canvas-builder/util/tsUtils.d.ts +0 -3
  171. package/lib/composables/useDetailsView.d.ts +0 -19
  172. package/lib/types/templateActions.d.ts +0 -10
  173. package/lib/util/gesture.util.d.ts +0 -6
  174. package/types/openapi/models/AppsDBGlobalEntry.d.ts +0 -8
  175. package/types/openapi/models/AppsDBGlobalEntryRequest.d.ts +0 -3
  176. package/types/openapi/models/AppsDBUserEntry.d.ts +0 -9
  177. package/types/openapi/models/AppsDBUserEntryRequest.d.ts +0 -3
  178. package/types/openapi/models/CanvasSectionRetrieve.d.ts +0 -7
  179. package/types/openapi/models/CanvasSectionRetrieveRequest.d.ts +0 -5
  180. package/types/openapi/models/FileRequest.d.ts +0 -13
  181. package/types/openapi/models/InstanceStorageCredentials.d.ts +0 -6
  182. package/types/openapi/models/MiniAccount.d.ts +0 -4
  183. package/types/openapi/models/PSPDFKitAuthPayload.d.ts +0 -3
  184. package/types/openapi/models/PSPDFKitAuthPayloadRequest.d.ts +0 -3
  185. package/types/openapi/models/PSPDFKitToken.d.ts +0 -7
  186. package/types/openapi/models/PSPDFKitTokenRequest.d.ts +0 -3
  187. package/types/openapi/models/PaginatedCanvasListList.d.ts +0 -8
package/js-api.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { camelCase, snakeCase, cloneDeep } from 'lodash-es';
1
+ import { camelCase, snakeCase, pickBy, cloneDeep, isEqual } from 'lodash-es';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  for (var i = 0; i < m.length; i++) {
@@ -2409,8 +2409,17 @@ function createCanvas$1(payload) {
2409
2409
  function deleteCanvas(payload) {
2410
2410
  return this.API.request("delete_canvas", payload);
2411
2411
  }
2412
- function updateCanvas$1(payload) {
2413
- return this.API.request("update_canvas", payload);
2412
+ function updateCanvas$2(payload) {
2413
+ let shouldDebug = false;
2414
+ if (typeof window !== "undefined") {
2415
+ const urlParams = new URLSearchParams(window.location.search);
2416
+ shouldDebug = urlParams.get("debug") === "true" || !!window.debug;
2417
+ }
2418
+ shouldDebug && console.info("JS API UPDATE CANVAS", payload);
2419
+ return this.API.request("update_canvas", payload).then((res) => {
2420
+ shouldDebug && console.info("JS API UPDATE CANVAS RESPONSE", res);
2421
+ return res;
2422
+ });
2414
2423
  }
2415
2424
  function getCanvas$1(payload) {
2416
2425
  return this.API.request("get_canvas", payload);
@@ -2419,7 +2428,7 @@ function shareCanvas(payload) {
2419
2428
  return this.API.request("share_canvas", payload);
2420
2429
  }
2421
2430
 
2422
- function getFiles(payload) {
2431
+ function getFiles$1(payload) {
2423
2432
  const p = { ...payload };
2424
2433
  if (p.type) {
2425
2434
  p.type = Array.isArray(p.type) ? p.type : [p.type];
@@ -2435,11 +2444,12 @@ function getRecentFiles(payload) {
2435
2444
  function downloadFile(payload) {
2436
2445
  return this.API.request("download_file", payload);
2437
2446
  }
2438
- function getAppConfig(payload) {
2447
+ function getAppConfig$1(payload) {
2439
2448
  return this.API.request("get_app_config", payload);
2440
2449
  }
2441
- function getFile(payload) {
2442
- return this.API.request("get_file", payload);
2450
+ function getFile$1(payload) {
2451
+ const { id, file_id } = payload;
2452
+ return this.API.request("get_file", { file_id: id || file_id });
2443
2453
  }
2444
2454
  function updateFile(payload) {
2445
2455
  return this.API.request("update_file", payload);
@@ -2462,7 +2472,10 @@ function getUsers(payload) {
2462
2472
  return this.API.request("get_users", payload);
2463
2473
  }
2464
2474
  function refreshServiceToken(payload) {
2465
- return this.API.request("refresh_service_token", payload);
2475
+ return this.API.request("refresh_service_token", payload ?? {});
2476
+ }
2477
+ function refreshAccessToken() {
2478
+ return this.API.request("refresh_access_token");
2466
2479
  }
2467
2480
 
2468
2481
  function fetchDocumentInfo(payload) {
@@ -2472,7 +2485,7 @@ function renderPageAsImage(payload) {
2472
2485
  return this.API.request("render_page_as_image", payload);
2473
2486
  }
2474
2487
 
2475
- function toast$1(payload) {
2488
+ function toast$2(payload) {
2476
2489
  return this.API.request("toast", payload);
2477
2490
  }
2478
2491
 
@@ -2551,14 +2564,14 @@ const modules = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2551
2564
  deleteFolder,
2552
2565
  downloadFile,
2553
2566
  fetchDocumentInfo,
2554
- getAppConfig,
2567
+ getAppConfig: getAppConfig$1,
2555
2568
  getCanvas: getCanvas$1,
2556
2569
  getCanvases: getCanvases$1,
2557
2570
  getEnv: getEnv$2,
2558
2571
  getEvents,
2559
2572
  getFavorites,
2560
- getFile,
2561
- getFiles,
2573
+ getFile: getFile$1,
2574
+ getFiles: getFiles$1,
2562
2575
  getFolder,
2563
2576
  getInstanceMetadataTemplates: getInstanceMetadataTemplates$1,
2564
2577
  getLanguages,
@@ -2570,16 +2583,17 @@ const modules = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2570
2583
  openExternalUrl,
2571
2584
  openWebViewAlwaysOnTop,
2572
2585
  query,
2586
+ refreshAccessToken,
2573
2587
  refreshServiceToken,
2574
2588
  renderPageAsImage,
2575
2589
  search,
2576
2590
  selectDeviceFile,
2577
2591
  shareCanvas,
2578
2592
  submitUserFeedback,
2579
- toast: toast$1,
2593
+ toast: toast$2,
2580
2594
  track,
2581
2595
  triggerNonFilesSync,
2582
- updateCanvas: updateCanvas$1,
2596
+ updateCanvas: updateCanvas$2,
2583
2597
  updateEvent,
2584
2598
  updateFile,
2585
2599
  updateFolder,
@@ -2661,6 +2675,51 @@ function v4(options, buf, offset) {
2661
2675
  return unsafeStringify(rnds);
2662
2676
  }
2663
2677
 
2678
+ const PITCHER_EVENT = "PITCHER_EVENT";
2679
+ var PitcherMessageType = /* @__PURE__ */ ((PitcherMessageType2) => {
2680
+ PitcherMessageType2["REQUEST"] = "PITCHER_REQUEST";
2681
+ PitcherMessageType2["RESPONSE"] = "PITCHER_RESPONSE";
2682
+ return PitcherMessageType2;
2683
+ })(PitcherMessageType || {});
2684
+ var PitcherResponseStatus = /* @__PURE__ */ ((PitcherResponseStatus2) => {
2685
+ PitcherResponseStatus2["OK"] = "ok";
2686
+ PitcherResponseStatus2["ERROR"] = "error";
2687
+ return PitcherResponseStatus2;
2688
+ })(PitcherResponseStatus || {});
2689
+ var PitcherEventName = /* @__PURE__ */ ((PitcherEventName2) => {
2690
+ PitcherEventName2["ENV_CHANGED"] = "env_changed";
2691
+ PitcherEventName2["PHOTOS_CAPTURED"] = "photos_captured";
2692
+ PitcherEventName2["FILE_DOWNLOADED"] = "file_downloaded";
2693
+ PitcherEventName2["FILE_UPLOAD_PROGRESS"] = "file_upload_progress";
2694
+ PitcherEventName2["UPDATE_LOCATION"] = "update_location";
2695
+ PitcherEventName2["CANVAS_UPDATED"] = "canvas_updated";
2696
+ PitcherEventName2["CANVAS_UPDATED_SUCCESS"] = "canvas_updated_success";
2697
+ PitcherEventName2["FILE_CLOSED"] = "file_closed";
2698
+ PitcherEventName2["APP_BACKGROUNDED"] = "app_backgrounded";
2699
+ PitcherEventName2["APP_FOREGROUNDED"] = "app_foregrounded";
2700
+ PitcherEventName2["NON_FILES_SYNC_FINISHED"] = "non_files_sync_finished";
2701
+ PitcherEventName2["CONTENT_LIST_REFRESH_REQUESTED"] = "content_list_refresh_requested";
2702
+ PitcherEventName2["NETWORK_CONNECTION_ESTABLISHED"] = "network_connection_established";
2703
+ PitcherEventName2["NETWORK_CONNECTION_LOST"] = "network_connection_lost";
2704
+ PitcherEventName2["ENTERED_FULLSCREEN"] = "entered_fullscreen";
2705
+ PitcherEventName2["EXITED_FULLSCREEN"] = "exited_fullscreen";
2706
+ PitcherEventName2["SUBMIT_POSTCALL_CLICKED"] = "submit_postcall_clicked";
2707
+ return PitcherEventName2;
2708
+ })(PitcherEventName || {});
2709
+ var PitcherBroadcastedEventName = /* @__PURE__ */ ((PitcherBroadcastedEventName2) => {
2710
+ PitcherBroadcastedEventName2["UI_SHOW_MODAL"] = "ui:show-modal";
2711
+ PitcherBroadcastedEventName2["UI_HIDE_MODAL"] = "ui:hide-modal";
2712
+ PitcherBroadcastedEventName2["FAVORITES_CHANGED"] = "favorites:changed";
2713
+ PitcherBroadcastedEventName2["FILE_DOWNLOAD"] = "file:download";
2714
+ return PitcherBroadcastedEventName2;
2715
+ })(PitcherBroadcastedEventName || {});
2716
+ var PitcherExternalEventName = /* @__PURE__ */ ((PitcherExternalEventName2) => {
2717
+ PitcherExternalEventName2["CREATE_AND_OPEN_CANVAS"] = "create_and_open_canvas";
2718
+ PitcherExternalEventName2["OPEN_CANVAS"] = "open_canvas";
2719
+ PitcherExternalEventName2["START_CALL"] = "start_call";
2720
+ return PitcherExternalEventName2;
2721
+ })(PitcherExternalEventName || {});
2722
+
2664
2723
  class AssertionError extends Error {
2665
2724
  }
2666
2725
  function assert(exp, message) {
@@ -2716,6 +2775,29 @@ const snakeCaseKeys = (obj, skipKeys = defaultSkipKeys, skipObjectKeys = default
2716
2775
  return obj;
2717
2776
  };
2718
2777
 
2778
+ function truncateObject(obj, currentDepth = 1, lengthTrigger = 20) {
2779
+ if (typeof obj !== "object" || obj === null) {
2780
+ return obj;
2781
+ }
2782
+ if (Array.isArray(obj)) {
2783
+ if (obj.length > lengthTrigger && currentDepth <= 0) {
2784
+ return `[Truncated - ${obj.length} length array]`;
2785
+ }
2786
+ return obj.map((item) => truncateObject(item, currentDepth - 1, lengthTrigger));
2787
+ }
2788
+ const keys = Object.keys(obj);
2789
+ if (keys.length > lengthTrigger && currentDepth <= 0) {
2790
+ return `{Truncated - ${keys.length} properties obj}`;
2791
+ }
2792
+ return keys.reduce(
2793
+ (acc, key) => {
2794
+ acc[key] = truncateObject(obj[key], currentDepth - 1, lengthTrigger);
2795
+ return acc;
2796
+ },
2797
+ {}
2798
+ );
2799
+ }
2800
+
2719
2801
  function isOriginValid(event, allowedOrigins = [], isDev = ["development", "test"].includes("production")) {
2720
2802
  if (isDev) {
2721
2803
  return true;
@@ -2733,12 +2815,259 @@ function isOriginValid(event, allowedOrigins = [], isDev = ["development", "test
2733
2815
  return isValid;
2734
2816
  }
2735
2817
 
2818
+ const MAX_RETRIES = 5;
2819
+ const BASE_DELAY = 1e3;
2820
+ let refreshPromise = null;
2821
+ async function refreshToken() {
2822
+ if (refreshPromise) return refreshPromise;
2823
+ console.info("Refreshing access token...");
2824
+ refreshPromise = (async () => {
2825
+ try {
2826
+ return await highLevelApi.refreshAccessToken().then(
2827
+ (accessTokenResponse) => highLevelApi.getEnv().then((env) => {
2828
+ setEnv(env);
2829
+ return accessTokenResponse.access_token;
2830
+ })
2831
+ );
2832
+ } catch (error) {
2833
+ console.error("Failed to refresh token:", error);
2834
+ throw error;
2835
+ } finally {
2836
+ refreshPromise = null;
2837
+ }
2838
+ })();
2839
+ return refreshPromise;
2840
+ }
2841
+ function paramsSerializer(params) {
2842
+ const searchParams = new URLSearchParams();
2843
+ function addParam(key, value) {
2844
+ if (value === void 0 || value === null) {
2845
+ return;
2846
+ }
2847
+ if (Array.isArray(value)) {
2848
+ value.forEach((val) => addParam(key, val));
2849
+ } else if (typeof value === "object" && !Array.isArray(value)) {
2850
+ for (const subKey in value) {
2851
+ addParam(`${key}[${subKey}]`, value[subKey]);
2852
+ }
2853
+ } else {
2854
+ searchParams.append(key, value);
2855
+ }
2856
+ }
2857
+ for (const key in params) {
2858
+ addParam(key, params[key]);
2859
+ }
2860
+ return searchParams.toString();
2861
+ }
2862
+ async function fetchWithRetry(url, options, remainingRetries = MAX_RETRIES) {
2863
+ try {
2864
+ const response = await fetch(url, options);
2865
+ if (!response.ok) {
2866
+ if (response.status === 401) {
2867
+ const newToken = await refreshToken();
2868
+ options.headers = options.headers || {};
2869
+ options.headers.Authorization = `Bearer ${newToken}`;
2870
+ return fetchWithRetry(url, options, remainingRetries);
2871
+ } else if (response.status >= 500 && response.status < 600 && remainingRetries > 0) {
2872
+ const delay = BASE_DELAY * Math.pow(2, MAX_RETRIES - remainingRetries);
2873
+ await new Promise((resolve) => setTimeout(resolve, delay));
2874
+ return fetchWithRetry(url, options, remainingRetries - 1);
2875
+ } else {
2876
+ const errorData = await response.json();
2877
+ const error = new Error(
2878
+ `HTTP error! status: ${response.status}, message: ${errorData.message || response.statusText}`
2879
+ );
2880
+ error.status = response.status;
2881
+ throw error;
2882
+ }
2883
+ }
2884
+ if (response.status === 204 || response.status === 205) {
2885
+ return;
2886
+ }
2887
+ return response.json();
2888
+ } catch (error) {
2889
+ if (remainingRetries > 0) {
2890
+ const delay = BASE_DELAY * Math.pow(2, MAX_RETRIES - remainingRetries);
2891
+ await new Promise((resolve) => setTimeout(resolve, delay));
2892
+ return fetchWithRetry(url, options, remainingRetries - 1);
2893
+ }
2894
+ throw error;
2895
+ }
2896
+ }
2897
+ function createHttpClient(origin, token) {
2898
+ const headers = {
2899
+ "Content-Type": "application/json",
2900
+ Authorization: `Bearer ${token}`
2901
+ };
2902
+ const basePath = origin + "/api/v1";
2903
+ const baseCommon = { credentials: "include" };
2904
+ return {
2905
+ get: async (endpoint, options = {}) => {
2906
+ const url = new URL(`${basePath}${endpoint}`);
2907
+ if (options.params) {
2908
+ url.search = paramsSerializer(options.params);
2909
+ }
2910
+ const data = await fetchWithRetry(url.toString(), {
2911
+ ...baseCommon,
2912
+ ...options,
2913
+ method: "GET",
2914
+ headers
2915
+ });
2916
+ return data;
2917
+ },
2918
+ post: async (endpoint, body, options = {}) => {
2919
+ const url = new URL(`${basePath}${endpoint}`);
2920
+ if (options.params) {
2921
+ url.search = paramsSerializer(options.params);
2922
+ }
2923
+ const data = await fetchWithRetry(url.toString(), {
2924
+ ...baseCommon,
2925
+ ...options,
2926
+ method: "POST",
2927
+ headers,
2928
+ body: JSON.stringify(body)
2929
+ });
2930
+ return data;
2931
+ },
2932
+ put: async (endpoint, body, options = {}) => {
2933
+ const url = new URL(`${basePath}${endpoint}`);
2934
+ if (options.params) {
2935
+ url.search = paramsSerializer(options.params);
2936
+ }
2937
+ const data = await fetchWithRetry(url.toString(), {
2938
+ ...baseCommon,
2939
+ ...options,
2940
+ method: "PUT",
2941
+ headers,
2942
+ body: JSON.stringify(body)
2943
+ });
2944
+ return data;
2945
+ },
2946
+ delete: async (endpoint, options = {}) => {
2947
+ const url = new URL(`${basePath}${endpoint}`);
2948
+ if (options.params) {
2949
+ url.search = paramsSerializer(options.params);
2950
+ }
2951
+ const data = await fetchWithRetry(url.toString(), {
2952
+ ...baseCommon,
2953
+ ...options,
2954
+ method: "DELETE",
2955
+ headers
2956
+ });
2957
+ return data;
2958
+ },
2959
+ patch: async (endpoint, body, options = {}) => {
2960
+ const url = new URL(`${basePath}${endpoint}`);
2961
+ if (options.params) {
2962
+ url.search = paramsSerializer(options.params);
2963
+ }
2964
+ const data = await fetchWithRetry(url.toString(), {
2965
+ ...baseCommon,
2966
+ ...options,
2967
+ method: "PATCH",
2968
+ headers,
2969
+ body: JSON.stringify(body)
2970
+ });
2971
+ return data;
2972
+ }
2973
+ };
2974
+ }
2975
+
2976
+ function normalizeNetworkFilterParams(params) {
2977
+ if (!params) return {};
2978
+ return Object.entries(params).reduce(
2979
+ (acc, [key, value]) => {
2980
+ acc[key] = key.endsWith("__range") && Array.isArray(value) ? value.join(",") : value;
2981
+ return acc;
2982
+ },
2983
+ {}
2984
+ );
2985
+ }
2986
+
2987
+ let env;
2988
+ let http;
2989
+ function check() {
2990
+ if (!env) throw new Error("Missing env");
2991
+ if (!http) throw new Error("Missing http");
2992
+ }
2993
+ function pickNonNullish(data) {
2994
+ return pickBy(data ?? {}, (v) => v !== void 0 && v !== null);
2995
+ }
2996
+ const setEnv = (e) => {
2997
+ env = e;
2998
+ http = createHttpClient(
2999
+ env.pitcher.token_claims["https://pitcher.com/claims/urls"].custom_domain,
3000
+ env.pitcher.access_token
3001
+ );
3002
+ };
3003
+ const onlineRestApiHandlers = {
3004
+ get_canvases: async (params) => {
3005
+ check();
3006
+ const { api_base_url, filters = {}, ...restParams } = params;
3007
+ const res = await http.get("/canvases", {
3008
+ params: {
3009
+ instance_id: env.pitcher.instance.id,
3010
+ ...normalizeNetworkFilterParams(filters),
3011
+ ...pickNonNullish(restParams)
3012
+ }
3013
+ });
3014
+ return res;
3015
+ },
3016
+ get_canvas: async (params) => {
3017
+ check();
3018
+ const { id, ...restParams } = params;
3019
+ const res = await http.get(`/canvases/${params.id}`, { params: restParams });
3020
+ return res;
3021
+ },
3022
+ create_canvas: async (params) => {
3023
+ check();
3024
+ const res = await http.post("/canvases", { ...params, instance_id: env.pitcher.instance.id });
3025
+ return res;
3026
+ },
3027
+ update_canvas: async (params) => {
3028
+ check();
3029
+ const { id, ...restParams } = params;
3030
+ const res = await http.patch(`/canvases/${params.id}`, restParams);
3031
+ return res;
3032
+ },
3033
+ delete_canvas: async (params) => {
3034
+ check();
3035
+ const res = await http.delete(`/canvases/${params.id}`);
3036
+ return res;
3037
+ },
3038
+ share_canvas: async (params) => {
3039
+ check();
3040
+ let link;
3041
+ try {
3042
+ link = await http.get(`/shared-links/canvas/${params.id}`);
3043
+ } catch (e) {
3044
+ if (e?.status === 404) {
3045
+ link = await http.post("/shared-links", {
3046
+ canvas_id: params.id
3047
+ });
3048
+ } else {
3049
+ throw e;
3050
+ }
3051
+ }
3052
+ return link;
3053
+ }
3054
+ };
3055
+
3056
+ const TRUNCATE_LENGTH_TRIGGER = 10;
3057
+ function updateOnlineHandlersEnv(env) {
3058
+ env && setEnv(env);
3059
+ }
2736
3060
  class LowLevelApi extends EventEmitter {
2737
3061
  constructor(options) {
2738
3062
  super();
2739
3063
  this.callbacks = {};
2740
- this.options = options ?? { casing: "snake", logLevel: "off", errorLogger: () => {
2741
- } };
3064
+ this.options = options ?? {
3065
+ casing: "snake",
3066
+ logLevel: "off",
3067
+ errorLogger: () => {
3068
+ },
3069
+ fetchMode: "postmessage"
3070
+ };
2742
3071
  if (typeof window !== "undefined") {
2743
3072
  window.addEventListener("message", (event) => {
2744
3073
  if (!isOriginValid(event)) return;
@@ -2768,6 +3097,7 @@ class LowLevelApi extends EventEmitter {
2768
3097
  this.emit("event", event);
2769
3098
  }
2770
3099
  request(type, body = null) {
3100
+ const fetchMode = this.options.fetchMode ?? "postmessage";
2771
3101
  return new Promise((resolve, reject) => {
2772
3102
  const id = v4();
2773
3103
  const callback = (res) => {
@@ -2776,11 +3106,14 @@ class LowLevelApi extends EventEmitter {
2776
3106
  resolve(
2777
3107
  this.options.casing === "camel" ? camelCaseKeys(res.response.body) : res.response.body
2778
3108
  );
3109
+ if (type === "get_env") updateOnlineHandlersEnv(res.response.body);
2779
3110
  } else if (res.response.status === "error") {
2780
- this.options.errorLogger?.({
2781
- message: `Pitcher JS API call failure: ${res.request.type}`,
2782
- js_api_response: JSON.stringify(res)
2783
- });
3111
+ if (this.options.errorLogger) {
3112
+ this.options.errorLogger({
3113
+ message: `Pitcher JS API call failure: ${res.request.type}`,
3114
+ js_api_response: JSON.stringify(truncateObject(res, 3, TRUNCATE_LENGTH_TRIGGER))
3115
+ });
3116
+ }
2784
3117
  reject(this.options.casing === "camel" ? camelCaseKeys(res.response.body) : res.response.body);
2785
3118
  } else {
2786
3119
  throw new Error("unsupported response status");
@@ -2793,18 +3126,40 @@ class LowLevelApi extends EventEmitter {
2793
3126
  payload: payload ?? {},
2794
3127
  callback
2795
3128
  };
2796
- if (typeof window !== "undefined" && window.top) {
2797
- window.top.postMessage(
2798
- {
2799
- type: "PITCHER_REQUEST",
2800
- request: {
2801
- type,
2802
- id,
2803
- body: payload
2804
- }
2805
- },
2806
- "*"
2807
- );
3129
+ if (fetchMode === "prefer-online" && type && onlineRestApiHandlers[type]) {
3130
+ onlineRestApiHandlers[type](payload).then((data) => {
3131
+ if (this.callbacks[id]) {
3132
+ this.callbacks[id].callback({
3133
+ type: PitcherMessageType.RESPONSE,
3134
+ request: { id, type },
3135
+ response: { status: PitcherResponseStatus.OK, body: data }
3136
+ });
3137
+ delete this.callbacks[id];
3138
+ }
3139
+ }).catch((error) => {
3140
+ if (this.callbacks[id]) {
3141
+ this.callbacks[id].callback({
3142
+ type: PitcherMessageType.RESPONSE,
3143
+ request: { id, type },
3144
+ response: { status: PitcherResponseStatus.ERROR, body: error }
3145
+ });
3146
+ delete this.callbacks[id];
3147
+ }
3148
+ });
3149
+ } else {
3150
+ if (typeof window !== "undefined" && window.top) {
3151
+ window.top.postMessage(
3152
+ {
3153
+ type: "PITCHER_REQUEST",
3154
+ request: {
3155
+ type,
3156
+ id,
3157
+ body: payload
3158
+ }
3159
+ },
3160
+ "*"
3161
+ );
3162
+ }
2808
3163
  }
2809
3164
  });
2810
3165
  }
@@ -2819,15 +3174,105 @@ function createHighLevelApi(options) {
2819
3174
  return {
2820
3175
  API,
2821
3176
  ...modules,
3177
+ /**
3178
+ * Subscribe to a given event type by its key.
3179
+ *
3180
+ * @param {string} type - The event type to subscribe to.
3181
+ * @param {(payload: PitcherEvent) => void} callback - The callback function to handle the event.
3182
+ * @returns A Promise resolving to a cleanup function to unsubscribe from the event. * @example
3183
+ *
3184
+ * @example
3185
+ * const unsubscribeFromSectionListUpdate = usePitcherApi().on('entered_fullscreen', (event: object) => {
3186
+ * // handle event
3187
+ * })
3188
+ * // later
3189
+ * unsubscribeFromSectionListUpdate()
3190
+ */
2822
3191
  on: (type, callback) => eventEmitter.on(type, callback),
3192
+ /**
3193
+ * Unsubscribe from a given event type by its key and the attached callback reference.
3194
+ * @param {string} type - The event type to unsubscribe from.
3195
+ * @param {(payload: PitcherEvent) => void} callback - The callback function reference to remove.
3196
+ *
3197
+ * @example
3198
+ * const callback = (event: object) => {
3199
+ * // handle event
3200
+ * }
3201
+ * usePitcherApi().on('entered_fullscreen', callback)
3202
+ * // later
3203
+ * usePitcherApi().off('entered_fullscreen', callback)
3204
+ */
2823
3205
  off: (type, callback) => eventEmitter.off(type, callback),
3206
+ /**
3207
+ * Make the entire CatalogIQ fullscreen.
3208
+ *
3209
+ * @example
3210
+ * usePitcherApi().enterFullscreen()
3211
+ */
2824
3212
  enterFullscreen: () => API.request("enter_fullscreen"),
3213
+ /**
3214
+ * Exit fullscreen mode.
3215
+ *
3216
+ * @example
3217
+ * usePitcherApi().exitFullscreen()
3218
+ */
2825
3219
  exitFullscreen: () => API.request("exit_fullscreen"),
3220
+ /**
3221
+ * Return is CatalogIQ in fullscreen.
3222
+ *
3223
+ * @example
3224
+ * usePitcherApi().isFullscreen()
3225
+ */
3226
+ isFullscreen: () => API.request("is_fullscreen"),
3227
+ /**
3228
+ * Log out the current user.
3229
+ *
3230
+ * @example
3231
+ * usePitcherApi().logout()
3232
+ */
2826
3233
  logout: () => API.request("logout"),
3234
+ /**
3235
+ * Quit the current instance and go to the instance selection screen.
3236
+ *
3237
+ * @example
3238
+ * usePitcherApi().quitInstance()
3239
+ */
2827
3240
  quitInstance: () => API.request("quit_instance"),
3241
+ /**
3242
+ * Get the request types.
3243
+ *
3244
+ * @returns {Promise<any>}
3245
+ */
2828
3246
  getRequestTypes: () => API.request("get_request_types"),
3247
+ /**
3248
+ * Broadcast an event to CatalogIQ.
3249
+ * @param {PitcherEvent} event - The event to broadcast.
3250
+ *
3251
+ * @example
3252
+ * usePitcherApi()
3253
+ * .broadcast({
3254
+ * type: "canvas_updated",
3255
+ * body: { context: { myContextProperty: 'test' } },
3256
+ * })
3257
+ * .then(function (result) {
3258
+ * useUi().toast({
3259
+ * message: "Canvas Populated.",
3260
+ * type: "info",
3261
+ * })
3262
+ * })
3263
+ */
2829
3264
  broadcast: (event) => API.request("broadcast", event),
3265
+ /**
3266
+ * Subscribe to updates.
3267
+ *
3268
+ * @returns {Promise<void>}
3269
+ */
2830
3270
  subscribe: () => API.request("subscribe"),
3271
+ /**
3272
+ * Unsubscribe from updates.
3273
+ *
3274
+ * @returns {Promise<void>}
3275
+ */
2831
3276
  unsubscribe: () => API.request("unsubscribe")
2832
3277
  };
2833
3278
  }
@@ -2841,17 +3286,20 @@ const UI_MESSAGE = "UI_MESSAGE";
2841
3286
  const UI_API_METHOD_TYPES = {
2842
3287
  UI_BROADCAST: "ui_broadcast",
2843
3288
  UI_SELECT_CONTENT: "ui_select_content",
3289
+ UI_SELECT_CANVASES: "ui_select_canvases",
2844
3290
  UI_OPEN: "ui_open",
2845
3291
  UI_EMBEDDABLE_READY: "ui_embeddable_ready",
2846
3292
  UI_TOAST: "ui_toast",
2847
3293
  UI_CAPTURE_APP_ERROR: "ui_capture_app_error",
2848
3294
  UI_UPDATE_CANVAS: "ui_update_canvas",
3295
+ UI_OPEN_CANVAS_OVERLAY: "ui_open_canvas_overlay",
2849
3296
  UI_UPDATE_LOCATION: "ui_update_location",
2850
3297
  UI_PRESELECT_SFDC_MEETING_ID: "ui_preselect_sfdc_meeting_id",
2851
3298
  UI_SET_POSTCALL_STYLE: "ui_set_postcall_style",
2852
3299
  UI_ENABLE_POSTCALL_SUBMIT: "ui_enable_postcall_submit",
2853
3300
  UI_DISABLE_POSTCALL_SUBMIT: "ui_disable_postcall_submit",
2854
3301
  UI_COMPLETE_POSTCALL: "ui_complete_postcall",
3302
+ UI_STOP_MEETING: "ui_stop_meeting",
2855
3303
  UI_CANVAS_NAVIGATE_NEXT_PAGE: "ui_canvas_navigate_next_page",
2856
3304
  UI_CANVAS_NAVIGATE_PREVIOUS_PAGE: "ui_canvas_navigate_previous_page",
2857
3305
  UI_CANVAS_NAVIGATE_PAGE: "ui_canvas_navigate_page",
@@ -2879,7 +3327,7 @@ async function ui_select_content(payload = {}) {
2879
3327
  const response = await pr.send(window.parent, UI_API_METHOD_TYPES.UI_SELECT_CONTENT, payload);
2880
3328
  return response.data;
2881
3329
  }
2882
- async function select_content(payload = {}) {
3330
+ async function selectContent$1(payload = {}) {
2883
3331
  const pr = await usePostRobot();
2884
3332
  const response = await pr.send(window.parent, UI_API_METHOD_TYPES.UI_SELECT_CONTENT, payload);
2885
3333
  return response.data;
@@ -2888,73 +3336,130 @@ async function open(payload) {
2888
3336
  const pr = await usePostRobot();
2889
3337
  await pr.send(window.parent, UI_API_METHOD_TYPES.UI_OPEN, payload);
2890
3338
  }
2891
- async function toast(payload) {
3339
+ async function toast$1(payload) {
2892
3340
  const pr = await usePostRobot();
2893
3341
  await pr.send(window.parent, UI_API_METHOD_TYPES.UI_TOAST, payload);
2894
3342
  }
2895
- async function preselect_sfdc_meeting_id(payload) {
3343
+ async function preselectSfdcMeetingId(payload) {
2896
3344
  const pr = await usePostRobot();
2897
3345
  const response = await pr.send(window.parent, UI_API_METHOD_TYPES.UI_PRESELECT_SFDC_MEETING_ID, payload);
2898
3346
  return response.data;
2899
3347
  }
2900
3348
 
2901
- async function embeddable_ready$1() {
3349
+ const contentUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3350
+ __proto__: null,
3351
+ open,
3352
+ preselectSfdcMeetingId,
3353
+ selectContent: selectContent$1,
3354
+ toast: toast$1,
3355
+ ui_select_content
3356
+ }, Symbol.toStringTag, { value: 'Module' }));
3357
+
3358
+ async function embeddableReady$1() {
2902
3359
  const pr = await usePostRobot();
2903
3360
  await pr.send(window.parent, UI_API_METHOD_TYPES.UI_EMBEDDABLE_READY);
2904
3361
  }
2905
3362
 
2906
- async function update_location(payload) {
3363
+ const loadingUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3364
+ __proto__: null,
3365
+ embeddableReady: embeddableReady$1
3366
+ }, Symbol.toStringTag, { value: 'Module' }));
3367
+
3368
+ async function updateLocation(payload) {
2907
3369
  const pr = await usePostRobot();
2908
3370
  return pr.send(window.top, UI_API_METHOD_TYPES.UI_UPDATE_LOCATION, payload);
2909
3371
  }
2910
3372
 
2911
- async function capture_app_error(payload) {
3373
+ const locationUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3374
+ __proto__: null,
3375
+ updateLocation
3376
+ }, Symbol.toStringTag, { value: 'Module' }));
3377
+
3378
+ async function captureAppError(payload) {
2912
3379
  const pr = await usePostRobot();
2913
3380
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_CAPTURE_APP_ERROR, payload);
2914
3381
  }
2915
3382
 
2916
- async function update_canvas(payload) {
3383
+ const appErrorsUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3384
+ __proto__: null,
3385
+ captureAppError
3386
+ }, Symbol.toStringTag, { value: 'Module' }));
3387
+
3388
+ async function updateCanvas$1(payload) {
2917
3389
  const pr = await usePostRobot();
2918
3390
  return pr.send(window.parent, UI_API_METHOD_TYPES.UI_UPDATE_CANVAS, payload).then((response) => response.data);
2919
3391
  }
2920
- async function app_loaded() {
3392
+ async function appLoaded() {
2921
3393
  window.parent.postMessage({ type: UI_API_METHOD_TYPES.UI_APP_LOADED, body: {} }, "*");
2922
3394
  }
2923
- async function app_resize(payload) {
3395
+ async function appResize(payload) {
2924
3396
  window.parent.postMessage({ type: UI_API_METHOD_TYPES.UI_APP_RESIZE, body: payload }, "*");
2925
3397
  }
2926
- async function canvas_navigate_next_page() {
3398
+ async function canvasNavigateNextPage() {
2927
3399
  const pr = await usePostRobot();
2928
3400
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_NEXT_PAGE);
2929
3401
  }
2930
- async function canvas_navigate_previous_page() {
3402
+ async function canvasNavigatePreviousPage() {
2931
3403
  const pr = await usePostRobot();
2932
3404
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_PREVIOUS_PAGE);
2933
3405
  }
2934
- async function canvas_navigate_page(payload) {
3406
+ async function canvasNavigatePage(payload) {
2935
3407
  const pr = await usePostRobot();
2936
3408
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_CANVAS_NAVIGATE_PAGE, payload);
2937
3409
  }
3410
+ async function openCanvasOverlay$1(payload) {
3411
+ const pr = await usePostRobot();
3412
+ await pr.send(window.parent, UI_API_METHOD_TYPES.UI_OPEN_CANVAS_OVERLAY, payload);
3413
+ }
3414
+ async function selectCanvases$1(payload = {}) {
3415
+ const pr = await usePostRobot();
3416
+ const response = await pr.send(window.parent, UI_API_METHOD_TYPES.UI_SELECT_CANVASES, payload);
3417
+ return response.data;
3418
+ }
2938
3419
 
2939
- async function complete_postcall(payload) {
3420
+ const canvasUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3421
+ __proto__: null,
3422
+ appLoaded,
3423
+ appResize,
3424
+ canvasNavigateNextPage,
3425
+ canvasNavigatePage,
3426
+ canvasNavigatePreviousPage,
3427
+ openCanvasOverlay: openCanvasOverlay$1,
3428
+ selectCanvases: selectCanvases$1,
3429
+ updateCanvas: updateCanvas$1
3430
+ }, Symbol.toStringTag, { value: 'Module' }));
3431
+
3432
+ async function completePostcall(payload) {
2940
3433
  const pr = await usePostRobot();
2941
3434
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_COMPLETE_POSTCALL, payload);
2942
3435
  }
2943
- async function enable_postcall_submit() {
3436
+ async function stopMeeting() {
3437
+ const pr = await usePostRobot();
3438
+ pr.send(window.parent, UI_API_METHOD_TYPES.UI_STOP_MEETING);
3439
+ }
3440
+ async function enablePostcallSubmit() {
2944
3441
  const pr = await usePostRobot();
2945
3442
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_ENABLE_POSTCALL_SUBMIT);
2946
3443
  }
2947
- async function disable_postcall_submit() {
3444
+ async function disablePostcallSubmit() {
2948
3445
  const pr = await usePostRobot();
2949
3446
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_DISABLE_POSTCALL_SUBMIT);
2950
3447
  }
2951
- async function set_postcall_style(payload) {
3448
+ async function setPostcallStyle(payload) {
2952
3449
  const pr = await usePostRobot();
2953
3450
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_SET_POSTCALL_STYLE, payload);
2954
3451
  }
2955
3452
 
2956
- async function on_native(type, handler) {
2957
- console.log("attaching native handler for type", type);
3453
+ const postCallUi = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3454
+ __proto__: null,
3455
+ completePostcall,
3456
+ disablePostcallSubmit,
3457
+ enablePostcallSubmit,
3458
+ setPostcallStyle,
3459
+ stopMeeting
3460
+ }, Symbol.toStringTag, { value: 'Module' }));
3461
+
3462
+ async function onNative(type, handler) {
2958
3463
  const messageListener = (event) => {
2959
3464
  if (event.data.type === type) {
2960
3465
  handler(event.data.body);
@@ -2963,65 +3468,51 @@ async function on_native(type, handler) {
2963
3468
  window.addEventListener("message", messageListener);
2964
3469
  return () => window.removeEventListener("message", messageListener);
2965
3470
  }
2966
- async function on_post_robot(type, handler) {
3471
+ async function onPostRobot(type, handler) {
2967
3472
  const pr = await usePostRobot();
2968
3473
  const listener = pr.on(type, (e) => handler(e.data));
2969
3474
  return listener.cancel;
2970
3475
  }
2971
3476
  function on$2(type, handler) {
2972
3477
  if (UI_NATIVE_MESSAGE_TYPES.includes(type)) {
2973
- return on_native(type, handler);
3478
+ return onNative(type, handler);
2974
3479
  }
2975
- return on_post_robot(type, handler);
3480
+ return onPostRobot(type, handler);
2976
3481
  }
2977
- function on_meeting_canceled(handler) {
3482
+ function onMeetingCanceled(handler) {
2978
3483
  return on$2(UI_MESSAGE_TYPES.UI_MEETING_CANCELED, handler);
2979
3484
  }
2980
- function on_canvas_updated(handler) {
3485
+ function onCanvasUpdated(handler) {
2981
3486
  return on$2(UI_MESSAGE_TYPES.UI_CANVAS_UPDATED, handler);
2982
3487
  }
2983
- function on_section_list_updated(handler) {
3488
+ function onSectionListUpdated(handler) {
2984
3489
  return on$2(UI_MESSAGE_TYPES.UI_SECTION_LIST_UPDATED, handler);
2985
3490
  }
2986
- function on_app_set_data(handler) {
3491
+ function onAppSetData(handler) {
2987
3492
  return on$2(UI_MESSAGE_TYPES.UI_APP_SET_DATA, handler);
2988
3493
  }
2989
- function on_app_update_data(handler) {
3494
+ function onAppUpdateData(handler) {
2990
3495
  return on$2(UI_MESSAGE_TYPES.UI_APP_UPDATE_DATA, handler);
2991
3496
  }
2992
- async function ui_broadcast(payload) {
3497
+ async function uiBroadcast(payload) {
2993
3498
  const pr = await usePostRobot();
2994
3499
  pr.send(window.parent, UI_API_METHOD_TYPES.UI_BROADCAST, payload);
2995
3500
  }
2996
-
2997
- const ui = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2998
- __proto__: null,
2999
- app_loaded,
3000
- app_resize,
3001
- canvas_navigate_next_page,
3002
- canvas_navigate_page,
3003
- canvas_navigate_previous_page,
3004
- capture_app_error,
3005
- complete_postcall,
3006
- disable_postcall_submit,
3007
- embeddable_ready: embeddable_ready$1,
3008
- enable_postcall_submit,
3009
- on: on$2,
3010
- on_app_set_data,
3011
- on_app_update_data,
3012
- on_canvas_updated,
3013
- on_meeting_canceled,
3014
- on_section_list_updated,
3015
- open,
3016
- preselect_sfdc_meeting_id,
3017
- select_content,
3018
- set_postcall_style,
3019
- toast,
3020
- ui_broadcast,
3021
- ui_select_content,
3022
- update_canvas,
3023
- update_location
3024
- }, Symbol.toStringTag, { value: 'Module' }));
3501
+ const ui = {
3502
+ on: on$2,
3503
+ onMeetingCanceled,
3504
+ onCanvasUpdated,
3505
+ onSectionListUpdated,
3506
+ onAppSetData,
3507
+ onAppUpdateData,
3508
+ uiBroadcast,
3509
+ ...contentUi,
3510
+ ...loadingUi,
3511
+ ...locationUi,
3512
+ ...appErrorsUi,
3513
+ ...canvasUi,
3514
+ ...postCallUi
3515
+ };
3025
3516
 
3026
3517
  const ADMIN_MESSAGE = "ADMIN_MESSAGE";
3027
3518
  const ADMIN_MESSAGE_TYPES = {
@@ -3033,12 +3524,18 @@ const ADMIN_API_TYPES = {
3033
3524
  };
3034
3525
  const ADMIN_API_METHOD_TYPES = {
3035
3526
  CREATE_CANVAS: "admin_create_canvas",
3036
- GET_ENV: "admin_get_env",
3527
+ GET_APP_CONFIG: "admin_get_app_config",
3037
3528
  GET_CANVAS: "admin_get_canvas",
3038
3529
  GET_CANVASES: "admin_get_canvases",
3039
- UPDATE_CANVAS: "admin_update_canvas",
3530
+ OPEN_CANVAS_OVERLAY: "admin_open_canvas_overlay",
3531
+ GET_ENV: "admin_get_env",
3532
+ GET_FILE: "admin_get_file",
3533
+ GET_FILES: "admin_get_files",
3040
3534
  GET_INSTANCE_METADATA_TEMPLATES: "admin_get_instance_metadata_templates",
3041
- GET_APP_CONFIG: "admin_get_app_config"
3535
+ TOAST: "admin_toast",
3536
+ UPDATE_CANVAS: "admin_update_canvas",
3537
+ SELECT_CONTENT: "admin_select_content",
3538
+ SELECT_CANVASES: "admin_select_canvases"
3042
3539
  };
3043
3540
 
3044
3541
  async function getEnv$1() {
@@ -3047,6 +3544,11 @@ async function getEnv$1() {
3047
3544
  return response.data;
3048
3545
  }
3049
3546
 
3547
+ const envAdmin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3548
+ __proto__: null,
3549
+ getEnv: getEnv$1
3550
+ }, Symbol.toStringTag, { value: 'Module' }));
3551
+
3050
3552
  async function createCanvas(payload) {
3051
3553
  const pr = await usePostRobot();
3052
3554
  const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.CREATE_CANVAS, payload);
@@ -3067,6 +3569,25 @@ async function updateCanvas(payload) {
3067
3569
  const r = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.UPDATE_CANVAS, payload);
3068
3570
  return r.data;
3069
3571
  }
3572
+ async function openCanvasOverlay(payload) {
3573
+ const pr = await usePostRobot();
3574
+ await pr.send(window.parent, ADMIN_API_METHOD_TYPES.OPEN_CANVAS_OVERLAY, payload);
3575
+ }
3576
+ async function selectCanvases(payload = {}) {
3577
+ const pr = await usePostRobot();
3578
+ const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.SELECT_CANVASES, payload);
3579
+ return response.data;
3580
+ }
3581
+
3582
+ const canvasAdmin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3583
+ __proto__: null,
3584
+ createCanvas,
3585
+ getCanvas,
3586
+ getCanvases,
3587
+ openCanvasOverlay,
3588
+ selectCanvases,
3589
+ updateCanvas
3590
+ }, Symbol.toStringTag, { value: 'Module' }));
3070
3591
 
3071
3592
  async function getInstanceMetadataTemplates(payload) {
3072
3593
  const pr = await usePostRobot();
@@ -3074,23 +3595,58 @@ async function getInstanceMetadataTemplates(payload) {
3074
3595
  return response.data;
3075
3596
  }
3076
3597
 
3077
- async function on$1(type, handler) {
3598
+ const metadataTemplatesAdmin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3599
+ __proto__: null,
3600
+ getInstanceMetadataTemplates
3601
+ }, Symbol.toStringTag, { value: 'Module' }));
3602
+
3603
+ async function getAppConfig(payload) {
3078
3604
  const pr = await usePostRobot();
3079
- const listener = pr.on(type, (e) => handler(e.data));
3080
- return listener.cancel;
3605
+ const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.GET_APP_CONFIG, payload);
3606
+ return response.data;
3607
+ }
3608
+ async function getFile(payload) {
3609
+ const pr = await usePostRobot();
3610
+ const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.GET_FILE, payload);
3611
+ return response.data;
3612
+ }
3613
+ async function getFiles(payload) {
3614
+ const pr = await usePostRobot();
3615
+ const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.GET_FILES, payload);
3616
+ return response.data;
3617
+ }
3618
+ async function selectContent(payload) {
3619
+ const pr = await usePostRobot();
3620
+ const response = await pr.send(window.parent, ADMIN_API_METHOD_TYPES.SELECT_CONTENT, payload);
3621
+ return response.data;
3081
3622
  }
3082
3623
 
3083
- const admin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3624
+ const filesAdmin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3084
3625
  __proto__: null,
3085
- createCanvas,
3086
- getCanvas,
3087
- getCanvases,
3088
- getEnv: getEnv$1,
3089
- getInstanceMetadataTemplates,
3090
- on: on$1,
3091
- updateCanvas
3626
+ getAppConfig,
3627
+ getFile,
3628
+ getFiles,
3629
+ selectContent
3092
3630
  }, Symbol.toStringTag, { value: 'Module' }));
3093
3631
 
3632
+ async function on$1(type, handler) {
3633
+ const pr = await usePostRobot();
3634
+ const listener = pr.on(type, (e) => handler(e.data));
3635
+ return listener.cancel;
3636
+ }
3637
+ async function toast(payload) {
3638
+ const pr = await usePostRobot();
3639
+ await pr.send(window.parent, ADMIN_API_METHOD_TYPES.TOAST, payload);
3640
+ }
3641
+ const admin = {
3642
+ on: on$1,
3643
+ toast,
3644
+ ...envAdmin,
3645
+ ...canvasAdmin,
3646
+ ...metadataTemplatesAdmin,
3647
+ ...filesAdmin
3648
+ };
3649
+
3094
3650
  const DSR_MESSAGE = "DSR_MESSAGE";
3095
3651
  const DSR_MESSAGE_TYPES = {
3096
3652
  ENV_CHANGED: "dsr_env_changed"
@@ -3110,106 +3666,59 @@ async function getEnv() {
3110
3666
  return response.data;
3111
3667
  }
3112
3668
 
3113
- async function embeddable_ready() {
3669
+ const envDsr = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3670
+ __proto__: null,
3671
+ getEnv
3672
+ }, Symbol.toStringTag, { value: 'Module' }));
3673
+
3674
+ async function embeddableReady() {
3114
3675
  const pr = await usePostRobot();
3115
3676
  await pr.send(window.parent, DSR_API_METHOD_TYPES.DSR_EMBEDDABLE_READY);
3116
3677
  }
3117
3678
 
3679
+ const loadingDsr = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3680
+ __proto__: null,
3681
+ embeddableReady
3682
+ }, Symbol.toStringTag, { value: 'Module' }));
3683
+
3118
3684
  async function on(type, handler) {
3119
3685
  const pr = await usePostRobot();
3120
3686
  const listener = pr.on(type, (e) => handler(e.data));
3121
3687
  return listener.cancel;
3122
3688
  }
3123
-
3124
- const dsr = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3125
- __proto__: null,
3126
- embeddable_ready,
3127
- getEnv,
3128
- on
3129
- }, Symbol.toStringTag, { value: 'Module' }));
3130
-
3131
- const PITCHER_EVENT = "PITCHER_EVENT";
3132
- var PitcherMessageType = /* @__PURE__ */ ((PitcherMessageType2) => {
3133
- PitcherMessageType2["REQUEST"] = "PITCHER_REQUEST";
3134
- PitcherMessageType2["RESPONSE"] = "PITCHER_RESPONSE";
3135
- return PitcherMessageType2;
3136
- })(PitcherMessageType || {});
3137
- var PitcherResponseStatus = /* @__PURE__ */ ((PitcherResponseStatus2) => {
3138
- PitcherResponseStatus2["OK"] = "ok";
3139
- PitcherResponseStatus2["ERROR"] = "error";
3140
- return PitcherResponseStatus2;
3141
- })(PitcherResponseStatus || {});
3142
- var PitcherEventName = /* @__PURE__ */ ((PitcherEventName2) => {
3143
- PitcherEventName2["ENV_CHANGED"] = "env_changed";
3144
- PitcherEventName2["PHOTOS_CAPTURED"] = "photos_captured";
3145
- PitcherEventName2["FILE_DOWNLOADED"] = "file_downloaded";
3146
- PitcherEventName2["FILE_UPLOAD_PROGRESS"] = "file_upload_progress";
3147
- PitcherEventName2["UPDATE_LOCATION"] = "update_location";
3148
- PitcherEventName2["CANVAS_UPDATED"] = "canvas_updated";
3149
- PitcherEventName2["CANVAS_UPDATED_SUCCESS"] = "canvas_updated_success";
3150
- PitcherEventName2["FILE_CLOSED"] = "file_closed";
3151
- PitcherEventName2["APP_BACKGROUNDED"] = "app_backgrounded";
3152
- PitcherEventName2["APP_FOREGROUNDED"] = "app_foregrounded";
3153
- PitcherEventName2["NON_FILES_SYNC_FINISHED"] = "non_files_sync_finished";
3154
- PitcherEventName2["CONTENT_LIST_REFRESH_REQUESTED"] = "content_list_refresh_requested";
3155
- PitcherEventName2["NETWORK_CONNECTION_ESTABLISHED"] = "network_connection_established";
3156
- PitcherEventName2["NETWORK_CONNECTION_LOST"] = "network_connection_lost";
3157
- PitcherEventName2["ENTERED_FULLSCREEN"] = "entered_fullscreen";
3158
- PitcherEventName2["EXITED_FULLSCREEN"] = "exited_fullscreen";
3159
- PitcherEventName2["SUBMIT_POSTCALL_CLICKED"] = "submit_postcall_clicked";
3160
- return PitcherEventName2;
3161
- })(PitcherEventName || {});
3162
- var PitcherBroadcastedEventName = /* @__PURE__ */ ((PitcherBroadcastedEventName2) => {
3163
- PitcherBroadcastedEventName2["UI_SHOW_MODAL"] = "ui:show-modal";
3164
- PitcherBroadcastedEventName2["UI_HIDE_MODAL"] = "ui:hide-modal";
3165
- PitcherBroadcastedEventName2["FAVORITES_CHANGED"] = "favorites:changed";
3166
- PitcherBroadcastedEventName2["FILE_DOWNLOAD"] = "file:download";
3167
- return PitcherBroadcastedEventName2;
3168
- })(PitcherBroadcastedEventName || {});
3169
- var PitcherExternalEventName = /* @__PURE__ */ ((PitcherExternalEventName2) => {
3170
- PitcherExternalEventName2["CREATE_AND_OPEN_CANVAS"] = "create_and_open_canvas";
3171
- PitcherExternalEventName2["OPEN_CANVAS"] = "open_canvas";
3172
- PitcherExternalEventName2["START_CALL"] = "start_call";
3173
- return PitcherExternalEventName2;
3174
- })(PitcherExternalEventName || {});
3689
+ const dsr = {
3690
+ on,
3691
+ ...envDsr,
3692
+ ...loadingDsr
3693
+ };
3175
3694
 
3176
3695
  let highLevelApi;
3696
+ let prevOptions;
3177
3697
  function usePitcherApi(options) {
3178
- if (!highLevelApi) highLevelApi = createHighLevelApi(options);
3698
+ if (!highLevelApi || !isEqual(options, prevOptions)) {
3699
+ highLevelApi = createHighLevelApi(options);
3700
+ prevOptions = options;
3701
+ }
3179
3702
  return highLevelApi;
3180
3703
  }
3181
- const uiApi = Object.entries(
3182
- ui
3183
- ).reduce(
3184
- (acc, [key, value]) => {
3185
- acc[key] = value;
3186
- acc[snakeCase(key)] = value;
3187
- return acc;
3188
- },
3189
- {}
3190
- );
3704
+ function enhanceWithSnakeCase(api) {
3705
+ Object.entries(api).forEach(([key, value]) => {
3706
+ const newKey = snakeCase(key);
3707
+ if (newKey && !api[newKey]) {
3708
+ api[newKey] = value;
3709
+ }
3710
+ });
3711
+ return api;
3712
+ }
3713
+ const uiApi = enhanceWithSnakeCase(ui);
3714
+ const adminApi = enhanceWithSnakeCase(admin);
3715
+ const dsrApi = enhanceWithSnakeCase(dsr);
3191
3716
  function useUi() {
3192
3717
  return uiApi;
3193
3718
  }
3194
- const adminApi = Object.entries(admin).reduce(
3195
- (acc, [key, value]) => {
3196
- acc[key] = value;
3197
- acc[snakeCase(key)] = value;
3198
- return acc;
3199
- },
3200
- {}
3201
- );
3202
3719
  function useAdmin() {
3203
3720
  return adminApi;
3204
3721
  }
3205
- const dsrApi = Object.entries(dsr).reduce(
3206
- (acc, [key, value]) => {
3207
- acc[key] = value;
3208
- acc[snakeCase(key)] = value;
3209
- return acc;
3210
- },
3211
- {}
3212
- );
3213
3722
  function useDsr() {
3214
3723
  return dsrApi;
3215
3724
  }
@@ -3218,7 +3727,7 @@ function getAvailableApis() {
3218
3727
  const location = window.parent.jsApiLocation;
3219
3728
  return location === "ui" ? ["ui", "impact"] : [location ?? "impact"];
3220
3729
  }
3221
- function useApi() {
3730
+ function useApi(options) {
3222
3731
  if (typeof window === "undefined") throw new Error("useApi: window is not defined");
3223
3732
  const location = window.parent.jsApiLocation;
3224
3733
  switch (location) {
@@ -3229,7 +3738,7 @@ function useApi() {
3229
3738
  case "dsr":
3230
3739
  return useDsr();
3231
3740
  case "impact":
3232
- return usePitcherApi();
3741
+ return usePitcherApi(options);
3233
3742
  default:
3234
3743
  throw new Error(`Unknown api for location: ${location}`);
3235
3744
  }