@thoughtspot/visual-embed-sdk 1.19.0 → 1.20.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +1 -1
  3. package/dist/src/auth.d.ts +9 -2
  4. package/dist/src/auth.d.ts.map +1 -1
  5. package/dist/src/auth.spec.d.ts.map +1 -1
  6. package/dist/src/embed/base.d.ts.map +1 -1
  7. package/dist/src/embed/search.d.ts +0 -4
  8. package/dist/src/embed/search.d.ts.map +1 -1
  9. package/dist/src/embed/ts-embed.d.ts +4 -0
  10. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +3 -3
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/types.d.ts +85 -4
  14. package/dist/src/types.d.ts.map +1 -1
  15. package/dist/src/utils/processData.d.ts.map +1 -1
  16. package/dist/src/utils.d.ts.map +1 -1
  17. package/dist/tsembed.es.js +167 -29
  18. package/dist/tsembed.js +168 -28
  19. package/lib/package.json +4 -10
  20. package/lib/src/auth.d.ts +9 -2
  21. package/lib/src/auth.d.ts.map +1 -1
  22. package/lib/src/auth.js +38 -14
  23. package/lib/src/auth.js.map +1 -1
  24. package/lib/src/auth.spec.d.ts.map +1 -1
  25. package/lib/src/auth.spec.js +24 -2
  26. package/lib/src/auth.spec.js.map +1 -1
  27. package/lib/src/embed/base.d.ts.map +1 -1
  28. package/lib/src/embed/base.js +9 -0
  29. package/lib/src/embed/base.js.map +1 -1
  30. package/lib/src/embed/base.spec.js +17 -0
  31. package/lib/src/embed/base.spec.js.map +1 -1
  32. package/lib/src/embed/search.d.ts +0 -4
  33. package/lib/src/embed/search.d.ts.map +1 -1
  34. package/lib/src/embed/search.js +1 -1
  35. package/lib/src/embed/search.js.map +1 -1
  36. package/lib/src/embed/ts-embed.d.ts +4 -0
  37. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  38. package/lib/src/embed/ts-embed.js +43 -3
  39. package/lib/src/embed/ts-embed.js.map +1 -1
  40. package/lib/src/embed/ts-embed.spec.js +139 -2
  41. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  42. package/lib/src/index.d.ts +3 -3
  43. package/lib/src/index.d.ts.map +1 -1
  44. package/lib/src/index.js +3 -3
  45. package/lib/src/index.js.map +1 -1
  46. package/lib/src/types.d.ts +85 -4
  47. package/lib/src/types.d.ts.map +1 -1
  48. package/lib/src/types.js +72 -2
  49. package/lib/src/types.js.map +1 -1
  50. package/lib/src/utils/processData.d.ts.map +1 -1
  51. package/lib/src/utils/processData.js +1 -11
  52. package/lib/src/utils/processData.js.map +1 -1
  53. package/lib/src/utils/processData.spec.js +0 -24
  54. package/lib/src/utils/processData.spec.js.map +1 -1
  55. package/lib/src/utils.d.ts.map +1 -1
  56. package/lib/src/utils.js +1 -1
  57. package/lib/src/utils.js.map +1 -1
  58. package/lib/src/visual-embed-sdk.d.ts +97 -13
  59. package/package.json +4 -10
  60. package/src/auth.spec.ts +32 -3
  61. package/src/auth.ts +46 -14
  62. package/src/embed/base.spec.ts +17 -0
  63. package/src/embed/base.ts +12 -0
  64. package/src/embed/search.ts +0 -5
  65. package/src/embed/ts-embed.spec.ts +164 -2
  66. package/src/embed/ts-embed.ts +49 -2
  67. package/src/index.ts +4 -2
  68. package/src/types.ts +83 -3
  69. package/src/utils/processData.spec.ts +0 -34
  70. package/src/utils/processData.ts +0 -12
  71. package/src/utils.ts +4 -1
@@ -229,11 +229,18 @@ var AuthType;
229
229
  */
230
230
  AuthType["AuthServer"] = "AuthServer";
231
231
  /**
232
- * Trusted authentication server, Use you own authentication server
232
+ * Trusted authentication server, Use your own authentication server
233
233
  * which returns a bearer token, generated using the secret_key obtained from
234
234
  * ThoughtSpot.
235
235
  */
236
236
  AuthType["TrustedAuthToken"] = "AuthServer";
237
+ /**
238
+ * Trusted authentication server Cookieless, Use you own authentication server
239
+ * which returns a bearer token, generated using the secret_key obtained from
240
+ * ThoughtSpot. This uses a cookieless authentication approach, recommended
241
+ * to by pass third-party cookie-blocking restriction implemented by some browsers
242
+ */
243
+ AuthType["TrustedAuthTokenCookieless"] = "AuthServerCookieless";
237
244
  /**
238
245
  * Use the ThoughtSpot login API to authenticate to the cluster directly.
239
246
  *
@@ -412,6 +419,12 @@ var EmbedEvent;
412
419
  * @hidden
413
420
  */
414
421
  EmbedEvent["EmbedIframeCenter"] = "EmbedIframeCenter";
422
+ /**
423
+ * Emitted when the "Get Data" button in Search Bar embed
424
+ * is clicked.
425
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.0-sw
426
+ */
427
+ EmbedEvent["GetDataClick"] = "getDataClick";
415
428
  /**
416
429
  * Detects the route change.
417
430
  */
@@ -639,10 +652,12 @@ var HostEvent;
639
652
  * - Although an array, only a single source
640
653
  * is supported at this time.
641
654
  * @param - searchQuery - The search query
655
+ * @param - execute - execute the existing / updated query
642
656
  * @example
643
657
  * searchEmbed.trigger(HostEvent.Search, {
644
658
  * searchQuery: "[sales] by [item type],
645
659
  * "dataSourceIds: ["cd252e5c-b552-49a8-821d-3eadaa049cca"]
660
+ * "execute": true
646
661
  * })
647
662
  */
648
663
  HostEvent["Search"] = "search";
@@ -848,7 +863,7 @@ var HostEvent;
848
863
  /**
849
864
  * Get TML for the current search.
850
865
  * @example searchEmbed.trigger(HostEvent.GetTML)
851
- * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
866
+ * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl
852
867
  */
853
868
  HostEvent["GetTML"] = "getTML";
854
869
  /**
@@ -1024,7 +1039,10 @@ var Param;
1024
1039
  // eslint-disable-next-line @typescript-eslint/no-shadow
1025
1040
  Param["AuthType"] = "authType";
1026
1041
  Param["IconSpriteUrl"] = "iconSprite";
1042
+ Param["cookieless"] = "cookieless";
1027
1043
  Param["ContextMenuTrigger"] = "isContextMenuEnabledOnLeftClick";
1044
+ Param["LinkOverride"] = "linkOverride";
1045
+ Param["ShowInsertToSlide"] = "insertInToSlide";
1028
1046
  })(Param || (Param = {}));
1029
1047
  /**
1030
1048
  * The list of actions that can be performed on visual ThoughtSpot
@@ -1182,6 +1200,58 @@ var Action;
1182
1200
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1183
1201
  */
1184
1202
  Action["RemoveCrossFilter"] = "context-menu-item-remove-cross-filter";
1203
+ /**
1204
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1205
+ */
1206
+ Action["AxisMenuAggregate"] = "axisMenuAggregate";
1207
+ /**
1208
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1209
+ */
1210
+ Action["AxisMenuTimeBucket"] = "axisMenuTimeBucket";
1211
+ /**
1212
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1213
+ */
1214
+ Action["AxisMenuFilter"] = "axisMenuFilter";
1215
+ /**
1216
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1217
+ */
1218
+ Action["AxisMenuConditionalFormat"] = "axisMenuConditionalFormat";
1219
+ /**
1220
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1221
+ */
1222
+ Action["AxisMenuSort"] = "axisMenuSort";
1223
+ /**
1224
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1225
+ */
1226
+ Action["AxisMenuGroup"] = "axisMenuGroup";
1227
+ /**
1228
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1229
+ */
1230
+ Action["AxisMenuPosition"] = "axisMenuPosition";
1231
+ /**
1232
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1233
+ */
1234
+ Action["AxisMenuRename"] = "axisMenuRename";
1235
+ /**
1236
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1237
+ */
1238
+ Action["AxisMenuEdit"] = "axisMenuEdit";
1239
+ /**
1240
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1241
+ */
1242
+ Action["AxisMenuNumberFormat"] = "axisMenuNumberFormat";
1243
+ /**
1244
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1245
+ */
1246
+ Action["AxisMenuTextWrapping"] = "axisMenuTextWrapping";
1247
+ /**
1248
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1249
+ */
1250
+ Action["AxisMenuRemove"] = "axisMenuRemove";
1251
+ /**
1252
+ * @hidden
1253
+ */
1254
+ Action["InsertInToSlide"] = "insertInToSlide";
1185
1255
  })(Action || (Action = {}));
1186
1256
  // eslint-disable-next-line no-shadow
1187
1257
  var OperationType;
@@ -8829,6 +8899,10 @@ let samlAuthWindow = null;
8829
8899
  // eslint-disable-next-line import/no-mutable-exports
8830
8900
  let samlCompletionPromise = null;
8831
8901
  let sessionInfo = null;
8902
+ let sessionInfoResolver = null;
8903
+ const sessionInfoPromise = new Promise((resolve) => {
8904
+ sessionInfoResolver = resolve;
8905
+ });
8832
8906
  let releaseVersion = '';
8833
8907
  const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
8834
8908
  const EndPoints = {
@@ -8895,7 +8969,7 @@ function notifyAuthSuccess() {
8895
8969
  console.error('SDK not initialized');
8896
8970
  return;
8897
8971
  }
8898
- authEE.emit(AuthStatus.SUCCESS);
8972
+ authEE.emit(AuthStatus.SUCCESS, sessionInfo);
8899
8973
  }
8900
8974
  function notifyAuthFailure(failureType) {
8901
8975
  if (!authEE) {
@@ -8934,9 +9008,17 @@ async function isLoggedIn(thoughtSpotHost) {
8934
9008
  function getReleaseVersion() {
8935
9009
  return releaseVersion;
8936
9010
  }
9011
+ /**
9012
+ * Return a promise that resolves with the session info when authentication is
9013
+ * successful. And info is available.
9014
+ */
9015
+ function getSessionInfo() {
9016
+ return sessionInfoPromise;
9017
+ }
8937
9018
  function initSession(sessionDetails) {
8938
9019
  sessionInfo = sessionDetails;
8939
9020
  initMixpanel(sessionInfo);
9021
+ sessionInfoResolver(sessionInfo);
8940
9022
  }
8941
9023
  const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
8942
9024
  'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
@@ -8965,6 +9047,19 @@ function removeSSORedirectUrlMarker() {
8965
9047
  // parent page URL until we find any use case where that creates an issue.
8966
9048
  window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
8967
9049
  }
9050
+ const getAuthenticaionToken = async (embedConfig) => {
9051
+ const { authEndpoint, getAuthToken } = embedConfig;
9052
+ let authToken = null;
9053
+ if (getAuthToken) {
9054
+ authToken = await getAuthToken();
9055
+ alertForDuplicateToken(authToken);
9056
+ }
9057
+ else {
9058
+ const response = await fetchAuthTokenService(authEndpoint);
9059
+ authToken = await response.text();
9060
+ }
9061
+ return authToken;
9062
+ };
8968
9063
  /**
8969
9064
  * Perform token based authentication
8970
9065
  * @param embedConfig The embed configuration
@@ -8976,15 +9071,7 @@ const doTokenAuth = async (embedConfig) => {
8976
9071
  }
8977
9072
  loggedInStatus = await isLoggedIn(thoughtSpotHost);
8978
9073
  if (!loggedInStatus) {
8979
- let authToken = null;
8980
- if (getAuthToken) {
8981
- authToken = await getAuthToken();
8982
- alertForDuplicateToken(authToken);
8983
- }
8984
- else {
8985
- const response = await fetchAuthTokenService(authEndpoint);
8986
- authToken = await response.text();
8987
- }
9074
+ const authToken = await getAuthenticaionToken(embedConfig);
8988
9075
  let resp;
8989
9076
  try {
8990
9077
  resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
@@ -9002,6 +9089,17 @@ const doTokenAuth = async (embedConfig) => {
9002
9089
  }
9003
9090
  return loggedInStatus;
9004
9091
  };
9092
+ /**
9093
+ * Validate embedConfig parameters required for cookielessTokenAuth
9094
+ * @param embedConfig The embed configuration
9095
+ */
9096
+ const doCookielessTokenAuth = async (embedConfig) => {
9097
+ const { authEndpoint, getAuthToken } = embedConfig;
9098
+ if (!authEndpoint && !getAuthToken) {
9099
+ throw new Error('Either auth endpoint or getAuthToken function must be provided');
9100
+ }
9101
+ return Promise.resolve(true);
9102
+ };
9005
9103
  /**
9006
9104
  * Perform basic authentication to the ThoughtSpot cluster using the cluster
9007
9105
  * credentials.
@@ -9078,7 +9176,7 @@ const doSSOAuth = async (embedConfig, ssoEndPoint) => {
9078
9176
  return;
9079
9177
  }
9080
9178
  const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
9081
- if (embedConfig.noRedirect || embedConfig.inPopup) {
9179
+ if (embedConfig.inPopup) {
9082
9180
  await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
9083
9181
  loggedInStatus = true;
9084
9182
  return;
@@ -9089,7 +9187,7 @@ const doSamlAuth = async (embedConfig) => {
9089
9187
  const { thoughtSpotHost } = embedConfig;
9090
9188
  // redirect for SSO, when the SSO authentication is done, this page will be loaded
9091
9189
  // again and the same JS will execute again.
9092
- const ssoRedirectUrl = embedConfig.noRedirect
9190
+ const ssoRedirectUrl = embedConfig.inPopup
9093
9191
  ? `${thoughtSpotHost}/v2/#/embed/saml-complete`
9094
9192
  : getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
9095
9193
  // bring back the page to the same URL
@@ -9132,6 +9230,8 @@ const authenticate = async (embedConfig) => {
9132
9230
  case AuthType.AuthServer:
9133
9231
  case AuthType.TrustedAuthToken:
9134
9232
  return doTokenAuth(embedConfig);
9233
+ case AuthType.TrustedAuthTokenCookieless:
9234
+ return doCookielessTokenAuth(embedConfig);
9135
9235
  case AuthType.Basic:
9136
9236
  return doBasicAuth(embedConfig);
9137
9237
  default:
@@ -9213,6 +9313,14 @@ function sanity(embedConfig) {
9213
9313
  }
9214
9314
  }
9215
9315
  }
9316
+ function backwardCompat(embedConfig) {
9317
+ const newConfig = { ...embedConfig };
9318
+ if (embedConfig.noRedirect !== undefined &&
9319
+ embedConfig.inPopup === undefined) {
9320
+ newConfig.inPopup = embedConfig.noRedirect;
9321
+ }
9322
+ return newConfig;
9323
+ }
9216
9324
  /**
9217
9325
  * Initializes the Visual Embed SDK globally and perform
9218
9326
  * authentication if applicable.
@@ -9231,6 +9339,7 @@ const init = (embedConfig) => {
9231
9339
  ...embedConfig,
9232
9340
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
9233
9341
  };
9342
+ config = backwardCompat(config);
9234
9343
  const authEE = new eventemitter3();
9235
9344
  setAuthEE(authEE);
9236
9345
  handleAuth();
@@ -9364,14 +9473,6 @@ function processAuthInit(e) {
9364
9473
  },
9365
9474
  };
9366
9475
  }
9367
- function processAuthExpire(e) {
9368
- const { autoLogin = false } = getEmbedConfig(); // Set default to false
9369
- if (autoLogin) {
9370
- handleAuth();
9371
- }
9372
- notifyAuthFailure(AuthFailureType.EXPIRY);
9373
- return e;
9374
- }
9375
9476
  function processNoCookieAccess(e, containerEl) {
9376
9477
  const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
9377
9478
  if (!suppressNoCookieAccessAlert) {
@@ -9406,8 +9507,6 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
9406
9507
  return processCustomAction(e, thoughtSpotHost);
9407
9508
  case EmbedEvent.AuthInit:
9408
9509
  return processAuthInit(e);
9409
- case EmbedEvent.AuthExpire:
9410
- return processAuthExpire(e);
9411
9510
  case EmbedEvent.NoCookieAccess:
9412
9511
  return processNoCookieAccess(e, containerEl);
9413
9512
  case EmbedEvent.AuthFailure:
@@ -9461,7 +9560,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
9461
9560
  });
9462
9561
  }
9463
9562
 
9464
- var name="@thoughtspot/visual-embed-sdk";var version="1.19.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":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.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",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 --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",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","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","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.13.1","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":"^6.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.9.4","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,typesVersions:typesVersions,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};
9563
+ var name="@thoughtspot/visual-embed-sdk";var version="1.20.0-alpha.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":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.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",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 --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",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",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.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.13.1","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":"6.7.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":"^8.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.9.4","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,typesVersions:typesVersions,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};
9465
9564
 
9466
9565
  /**
9467
9566
  * Copyright (c) 2022
@@ -9476,6 +9575,7 @@ const { version: version$1 } = pkgInfo;
9476
9575
  * Global prefix for all Thoughtspot postHash Params.
9477
9576
  */
9478
9577
  const THOUGHTSPOT_PARAM_PREFIX = 'ts-';
9578
+ const TS_EMBED_ID = '_thoughtspot-embed';
9479
9579
  /**
9480
9580
  * The event id map from v2 event names to v1 event id
9481
9581
  * v1 events are the classic embed events implemented in Blink v1
@@ -9501,19 +9601,42 @@ class TsEmbed {
9501
9601
  /**
9502
9602
  * Send Custom style as part of payload of APP_INIT
9503
9603
  */
9504
- this.appInitCb = (_, responder) => {
9604
+ this.appInitCb = async (_, responder) => {
9605
+ let authToken = '';
9606
+ if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
9607
+ authToken = await getAuthenticaionToken(this.embedConfig);
9608
+ }
9505
9609
  responder({
9506
9610
  type: EmbedEvent.APP_INIT,
9507
9611
  data: {
9508
9612
  customisations: getCustomisations(this.embedConfig, this.viewConfig),
9613
+ authToken,
9509
9614
  },
9510
9615
  });
9511
9616
  };
9617
+ /**
9618
+ * Sends updated auth token to the iFrame to avoid user logout
9619
+ */
9620
+ this.updateAuthToken = async (_, responder) => {
9621
+ const { autoLogin = false, authType } = this.embedConfig; // Set autoLogin default to false
9622
+ if (authType === AuthType.TrustedAuthTokenCookieless) {
9623
+ const authToken = await getAuthenticaionToken(this.embedConfig);
9624
+ responder({
9625
+ type: EmbedEvent.AuthExpire,
9626
+ data: { authToken },
9627
+ });
9628
+ }
9629
+ else if (autoLogin) {
9630
+ handleAuth();
9631
+ }
9632
+ notifyAuthFailure(AuthFailureType.EXPIRY);
9633
+ };
9512
9634
  /**
9513
9635
  * Register APP_INIT event and sendback init payload
9514
9636
  */
9515
9637
  this.registerAppInit = () => {
9516
9638
  this.on(EmbedEvent.APP_INIT, this.appInitCb);
9639
+ this.on(EmbedEvent.AuthExpire, this.updateAuthToken);
9517
9640
  };
9518
9641
  this.el = getDOMNode(domSelector);
9519
9642
  // TODO: handle error
@@ -9638,7 +9761,10 @@ class TsEmbed {
9638
9761
  if (this.embedConfig.authType === AuthType.EmbeddedSSO) {
9639
9762
  queryParams[Param.ForceSAMLAutoRedirect] = true;
9640
9763
  }
9641
- const { disabledActions, disabledActionReason, hiddenActions, visibleActions, showAlerts, additionalFlags, locale, customizations, contextMenuTrigger, } = this.viewConfig;
9764
+ if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
9765
+ queryParams[Param.cookieless] = true;
9766
+ }
9767
+ const { disabledActions, disabledActionReason, hiddenActions, visibleActions, showAlerts, additionalFlags, locale, customizations, contextMenuTrigger, linkOverride, insertInToSlide, } = this.viewConfig;
9642
9768
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
9643
9769
  this.handleError('You cannot have both hidden actions and visible actions');
9644
9770
  return queryParams;
@@ -9684,6 +9810,12 @@ class TsEmbed {
9684
9810
  if (additionalFlags && additionalFlags.constructor.name === 'Object') {
9685
9811
  Object.assign(queryParams, additionalFlags);
9686
9812
  }
9813
+ if (linkOverride) {
9814
+ queryParams[Param.LinkOverride] = linkOverride;
9815
+ }
9816
+ if (insertInToSlide) {
9817
+ queryParams[Param.ShowInsertToSlide] = insertInToSlide;
9818
+ }
9687
9819
  return queryParams;
9688
9820
  }
9689
9821
  /**
@@ -9741,6 +9873,7 @@ class TsEmbed {
9741
9873
  this.iFrame =
9742
9874
  this.iFrame || document.createElement('iframe');
9743
9875
  this.iFrame.src = url;
9876
+ this.iFrame.id = TS_EMBED_ID;
9744
9877
  // according to screenfull.js documentation
9745
9878
  // allowFullscreen, webkitallowfullscreen and mozallowfullscreen must be true
9746
9879
  this.iFrame.allowFullscreen = true;
@@ -9794,13 +9927,18 @@ class TsEmbed {
9794
9927
  });
9795
9928
  }
9796
9929
  insertIntoDOM(child) {
9930
+ var _a;
9797
9931
  if (this.viewConfig.insertAsSibling) {
9798
9932
  if (typeof child === 'string') {
9799
9933
  const div = document.createElement('div');
9800
9934
  div.innerHTML = child;
9935
+ div.id = TS_EMBED_ID;
9801
9936
  // eslint-disable-next-line no-param-reassign
9802
9937
  child = div;
9803
9938
  }
9939
+ if (((_a = this.el.nextElementSibling) === null || _a === void 0 ? void 0 : _a.id) === TS_EMBED_ID) {
9940
+ this.el.nextElementSibling.remove();
9941
+ }
9804
9942
  this.el.parentElement.insertBefore(child, this.el.nextSibling);
9805
9943
  }
9806
9944
  else if (typeof child === 'string') {
@@ -10354,7 +10492,7 @@ class SearchEmbed extends TsEmbed {
10354
10492
  */
10355
10493
  getIFrameSrc(answerId, dataSources) {
10356
10494
  var _a;
10357
- const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, } = this.viewConfig;
10495
+ const { hideResults, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, } = this.viewConfig;
10358
10496
  const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
10359
10497
  const queryParams = this.getBaseQueryParams();
10360
10498
  queryParams[Param.HideActions] = [
@@ -10471,4 +10609,4 @@ class SearchBarEmbed extends TsEmbed {
10471
10609
  }
10472
10610
  }
10473
10611
 
10474
- export { Action, AppEmbed, AuthEvent, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SearchBarEmbed, SearchEmbed, init, logout$1 as logout, prefetch };
10612
+ export { Action, AppEmbed, AuthEvent, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SearchBarEmbed, SearchEmbed, getEmbedConfig as getInitConfig, getSessionInfo, init, logout$1 as logout, prefetch };