@thoughtspot/visual-embed-sdk 1.13.0-alpha.2 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +31 -6
  2. package/README.md +1 -1
  3. package/dist/src/auth.d.ts +4 -1
  4. package/dist/src/auth.spec.d.ts +1 -0
  5. package/dist/src/embed/app.d.ts +5 -0
  6. package/dist/src/embed/liveboard.d.ts +12 -1
  7. package/dist/src/embed/search.d.ts +5 -0
  8. package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +1 -0
  9. package/dist/src/embed/ts-embed.d.ts +12 -3
  10. package/dist/src/errors.d.ts +2 -0
  11. package/dist/src/test/test-utils.d.ts +6 -0
  12. package/dist/src/types.d.ts +211 -4
  13. package/dist/src/utils/processTrigger.d.ts +1 -1
  14. package/dist/src/utils.d.ts +3 -1
  15. package/dist/tsembed.es.js +292 -24
  16. package/dist/tsembed.js +292 -24
  17. package/lib/package.json +4 -2
  18. package/lib/src/auth.d.ts +4 -1
  19. package/lib/src/auth.js +11 -2
  20. package/lib/src/auth.js.map +1 -1
  21. package/lib/src/auth.spec.d.ts +1 -0
  22. package/lib/src/auth.spec.js +13 -1
  23. package/lib/src/auth.spec.js.map +1 -1
  24. package/lib/src/config.spec.js +7 -0
  25. package/lib/src/config.spec.js.map +1 -1
  26. package/lib/src/embed/app.d.ts +5 -0
  27. package/lib/src/embed/app.js +1 -1
  28. package/lib/src/embed/app.js.map +1 -1
  29. package/lib/src/embed/app.spec.js +18 -6
  30. package/lib/src/embed/app.spec.js.map +1 -1
  31. package/lib/src/embed/embed.spec.js +2 -0
  32. package/lib/src/embed/embed.spec.js.map +1 -1
  33. package/lib/src/embed/events.spec.js +3 -1
  34. package/lib/src/embed/events.spec.js.map +1 -1
  35. package/lib/src/embed/liveboard.d.ts +12 -1
  36. package/lib/src/embed/liveboard.js +22 -4
  37. package/lib/src/embed/liveboard.js.map +1 -1
  38. package/lib/src/embed/liveboard.spec.js +33 -6
  39. package/lib/src/embed/liveboard.spec.js.map +1 -1
  40. package/lib/src/embed/pinboard.spec.js +7 -5
  41. package/lib/src/embed/pinboard.spec.js.map +1 -1
  42. package/lib/src/embed/search.d.ts +5 -0
  43. package/lib/src/embed/search.js +10 -2
  44. package/lib/src/embed/search.js.map +1 -1
  45. package/lib/src/embed/search.spec.js +9 -1
  46. package/lib/src/embed/search.spec.js.map +1 -1
  47. package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +1 -0
  48. package/lib/src/embed/searchEmbed-basic-auth.spec.js +96 -0
  49. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
  50. package/lib/src/embed/ts-embed.d.ts +12 -3
  51. package/lib/src/embed/ts-embed.js +29 -10
  52. package/lib/src/embed/ts-embed.js.map +1 -1
  53. package/lib/src/embed/ts-embed.spec.js +38 -5
  54. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  55. package/lib/src/errors.d.ts +2 -0
  56. package/lib/src/errors.js +2 -0
  57. package/lib/src/errors.js.map +1 -1
  58. package/lib/src/react/index.js +3 -2
  59. package/lib/src/react/index.js.map +1 -1
  60. package/lib/src/react/index.spec.js +6 -4
  61. package/lib/src/react/index.spec.js.map +1 -1
  62. package/lib/src/test/test-utils.d.ts +6 -0
  63. package/lib/src/test/test-utils.js +15 -0
  64. package/lib/src/test/test-utils.js.map +1 -1
  65. package/lib/src/types.d.ts +211 -4
  66. package/lib/src/types.js +176 -0
  67. package/lib/src/types.js.map +1 -1
  68. package/lib/src/utils/processTrigger.d.ts +1 -1
  69. package/lib/src/utils/processTrigger.js +28 -8
  70. package/lib/src/utils/processTrigger.js.map +1 -1
  71. package/lib/src/utils/processTrigger.spec.js +11 -1
  72. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  73. package/lib/src/utils.d.ts +3 -1
  74. package/lib/src/utils.js +20 -0
  75. package/lib/src/utils.js.map +1 -1
  76. package/lib/src/utils.spec.js +22 -1
  77. package/lib/src/utils.spec.js.map +1 -1
  78. package/lib/src/visual-embed-sdk.d.ts +240 -9
  79. package/package.json +4 -2
  80. package/src/auth.spec.ts +20 -1
  81. package/src/auth.ts +12 -2
  82. package/src/config.spec.ts +11 -0
  83. package/src/embed/app.spec.ts +22 -3
  84. package/src/embed/app.ts +6 -0
  85. package/src/embed/embed.spec.ts +2 -0
  86. package/src/embed/events.spec.ts +3 -0
  87. package/src/embed/liveboard.spec.ts +46 -6
  88. package/src/embed/liveboard.ts +34 -2
  89. package/src/embed/pinboard.spec.ts +8 -6
  90. package/src/embed/search.spec.ts +11 -1
  91. package/src/embed/search.ts +20 -1
  92. package/src/embed/searchEmbed-basic-auth.spec.ts +115 -0
  93. package/src/embed/ts-embed.spec.ts +51 -5
  94. package/src/embed/ts-embed.ts +40 -12
  95. package/src/errors.ts +3 -0
  96. package/src/react/index.spec.tsx +7 -2
  97. package/src/react/index.tsx +3 -2
  98. package/src/test/test-utils.ts +16 -0
  99. package/src/types.ts +209 -0
  100. package/src/utils/processTrigger.spec.ts +11 -1
  101. package/src/utils/processTrigger.ts +36 -12
  102. package/src/utils.spec.ts +29 -0
  103. package/src/utils.ts +34 -1
@@ -121,6 +121,26 @@ const setAttributes = (element, attributes) => {
121
121
  Object.keys(attributes).forEach((key) => {
122
122
  element.setAttribute(key, attributes[key].toString());
123
123
  });
124
+ };
125
+ const isCloudRelease = (version) => version.endsWith('.cl');
126
+ /* For Search Embed: ReleaseVersionInBeta */
127
+ const checkReleaseVersionInBeta = (releaseVersion, suppressBetaWarning) => {
128
+ if (releaseVersion !== '' && !isCloudRelease(releaseVersion)) {
129
+ const splittedReleaseVersion = releaseVersion.split('.');
130
+ const majorVersion = Number(splittedReleaseVersion[0]);
131
+ const isBetaVersion = majorVersion < 8;
132
+ return !suppressBetaWarning && isBetaVersion;
133
+ }
134
+ return false;
135
+ };
136
+ const getCustomisations = (embedConfig) => {
137
+ const { customCssUrl } = embedConfig;
138
+ let { customisations } = embedConfig;
139
+ customisations = customisations || {};
140
+ customisations.style = customisations.style || {};
141
+ customisations.style.customCSSUrl =
142
+ customisations.style.customCSSUrl || customCssUrl;
143
+ return customisations;
124
144
  };
125
145
 
126
146
  /**
@@ -144,8 +164,13 @@ var AuthType;
144
164
  AuthType["None"] = "None";
145
165
  /**
146
166
  * SSO using SAML
167
+ * @deprecated Use {@link SAML} instead
147
168
  */
148
169
  AuthType["SSO"] = "SSO_SAML";
170
+ /**
171
+ * SSO using SAML
172
+ */
173
+ AuthType["SAML"] = "SSO_SAML";
149
174
  /**
150
175
  * SSO using OIDC
151
176
  */
@@ -472,6 +497,65 @@ var EmbedEvent;
472
497
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
473
498
  */
474
499
  EmbedEvent["AnswerChartSwitcher"] = "answerChartSwitcher";
500
+ /**
501
+ *
502
+ */
503
+ EmbedEvent["APP_INIT"] = "appInit";
504
+ /**
505
+ * Emitted when a user clicks Show Liveboard details on a Liveboard
506
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
507
+ */
508
+ EmbedEvent["LiveboardInfo"] = "pinboardInfo";
509
+ /**
510
+ * Emitted when a user clicks on the Favorite icon on a Liveboard
511
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
512
+ */
513
+ EmbedEvent["AddToFavorites"] = "addToFavorites";
514
+ /**
515
+ * Emitted when a user clicks Schedule on a Liveboard
516
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
517
+ */
518
+ EmbedEvent["Schedule"] = "subscription";
519
+ /**
520
+ * Emitted when a user clicks Edit on a Liveboard or visualization
521
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
522
+ */
523
+ EmbedEvent["Edit"] = "edit";
524
+ /**
525
+ * Emitted when a user clicks Make a copy on a Liveboard
526
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
527
+ */
528
+ EmbedEvent["MakeACopy"] = "makeACopy";
529
+ /**
530
+ * Emitted when a user clicks Present on a Liveboard or visualization
531
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
532
+ */
533
+ EmbedEvent["Present"] = "present";
534
+ /**
535
+ * Emitted when a user clicks Delete on a Liveboard
536
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
537
+ */
538
+ EmbedEvent["Delete"] = "delete";
539
+ /**
540
+ * Emitted when a user clicks Manage schedules on a Liveboard
541
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
542
+ */
543
+ EmbedEvent["SchedulesList"] = "schedule-list";
544
+ /**
545
+ * Emitted when a user clicks Cancel in edit mode on a Liveboard
546
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
547
+ */
548
+ EmbedEvent["Cancel"] = "cancel";
549
+ /**
550
+ * Emitted when a user clicks Explore on a visualization
551
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
552
+ */
553
+ EmbedEvent["Explore"] = "explore";
554
+ /**
555
+ * Emitted when a user clicks Copy link action on a visualization
556
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
557
+ */
558
+ EmbedEvent["CopyLink"] = "embedDocument";
475
559
  })(EmbedEvent || (EmbedEvent = {}));
476
560
  /**
477
561
  * Event types that can be triggered by the host application
@@ -529,6 +613,112 @@ var HostEvent;
529
613
  * @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
530
614
  */
531
615
  HostEvent["Navigate"] = "Navigate";
616
+ /**
617
+ * Gets the current pinboard content.
618
+ * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
619
+ */
620
+ HostEvent["getExportRequestForCurrentPinboard"] = "getExportRequestForCurrentPinboard";
621
+ /**
622
+ * Triggers the Pin action on an embedded object
623
+ * @param - incase of Liveboard embed, takes in an object with vizId as a key
624
+ * can be left empty for search and visualization embeds
625
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
626
+ */
627
+ HostEvent["Pin"] = "pin";
628
+ /**
629
+ * Triggers the Show Liveboard details action on a Liveboard
630
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
631
+ */
632
+ HostEvent["LiveboardInfo"] = "pinboardInfo";
633
+ /**
634
+ * Triggers the Schedule action on a Liveboard
635
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
636
+ */
637
+ HostEvent["Schedule"] = "subscription";
638
+ /**
639
+ * Triggers the Manage schedule action on a Liveboard
640
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
641
+ */
642
+ HostEvent["SchedulesList"] = "schedule-list";
643
+ /**
644
+ * Triggers the Export TML action on a Liveboard
645
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
646
+ */
647
+ HostEvent["ExportTML"] = "exportTSL";
648
+ /**
649
+ * Triggers the Edit TML action on a Liveboard
650
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
651
+ */
652
+ HostEvent["EditTML"] = "editTSL";
653
+ /**
654
+ * Triggers the Update TML action on a Liveboard
655
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
656
+ */
657
+ HostEvent["UpdateTML"] = "updateTSL";
658
+ /**
659
+ * Triggers the Download PDF action on a Liveboard
660
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
661
+ */
662
+ HostEvent["DownloadAsPdf"] = "downloadAsPdf";
663
+ /**
664
+ * Triggers the Make a copy action on a Liveboard
665
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
666
+ */
667
+ HostEvent["MakeACopy"] = "makeACopy";
668
+ /**
669
+ * Triggers the Delete action on a Liveboard
670
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
671
+ */
672
+ HostEvent["Remove"] = "delete";
673
+ /**
674
+ * Triggers the Explore action on a visualization
675
+ * @param - an object with vizId as a key
676
+ * eg: {vizId: '730496d6-6903-4601-937e-2c691821af3c'}
677
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
678
+ */
679
+ HostEvent["Explore"] = "explore";
680
+ /**
681
+ * Triggers the Create alert action on a visualization
682
+ * @param - an object with vizId as a key
683
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
684
+ */
685
+ HostEvent["CreateMonitor"] = "createMonitor";
686
+ /**
687
+ * Triggers the Manage alert action on a visualization
688
+ * @param - an object with vizId as a key
689
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
690
+ */
691
+ HostEvent["ManageMonitor"] = "manageMonitor";
692
+ /**
693
+ * Triggers the Edit action on a Liveboard or visualization
694
+ * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
695
+ * @example
696
+ * liveboardEmbed.trigger(HostEvent.Edit)
697
+ * liveboardEmbed.trigger(HostEvent.Edit, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
698
+ * vizEmbed.trigger((HostEvent.Edit)
699
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
700
+ */
701
+ HostEvent["Edit"] = "edit";
702
+ /**
703
+ * Triggers the Copy link action on a Liveboard or visualization
704
+ * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
705
+ * @example
706
+ * liveboardEmbed.trigger(HostEvent.CopyLink)
707
+ * liveboardEmbed.trigger(HostEvent.CopyLink, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
708
+ * vizEmbed.trigger((HostEvent.CopyLink)
709
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
710
+ */
711
+ HostEvent["CopyLink"] = "embedDocument";
712
+ /**
713
+ * Triggers the Present action on a Liveboard or visualization
714
+ * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
715
+ * @example
716
+ * liveboardEmbed.trigger(HostEvent.Present)
717
+ * liveboardEmbed.trigger(HostEvent.Present, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
718
+ * vizEmbed.trigger((HostEvent.Present)
719
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
720
+ */
721
+ HostEvent["Present"] = "present";
532
722
  })(HostEvent || (HostEvent = {}));
533
723
  /**
534
724
  * The different visual modes that the data sources panel within
@@ -577,6 +767,7 @@ var Param;
577
767
  Param["fullHeight"] = "isFullHeightPinboard";
578
768
  Param["livedBoardEmbed"] = "isLiveboardEmbed";
579
769
  Param["searchEmbed"] = "isSearchEmbed";
770
+ Param["vizEmbed"] = "isVizEmbed";
580
771
  Param["Version"] = "sdkVersion";
581
772
  Param["ViewPortHeight"] = "viewPortHeight";
582
773
  Param["ViewPortWidth"] = "viewPortWidth";
@@ -587,6 +778,7 @@ var Param;
587
778
  Param["LiveboardV2Enabled"] = "isPinboardV2Enabled";
588
779
  Param["ShowAlerts"] = "showAlerts";
589
780
  Param["Locale"] = "locale";
781
+ Param["CustomStyle"] = "customStyle";
590
782
  })(Param || (Param = {}));
591
783
  /**
592
784
  * The list of actions that can be performed on visual ThoughtSpot
@@ -729,6 +921,10 @@ var Action;
729
921
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
730
922
  */
731
923
  Action["CreateMonitor"] = "createMonitor";
924
+ /**
925
+ * @version SDK: 1.11.1 | ThoughtSpot: 8.3.0.cl
926
+ */
927
+ Action["ReportError"] = "reportError";
732
928
  })(Action || (Action = {}));
733
929
  // eslint-disable-next-line no-shadow
734
930
  var OperationType;
@@ -740,6 +936,8 @@ var OperationType;
740
936
  const ERROR_MESSAGE = {
741
937
  INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
742
938
  LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
939
+ TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
940
+ SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
743
941
  };
744
942
 
745
943
  /**
@@ -7227,8 +7425,8 @@ let loggedInStatus = false;
7227
7425
  let samlAuthWindow = null;
7228
7426
  // eslint-disable-next-line import/no-mutable-exports
7229
7427
  let samlCompletionPromise = null;
7230
- // eslint-disable-next-line import/no-mutable-exports
7231
7428
  let sessionInfo = null;
7429
+ let releaseVersion = '';
7232
7430
  const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
7233
7431
  const EndPoints = {
7234
7432
  AUTH_VERIFICATION: '/callosum/v1/session/info',
@@ -7273,12 +7471,20 @@ async function isLoggedIn(thoughtSpotHost) {
7273
7471
  let response = null;
7274
7472
  try {
7275
7473
  response = await fetchSessionInfoService(authVerificationUrl);
7474
+ const sessionInfoResp = await response.json();
7475
+ releaseVersion = sessionInfoResp.releaseVersion;
7276
7476
  }
7277
7477
  catch (e) {
7278
7478
  return false;
7279
7479
  }
7280
7480
  return response.status === 200;
7281
7481
  }
7482
+ /**
7483
+ * Return releaseVersion if available
7484
+ */
7485
+ function getReleaseVersion() {
7486
+ return releaseVersion;
7487
+ }
7282
7488
  function initSession(sessionDetails) {
7283
7489
  sessionInfo = sessionDetails;
7284
7490
  initMixpanel(sessionInfo);
@@ -7455,6 +7661,7 @@ const authenticate = async (embedConfig) => {
7455
7661
  const { authType } = embedConfig;
7456
7662
  switch (authType) {
7457
7663
  case AuthType.SSO:
7664
+ case AuthType.SAML:
7458
7665
  return doSamlAuth(embedConfig);
7459
7666
  case AuthType.OIDC:
7460
7667
  return doOIDCAuth(embedConfig);
@@ -7749,19 +7956,38 @@ function reload(iFrame) {
7749
7956
  /**
7750
7957
  * Post Iframe message.
7751
7958
  */
7752
- function postIframeMessage(iFrame, message, thoughtSpotHost) {
7753
- return iFrame.contentWindow.postMessage(message, thoughtSpotHost);
7959
+ function postIframeMessage(iFrame, message, thoughtSpotHost, channel) {
7960
+ return iFrame.contentWindow.postMessage(message, thoughtSpotHost, [
7961
+ channel === null || channel === void 0 ? void 0 : channel.port2,
7962
+ ]);
7754
7963
  }
7964
+ const TRIGGER_TIMEOUT = 30000;
7755
7965
  function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
7756
- switch (messageType) {
7757
- case HostEvent.Reload:
7758
- return reload(iFrame);
7759
- default:
7760
- return postIframeMessage(iFrame, { type: messageType, data }, thoughtSpotHost);
7761
- }
7966
+ return new Promise((res, rej) => {
7967
+ if (messageType === HostEvent.Reload) {
7968
+ reload(iFrame);
7969
+ return res(null);
7970
+ }
7971
+ const channel = new MessageChannel();
7972
+ channel.port1.onmessage = ({ data: responseData }) => {
7973
+ channel.port1.close();
7974
+ if (responseData.error) {
7975
+ rej(responseData.error);
7976
+ }
7977
+ else {
7978
+ res(responseData);
7979
+ }
7980
+ };
7981
+ // Close the messageChannel and resolve the promise if timeout.
7982
+ setTimeout(() => {
7983
+ channel.port1.close();
7984
+ res(new Error(ERROR_MESSAGE.TRIGGER_TIMED_OUT));
7985
+ }, TRIGGER_TIMEOUT);
7986
+ return postIframeMessage(iFrame, { type: messageType, data }, thoughtSpotHost, channel);
7987
+ });
7762
7988
  }
7763
7989
 
7764
- var name="@thoughtspot/visual-embed-sdk";var version="1.13.0-alpha.2";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/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","mixpanel-browser":"^2.45.0"};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","@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/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","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","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.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-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",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:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.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","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,description:description,module:module,main:main,types:types,files:files,exports:exports,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};
7990
+ var name="@thoughtspot/visual-embed-sdk";var version="1.13.0";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/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","html-react-parser":"^1.4.12","mixpanel-browser":"^2.45.0","use-deep-compare-effect":"^1.8.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","@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/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","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","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.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-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",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:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.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","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,description:description,module:module,main:main,types:types,files:files,exports:exports,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};
7765
7991
 
7766
7992
  /**
7767
7993
  * Copyright (c) 2022
@@ -7799,6 +8025,22 @@ class TsEmbed {
7799
8025
  * @default false
7800
8026
  */
7801
8027
  this.shouldEncodeUrlQueryParams = false;
8028
+ this.defaultHiddenActions = [Action.ReportError];
8029
+ /**
8030
+ * Send Custom style as part of payload of APP_INIT
8031
+ */
8032
+ this.appInitCb = (_, responder) => {
8033
+ responder({
8034
+ type: EmbedEvent.APP_INIT,
8035
+ data: { customisations: getCustomisations(this.embedConfig) },
8036
+ });
8037
+ };
8038
+ /**
8039
+ * Register APP_INIT event and sendback init payload
8040
+ */
8041
+ this.registerAppInit = () => {
8042
+ this.on(EmbedEvent.APP_INIT, this.appInitCb);
8043
+ };
7802
8044
  this.el = this.getDOMNode(domSelector);
7803
8045
  // TODO: handle error
7804
8046
  this.embedConfig = getEmbedConfig();
@@ -7808,6 +8050,7 @@ class TsEmbed {
7808
8050
  this.isError = false;
7809
8051
  this.viewConfig = viewConfig;
7810
8052
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
8053
+ this.registerAppInit();
7811
8054
  }
7812
8055
  /**
7813
8056
  * Gets a reference to the root DOM node where
@@ -7835,7 +8078,7 @@ class TsEmbed {
7835
8078
  error,
7836
8079
  });
7837
8080
  // Log error
7838
- console.log(error);
8081
+ console.error(error);
7839
8082
  }
7840
8083
  /**
7841
8084
  * Extracts the type field from the event payload
@@ -7927,6 +8170,7 @@ class TsEmbed {
7927
8170
  this.embedConfig.autoLogin === true) {
7928
8171
  queryParams[Param.DisableLoginRedirect] = true;
7929
8172
  }
8173
+ // TODO remove this
7930
8174
  if (this.embedConfig.customCssUrl) {
7931
8175
  queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
7932
8176
  }
@@ -7941,9 +8185,10 @@ class TsEmbed {
7941
8185
  if (disabledActionReason) {
7942
8186
  queryParams[Param.DisableActionReason] = disabledActionReason;
7943
8187
  }
7944
- if (hiddenActions === null || hiddenActions === void 0 ? void 0 : hiddenActions.length) {
7945
- queryParams[Param.HideActions] = hiddenActions;
7946
- }
8188
+ queryParams[Param.HideActions] = [
8189
+ ...this.defaultHiddenActions,
8190
+ ...(hiddenActions !== null && hiddenActions !== void 0 ? hiddenActions : []),
8191
+ ];
7947
8192
  if (Array.isArray(visibleActions)) {
7948
8193
  queryParams[Param.VisibleActions] = visibleActions;
7949
8194
  }
@@ -7965,11 +8210,12 @@ class TsEmbed {
7965
8210
  * @param isAppEmbed A Boolean parameter to specify if you are embedding
7966
8211
  * the full application.
7967
8212
  */
7968
- getV1EmbedBasePath(queryString, showPrimaryNavbar = false, disableProfileAndHelp = false, isAppEmbed = false) {
8213
+ getV1EmbedBasePath(queryString, showPrimaryNavbar = false, disableProfileAndHelp = false, isAppEmbed = false, enableSearchAssist = false) {
7969
8214
  const queryStringFrag = queryString ? `&${queryString}` : '';
7970
8215
  const primaryNavParam = `&primaryNavHidden=${!showPrimaryNavbar}`;
7971
8216
  const disableProfileAndHelpParam = `&profileAndHelpInNavBarHidden=${disableProfileAndHelp}`;
7972
- let queryParams = `?embedApp=true${isAppEmbed ? primaryNavParam : ''}${isAppEmbed ? disableProfileAndHelpParam : ''}${queryStringFrag}`;
8217
+ const enableSearchAssistParam = `&${Param.EnableSearchAssist}=${enableSearchAssist}`;
8218
+ let queryParams = `?embedApp=true${isAppEmbed ? primaryNavParam : ''}${isAppEmbed ? disableProfileAndHelpParam : ''}${enableSearchAssist ? enableSearchAssistParam : ''}${queryStringFrag}`;
7973
8219
  if (this.shouldEncodeUrlQueryParams) {
7974
8220
  queryParams = `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryParams.substr(1))}`;
7975
8221
  }
@@ -8188,9 +8434,8 @@ class TsEmbed {
8188
8434
  * @param data The payload to send with the message
8189
8435
  */
8190
8436
  trigger(messageType, data) {
8191
- processTrigger(this.iFrame, messageType, this.thoughtSpotHost, data);
8192
8437
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
8193
- return this;
8438
+ return processTrigger(this.iFrame, messageType, this.thoughtSpotHost, data);
8194
8439
  }
8195
8440
  /**
8196
8441
  * Marks the ThoughtSpot object to have been rendered
@@ -8332,7 +8577,7 @@ class AppEmbed extends V1Embed {
8332
8577
  const queryString = [filterQuery, queryParams]
8333
8578
  .filter(Boolean)
8334
8579
  .join('&');
8335
- let url = `${this.getV1EmbedBasePath(queryString, this.viewConfig.showPrimaryNavbar, this.viewConfig.disableProfileAndHelp, true)}/${pageId}`;
8580
+ let url = `${this.getV1EmbedBasePath(queryString, this.viewConfig.showPrimaryNavbar, this.viewConfig.disableProfileAndHelp, true, this.viewConfig.enableSearchAssist)}/${pageId}`;
8336
8581
  const tsPostHashParams = this.getThoughtSpotPostUrlParams();
8337
8582
  url = `${url}${tsPostHashParams}`;
8338
8583
  return url;
@@ -8460,7 +8705,7 @@ class LiveboardEmbed extends V1Embed {
8460
8705
  */
8461
8706
  getEmbedParams() {
8462
8707
  const params = this.getBaseQueryParams();
8463
- const { enableVizTransformations, fullHeight, defaultHeight, visibleVizs, liveboardV2 = false, } = this.viewConfig;
8708
+ const { enableVizTransformations, fullHeight, defaultHeight, visibleVizs, liveboardV2 = false, vizId, activeTabId, } = this.viewConfig;
8464
8709
  const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval ||
8465
8710
  this.viewConfig.preventPinboardFilterRemoval;
8466
8711
  if (fullHeight === true) {
@@ -8479,6 +8724,9 @@ class LiveboardEmbed extends V1Embed {
8479
8724
  params[Param.visibleVizs] = visibleVizs;
8480
8725
  }
8481
8726
  params[Param.livedBoardEmbed] = true;
8727
+ if (vizId) {
8728
+ params[Param.vizEmbed] = true;
8729
+ }
8482
8730
  params[Param.LiveboardV2Enabled] = liveboardV2;
8483
8731
  const queryParams = getQueryParamString(params, true);
8484
8732
  return queryParams;
@@ -8491,13 +8739,16 @@ class LiveboardEmbed extends V1Embed {
8491
8739
  * @param runtimeFilters A list of runtime filters to be applied to
8492
8740
  * the Liveboard or visualization on load.
8493
8741
  */
8494
- getIFrameSrc(liveboardId, vizId, runtimeFilters) {
8742
+ getIFrameSrc(liveboardId, vizId, runtimeFilters, activeTabId) {
8495
8743
  const filterQuery = getFilterQuery(runtimeFilters || []);
8496
8744
  const queryParams = this.getEmbedParams();
8497
8745
  const queryString = [filterQuery, queryParams]
8498
8746
  .filter(Boolean)
8499
8747
  .join('&');
8500
8748
  let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${liveboardId}`;
8749
+ if (activeTabId) {
8750
+ url = `${url}/tab/${activeTabId}`;
8751
+ }
8501
8752
  if (vizId) {
8502
8753
  url = `${url}/${vizId}`;
8503
8754
  }
@@ -8505,6 +8756,18 @@ class LiveboardEmbed extends V1Embed {
8505
8756
  url = `${url}${tsPostHashParams}`;
8506
8757
  return url;
8507
8758
  }
8759
+ /**
8760
+ * Triggers an event to the embedded app
8761
+ * @param messageType The event type
8762
+ * @param data The payload to send with the message
8763
+ */
8764
+ trigger(messageType, data = {}) {
8765
+ const dataWithVizId = data;
8766
+ if (this.viewConfig.vizId) {
8767
+ dataWithVizId.vizId = this.viewConfig.vizId;
8768
+ }
8769
+ return super.trigger(messageType, dataWithVizId);
8770
+ }
8508
8771
  /**
8509
8772
  * Render an embedded ThoughtSpot Liveboard or visualization
8510
8773
  * @param renderOptions An object specifying the Liveboard ID,
@@ -8512,7 +8775,7 @@ class LiveboardEmbed extends V1Embed {
8512
8775
  */
8513
8776
  render() {
8514
8777
  var _a;
8515
- const { vizId, runtimeFilters } = this.viewConfig;
8778
+ const { vizId, activeTabId, runtimeFilters } = this.viewConfig;
8516
8779
  const liveboardId = (_a = this.viewConfig.liveboardId) !== null && _a !== void 0 ? _a : this.viewConfig.pinboardId;
8517
8780
  if (!liveboardId) {
8518
8781
  this.handleError(ERROR_MESSAGE.LIVEBOARD_VIZ_ID_VALIDATION);
@@ -8523,7 +8786,7 @@ class LiveboardEmbed extends V1Embed {
8523
8786
  this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
8524
8787
  }
8525
8788
  super.render();
8526
- const src = this.getIFrameSrc(liveboardId, vizId, runtimeFilters);
8789
+ const src = this.getIFrameSrc(liveboardId, vizId, runtimeFilters, activeTabId);
8527
8790
  this.renderV1Embed(src);
8528
8791
  return this;
8529
8792
  }
@@ -8581,7 +8844,7 @@ class SearchEmbed extends TsEmbed {
8581
8844
  */
8582
8845
  getIFrameSrc(answerId, dataSources) {
8583
8846
  var _a;
8584
- const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
8847
+ const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
8585
8848
  const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
8586
8849
  const queryParams = this.getBaseQueryParams();
8587
8850
  queryParams[Param.HideActions] = [
@@ -8625,6 +8888,11 @@ class SearchEmbed extends TsEmbed {
8625
8888
  const { answerId, dataSources } = this.viewConfig;
8626
8889
  const src = this.getIFrameSrc(answerId, dataSources);
8627
8890
  this.renderIFrame(src, this.viewConfig.frameParams);
8891
+ getAuthPromise().then(() => {
8892
+ if (checkReleaseVersionInBeta(getReleaseVersion(), getEmbedConfig().suppressSearchEmbedBetaWarning)) {
8893
+ alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
8894
+ }
8895
+ });
8628
8896
  return this;
8629
8897
  }
8630
8898
  }