@thoughtspot/visual-embed-sdk 1.35.5-hostEvent.6 → 1.35.5-hostEvent.7

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 (78) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/embed/hostEventClient/contracts.d.ts +26 -30
  3. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  4. package/cjs/src/embed/hostEventClient/contracts.js +10 -10
  5. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  6. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  7. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  8. package/cjs/src/embed/hostEventClient/host-event-client.js +61 -27
  9. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  10. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +43 -39
  11. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  12. package/cjs/src/embed/liveboard.spec.js +4 -2
  13. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  14. package/cjs/src/embed/ts-embed.d.ts +13 -8
  15. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  16. package/cjs/src/embed/ts-embed.js +22 -14
  17. package/cjs/src/embed/ts-embed.js.map +1 -1
  18. package/cjs/src/embed/ts-embed.spec.js +4 -4
  19. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  20. package/cjs/src/index.d.ts +2 -2
  21. package/cjs/src/index.js +2 -2
  22. package/cjs/src/react/all-types-export.d.ts +1 -1
  23. package/cjs/src/react/all-types-export.js +2 -2
  24. package/cjs/src/types.d.ts +1 -1
  25. package/cjs/src/types.js +1 -1
  26. package/dist/index-DaLHJaLd.js +7370 -0
  27. package/dist/src/embed/hostEventClient/contracts.d.ts +26 -30
  28. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  29. package/dist/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  30. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  31. package/dist/src/embed/ts-embed.d.ts +13 -8
  32. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  33. package/dist/src/index.d.ts +2 -2
  34. package/dist/src/react/all-types-export.d.ts +1 -1
  35. package/dist/src/types.d.ts +1 -1
  36. package/dist/tsembed-react.es.js +95 -54
  37. package/dist/tsembed-react.js +94 -53
  38. package/dist/tsembed.es.js +96 -55
  39. package/dist/tsembed.js +94 -53
  40. package/dist/visual-embed-sdk-react-full.d.ts +60 -45
  41. package/dist/visual-embed-sdk-react.d.ts +60 -45
  42. package/dist/visual-embed-sdk.d.ts +60 -45
  43. package/lib/package.json +1 -1
  44. package/lib/src/embed/hostEventClient/contracts.d.ts +26 -30
  45. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  46. package/lib/src/embed/hostEventClient/contracts.js +9 -9
  47. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  48. package/lib/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  49. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  50. package/lib/src/embed/hostEventClient/host-event-client.js +63 -29
  51. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  52. package/lib/src/embed/hostEventClient/host-event-client.spec.js +43 -40
  53. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  54. package/lib/src/embed/liveboard.spec.js +4 -2
  55. package/lib/src/embed/liveboard.spec.js.map +1 -1
  56. package/lib/src/embed/ts-embed.d.ts +13 -8
  57. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  58. package/lib/src/embed/ts-embed.js +22 -14
  59. package/lib/src/embed/ts-embed.js.map +1 -1
  60. package/lib/src/embed/ts-embed.spec.js +5 -5
  61. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  62. package/lib/src/index.d.ts +2 -2
  63. package/lib/src/index.js +2 -2
  64. package/lib/src/react/all-types-export.d.ts +1 -1
  65. package/lib/src/react/all-types-export.js +1 -1
  66. package/lib/src/types.d.ts +1 -1
  67. package/lib/src/types.js +1 -1
  68. package/lib/src/visual-embed-sdk.d.ts +63 -48
  69. package/package.json +1 -1
  70. package/src/embed/hostEventClient/contracts.ts +43 -32
  71. package/src/embed/hostEventClient/host-event-client.spec.ts +58 -54
  72. package/src/embed/hostEventClient/host-event-client.ts +109 -47
  73. package/src/embed/liveboard.spec.ts +4 -2
  74. package/src/embed/ts-embed.spec.ts +6 -6
  75. package/src/embed/ts-embed.ts +38 -27
  76. package/src/index.ts +2 -2
  77. package/src/react/all-types-export.ts +1 -1
  78. package/src/types.ts +1 -1
@@ -1,4 +1,4 @@
1
- /* @thoughtspot/visual-embed-sdk version 1.35.5-hostEvent.6 */
1
+ /* @thoughtspot/visual-embed-sdk version 1.35.5-hostEvent.7 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -2694,7 +2694,7 @@
2694
2694
  * EmbedApi
2695
2695
  * @hidden
2696
2696
  */
2697
- HostEvent["UiPassthrough"] = "UiPassthrough";
2697
+ HostEvent["UIPassthrough"] = "UiPassthrough";
2698
2698
  })(exports.HostEvent || (exports.HostEvent = {}));
2699
2699
  /**
2700
2700
  * The different visual modes that the data sources panel within
@@ -14525,7 +14525,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14525
14525
  return e;
14526
14526
  }
14527
14527
 
14528
- var name="@thoughtspot/visual-embed-sdk";var version$1="1.35.5-hostEvent.6";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
14528
+ var name="@thoughtspot/visual-embed-sdk";var version$1="1.35.5-hostEvent.7";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
14529
14529
 
14530
14530
  /**
14531
14531
  * Reloads the ThoughtSpot iframe.
@@ -14585,61 +14585,94 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14585
14585
  });
14586
14586
  }
14587
14587
 
14588
- var UiPassthroughEvent;
14589
- (function (UiPassthroughEvent) {
14590
- UiPassthroughEvent["addVizToPinboard"] = "addVizToPinboard";
14591
- UiPassthroughEvent["saveAnswer"] = "saveAnswer";
14592
- UiPassthroughEvent["getDiscoverabilityStatus"] = "getDiscoverabilityStatus";
14593
- UiPassthroughEvent["getAvailableUiPassthroughs"] = "getAvailableUiPassthroughs";
14594
- UiPassthroughEvent["getAnswerPageConfig"] = "getAnswerPageConfig";
14595
- UiPassthroughEvent["getPinboardPageConfig"] = "getPinboardPageConfig";
14596
- })(UiPassthroughEvent || (UiPassthroughEvent = {}));
14588
+ var UIPassthroughEvent;
14589
+ (function (UIPassthroughEvent) {
14590
+ UIPassthroughEvent["PinAnswerToLiveboard"] = "addVizToPinboard";
14591
+ UIPassthroughEvent["SaveAnswer"] = "saveAnswer";
14592
+ UIPassthroughEvent["GetDiscoverabilityStatus"] = "getDiscoverabilityStatus";
14593
+ UIPassthroughEvent["GetAvailableUIPassthroughs"] = "getAvailableUIPassthroughs";
14594
+ UIPassthroughEvent["GetAnswerConfig"] = "getAnswerPageConfig";
14595
+ UIPassthroughEvent["GetLiveboardConfig"] = "getPinboardPageConfig";
14596
+ })(UIPassthroughEvent || (UIPassthroughEvent = {}));
14597
14597
 
14598
14598
  class HostEventClient {
14599
- constructor(thoughtSpotHost) {
14600
- this.thoughtSpotHost = thoughtSpotHost;
14599
+ constructor(iFrame) {
14600
+ this.iFrame = iFrame;
14601
14601
  }
14602
- async executeUiPassthroughApi(iFrame, apiName, parameters) {
14603
- const res = await processTrigger(iFrame, exports.HostEvent.UiPassthrough, this.thoughtSpotHost, {
14604
- type: apiName,
14605
- parameters,
14606
- });
14607
- return res;
14602
+ /**
14603
+ * A wrapper over process trigger to
14604
+ * @param {HostEvent} message Host event to send
14605
+ * @param {any} data Data to send with the host event
14606
+ * @returns {Promise<any>} - the response from the process trigger
14607
+ */
14608
+ async processTrigger(message, data) {
14609
+ if (!this.iFrame) {
14610
+ throw new Error('Iframe element is not set');
14611
+ }
14612
+ const thoughtspotHost = getEmbedConfig().thoughtSpotHost;
14613
+ return processTrigger(this.iFrame, message, thoughtspotHost, data);
14608
14614
  }
14609
- async handleUiPassthroughForHostEvent(iFrame, apiName, parameters) {
14610
- var _a, _b, _c;
14611
- const response = (_b = (_a = (await this.executeUiPassthroughApi(iFrame, apiName, parameters))) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, (r) => r.error || r.value)[0];
14615
+ async handleHostEventWithParam(apiName, parameters) {
14616
+ var _a, _b, _c, _d;
14617
+ const response = (_b = (_a = (await this.triggerUIPassthroughApi(apiName, parameters))) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, (r) => r.error || r.value)[0];
14612
14618
  if (!response) {
14613
14619
  const error = `No answer found${parameters.vizId ? ` for vizId: ${parameters.vizId}` : ''}.`;
14614
14620
  // eslint-disable-next-line no-throw-literal
14615
14621
  throw { error };
14616
14622
  }
14617
- const errors = response.error || ((_c = response.value) === null || _c === void 0 ? void 0 : _c.errors);
14623
+ const errors = response.error
14624
+ || ((_c = response.value) === null || _c === void 0 ? void 0 : _c.errors)
14625
+ || ((_d = response.value) === null || _d === void 0 ? void 0 : _d.error);
14618
14626
  if (errors) {
14619
14627
  // eslint-disable-next-line no-throw-literal
14620
14628
  throw { error: response.error };
14621
14629
  }
14622
14630
  return { ...response.value };
14623
14631
  }
14624
- async hostEventFallback(iFrame, hostEvent, data) {
14625
- return processTrigger(iFrame, hostEvent, this.thoughtSpotHost, data);
14632
+ async hostEventFallback(hostEvent, data) {
14633
+ return this.processTrigger(hostEvent, data);
14634
+ }
14635
+ /**
14636
+ * Setter for the iframe element used for host events
14637
+ * @param {HTMLIFrameElement} iFrame - the iframe element to set
14638
+ */
14639
+ setIframeElement(iFrame) {
14640
+ this.iFrame = iFrame;
14641
+ }
14642
+ async triggerUIPassthroughApi(apiName, parameters) {
14643
+ const res = await this.processTrigger(exports.HostEvent.UIPassthrough, {
14644
+ type: apiName,
14645
+ parameters,
14646
+ });
14647
+ return res;
14648
+ }
14649
+ async handlePinEvent(payload) {
14650
+ if (!payload || !('newVizName' in payload)) {
14651
+ return this.hostEventFallback(exports.HostEvent.Pin, payload);
14652
+ }
14653
+ return this.handleHostEventWithParam(UIPassthroughEvent.PinAnswerToLiveboard, payload);
14626
14654
  }
14627
- async executeHostEvent(iFrame, hostEvent, payload) {
14655
+ async handleSaveAnswerEvent(payload) {
14628
14656
  var _a, _b, _c, _d;
14629
- if (hostEvent === exports.HostEvent.Pin && (payload === null || payload === void 0 ? void 0 : payload.newVizName)) {
14630
- return this.handleUiPassthroughForHostEvent(iFrame, UiPassthroughEvent.addVizToPinboard, payload);
14657
+ if (!payload || !('name' in payload) || !('description' in payload)) {
14658
+ // Save is the fallback for SaveAnswer
14659
+ return this.hostEventFallback(exports.HostEvent.Save, payload);
14631
14660
  }
14632
- if (hostEvent === exports.HostEvent.SaveAnswer && (payload === null || payload === void 0 ? void 0 : payload.name)) {
14633
- const data = await this.handleUiPassthroughForHostEvent(iFrame, UiPassthroughEvent.saveAnswer, payload);
14634
- return {
14635
- ...data,
14636
- answerId: (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.saveResponse) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Answer__save) === null || _c === void 0 ? void 0 : _c.answer) === null || _d === void 0 ? void 0 : _d.id,
14637
- };
14661
+ const data = await this.handleHostEventWithParam(UIPassthroughEvent.SaveAnswer, payload);
14662
+ return {
14663
+ ...data,
14664
+ answerId: (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.saveResponse) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Answer__save) === null || _c === void 0 ? void 0 : _c.answer) === null || _d === void 0 ? void 0 : _d.id,
14665
+ };
14666
+ }
14667
+ async triggerHostEvent(hostEvent, payload) {
14668
+ switch (hostEvent) {
14669
+ case exports.HostEvent.Pin:
14670
+ return this.handlePinEvent(payload);
14671
+ case exports.HostEvent.SaveAnswer:
14672
+ return this.handleSaveAnswerEvent(payload);
14673
+ default:
14674
+ return this.hostEventFallback(hostEvent, payload);
14638
14675
  }
14639
- // fallback for save answer is Save
14640
- if (hostEvent === exports.HostEvent.SaveAnswer)
14641
- hostEvent = exports.HostEvent.Save;
14642
- return this.hostEventFallback(iFrame, hostEvent, payload);
14643
14676
  }
14644
14677
  }
14645
14678
 
@@ -14669,6 +14702,14 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14669
14702
  * React+GraphQL
14670
14703
  */
14671
14704
  class TsEmbed {
14705
+ /**
14706
+ * Setter for the iframe element
14707
+ * @param {HTMLIFrameElement} iFrame HTMLIFrameElement
14708
+ */
14709
+ setIframeElement(iFrame) {
14710
+ this.iFrame = iFrame;
14711
+ this.hostEventClient.setIframeElement(iFrame);
14712
+ }
14672
14713
  constructor(domSelector, viewConfig) {
14673
14714
  /**
14674
14715
  * The key to store the embed instance in the DOM node
@@ -14797,7 +14838,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14797
14838
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
14798
14839
  ...viewConfig,
14799
14840
  });
14800
- this.hostEventClient = new HostEventClient(this.embedConfig.thoughtSpotHost);
14841
+ this.hostEventClient = new HostEventClient(this.iFrame);
14801
14842
  }
14802
14843
  /**
14803
14844
  * Throws error encountered during initialization.
@@ -15118,7 +15159,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15118
15159
  this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
15119
15160
  return;
15120
15161
  }
15121
- this.iFrame = this.iFrame || this.createIframeEl(url);
15162
+ this.setIframeElement(this.iFrame || this.createIframeEl(url));
15122
15163
  this.iFrame.addEventListener('load', () => {
15123
15164
  nextInQueue();
15124
15165
  const loadTimestamp = Date.now();
@@ -15177,7 +15218,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15177
15218
  if (this.preRenderWrapper && this.preRenderChild) {
15178
15219
  this.isPreRendered = true;
15179
15220
  if (this.preRenderChild instanceof HTMLIFrameElement) {
15180
- this.iFrame = this.preRenderChild;
15221
+ this.setIframeElement(this.preRenderChild);
15181
15222
  }
15182
15223
  this.insertedDomEl = this.preRenderWrapper;
15183
15224
  this.isRendered = true;
@@ -15215,7 +15256,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15215
15256
  this.preRenderChild = preRenderChild;
15216
15257
  this.preRenderWrapper = preRenderWrapper;
15217
15258
  if (preRenderChild instanceof HTMLIFrameElement) {
15218
- this.iFrame = preRenderChild;
15259
+ this.setIframeElement(preRenderChild);
15219
15260
  }
15220
15261
  this.insertedDomEl = preRenderWrapper;
15221
15262
  if (this.showPreRenderByDefault) {
@@ -15414,11 +15455,11 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15414
15455
  }
15415
15456
  /**
15416
15457
  * Triggers an event to the embedded app
15417
- * @param messageType The event type
15418
- * @param data The payload to send with the message
15458
+ * @param {HostEvent} messageType The event type
15459
+ * @param {any} data The payload to send with the message
15419
15460
  * @returns A promise that resolves with the response from the embedded app
15420
15461
  */
15421
- trigger(messageType, data) {
15462
+ async trigger(messageType, data) {
15422
15463
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
15423
15464
  if (!this.isRendered) {
15424
15465
  this.handleError('Please call render before triggering events');
@@ -15428,18 +15469,18 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15428
15469
  this.handleError('Host event type is undefined');
15429
15470
  return null;
15430
15471
  }
15431
- return this.hostEventClient.executeHostEvent(this.iFrame, messageType, data);
15472
+ return this.hostEventClient.triggerHostEvent(messageType, data);
15432
15473
  }
15433
15474
  /**
15434
15475
  * Triggers an event to the embedded app, skipping the UI flow.
15435
- * @param {UiPassthroughEvent} apiName - The name of the API to be triggered.
15436
- * @param {UiPassthroughRequest} parameters - The parameters to be passed to the API.
15437
- * @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
15476
+ * @param {UIPassthroughEvent} apiName - The name of the API to be triggered.
15477
+ * @param {UIPassthroughRequest} parameters - The parameters to be passed to the API.
15478
+ * @returns {Promise<UIPassthroughRequest>} - A promise that resolves with the response
15438
15479
  * from the embedded app.
15439
15480
  */
15440
- // eslint-disable-next-line arrow-body-style
15441
- triggerUiPassThrough(apiName, parameters) {
15442
- return this.hostEventClient.executeUiPassthroughApi(this.iFrame, apiName, parameters);
15481
+ async triggerUIPassThrough(apiName, parameters) {
15482
+ const response = this.hostEventClient.triggerUIPassthroughApi(apiName, parameters);
15483
+ return response;
15443
15484
  }
15444
15485
  /**
15445
15486
  * Marks the ThoughtSpot object to have been rendered
@@ -1,4 +1,4 @@
1
- /* @thoughtspot/visual-embed-sdk version 1.35.5-hostEvent.6 */
1
+ /* @thoughtspot/visual-embed-sdk version 1.35.5-hostEvent.7 */
2
2
  function _mergeNamespaces(n, m) {
3
3
  m.forEach(function (e) {
4
4
  e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
@@ -2557,7 +2557,7 @@ var HostEvent;
2557
2557
  * EmbedApi
2558
2558
  * @hidden
2559
2559
  */
2560
- HostEvent["UiPassthrough"] = "UiPassthrough";
2560
+ HostEvent["UIPassthrough"] = "UiPassthrough";
2561
2561
  })(HostEvent || (HostEvent = {}));
2562
2562
  /**
2563
2563
  * The different visual modes that the data sources panel within
@@ -7059,7 +7059,7 @@ class AnswerService {
7059
7059
  async getTML() {
7060
7060
  const { object } = await this.executeQuery(getAnswerTML, {});
7061
7061
  const edoc = object[0].edoc;
7062
- const YAML = await import('./index-DOIjN0N_.js');
7062
+ const YAML = await import('./index-DaLHJaLd.js');
7063
7063
  const parsedDoc = YAML.parse(edoc);
7064
7064
  return {
7065
7065
  answer: {
@@ -14745,7 +14745,7 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
14745
14745
  return e;
14746
14746
  }
14747
14747
 
14748
- var name="@thoughtspot/visual-embed-sdk";var version$1="1.35.5-hostEvent.6";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
14748
+ var name="@thoughtspot/visual-embed-sdk";var version$1="1.35.5-hostEvent.7";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
14749
14749
 
14750
14750
  /**
14751
14751
  * Reloads the ThoughtSpot iframe.
@@ -14805,61 +14805,94 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
14805
14805
  });
14806
14806
  }
14807
14807
 
14808
- var UiPassthroughEvent;
14809
- (function (UiPassthroughEvent) {
14810
- UiPassthroughEvent["addVizToPinboard"] = "addVizToPinboard";
14811
- UiPassthroughEvent["saveAnswer"] = "saveAnswer";
14812
- UiPassthroughEvent["getDiscoverabilityStatus"] = "getDiscoverabilityStatus";
14813
- UiPassthroughEvent["getAvailableUiPassthroughs"] = "getAvailableUiPassthroughs";
14814
- UiPassthroughEvent["getAnswerPageConfig"] = "getAnswerPageConfig";
14815
- UiPassthroughEvent["getPinboardPageConfig"] = "getPinboardPageConfig";
14816
- })(UiPassthroughEvent || (UiPassthroughEvent = {}));
14808
+ var UIPassthroughEvent;
14809
+ (function (UIPassthroughEvent) {
14810
+ UIPassthroughEvent["PinAnswerToLiveboard"] = "addVizToPinboard";
14811
+ UIPassthroughEvent["SaveAnswer"] = "saveAnswer";
14812
+ UIPassthroughEvent["GetDiscoverabilityStatus"] = "getDiscoverabilityStatus";
14813
+ UIPassthroughEvent["GetAvailableUIPassthroughs"] = "getAvailableUIPassthroughs";
14814
+ UIPassthroughEvent["GetAnswerConfig"] = "getAnswerPageConfig";
14815
+ UIPassthroughEvent["GetLiveboardConfig"] = "getPinboardPageConfig";
14816
+ })(UIPassthroughEvent || (UIPassthroughEvent = {}));
14817
14817
 
14818
14818
  class HostEventClient {
14819
- constructor(thoughtSpotHost) {
14820
- this.thoughtSpotHost = thoughtSpotHost;
14819
+ constructor(iFrame) {
14820
+ this.iFrame = iFrame;
14821
14821
  }
14822
- async executeUiPassthroughApi(iFrame, apiName, parameters) {
14823
- const res = await processTrigger(iFrame, HostEvent.UiPassthrough, this.thoughtSpotHost, {
14824
- type: apiName,
14825
- parameters,
14826
- });
14827
- return res;
14822
+ /**
14823
+ * A wrapper over process trigger to
14824
+ * @param {HostEvent} message Host event to send
14825
+ * @param {any} data Data to send with the host event
14826
+ * @returns {Promise<any>} - the response from the process trigger
14827
+ */
14828
+ async processTrigger(message, data) {
14829
+ if (!this.iFrame) {
14830
+ throw new Error('Iframe element is not set');
14831
+ }
14832
+ const thoughtspotHost = getEmbedConfig().thoughtSpotHost;
14833
+ return processTrigger(this.iFrame, message, thoughtspotHost, data);
14828
14834
  }
14829
- async handleUiPassthroughForHostEvent(iFrame, apiName, parameters) {
14830
- var _a, _b, _c;
14831
- const response = (_b = (_a = (await this.executeUiPassthroughApi(iFrame, apiName, parameters))) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, (r) => r.error || r.value)[0];
14835
+ async handleHostEventWithParam(apiName, parameters) {
14836
+ var _a, _b, _c, _d;
14837
+ const response = (_b = (_a = (await this.triggerUIPassthroughApi(apiName, parameters))) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, (r) => r.error || r.value)[0];
14832
14838
  if (!response) {
14833
14839
  const error = `No answer found${parameters.vizId ? ` for vizId: ${parameters.vizId}` : ''}.`;
14834
14840
  // eslint-disable-next-line no-throw-literal
14835
14841
  throw { error };
14836
14842
  }
14837
- const errors = response.error || ((_c = response.value) === null || _c === void 0 ? void 0 : _c.errors);
14843
+ const errors = response.error
14844
+ || ((_c = response.value) === null || _c === void 0 ? void 0 : _c.errors)
14845
+ || ((_d = response.value) === null || _d === void 0 ? void 0 : _d.error);
14838
14846
  if (errors) {
14839
14847
  // eslint-disable-next-line no-throw-literal
14840
14848
  throw { error: response.error };
14841
14849
  }
14842
14850
  return { ...response.value };
14843
14851
  }
14844
- async hostEventFallback(iFrame, hostEvent, data) {
14845
- return processTrigger(iFrame, hostEvent, this.thoughtSpotHost, data);
14852
+ async hostEventFallback(hostEvent, data) {
14853
+ return this.processTrigger(hostEvent, data);
14854
+ }
14855
+ /**
14856
+ * Setter for the iframe element used for host events
14857
+ * @param {HTMLIFrameElement} iFrame - the iframe element to set
14858
+ */
14859
+ setIframeElement(iFrame) {
14860
+ this.iFrame = iFrame;
14861
+ }
14862
+ async triggerUIPassthroughApi(apiName, parameters) {
14863
+ const res = await this.processTrigger(HostEvent.UIPassthrough, {
14864
+ type: apiName,
14865
+ parameters,
14866
+ });
14867
+ return res;
14868
+ }
14869
+ async handlePinEvent(payload) {
14870
+ if (!payload || !('newVizName' in payload)) {
14871
+ return this.hostEventFallback(HostEvent.Pin, payload);
14872
+ }
14873
+ return this.handleHostEventWithParam(UIPassthroughEvent.PinAnswerToLiveboard, payload);
14846
14874
  }
14847
- async executeHostEvent(iFrame, hostEvent, payload) {
14875
+ async handleSaveAnswerEvent(payload) {
14848
14876
  var _a, _b, _c, _d;
14849
- if (hostEvent === HostEvent.Pin && (payload === null || payload === void 0 ? void 0 : payload.newVizName)) {
14850
- return this.handleUiPassthroughForHostEvent(iFrame, UiPassthroughEvent.addVizToPinboard, payload);
14877
+ if (!payload || !('name' in payload) || !('description' in payload)) {
14878
+ // Save is the fallback for SaveAnswer
14879
+ return this.hostEventFallback(HostEvent.Save, payload);
14851
14880
  }
14852
- if (hostEvent === HostEvent.SaveAnswer && (payload === null || payload === void 0 ? void 0 : payload.name)) {
14853
- const data = await this.handleUiPassthroughForHostEvent(iFrame, UiPassthroughEvent.saveAnswer, payload);
14854
- return {
14855
- ...data,
14856
- answerId: (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.saveResponse) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Answer__save) === null || _c === void 0 ? void 0 : _c.answer) === null || _d === void 0 ? void 0 : _d.id,
14857
- };
14881
+ const data = await this.handleHostEventWithParam(UIPassthroughEvent.SaveAnswer, payload);
14882
+ return {
14883
+ ...data,
14884
+ answerId: (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.saveResponse) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Answer__save) === null || _c === void 0 ? void 0 : _c.answer) === null || _d === void 0 ? void 0 : _d.id,
14885
+ };
14886
+ }
14887
+ async triggerHostEvent(hostEvent, payload) {
14888
+ switch (hostEvent) {
14889
+ case HostEvent.Pin:
14890
+ return this.handlePinEvent(payload);
14891
+ case HostEvent.SaveAnswer:
14892
+ return this.handleSaveAnswerEvent(payload);
14893
+ default:
14894
+ return this.hostEventFallback(hostEvent, payload);
14858
14895
  }
14859
- // fallback for save answer is Save
14860
- if (hostEvent === HostEvent.SaveAnswer)
14861
- hostEvent = HostEvent.Save;
14862
- return this.hostEventFallback(iFrame, hostEvent, payload);
14863
14896
  }
14864
14897
  }
14865
14898
 
@@ -14889,6 +14922,14 @@ const V1EventMap = {};
14889
14922
  * React+GraphQL
14890
14923
  */
14891
14924
  class TsEmbed {
14925
+ /**
14926
+ * Setter for the iframe element
14927
+ * @param {HTMLIFrameElement} iFrame HTMLIFrameElement
14928
+ */
14929
+ setIframeElement(iFrame) {
14930
+ this.iFrame = iFrame;
14931
+ this.hostEventClient.setIframeElement(iFrame);
14932
+ }
14892
14933
  constructor(domSelector, viewConfig) {
14893
14934
  /**
14894
14935
  * The key to store the embed instance in the DOM node
@@ -15017,7 +15058,7 @@ class TsEmbed {
15017
15058
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
15018
15059
  ...viewConfig,
15019
15060
  });
15020
- this.hostEventClient = new HostEventClient(this.embedConfig.thoughtSpotHost);
15061
+ this.hostEventClient = new HostEventClient(this.iFrame);
15021
15062
  }
15022
15063
  /**
15023
15064
  * Throws error encountered during initialization.
@@ -15338,7 +15379,7 @@ class TsEmbed {
15338
15379
  this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
15339
15380
  return;
15340
15381
  }
15341
- this.iFrame = this.iFrame || this.createIframeEl(url);
15382
+ this.setIframeElement(this.iFrame || this.createIframeEl(url));
15342
15383
  this.iFrame.addEventListener('load', () => {
15343
15384
  nextInQueue();
15344
15385
  const loadTimestamp = Date.now();
@@ -15397,7 +15438,7 @@ class TsEmbed {
15397
15438
  if (this.preRenderWrapper && this.preRenderChild) {
15398
15439
  this.isPreRendered = true;
15399
15440
  if (this.preRenderChild instanceof HTMLIFrameElement) {
15400
- this.iFrame = this.preRenderChild;
15441
+ this.setIframeElement(this.preRenderChild);
15401
15442
  }
15402
15443
  this.insertedDomEl = this.preRenderWrapper;
15403
15444
  this.isRendered = true;
@@ -15435,7 +15476,7 @@ class TsEmbed {
15435
15476
  this.preRenderChild = preRenderChild;
15436
15477
  this.preRenderWrapper = preRenderWrapper;
15437
15478
  if (preRenderChild instanceof HTMLIFrameElement) {
15438
- this.iFrame = preRenderChild;
15479
+ this.setIframeElement(preRenderChild);
15439
15480
  }
15440
15481
  this.insertedDomEl = preRenderWrapper;
15441
15482
  if (this.showPreRenderByDefault) {
@@ -15634,11 +15675,11 @@ class TsEmbed {
15634
15675
  }
15635
15676
  /**
15636
15677
  * Triggers an event to the embedded app
15637
- * @param messageType The event type
15638
- * @param data The payload to send with the message
15678
+ * @param {HostEvent} messageType The event type
15679
+ * @param {any} data The payload to send with the message
15639
15680
  * @returns A promise that resolves with the response from the embedded app
15640
15681
  */
15641
- trigger(messageType, data) {
15682
+ async trigger(messageType, data) {
15642
15683
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
15643
15684
  if (!this.isRendered) {
15644
15685
  this.handleError('Please call render before triggering events');
@@ -15648,18 +15689,18 @@ class TsEmbed {
15648
15689
  this.handleError('Host event type is undefined');
15649
15690
  return null;
15650
15691
  }
15651
- return this.hostEventClient.executeHostEvent(this.iFrame, messageType, data);
15692
+ return this.hostEventClient.triggerHostEvent(messageType, data);
15652
15693
  }
15653
15694
  /**
15654
15695
  * Triggers an event to the embedded app, skipping the UI flow.
15655
- * @param {UiPassthroughEvent} apiName - The name of the API to be triggered.
15656
- * @param {UiPassthroughRequest} parameters - The parameters to be passed to the API.
15657
- * @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
15696
+ * @param {UIPassthroughEvent} apiName - The name of the API to be triggered.
15697
+ * @param {UIPassthroughRequest} parameters - The parameters to be passed to the API.
15698
+ * @returns {Promise<UIPassthroughRequest>} - A promise that resolves with the response
15658
15699
  * from the embedded app.
15659
15700
  */
15660
- // eslint-disable-next-line arrow-body-style
15661
- triggerUiPassThrough(apiName, parameters) {
15662
- return this.hostEventClient.executeUiPassthroughApi(this.iFrame, apiName, parameters);
15701
+ async triggerUIPassThrough(apiName, parameters) {
15702
+ const response = this.hostEventClient.triggerUIPassthroughApi(apiName, parameters);
15703
+ return response;
15663
15704
  }
15664
15705
  /**
15665
15706
  * Marks the ThoughtSpot object to have been rendered
@@ -17867,4 +17908,4 @@ const createLiveboardWithAnswers = async (answers, name) => {
17867
17908
  return result;
17868
17909
  };
17869
17910
 
17870
- export { Action, AnswerService, AppEmbed, AuthEvent, AuthFailureType, AuthStatus, AuthType, BodylessConversation, ContextMenuTriggerOptions, ConversationEmbed, DataSourceVisualMode, EmbedEvent, HomeLeftNavItem, HomePageSearchBarMode, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, MIXPANEL_EVENT, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, UiPassthroughEvent, createLiveboardWithAnswers, executeTML, exportTML, getAnswerFromQuery, getEmbedConfig as getInitConfig, getSessionInfo, init, logout, prefetch, resetCachedAuthToken, tokenizedFetch, uploadMixpanelEvent };
17911
+ export { Action, AnswerService, AppEmbed, AuthEvent, AuthFailureType, AuthStatus, AuthType, BodylessConversation, ContextMenuTriggerOptions, ConversationEmbed, DataSourceVisualMode, EmbedEvent, HomeLeftNavItem, HomePageSearchBarMode, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, MIXPANEL_EVENT, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, UIPassthroughEvent, createLiveboardWithAnswers, executeTML, exportTML, getAnswerFromQuery, getEmbedConfig as getInitConfig, getSessionInfo, init, logout, prefetch, resetCachedAuthToken, tokenizedFetch, uploadMixpanelEvent };