@thoughtspot/visual-embed-sdk 1.28.0-alpha.5 → 1.28.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.
- package/README.md +1 -1
- package/cjs/package.json +2 -2
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +2 -2
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/authToken.d.ts +0 -6
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +0 -6
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/embed/app.d.ts +13 -20
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +2 -2
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +5 -7
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -1
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +2 -8
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/search.d.ts +5 -11
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -4
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +6 -6
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +18 -9
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +0 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +1 -3
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +12 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +36 -29
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +23 -12
- package/cjs/src/types.js.map +1 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +0 -6
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +13 -20
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -8
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +5 -11
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +36 -29
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1465 -1460
- package/dist/tsembed-react.js +2225 -2233
- package/dist/tsembed.es.js +1850 -1846
- package/dist/tsembed.js +15342 -15352
- package/dist/visual-embed-sdk-react-full.d.ts +54 -75
- package/dist/visual-embed-sdk-react.d.ts +54 -75
- package/dist/visual-embed-sdk.d.ts +54 -75
- package/lib/package.json +2 -2
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +3 -3
- package/lib/src/auth.js.map +1 -1
- package/lib/src/authToken.d.ts +0 -6
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +0 -6
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/embed/app.d.ts +13 -20
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +2 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +5 -7
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +2 -8
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/search.d.ts +5 -11
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +5 -5
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +9 -9
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +18 -9
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +0 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +0 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.spec.js +12 -0
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +36 -29
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +23 -12
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +1 -1
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +58 -83
- package/package.json +2 -2
- package/src/auth.ts +6 -6
- package/src/authToken.ts +0 -6
- package/src/embed/app.ts +15 -27
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/base.ts +12 -14
- package/src/embed/liveboard.ts +3 -16
- package/src/embed/search.ts +10 -19
- package/src/embed/ts-embed.spec.ts +34 -26
- package/src/embed/ts-embed.ts +39 -43
- package/src/index.ts +0 -2
- package/src/react/index.spec.tsx +29 -0
- package/src/types.ts +37 -29
- package/src/utils/authService/authService.spec.ts +4 -4
package/dist/tsembed-react.es.js
CHANGED
|
@@ -564,6 +564,7 @@ var AuthType;
|
|
|
564
564
|
* .then((data) => data.token);
|
|
565
565
|
* }
|
|
566
566
|
* });
|
|
567
|
+
* });
|
|
567
568
|
* ```
|
|
568
569
|
*/
|
|
569
570
|
AuthType["TrustedAuthToken"] = "AuthServer";
|
|
@@ -596,30 +597,38 @@ var AuthType;
|
|
|
596
597
|
*/
|
|
597
598
|
AuthType["Basic"] = "Basic";
|
|
598
599
|
})(AuthType || (AuthType = {}));
|
|
600
|
+
/**
|
|
601
|
+
*
|
|
602
|
+
* This option does not apply to the classic homepage experience.
|
|
603
|
+
* To access the updated modular homepage,
|
|
604
|
+
* set `modularHomeExperience` to `true`
|
|
605
|
+
* (available as Early Access feature in 9.12.5.cl).
|
|
606
|
+
*
|
|
607
|
+
*/
|
|
599
608
|
var HomeLeftNavItem;
|
|
600
609
|
(function (HomeLeftNavItem) {
|
|
601
610
|
/**
|
|
602
|
-
* @version SDK: 1.
|
|
611
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
603
612
|
*/
|
|
604
613
|
HomeLeftNavItem["SearchData"] = "search-data";
|
|
605
614
|
/**
|
|
606
|
-
* @version SDK: 1.
|
|
615
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
607
616
|
*/
|
|
608
617
|
HomeLeftNavItem["Home"] = "insights-home";
|
|
609
618
|
/**
|
|
610
|
-
* @version SDK: 1.
|
|
619
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
611
620
|
*/
|
|
612
621
|
HomeLeftNavItem["Liveboards"] = "liveboards";
|
|
613
622
|
/**
|
|
614
|
-
* @version SDK: 1.
|
|
623
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
615
624
|
*/
|
|
616
625
|
HomeLeftNavItem["Answers"] = "answers";
|
|
617
626
|
/**
|
|
618
|
-
* @version SDK: 1.
|
|
627
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
619
628
|
*/
|
|
620
629
|
HomeLeftNavItem["MonitorSubscription"] = "monitor-alerts";
|
|
621
630
|
/**
|
|
622
|
-
* @version SDK: 1.
|
|
631
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
623
632
|
*/
|
|
624
633
|
HomeLeftNavItem["SpotIQAnalysis"] = "spotiq-analysis";
|
|
625
634
|
})(HomeLeftNavItem || (HomeLeftNavItem = {}));
|
|
@@ -687,7 +696,12 @@ var RuntimeFilterOp;
|
|
|
687
696
|
RuntimeFilterOp["IN"] = "IN";
|
|
688
697
|
})(RuntimeFilterOp || (RuntimeFilterOp = {}));
|
|
689
698
|
/**
|
|
690
|
-
* Home page module that can be hidden
|
|
699
|
+
* Home page module that can be hidden.
|
|
700
|
+
* **Note**: This option does not apply to the classic homepage.
|
|
701
|
+
* To access the updated modular homepage, set
|
|
702
|
+
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
703
|
+
*
|
|
704
|
+
* @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
|
|
691
705
|
*/
|
|
692
706
|
// eslint-disable-next-line no-shadow
|
|
693
707
|
var HomepageModule;
|
|
@@ -710,10 +724,6 @@ var HomepageModule;
|
|
|
710
724
|
HomepageModule["MyLibrary"] = "MY_LIBRARY";
|
|
711
725
|
/**
|
|
712
726
|
* Trending list
|
|
713
|
-
*
|
|
714
|
-
* **Note**: This option does not apply to the classic homepage.
|
|
715
|
-
* To access the updated modular homepage, set
|
|
716
|
-
* `modularHomeExperience` to `true` (available in Early Access from 9.12.0.cl onwards).
|
|
717
727
|
*/
|
|
718
728
|
HomepageModule["Trending"] = "TRENDING";
|
|
719
729
|
/**
|
|
@@ -929,7 +939,8 @@ var EmbedEvent;
|
|
|
929
939
|
*
|
|
930
940
|
* API - API call failure error.
|
|
931
941
|
*
|
|
932
|
-
* FULLSCREEN - Error when presenting a Liveboard or visualization in full screen
|
|
942
|
+
* FULLSCREEN - Error when presenting a Liveboard or visualization in full screen
|
|
943
|
+
* mode.
|
|
933
944
|
*
|
|
934
945
|
* SINGLE_VALUE_FILTER - Error due to multiple values in the single value filter.
|
|
935
946
|
*
|
|
@@ -5792,6 +5803,8 @@ function isEqual(value, other) {
|
|
|
5792
5803
|
|
|
5793
5804
|
var isEqual_1 = isEqual;
|
|
5794
5805
|
|
|
5806
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.28.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/**","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",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-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","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","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"};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","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",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","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","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","@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/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","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","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-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:"2.30.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"};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,"size-limit":[{path:"dist/tsembed.js",limit:"45 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};
|
|
5807
|
+
|
|
5795
5808
|
/**
|
|
5796
5809
|
* Checks if `value` is `undefined`.
|
|
5797
5810
|
*
|
|
@@ -6064,782 +6077,235 @@ const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
|
6064
6077
|
throw new Error(INVALID_TOKEN_ERR);
|
|
6065
6078
|
}
|
|
6066
6079
|
};
|
|
6067
|
-
/**
|
|
6068
|
-
* Resets the auth token and a new token will be fetched on the next request.
|
|
6069
|
-
*
|
|
6070
|
-
* @version SDK: 1.28.0 | ThoughtSpot: *
|
|
6071
|
-
* @group Authentication / Init
|
|
6072
|
-
*/
|
|
6073
6080
|
const resetCachedAuthToken = () => {
|
|
6074
6081
|
cachedAuthToken = null;
|
|
6075
6082
|
};
|
|
6076
6083
|
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
*
|
|
6081
|
-
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
6082
|
-
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
6083
|
-
* @group Global methods
|
|
6084
|
-
*/
|
|
6085
|
-
const getEmbedConfig = () => config;
|
|
6086
|
-
|
|
6087
|
-
/**
|
|
6088
|
-
* Fetch wrapper that adds the authentication token to the request.
|
|
6089
|
-
* Use this to call the ThoughtSpot APIs when using the visual embed sdk.
|
|
6090
|
-
*
|
|
6091
|
-
* @param input
|
|
6092
|
-
* @param init
|
|
6093
|
-
* @version SDK: 1.28.0
|
|
6094
|
-
* @group Global methods
|
|
6095
|
-
*/
|
|
6096
|
-
const tokenizedFetch = async (input, init) => {
|
|
6097
|
-
const embedConfig = getEmbedConfig();
|
|
6098
|
-
if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
|
|
6099
|
-
return fetch(input, init);
|
|
6100
|
-
}
|
|
6101
|
-
const req = new Request(input, init);
|
|
6102
|
-
const authToken = await getAuthenticationToken(embedConfig);
|
|
6103
|
-
if (authToken) {
|
|
6104
|
-
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
6105
|
-
}
|
|
6106
|
-
return fetch(req);
|
|
6084
|
+
var Config = {
|
|
6085
|
+
DEBUG: false,
|
|
6086
|
+
LIB_VERSION: '2.45.0'
|
|
6107
6087
|
};
|
|
6108
6088
|
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
'accept-language': 'en-us',
|
|
6127
|
-
},
|
|
6128
|
-
body: JSON.stringify({
|
|
6129
|
-
operationName,
|
|
6130
|
-
query,
|
|
6131
|
-
variables,
|
|
6132
|
-
}),
|
|
6133
|
-
credentials: 'include',
|
|
6134
|
-
});
|
|
6135
|
-
const result = await response.json();
|
|
6136
|
-
const dataValues = Object.values(result.data);
|
|
6137
|
-
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
6138
|
-
}
|
|
6139
|
-
catch (error) {
|
|
6140
|
-
return error;
|
|
6141
|
-
}
|
|
6089
|
+
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
6090
|
+
var window$1;
|
|
6091
|
+
if (typeof(window) === 'undefined') {
|
|
6092
|
+
var loc = {
|
|
6093
|
+
hostname: ''
|
|
6094
|
+
};
|
|
6095
|
+
window$1 = {
|
|
6096
|
+
navigator: { userAgent: '' },
|
|
6097
|
+
document: {
|
|
6098
|
+
location: loc,
|
|
6099
|
+
referrer: ''
|
|
6100
|
+
},
|
|
6101
|
+
screen: { width: 0, height: 0 },
|
|
6102
|
+
location: loc
|
|
6103
|
+
};
|
|
6104
|
+
} else {
|
|
6105
|
+
window$1 = window;
|
|
6142
6106
|
}
|
|
6143
6107
|
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
name
|
|
6149
|
-
description
|
|
6150
|
-
authorName
|
|
6151
|
-
authorDisplayName
|
|
6152
|
-
isExternal
|
|
6153
|
-
type
|
|
6154
|
-
created
|
|
6155
|
-
modified
|
|
6156
|
-
columns {
|
|
6157
|
-
id
|
|
6158
|
-
name
|
|
6159
|
-
author
|
|
6160
|
-
authorDisplayName
|
|
6161
|
-
description
|
|
6162
|
-
dataType
|
|
6163
|
-
type
|
|
6164
|
-
modified
|
|
6165
|
-
ownerName
|
|
6166
|
-
owner
|
|
6167
|
-
dataRecency
|
|
6168
|
-
sources {
|
|
6169
|
-
tableId
|
|
6170
|
-
tableName
|
|
6171
|
-
columnId
|
|
6172
|
-
columnName
|
|
6173
|
-
__typename
|
|
6174
|
-
}
|
|
6175
|
-
synonyms
|
|
6176
|
-
cohortAnswerId
|
|
6177
|
-
__typename
|
|
6178
|
-
}
|
|
6179
|
-
relationships
|
|
6180
|
-
destinationRelationships
|
|
6181
|
-
dataSourceId
|
|
6182
|
-
__typename
|
|
6183
|
-
}
|
|
6184
|
-
}
|
|
6185
|
-
`;
|
|
6186
|
-
const sourceDetailCache = new Map();
|
|
6187
|
-
/**
|
|
6188
|
-
*
|
|
6189
|
-
* @param thoughtSpotHost
|
|
6190
|
-
* @param sourceId
|
|
6191
|
-
*/
|
|
6192
|
-
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
6193
|
-
if (sourceDetailCache.get(sourceId)) {
|
|
6194
|
-
return sourceDetailCache.get(sourceId);
|
|
6195
|
-
}
|
|
6196
|
-
const details = await graphqlQuery({
|
|
6197
|
-
query: getSourceDetailQuery,
|
|
6198
|
-
variables: {
|
|
6199
|
-
ids: [sourceId],
|
|
6200
|
-
},
|
|
6201
|
-
thoughtSpotHost,
|
|
6202
|
-
});
|
|
6203
|
-
const souceDetails = details[0];
|
|
6204
|
-
if (souceDetails) {
|
|
6205
|
-
sourceDetailCache.set(sourceId, souceDetails);
|
|
6206
|
-
}
|
|
6207
|
-
return souceDetails;
|
|
6208
|
-
}
|
|
6108
|
+
/*
|
|
6109
|
+
* Saved references to long variable names, so that closure compiler can
|
|
6110
|
+
* minimize file size.
|
|
6111
|
+
*/
|
|
6209
6112
|
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6113
|
+
var ArrayProto = Array.prototype;
|
|
6114
|
+
var FuncProto = Function.prototype;
|
|
6115
|
+
var ObjProto = Object.prototype;
|
|
6116
|
+
var slice = ArrayProto.slice;
|
|
6117
|
+
var toString = ObjProto.toString;
|
|
6118
|
+
var hasOwnProperty$9 = ObjProto.hasOwnProperty;
|
|
6119
|
+
var windowConsole = window$1.console;
|
|
6120
|
+
var navigator = window$1.navigator;
|
|
6121
|
+
var document$1 = window$1.document;
|
|
6122
|
+
var windowOpera = window$1.opera;
|
|
6123
|
+
var screen = window$1.screen;
|
|
6124
|
+
var userAgent = navigator.userAgent;
|
|
6125
|
+
var nativeBind = FuncProto.bind;
|
|
6126
|
+
var nativeForEach = ArrayProto.forEach;
|
|
6127
|
+
var nativeIndexOf = ArrayProto.indexOf;
|
|
6128
|
+
var nativeMap = ArrayProto.map;
|
|
6129
|
+
var nativeIsArray = Array.isArray;
|
|
6130
|
+
var breaker = {};
|
|
6131
|
+
var _ = {
|
|
6132
|
+
trim: function(str) {
|
|
6133
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6134
|
+
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6217
6135
|
}
|
|
6218
|
-
}
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
referencedColumns {
|
|
6232
|
-
guid
|
|
6233
|
-
displayName
|
|
6234
|
-
}
|
|
6235
|
-
}
|
|
6236
|
-
}
|
|
6237
|
-
}
|
|
6136
|
+
};
|
|
6137
|
+
|
|
6138
|
+
// Console override
|
|
6139
|
+
var console$1 = {
|
|
6140
|
+
/** @type {function(...*)} */
|
|
6141
|
+
log: function() {
|
|
6142
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6143
|
+
try {
|
|
6144
|
+
windowConsole.log.apply(windowConsole, arguments);
|
|
6145
|
+
} catch (err) {
|
|
6146
|
+
_.each(arguments, function(arg) {
|
|
6147
|
+
windowConsole.log(arg);
|
|
6148
|
+
});
|
|
6238
6149
|
}
|
|
6239
6150
|
}
|
|
6240
|
-
}
|
|
6241
|
-
}
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
}
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6151
|
+
},
|
|
6152
|
+
/** @type {function(...*)} */
|
|
6153
|
+
warn: function() {
|
|
6154
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6155
|
+
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6156
|
+
try {
|
|
6157
|
+
windowConsole.warn.apply(windowConsole, args);
|
|
6158
|
+
} catch (err) {
|
|
6159
|
+
_.each(args, function(arg) {
|
|
6160
|
+
windowConsole.warn(arg);
|
|
6161
|
+
});
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6164
|
+
},
|
|
6165
|
+
/** @type {function(...*)} */
|
|
6166
|
+
error: function() {
|
|
6167
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6168
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6169
|
+
try {
|
|
6170
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6171
|
+
} catch (err) {
|
|
6172
|
+
_.each(args, function(arg) {
|
|
6173
|
+
windowConsole.error(arg);
|
|
6174
|
+
});
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6177
|
+
},
|
|
6178
|
+
/** @type {function(...*)} */
|
|
6179
|
+
critical: function() {
|
|
6180
|
+
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6181
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6182
|
+
try {
|
|
6183
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6184
|
+
} catch (err) {
|
|
6185
|
+
_.each(args, function(arg) {
|
|
6186
|
+
windowConsole.error(arg);
|
|
6187
|
+
});
|
|
6188
|
+
}
|
|
6258
6189
|
}
|
|
6259
6190
|
}
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6191
|
+
};
|
|
6192
|
+
|
|
6193
|
+
var log_func_with_prefix = function(func, prefix) {
|
|
6194
|
+
return function() {
|
|
6195
|
+
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6196
|
+
return func.apply(console$1, arguments);
|
|
6197
|
+
};
|
|
6198
|
+
};
|
|
6199
|
+
var console_with_prefix = function(prefix) {
|
|
6200
|
+
return {
|
|
6201
|
+
log: log_func_with_prefix(console$1.log, prefix),
|
|
6202
|
+
error: log_func_with_prefix(console$1.error, prefix),
|
|
6203
|
+
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6204
|
+
};
|
|
6205
|
+
};
|
|
6206
|
+
|
|
6207
|
+
|
|
6208
|
+
// UNDERSCORE
|
|
6209
|
+
// Embed part of the Underscore Library
|
|
6210
|
+
_.bind = function(func, context) {
|
|
6211
|
+
var args, bound;
|
|
6212
|
+
if (nativeBind && func.bind === nativeBind) {
|
|
6213
|
+
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6214
|
+
}
|
|
6215
|
+
if (!_.isFunction(func)) {
|
|
6216
|
+
throw new TypeError();
|
|
6217
|
+
}
|
|
6218
|
+
args = slice.call(arguments, 2);
|
|
6219
|
+
bound = function() {
|
|
6220
|
+
if (!(this instanceof bound)) {
|
|
6221
|
+
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6222
|
+
}
|
|
6223
|
+
var ctor = {};
|
|
6224
|
+
ctor.prototype = func.prototype;
|
|
6225
|
+
var self = new ctor();
|
|
6226
|
+
ctor.prototype = null;
|
|
6227
|
+
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6228
|
+
if (Object(result) === result) {
|
|
6229
|
+
return result;
|
|
6230
|
+
}
|
|
6231
|
+
return self;
|
|
6232
|
+
};
|
|
6233
|
+
return bound;
|
|
6234
|
+
};
|
|
6235
|
+
|
|
6236
|
+
/**
|
|
6237
|
+
* @param {*=} obj
|
|
6238
|
+
* @param {function(...*)=} iterator
|
|
6239
|
+
* @param {Object=} context
|
|
6240
|
+
*/
|
|
6241
|
+
_.each = function(obj, iterator, context) {
|
|
6242
|
+
if (obj === null || obj === undefined) {
|
|
6243
|
+
return;
|
|
6244
|
+
}
|
|
6245
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6246
|
+
obj.forEach(iterator, context);
|
|
6247
|
+
} else if (obj.length === +obj.length) {
|
|
6248
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6249
|
+
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6250
|
+
return;
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
} else {
|
|
6254
|
+
for (var key in obj) {
|
|
6255
|
+
if (hasOwnProperty$9.call(obj, key)) {
|
|
6256
|
+
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6257
|
+
return;
|
|
6281
6258
|
}
|
|
6282
6259
|
}
|
|
6283
6260
|
}
|
|
6284
6261
|
}
|
|
6285
|
-
|
|
6262
|
+
};
|
|
6286
6263
|
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
(
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
}
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
* graphql queries in the context of the answer on which the
|
|
6297
|
-
* custom action was triggered.
|
|
6298
|
-
*
|
|
6299
|
-
* @example
|
|
6300
|
-
* ```js
|
|
6301
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6302
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6303
|
-
* 'col name 1'
|
|
6304
|
-
* ]);
|
|
6305
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6306
|
-
* })
|
|
6307
|
-
* ```
|
|
6308
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6309
|
-
* @group Events
|
|
6310
|
-
*/
|
|
6311
|
-
class AnswerService {
|
|
6312
|
-
/**
|
|
6313
|
-
* Should not need to be called directly.
|
|
6314
|
-
*
|
|
6315
|
-
* @param session
|
|
6316
|
-
* @param answer
|
|
6317
|
-
* @param thoughtSpotHost
|
|
6318
|
-
* @param selectedPoints
|
|
6319
|
-
*/
|
|
6320
|
-
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
6321
|
-
this.session = session;
|
|
6322
|
-
this.answer = answer;
|
|
6323
|
-
this.thoughtSpotHost = thoughtSpotHost;
|
|
6324
|
-
this.selectedPoints = selectedPoints;
|
|
6325
|
-
this.session = removeTypename(session);
|
|
6326
|
-
}
|
|
6327
|
-
/**
|
|
6328
|
-
* Get the details about the source used in the answer.
|
|
6329
|
-
* This can be used to get the list of all columns in the data source for example.
|
|
6330
|
-
*/
|
|
6331
|
-
async getSourceDetail() {
|
|
6332
|
-
const sourceId = this.answer.sources[0].header.guid;
|
|
6333
|
-
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
6334
|
-
}
|
|
6335
|
-
/**
|
|
6336
|
-
* Remove columnIds and return updated answer session.
|
|
6337
|
-
*
|
|
6338
|
-
* @param columnIds
|
|
6339
|
-
* @returns
|
|
6340
|
-
*/
|
|
6341
|
-
async removeColumns(columnIds) {
|
|
6342
|
-
return this.executeQuery(removeColumns, {
|
|
6343
|
-
logicalColumnIds: columnIds,
|
|
6344
|
-
});
|
|
6345
|
-
}
|
|
6346
|
-
/**
|
|
6347
|
-
* Add columnIds and return updated answer session.
|
|
6348
|
-
*
|
|
6349
|
-
* @param columnIds
|
|
6350
|
-
* @returns
|
|
6351
|
-
*/
|
|
6352
|
-
async addColumns(columnIds) {
|
|
6353
|
-
return this.executeQuery(addColumns, {
|
|
6354
|
-
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
6355
|
-
});
|
|
6356
|
-
}
|
|
6357
|
-
/**
|
|
6358
|
-
* Fetch data from the answer.
|
|
6359
|
-
*
|
|
6360
|
-
* @param offset
|
|
6361
|
-
* @param size
|
|
6362
|
-
* @returns
|
|
6363
|
-
*/
|
|
6364
|
-
async fetchData(offset = 0, size = 1000) {
|
|
6365
|
-
const { answer } = await this.executeQuery(getAnswerData, {
|
|
6366
|
-
deadline: 0,
|
|
6367
|
-
dataPaginationParams: {
|
|
6368
|
-
isClientPaginated: true,
|
|
6369
|
-
offset,
|
|
6370
|
-
size,
|
|
6371
|
-
},
|
|
6372
|
-
});
|
|
6373
|
-
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
6374
|
-
return {
|
|
6375
|
-
columns,
|
|
6376
|
-
data,
|
|
6377
|
-
};
|
|
6378
|
-
}
|
|
6379
|
-
/**
|
|
6380
|
-
* Fetch the data for the answer as a CSV blob. This might be
|
|
6381
|
-
* quicker for larger data.
|
|
6382
|
-
*
|
|
6383
|
-
* @param userLocale
|
|
6384
|
-
* @param includeInfo Include the CSV header in the output
|
|
6385
|
-
* @returns Response
|
|
6386
|
-
*/
|
|
6387
|
-
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
6388
|
-
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
6389
|
-
return tokenizedFetch(fetchUrl, {
|
|
6390
|
-
credentials: 'include',
|
|
6391
|
-
});
|
|
6392
|
-
}
|
|
6393
|
-
/**
|
|
6394
|
-
* Just get the internal URL for this answer's data
|
|
6395
|
-
* as a CSV blob.
|
|
6396
|
-
*
|
|
6397
|
-
* @param userLocale
|
|
6398
|
-
* @param includeInfo
|
|
6399
|
-
* @returns
|
|
6400
|
-
*/
|
|
6401
|
-
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
6402
|
-
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
6403
|
-
}
|
|
6404
|
-
/**
|
|
6405
|
-
* Get underlying data given a point and the output column names.
|
|
6406
|
-
* In case of a context menu action, the selectedPoints are
|
|
6407
|
-
* automatically passed.
|
|
6408
|
-
*
|
|
6409
|
-
* @param outputColumnNames
|
|
6410
|
-
* @param selectedPoints
|
|
6411
|
-
* @example
|
|
6412
|
-
* ```js
|
|
6413
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6414
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6415
|
-
* 'col name 1' // The column should exist in the data source.
|
|
6416
|
-
* ]);
|
|
6417
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6418
|
-
* })
|
|
6419
|
-
* ```
|
|
6420
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6421
|
-
*/
|
|
6422
|
-
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
6423
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
6424
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
6425
|
-
}
|
|
6426
|
-
if (!selectedPoints) {
|
|
6427
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
6428
|
-
}
|
|
6429
|
-
const sourceDetail = await this.getSourceDetail();
|
|
6430
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
6431
|
-
const unAggAnswer = await graphqlQuery({
|
|
6432
|
-
query: getUnaggregatedAnswerSession,
|
|
6433
|
-
variables: {
|
|
6434
|
-
session: this.session,
|
|
6435
|
-
columns: selectedPoints,
|
|
6436
|
-
},
|
|
6437
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6438
|
-
});
|
|
6439
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
6440
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
6441
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
6442
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
6443
|
-
if (columnsToAdd.length) {
|
|
6444
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
6445
|
-
}
|
|
6446
|
-
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
6447
|
-
if (columnsToRemove.length) {
|
|
6448
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
6449
|
-
}
|
|
6450
|
-
return unaggAnswerSession;
|
|
6451
|
-
}
|
|
6452
|
-
/**
|
|
6453
|
-
* Execute a custom graphql query in the context of the answer.
|
|
6454
|
-
*
|
|
6455
|
-
* @param query graphql query
|
|
6456
|
-
* @param variables graphql variables
|
|
6457
|
-
* @returns
|
|
6458
|
-
*/
|
|
6459
|
-
async executeQuery(query, variables) {
|
|
6460
|
-
const data = await graphqlQuery({
|
|
6461
|
-
query,
|
|
6462
|
-
variables: {
|
|
6463
|
-
session: this.session,
|
|
6464
|
-
...variables,
|
|
6465
|
-
},
|
|
6466
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6467
|
-
isCompositeQuery: false,
|
|
6468
|
-
});
|
|
6469
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
6470
|
-
return data;
|
|
6471
|
-
}
|
|
6472
|
-
/**
|
|
6473
|
-
* Get the internal session details for the answer.
|
|
6474
|
-
*
|
|
6475
|
-
* @returns
|
|
6476
|
-
*/
|
|
6477
|
-
getSession() {
|
|
6478
|
-
return this.session;
|
|
6479
|
-
}
|
|
6480
|
-
}
|
|
6481
|
-
/**
|
|
6482
|
-
*
|
|
6483
|
-
* @param sourceDetail
|
|
6484
|
-
* @param colNames
|
|
6485
|
-
*/
|
|
6486
|
-
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
6487
|
-
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
6488
|
-
colSet[col.name] = col;
|
|
6489
|
-
return colSet;
|
|
6490
|
-
}, {});
|
|
6491
|
-
return new Set(colNames.map((colName) => {
|
|
6492
|
-
const col = cols[colName];
|
|
6493
|
-
return col.id;
|
|
6494
|
-
}));
|
|
6495
|
-
}
|
|
6496
|
-
/**
|
|
6497
|
-
*
|
|
6498
|
-
* @param selectedPoints
|
|
6499
|
-
*/
|
|
6500
|
-
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
6501
|
-
const underlyingDataPoint = [];
|
|
6502
|
-
/**
|
|
6503
|
-
*
|
|
6504
|
-
* @param colVal
|
|
6505
|
-
*/
|
|
6506
|
-
function addPointFromColVal(colVal) {
|
|
6507
|
-
var _a;
|
|
6508
|
-
const dataType = colVal.column.dataType;
|
|
6509
|
-
const id = colVal.column.id;
|
|
6510
|
-
let dataValue;
|
|
6511
|
-
if (dataType === 'DATE') {
|
|
6512
|
-
if (Number.isFinite(colVal.value)) {
|
|
6513
|
-
dataValue = [{
|
|
6514
|
-
epochRange: {
|
|
6515
|
-
startEpoch: colVal.value,
|
|
6516
|
-
},
|
|
6517
|
-
}];
|
|
6518
|
-
// Case for custom calendar.
|
|
6519
|
-
}
|
|
6520
|
-
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
6521
|
-
dataValue = [{
|
|
6522
|
-
epochRange: {
|
|
6523
|
-
startEpoch: colVal.value.v.s,
|
|
6524
|
-
endEpoch: colVal.value.v.e,
|
|
6525
|
-
},
|
|
6526
|
-
}];
|
|
6527
|
-
}
|
|
6528
|
-
}
|
|
6529
|
-
else {
|
|
6530
|
-
dataValue = [{ value: colVal.value }];
|
|
6531
|
-
}
|
|
6532
|
-
underlyingDataPoint.push({
|
|
6533
|
-
columnId: colVal.column.id,
|
|
6534
|
-
dataValue,
|
|
6535
|
-
});
|
|
6536
|
-
}
|
|
6537
|
-
selectedPoints.forEach((p) => {
|
|
6538
|
-
p.selectedAttributes.forEach(addPointFromColVal);
|
|
6539
|
-
});
|
|
6540
|
-
return underlyingDataPoint;
|
|
6541
|
-
}
|
|
6542
|
-
|
|
6543
|
-
const ERROR_MESSAGE = {
|
|
6544
|
-
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
6545
|
-
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
6546
|
-
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
6547
|
-
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
6548
|
-
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
6264
|
+
_.extend = function(obj) {
|
|
6265
|
+
_.each(slice.call(arguments, 1), function(source) {
|
|
6266
|
+
for (var prop in source) {
|
|
6267
|
+
if (source[prop] !== void 0) {
|
|
6268
|
+
obj[prop] = source[prop];
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
});
|
|
6272
|
+
return obj;
|
|
6549
6273
|
};
|
|
6550
6274
|
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
* Utilities related to reading configuration objects
|
|
6555
|
-
*
|
|
6556
|
-
* @summary Config-related utils
|
|
6557
|
-
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
6558
|
-
*/
|
|
6559
|
-
const urlRegex = new RegExp([
|
|
6560
|
-
'(^(https?:)//)?',
|
|
6561
|
-
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
6562
|
-
'(/{0,1}[^?#]*)',
|
|
6563
|
-
'(\\?[^#]*|)',
|
|
6564
|
-
'(#.*|)$', // hash
|
|
6565
|
-
].join(''));
|
|
6566
|
-
/**
|
|
6567
|
-
* Parse and construct the ThoughtSpot hostname or IP address
|
|
6568
|
-
* from the embed configuration object.
|
|
6569
|
-
*
|
|
6570
|
-
* @param config
|
|
6571
|
-
*/
|
|
6572
|
-
const getThoughtSpotHost = (config) => {
|
|
6573
|
-
if (!config.thoughtSpotHost) {
|
|
6574
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6575
|
-
}
|
|
6576
|
-
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
6577
|
-
if (!urlParts) {
|
|
6578
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6579
|
-
}
|
|
6580
|
-
const protocol = urlParts[2] || window.location.protocol;
|
|
6581
|
-
const host = urlParts[3];
|
|
6582
|
-
let path = urlParts[6];
|
|
6583
|
-
// Lose the trailing / if any
|
|
6584
|
-
if (path.charAt(path.length - 1) === '/') {
|
|
6585
|
-
path = path.substring(0, path.length - 1);
|
|
6586
|
-
}
|
|
6587
|
-
// const urlParams = urlParts[7];
|
|
6588
|
-
// const hash = urlParts[8];
|
|
6589
|
-
return `${protocol}//${host}${path}`;
|
|
6590
|
-
};
|
|
6591
|
-
const getV2BasePath = (config) => {
|
|
6592
|
-
if (config.basepath) {
|
|
6593
|
-
return config.basepath;
|
|
6594
|
-
}
|
|
6595
|
-
const tsHost = getThoughtSpotHost(config);
|
|
6596
|
-
// This is to handle when e2e's. Search is run on pods for
|
|
6597
|
-
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
6598
|
-
// This is to handle when the developer is developing in their local
|
|
6599
|
-
// environment.
|
|
6600
|
-
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
6601
|
-
return '';
|
|
6602
|
-
}
|
|
6603
|
-
return 'v2';
|
|
6604
|
-
};
|
|
6605
|
-
/**
|
|
6606
|
-
* It is a good idea to keep URLs under 2000 chars.
|
|
6607
|
-
* If this is ever breached, since we pass view configuration through
|
|
6608
|
-
* URL params, we would like to log a warning.
|
|
6609
|
-
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
6610
|
-
*/
|
|
6611
|
-
const URL_MAX_LENGTH = 2000;
|
|
6612
|
-
/**
|
|
6613
|
-
* The default CSS dimensions of the embedded app
|
|
6614
|
-
*/
|
|
6615
|
-
const DEFAULT_EMBED_WIDTH = '100%';
|
|
6616
|
-
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
6275
|
+
_.isArray = nativeIsArray || function(obj) {
|
|
6276
|
+
return toString.call(obj) === '[object Array]';
|
|
6277
|
+
};
|
|
6617
6278
|
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6279
|
+
// from a comment on http://dbj.org/dbj/?p=286
|
|
6280
|
+
// fails on only one very rare and deliberate custom object:
|
|
6281
|
+
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6282
|
+
_.isFunction = function(f) {
|
|
6283
|
+
try {
|
|
6284
|
+
return /^\s*\bfunction\b/.test(f);
|
|
6285
|
+
} catch (x) {
|
|
6286
|
+
return false;
|
|
6287
|
+
}
|
|
6621
6288
|
};
|
|
6622
6289
|
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
var loc = {
|
|
6627
|
-
hostname: ''
|
|
6628
|
-
};
|
|
6629
|
-
window$1 = {
|
|
6630
|
-
navigator: { userAgent: '' },
|
|
6631
|
-
document: {
|
|
6632
|
-
location: loc,
|
|
6633
|
-
referrer: ''
|
|
6634
|
-
},
|
|
6635
|
-
screen: { width: 0, height: 0 },
|
|
6636
|
-
location: loc
|
|
6637
|
-
};
|
|
6638
|
-
} else {
|
|
6639
|
-
window$1 = window;
|
|
6640
|
-
}
|
|
6290
|
+
_.isArguments = function(obj) {
|
|
6291
|
+
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6292
|
+
};
|
|
6641
6293
|
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
var screen = window$1.screen;
|
|
6658
|
-
var userAgent = navigator.userAgent;
|
|
6659
|
-
var nativeBind = FuncProto.bind;
|
|
6660
|
-
var nativeForEach = ArrayProto.forEach;
|
|
6661
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
6662
|
-
var nativeMap = ArrayProto.map;
|
|
6663
|
-
var nativeIsArray = Array.isArray;
|
|
6664
|
-
var breaker = {};
|
|
6665
|
-
var _ = {
|
|
6666
|
-
trim: function(str) {
|
|
6667
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6668
|
-
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6669
|
-
}
|
|
6670
|
-
};
|
|
6671
|
-
|
|
6672
|
-
// Console override
|
|
6673
|
-
var console$1 = {
|
|
6674
|
-
/** @type {function(...*)} */
|
|
6675
|
-
log: function() {
|
|
6676
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6677
|
-
try {
|
|
6678
|
-
windowConsole.log.apply(windowConsole, arguments);
|
|
6679
|
-
} catch (err) {
|
|
6680
|
-
_.each(arguments, function(arg) {
|
|
6681
|
-
windowConsole.log(arg);
|
|
6682
|
-
});
|
|
6683
|
-
}
|
|
6684
|
-
}
|
|
6685
|
-
},
|
|
6686
|
-
/** @type {function(...*)} */
|
|
6687
|
-
warn: function() {
|
|
6688
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6689
|
-
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6690
|
-
try {
|
|
6691
|
-
windowConsole.warn.apply(windowConsole, args);
|
|
6692
|
-
} catch (err) {
|
|
6693
|
-
_.each(args, function(arg) {
|
|
6694
|
-
windowConsole.warn(arg);
|
|
6695
|
-
});
|
|
6696
|
-
}
|
|
6697
|
-
}
|
|
6698
|
-
},
|
|
6699
|
-
/** @type {function(...*)} */
|
|
6700
|
-
error: function() {
|
|
6701
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6702
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6703
|
-
try {
|
|
6704
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6705
|
-
} catch (err) {
|
|
6706
|
-
_.each(args, function(arg) {
|
|
6707
|
-
windowConsole.error(arg);
|
|
6708
|
-
});
|
|
6709
|
-
}
|
|
6710
|
-
}
|
|
6711
|
-
},
|
|
6712
|
-
/** @type {function(...*)} */
|
|
6713
|
-
critical: function() {
|
|
6714
|
-
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6715
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6716
|
-
try {
|
|
6717
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6718
|
-
} catch (err) {
|
|
6719
|
-
_.each(args, function(arg) {
|
|
6720
|
-
windowConsole.error(arg);
|
|
6721
|
-
});
|
|
6722
|
-
}
|
|
6723
|
-
}
|
|
6724
|
-
}
|
|
6725
|
-
};
|
|
6726
|
-
|
|
6727
|
-
var log_func_with_prefix = function(func, prefix) {
|
|
6728
|
-
return function() {
|
|
6729
|
-
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6730
|
-
return func.apply(console$1, arguments);
|
|
6731
|
-
};
|
|
6732
|
-
};
|
|
6733
|
-
var console_with_prefix = function(prefix) {
|
|
6734
|
-
return {
|
|
6735
|
-
log: log_func_with_prefix(console$1.log, prefix),
|
|
6736
|
-
error: log_func_with_prefix(console$1.error, prefix),
|
|
6737
|
-
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6738
|
-
};
|
|
6739
|
-
};
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
// UNDERSCORE
|
|
6743
|
-
// Embed part of the Underscore Library
|
|
6744
|
-
_.bind = function(func, context) {
|
|
6745
|
-
var args, bound;
|
|
6746
|
-
if (nativeBind && func.bind === nativeBind) {
|
|
6747
|
-
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6748
|
-
}
|
|
6749
|
-
if (!_.isFunction(func)) {
|
|
6750
|
-
throw new TypeError();
|
|
6751
|
-
}
|
|
6752
|
-
args = slice.call(arguments, 2);
|
|
6753
|
-
bound = function() {
|
|
6754
|
-
if (!(this instanceof bound)) {
|
|
6755
|
-
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6756
|
-
}
|
|
6757
|
-
var ctor = {};
|
|
6758
|
-
ctor.prototype = func.prototype;
|
|
6759
|
-
var self = new ctor();
|
|
6760
|
-
ctor.prototype = null;
|
|
6761
|
-
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6762
|
-
if (Object(result) === result) {
|
|
6763
|
-
return result;
|
|
6764
|
-
}
|
|
6765
|
-
return self;
|
|
6766
|
-
};
|
|
6767
|
-
return bound;
|
|
6768
|
-
};
|
|
6769
|
-
|
|
6770
|
-
/**
|
|
6771
|
-
* @param {*=} obj
|
|
6772
|
-
* @param {function(...*)=} iterator
|
|
6773
|
-
* @param {Object=} context
|
|
6774
|
-
*/
|
|
6775
|
-
_.each = function(obj, iterator, context) {
|
|
6776
|
-
if (obj === null || obj === undefined) {
|
|
6777
|
-
return;
|
|
6778
|
-
}
|
|
6779
|
-
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6780
|
-
obj.forEach(iterator, context);
|
|
6781
|
-
} else if (obj.length === +obj.length) {
|
|
6782
|
-
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6783
|
-
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6784
|
-
return;
|
|
6785
|
-
}
|
|
6786
|
-
}
|
|
6787
|
-
} else {
|
|
6788
|
-
for (var key in obj) {
|
|
6789
|
-
if (hasOwnProperty$9.call(obj, key)) {
|
|
6790
|
-
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6791
|
-
return;
|
|
6792
|
-
}
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6795
|
-
}
|
|
6796
|
-
};
|
|
6797
|
-
|
|
6798
|
-
_.extend = function(obj) {
|
|
6799
|
-
_.each(slice.call(arguments, 1), function(source) {
|
|
6800
|
-
for (var prop in source) {
|
|
6801
|
-
if (source[prop] !== void 0) {
|
|
6802
|
-
obj[prop] = source[prop];
|
|
6803
|
-
}
|
|
6804
|
-
}
|
|
6805
|
-
});
|
|
6806
|
-
return obj;
|
|
6807
|
-
};
|
|
6808
|
-
|
|
6809
|
-
_.isArray = nativeIsArray || function(obj) {
|
|
6810
|
-
return toString.call(obj) === '[object Array]';
|
|
6811
|
-
};
|
|
6812
|
-
|
|
6813
|
-
// from a comment on http://dbj.org/dbj/?p=286
|
|
6814
|
-
// fails on only one very rare and deliberate custom object:
|
|
6815
|
-
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6816
|
-
_.isFunction = function(f) {
|
|
6817
|
-
try {
|
|
6818
|
-
return /^\s*\bfunction\b/.test(f);
|
|
6819
|
-
} catch (x) {
|
|
6820
|
-
return false;
|
|
6821
|
-
}
|
|
6822
|
-
};
|
|
6823
|
-
|
|
6824
|
-
_.isArguments = function(obj) {
|
|
6825
|
-
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6826
|
-
};
|
|
6827
|
-
|
|
6828
|
-
_.toArray = function(iterable) {
|
|
6829
|
-
if (!iterable) {
|
|
6830
|
-
return [];
|
|
6831
|
-
}
|
|
6832
|
-
if (iterable.toArray) {
|
|
6833
|
-
return iterable.toArray();
|
|
6834
|
-
}
|
|
6835
|
-
if (_.isArray(iterable)) {
|
|
6836
|
-
return slice.call(iterable);
|
|
6837
|
-
}
|
|
6838
|
-
if (_.isArguments(iterable)) {
|
|
6839
|
-
return slice.call(iterable);
|
|
6840
|
-
}
|
|
6841
|
-
return _.values(iterable);
|
|
6842
|
-
};
|
|
6294
|
+
_.toArray = function(iterable) {
|
|
6295
|
+
if (!iterable) {
|
|
6296
|
+
return [];
|
|
6297
|
+
}
|
|
6298
|
+
if (iterable.toArray) {
|
|
6299
|
+
return iterable.toArray();
|
|
6300
|
+
}
|
|
6301
|
+
if (_.isArray(iterable)) {
|
|
6302
|
+
return slice.call(iterable);
|
|
6303
|
+
}
|
|
6304
|
+
if (_.isArguments(iterable)) {
|
|
6305
|
+
return slice.call(iterable);
|
|
6306
|
+
}
|
|
6307
|
+
return _.values(iterable);
|
|
6308
|
+
};
|
|
6843
6309
|
|
|
6844
6310
|
_.map = function(arr, callback, context) {
|
|
6845
6311
|
if (nativeMap && arr.map === nativeMap) {
|
|
@@ -12672,749 +12138,1290 @@ function initMixpanel(sessionInfo) {
|
|
|
12672
12138
|
}
|
|
12673
12139
|
}
|
|
12674
12140
|
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
*
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
* @constructor
|
|
12685
|
-
* @private
|
|
12686
|
-
*/
|
|
12687
|
-
function Events() {}
|
|
12688
|
-
|
|
12689
|
-
//
|
|
12690
|
-
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
12691
|
-
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
12692
|
-
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
12693
|
-
// character to make sure that the built-in object properties are not
|
|
12694
|
-
// overridden or used as an attack vector.
|
|
12695
|
-
//
|
|
12696
|
-
if (Object.create) {
|
|
12697
|
-
Events.prototype = Object.create(null);
|
|
12141
|
+
let config = {};
|
|
12142
|
+
/**
|
|
12143
|
+
* Gets the configuration embed was initialized with.
|
|
12144
|
+
*
|
|
12145
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
12146
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
12147
|
+
* @group Global methods
|
|
12148
|
+
*/
|
|
12149
|
+
const getEmbedConfig = () => config;
|
|
12698
12150
|
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12151
|
+
/**
|
|
12152
|
+
* Fetch wrapper that adds the authentication token to the request.
|
|
12153
|
+
* Use this to call the ThoughtSpot APIs when using the visual embed sdk.
|
|
12154
|
+
*
|
|
12155
|
+
* @param input
|
|
12156
|
+
* @param init
|
|
12157
|
+
* @version SDK: 1.28.0
|
|
12158
|
+
* @group Global methods
|
|
12159
|
+
*/
|
|
12160
|
+
const tokenizedFetch = async (input, init) => {
|
|
12161
|
+
const embedConfig = getEmbedConfig();
|
|
12162
|
+
if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
|
|
12163
|
+
return fetch(input, init);
|
|
12164
|
+
}
|
|
12165
|
+
const req = new Request(input, init);
|
|
12166
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12167
|
+
if (authToken) {
|
|
12168
|
+
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
12169
|
+
}
|
|
12170
|
+
return fetch(req);
|
|
12171
|
+
};
|
|
12705
12172
|
|
|
12706
|
-
/**
|
|
12707
|
-
*
|
|
12708
|
-
*
|
|
12709
|
-
* @param
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
}
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
*
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
12729
|
-
* @returns {EventEmitter}
|
|
12730
|
-
* @private
|
|
12731
|
-
*/
|
|
12732
|
-
function addListener(emitter, event, fn, context, once) {
|
|
12733
|
-
if (typeof fn !== 'function') {
|
|
12734
|
-
throw new TypeError('The listener must be a function');
|
|
12735
|
-
}
|
|
12736
|
-
|
|
12737
|
-
var listener = new EE(fn, context || emitter, once)
|
|
12738
|
-
, evt = prefix ? prefix + event : event;
|
|
12739
|
-
|
|
12740
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
12741
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
12742
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
12743
|
-
|
|
12744
|
-
return emitter;
|
|
12745
|
-
}
|
|
12746
|
-
|
|
12747
|
-
/**
|
|
12748
|
-
* Clear event by name.
|
|
12749
|
-
*
|
|
12750
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
12751
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
12752
|
-
* @private
|
|
12753
|
-
*/
|
|
12754
|
-
function clearEvent(emitter, evt) {
|
|
12755
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
12756
|
-
else delete emitter._events[evt];
|
|
12757
|
-
}
|
|
12758
|
-
|
|
12759
|
-
/**
|
|
12760
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
12761
|
-
* `EventEmitter` interface.
|
|
12762
|
-
*
|
|
12763
|
-
* @constructor
|
|
12764
|
-
* @public
|
|
12765
|
-
*/
|
|
12766
|
-
function EventEmitter() {
|
|
12767
|
-
this._events = new Events();
|
|
12768
|
-
this._eventsCount = 0;
|
|
12173
|
+
/**
|
|
12174
|
+
*
|
|
12175
|
+
* @param url
|
|
12176
|
+
* @param options
|
|
12177
|
+
*/
|
|
12178
|
+
function tokenisedFailureLoggedFetch(url, options = {}) {
|
|
12179
|
+
return tokenizedFetch(url, options).then(async (r) => {
|
|
12180
|
+
var _a;
|
|
12181
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
12182
|
+
logger.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
12183
|
+
}
|
|
12184
|
+
return r;
|
|
12185
|
+
});
|
|
12186
|
+
}
|
|
12187
|
+
/**
|
|
12188
|
+
*
|
|
12189
|
+
* @param authVerificationUrl
|
|
12190
|
+
*/
|
|
12191
|
+
function fetchSessionInfoService(authVerificationUrl) {
|
|
12192
|
+
return tokenisedFailureLoggedFetch(authVerificationUrl, {
|
|
12193
|
+
credentials: 'include',
|
|
12194
|
+
});
|
|
12769
12195
|
}
|
|
12770
12196
|
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
*
|
|
12799
|
-
*
|
|
12800
|
-
* @
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
};
|
|
12904
|
-
|
|
12905
|
-
/**
|
|
12906
|
-
*
|
|
12907
|
-
*
|
|
12908
|
-
* @param
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12197
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12198
|
+
let loggedInStatus = false;
|
|
12199
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12200
|
+
let samlAuthWindow = null;
|
|
12201
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12202
|
+
let samlCompletionPromise = null;
|
|
12203
|
+
let sessionInfo = null;
|
|
12204
|
+
let sessionInfoResolver = null;
|
|
12205
|
+
const sessionInfoPromise = new Promise((resolve) => {
|
|
12206
|
+
sessionInfoResolver = resolve;
|
|
12207
|
+
});
|
|
12208
|
+
let releaseVersion = '';
|
|
12209
|
+
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
12210
|
+
/**
|
|
12211
|
+
* Enum for auth failure types. This is the parameter passed to the listner
|
|
12212
|
+
* of {@link AuthStatus.FAILURE}.
|
|
12213
|
+
*
|
|
12214
|
+
* @group Authentication / Init
|
|
12215
|
+
*/
|
|
12216
|
+
var AuthFailureType;
|
|
12217
|
+
(function (AuthFailureType) {
|
|
12218
|
+
AuthFailureType["SDK"] = "SDK";
|
|
12219
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
12220
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
12221
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
12222
|
+
})(AuthFailureType || (AuthFailureType = {}));
|
|
12223
|
+
/**
|
|
12224
|
+
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
12225
|
+
*
|
|
12226
|
+
* @group Authentication / Init
|
|
12227
|
+
*/
|
|
12228
|
+
var AuthStatus;
|
|
12229
|
+
(function (AuthStatus) {
|
|
12230
|
+
/**
|
|
12231
|
+
* Emits when the SDK fails to authenticate
|
|
12232
|
+
*/
|
|
12233
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
12234
|
+
/**
|
|
12235
|
+
* Emits when the SDK authenticates successfully
|
|
12236
|
+
*/
|
|
12237
|
+
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
12238
|
+
/**
|
|
12239
|
+
* Emits when the app sends an authentication success message
|
|
12240
|
+
*/
|
|
12241
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
12242
|
+
/**
|
|
12243
|
+
* Emits when a user logs out
|
|
12244
|
+
*/
|
|
12245
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
12246
|
+
/**
|
|
12247
|
+
* Emitted when inPopup is true in the SAMLRedirect flow and the
|
|
12248
|
+
* popup is waiting to be triggered either programmatically
|
|
12249
|
+
* or by the trigger button.
|
|
12250
|
+
*
|
|
12251
|
+
* @version SDK: 1.19.0
|
|
12252
|
+
*/
|
|
12253
|
+
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
12254
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
12255
|
+
/**
|
|
12256
|
+
* Events which can be triggered on the emitter returned from {@link init}.
|
|
12257
|
+
*
|
|
12258
|
+
* @group Authentication / Init
|
|
12259
|
+
*/
|
|
12260
|
+
var AuthEvent;
|
|
12261
|
+
(function (AuthEvent) {
|
|
12262
|
+
/**
|
|
12263
|
+
* Manually trigger the SSO popup. This is useful when
|
|
12264
|
+
* authStatus is SAMLRedirect/OIDCRedirect and inPopup is set to true
|
|
12265
|
+
*/
|
|
12266
|
+
AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
|
|
12267
|
+
})(AuthEvent || (AuthEvent = {}));
|
|
12268
|
+
/**
|
|
12269
|
+
*
|
|
12270
|
+
*/
|
|
12271
|
+
function notifyAuthSDKSuccess() {
|
|
12272
|
+
{
|
|
12273
|
+
logger.error('SDK not initialized');
|
|
12274
|
+
return;
|
|
12275
|
+
}
|
|
12276
|
+
}
|
|
12277
|
+
/**
|
|
12278
|
+
*
|
|
12279
|
+
*/
|
|
12280
|
+
function notifyAuthSuccess() {
|
|
12281
|
+
{
|
|
12282
|
+
logger.error('SDK not initialized');
|
|
12283
|
+
return;
|
|
12284
|
+
}
|
|
12285
|
+
}
|
|
12286
|
+
/**
|
|
12287
|
+
*
|
|
12288
|
+
* @param failureType
|
|
12289
|
+
*/
|
|
12290
|
+
function notifyAuthFailure(failureType) {
|
|
12291
|
+
{
|
|
12292
|
+
logger.error('SDK not initialized');
|
|
12293
|
+
return;
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
/**
|
|
12297
|
+
*
|
|
12298
|
+
*/
|
|
12299
|
+
function notifyLogout() {
|
|
12300
|
+
{
|
|
12301
|
+
logger.error('SDK not initialized');
|
|
12302
|
+
return;
|
|
12303
|
+
}
|
|
12304
|
+
}
|
|
12305
|
+
const initSession = (sessionDetails) => {
|
|
12306
|
+
const embedConfig = getEmbedConfig();
|
|
12307
|
+
if (sessionInfo == null) {
|
|
12308
|
+
sessionInfo = sessionDetails;
|
|
12309
|
+
if (!embedConfig.disableSDKTracking) {
|
|
12310
|
+
initMixpanel(sessionInfo);
|
|
12311
|
+
}
|
|
12312
|
+
sessionInfoResolver(sessionInfo);
|
|
12313
|
+
}
|
|
12314
|
+
};
|
|
12315
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
12316
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
12317
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
12318
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
12319
|
+
? prodMixpanelToken
|
|
12320
|
+
: devMixpanelToken;
|
|
12321
|
+
return {
|
|
12322
|
+
userGUID: sessionInfoResp.userGUID,
|
|
12323
|
+
mixpanelToken,
|
|
12324
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
12325
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
12326
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
12327
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
12328
|
+
...sessionInfoResp,
|
|
12329
|
+
};
|
|
12330
|
+
};
|
|
12331
|
+
/**
|
|
12332
|
+
* Check if we are logged into the ThoughtSpot cluster
|
|
12333
|
+
*
|
|
12334
|
+
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
12335
|
+
*/
|
|
12336
|
+
async function isLoggedIn(thoughtSpotHost) {
|
|
12337
|
+
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
12338
|
+
let response = null;
|
|
12339
|
+
try {
|
|
12340
|
+
response = await fetchSessionInfoService(authVerificationUrl);
|
|
12341
|
+
const sessionInfoResp = await response.json();
|
|
12342
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
12343
|
+
// Store user session details from session info
|
|
12344
|
+
initSession(sessionDetails);
|
|
12345
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12346
|
+
}
|
|
12347
|
+
catch (e) {
|
|
12348
|
+
return false;
|
|
12349
|
+
}
|
|
12350
|
+
return response.status === 200;
|
|
12351
|
+
}
|
|
12352
|
+
/**
|
|
12353
|
+
* Return releaseVersion if available
|
|
12354
|
+
*/
|
|
12355
|
+
function getReleaseVersion() {
|
|
12356
|
+
return releaseVersion;
|
|
12357
|
+
}
|
|
12358
|
+
/**
|
|
12359
|
+
* Check if we are stuck at the SSO redirect URL
|
|
12360
|
+
*/
|
|
12361
|
+
function isAtSSORedirectUrl() {
|
|
12362
|
+
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
12363
|
+
}
|
|
12364
|
+
/**
|
|
12365
|
+
* Remove the SSO redirect URL marker
|
|
12366
|
+
*/
|
|
12367
|
+
function removeSSORedirectUrlMarker() {
|
|
12368
|
+
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
12369
|
+
// to begin with. Trying to remove the hash by changing window.location will
|
|
12370
|
+
// reload the page which we don't want. We'll live with adding an
|
|
12371
|
+
// unnecessary hash to the parent page URL until we find any use case where
|
|
12372
|
+
// that creates an issue.
|
|
12373
|
+
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
12374
|
+
}
|
|
12375
|
+
/**
|
|
12376
|
+
* Perform token based authentication
|
|
12377
|
+
*
|
|
12378
|
+
* @param embedConfig The embed configuration
|
|
12379
|
+
*/
|
|
12380
|
+
const doTokenAuth = async (embedConfig) => {
|
|
12381
|
+
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
12382
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12383
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12384
|
+
}
|
|
12385
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12386
|
+
if (!loggedInStatus) {
|
|
12387
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12388
|
+
let resp;
|
|
12389
|
+
try {
|
|
12390
|
+
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
12391
|
+
}
|
|
12392
|
+
catch (e) {
|
|
12393
|
+
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
12394
|
+
}
|
|
12395
|
+
// token login issues a 302 when successful
|
|
12396
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
12397
|
+
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
12398
|
+
// When 3rd party cookie access is blocked, this will fail because
|
|
12399
|
+
// cookies will not be sent with the call.
|
|
12400
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12401
|
+
}
|
|
12402
|
+
}
|
|
12403
|
+
return loggedInStatus;
|
|
12404
|
+
};
|
|
12405
|
+
/**
|
|
12406
|
+
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
12407
|
+
*
|
|
12408
|
+
* @param embedConfig The embed configuration
|
|
12409
|
+
*/
|
|
12410
|
+
const doCookielessTokenAuth = async (embedConfig) => {
|
|
12411
|
+
const { authEndpoint, getAuthToken } = embedConfig;
|
|
12412
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12413
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12414
|
+
}
|
|
12415
|
+
let authSuccess = false;
|
|
12416
|
+
try {
|
|
12417
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12418
|
+
if (authToken) {
|
|
12419
|
+
authSuccess = true;
|
|
12420
|
+
}
|
|
12421
|
+
}
|
|
12422
|
+
catch {
|
|
12423
|
+
authSuccess = false;
|
|
12424
|
+
}
|
|
12425
|
+
return authSuccess;
|
|
12426
|
+
};
|
|
12427
|
+
/**
|
|
12428
|
+
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
12429
|
+
* credentials.
|
|
12430
|
+
*
|
|
12431
|
+
* Warning: This feature is primarily intended for developer testing. It is
|
|
12432
|
+
* strongly advised not to use this authentication method in production.
|
|
12433
|
+
*
|
|
12434
|
+
* @param embedConfig The embed configuration
|
|
12435
|
+
*/
|
|
12436
|
+
const doBasicAuth = async (embedConfig) => {
|
|
12437
|
+
const { thoughtSpotHost, username, password } = embedConfig;
|
|
12438
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12439
|
+
if (!loggedIn) {
|
|
12440
|
+
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
12441
|
+
loggedInStatus = response.ok;
|
|
12442
|
+
if (embedConfig.detectCookieAccessSlow) {
|
|
12443
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12444
|
+
}
|
|
12445
|
+
}
|
|
12446
|
+
else {
|
|
12447
|
+
loggedInStatus = true;
|
|
12448
|
+
}
|
|
12449
|
+
return loggedInStatus;
|
|
12450
|
+
};
|
|
12451
|
+
/**
|
|
12452
|
+
*
|
|
12453
|
+
* @param ssoURL
|
|
12454
|
+
* @param triggerContainer
|
|
12455
|
+
* @param triggerText
|
|
12456
|
+
*/
|
|
12457
|
+
async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
12458
|
+
const openPopup = () => {
|
|
12459
|
+
if (samlAuthWindow === null || samlAuthWindow.closed) {
|
|
12460
|
+
samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
|
|
12461
|
+
}
|
|
12462
|
+
else {
|
|
12463
|
+
samlAuthWindow.focus();
|
|
12464
|
+
}
|
|
12465
|
+
};
|
|
12466
|
+
const containerEl = getDOMNode(triggerContainer);
|
|
12467
|
+
if (containerEl) {
|
|
12468
|
+
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
12469
|
+
const authElem = document.getElementById('ts-auth-btn');
|
|
12470
|
+
authElem.textContent = triggerText;
|
|
12471
|
+
authElem.addEventListener('click', openPopup, { once: true });
|
|
12472
|
+
}
|
|
12473
|
+
samlCompletionPromise = samlCompletionPromise
|
|
12474
|
+
|| new Promise((resolve, reject) => {
|
|
12475
|
+
window.addEventListener('message', (e) => {
|
|
12476
|
+
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
12477
|
+
e.source.close();
|
|
12478
|
+
resolve();
|
|
12479
|
+
}
|
|
12480
|
+
});
|
|
12481
|
+
});
|
|
12482
|
+
return samlCompletionPromise;
|
|
12483
|
+
}
|
|
12484
|
+
/**
|
|
12485
|
+
* Perform SAML authentication
|
|
12486
|
+
*
|
|
12487
|
+
* @param embedConfig The embed configuration
|
|
12488
|
+
* @param ssoEndPoint
|
|
12489
|
+
*/
|
|
12490
|
+
const doSSOAuth = async (embedConfig, ssoEndPoint) => {
|
|
12491
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12492
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12493
|
+
if (loggedIn) {
|
|
12494
|
+
if (isAtSSORedirectUrl()) {
|
|
12495
|
+
removeSSORedirectUrlMarker();
|
|
12496
|
+
}
|
|
12497
|
+
loggedInStatus = true;
|
|
12498
|
+
return;
|
|
12499
|
+
}
|
|
12500
|
+
// we have already tried authentication and it did not succeed, restore
|
|
12501
|
+
// the current URL to the original one and invoke the callback.
|
|
12502
|
+
if (isAtSSORedirectUrl()) {
|
|
12503
|
+
removeSSORedirectUrlMarker();
|
|
12504
|
+
loggedInStatus = false;
|
|
12505
|
+
return;
|
|
12506
|
+
}
|
|
12507
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
12508
|
+
if (embedConfig.inPopup) {
|
|
12509
|
+
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
12510
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12511
|
+
return;
|
|
12512
|
+
}
|
|
12513
|
+
window.location.href = ssoURL;
|
|
12514
|
+
};
|
|
12515
|
+
const doSamlAuth = async (embedConfig) => {
|
|
12516
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12517
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12518
|
+
// loaded again and the same JS will execute again.
|
|
12519
|
+
const ssoRedirectUrl = embedConfig.inPopup
|
|
12520
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12521
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12522
|
+
// bring back the page to the same URL
|
|
12523
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12524
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12525
|
+
return loggedInStatus;
|
|
12526
|
+
};
|
|
12527
|
+
const doOIDCAuth = async (embedConfig) => {
|
|
12528
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12529
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12530
|
+
// loaded again and the same JS will execute again.
|
|
12531
|
+
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
12532
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12533
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12534
|
+
// bring back the page to the same URL
|
|
12535
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12536
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12537
|
+
return loggedInStatus;
|
|
12538
|
+
};
|
|
12539
|
+
/**
|
|
12540
|
+
* Perform authentication on the ThoughtSpot cluster
|
|
12541
|
+
*
|
|
12542
|
+
* @param embedConfig The embed configuration
|
|
12543
|
+
*/
|
|
12544
|
+
const authenticate = async (embedConfig) => {
|
|
12545
|
+
const { authType } = embedConfig;
|
|
12546
|
+
switch (authType) {
|
|
12547
|
+
case AuthType.SSO:
|
|
12548
|
+
case AuthType.SAMLRedirect:
|
|
12549
|
+
case AuthType.SAML:
|
|
12550
|
+
return doSamlAuth(embedConfig);
|
|
12551
|
+
case AuthType.OIDC:
|
|
12552
|
+
case AuthType.OIDCRedirect:
|
|
12553
|
+
return doOIDCAuth(embedConfig);
|
|
12554
|
+
case AuthType.AuthServer:
|
|
12555
|
+
case AuthType.TrustedAuthToken:
|
|
12556
|
+
return doTokenAuth(embedConfig);
|
|
12557
|
+
case AuthType.TrustedAuthTokenCookieless:
|
|
12558
|
+
return doCookielessTokenAuth(embedConfig);
|
|
12559
|
+
case AuthType.Basic:
|
|
12560
|
+
return doBasicAuth(embedConfig);
|
|
12561
|
+
default:
|
|
12562
|
+
return Promise.resolve(true);
|
|
12563
|
+
}
|
|
12966
12564
|
};
|
|
12967
12565
|
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
*/
|
|
12975
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
12976
|
-
var evt;
|
|
12977
|
-
|
|
12978
|
-
if (event) {
|
|
12979
|
-
evt = prefix ? prefix + event : event;
|
|
12980
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
12981
|
-
} else {
|
|
12982
|
-
this._events = new Events();
|
|
12983
|
-
this._eventsCount = 0;
|
|
12984
|
-
}
|
|
12985
|
-
|
|
12986
|
-
return this;
|
|
12566
|
+
const ERROR_MESSAGE = {
|
|
12567
|
+
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
12568
|
+
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
12569
|
+
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
12570
|
+
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
12571
|
+
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
12987
12572
|
};
|
|
12988
12573
|
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
//
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
12574
|
+
/**
|
|
12575
|
+
* Copyright (c) 2023
|
|
12576
|
+
*
|
|
12577
|
+
* Utilities related to reading configuration objects
|
|
12578
|
+
*
|
|
12579
|
+
* @summary Config-related utils
|
|
12580
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
12581
|
+
*/
|
|
12582
|
+
const urlRegex = new RegExp([
|
|
12583
|
+
'(^(https?:)//)?',
|
|
12584
|
+
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
12585
|
+
'(/{0,1}[^?#]*)',
|
|
12586
|
+
'(\\?[^#]*|)',
|
|
12587
|
+
'(#.*|)$', // hash
|
|
12588
|
+
].join(''));
|
|
12589
|
+
/**
|
|
12590
|
+
* Parse and construct the ThoughtSpot hostname or IP address
|
|
12591
|
+
* from the embed configuration object.
|
|
12592
|
+
*
|
|
12593
|
+
* @param config
|
|
12594
|
+
*/
|
|
12595
|
+
const getThoughtSpotHost = (config) => {
|
|
12596
|
+
if (!config.thoughtSpotHost) {
|
|
12597
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12598
|
+
}
|
|
12599
|
+
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
12600
|
+
if (!urlParts) {
|
|
12601
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12602
|
+
}
|
|
12603
|
+
const protocol = urlParts[2] || window.location.protocol;
|
|
12604
|
+
const host = urlParts[3];
|
|
12605
|
+
let path = urlParts[6];
|
|
12606
|
+
// Lose the trailing / if any
|
|
12607
|
+
if (path.charAt(path.length - 1) === '/') {
|
|
12608
|
+
path = path.substring(0, path.length - 1);
|
|
12609
|
+
}
|
|
12610
|
+
// const urlParams = urlParts[7];
|
|
12611
|
+
// const hash = urlParts[8];
|
|
12612
|
+
return `${protocol}//${host}${path}`;
|
|
12613
|
+
};
|
|
12614
|
+
const getV2BasePath = (config) => {
|
|
12615
|
+
if (config.basepath) {
|
|
12616
|
+
return config.basepath;
|
|
12617
|
+
}
|
|
12618
|
+
const tsHost = getThoughtSpotHost(config);
|
|
12619
|
+
// This is to handle when e2e's. Search is run on pods for
|
|
12620
|
+
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
12621
|
+
// This is to handle when the developer is developing in their local
|
|
12622
|
+
// environment.
|
|
12623
|
+
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
12624
|
+
return '';
|
|
12625
|
+
}
|
|
12626
|
+
return 'v2';
|
|
12627
|
+
};
|
|
12628
|
+
/**
|
|
12629
|
+
* It is a good idea to keep URLs under 2000 chars.
|
|
12630
|
+
* If this is ever breached, since we pass view configuration through
|
|
12631
|
+
* URL params, we would like to log a warning.
|
|
12632
|
+
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
12633
|
+
*/
|
|
12634
|
+
const URL_MAX_LENGTH = 2000;
|
|
12635
|
+
/**
|
|
12636
|
+
* The default CSS dimensions of the embedded app
|
|
12637
|
+
*/
|
|
12638
|
+
const DEFAULT_EMBED_WIDTH = '100%';
|
|
12639
|
+
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
13026
12640
|
|
|
13027
12641
|
/**
|
|
13028
12642
|
*
|
|
13029
|
-
* @param
|
|
13030
|
-
* @param
|
|
12643
|
+
* @param root0
|
|
12644
|
+
* @param root0.query
|
|
12645
|
+
* @param root0.variables
|
|
12646
|
+
* @param root0.thoughtSpotHost
|
|
12647
|
+
* @param root0.isCompositeQuery
|
|
13031
12648
|
*/
|
|
13032
|
-
function
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
12649
|
+
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
12650
|
+
const operationName = getOperationNameFromQuery(query);
|
|
12651
|
+
try {
|
|
12652
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
12653
|
+
method: 'POST',
|
|
12654
|
+
headers: {
|
|
12655
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
12656
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12657
|
+
accept: '*/*',
|
|
12658
|
+
'accept-language': 'en-us',
|
|
12659
|
+
},
|
|
12660
|
+
body: JSON.stringify({
|
|
12661
|
+
operationName,
|
|
12662
|
+
query,
|
|
12663
|
+
variables,
|
|
12664
|
+
}),
|
|
12665
|
+
credentials: 'include',
|
|
12666
|
+
});
|
|
12667
|
+
const result = await response.json();
|
|
12668
|
+
const dataValues = Object.values(result.data);
|
|
12669
|
+
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
12670
|
+
}
|
|
12671
|
+
catch (error) {
|
|
12672
|
+
return error;
|
|
12673
|
+
}
|
|
12674
|
+
}
|
|
12675
|
+
|
|
12676
|
+
const getSourceDetailQuery = `
|
|
12677
|
+
query GetSourceDetail($ids: [GUID!]!) {
|
|
12678
|
+
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
12679
|
+
id
|
|
12680
|
+
name
|
|
12681
|
+
description
|
|
12682
|
+
authorName
|
|
12683
|
+
authorDisplayName
|
|
12684
|
+
isExternal
|
|
12685
|
+
type
|
|
12686
|
+
created
|
|
12687
|
+
modified
|
|
12688
|
+
columns {
|
|
12689
|
+
id
|
|
12690
|
+
name
|
|
12691
|
+
author
|
|
12692
|
+
authorDisplayName
|
|
12693
|
+
description
|
|
12694
|
+
dataType
|
|
12695
|
+
type
|
|
12696
|
+
modified
|
|
12697
|
+
ownerName
|
|
12698
|
+
owner
|
|
12699
|
+
dataRecency
|
|
12700
|
+
sources {
|
|
12701
|
+
tableId
|
|
12702
|
+
tableName
|
|
12703
|
+
columnId
|
|
12704
|
+
columnName
|
|
12705
|
+
__typename
|
|
12706
|
+
}
|
|
12707
|
+
synonyms
|
|
12708
|
+
cohortAnswerId
|
|
12709
|
+
__typename
|
|
12710
|
+
}
|
|
12711
|
+
relationships
|
|
12712
|
+
destinationRelationships
|
|
12713
|
+
dataSourceId
|
|
12714
|
+
__typename
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
`;
|
|
12718
|
+
const sourceDetailCache = new Map();
|
|
13041
12719
|
/**
|
|
13042
12720
|
*
|
|
13043
|
-
* @param
|
|
12721
|
+
* @param thoughtSpotHost
|
|
12722
|
+
* @param sourceId
|
|
13044
12723
|
*/
|
|
13045
|
-
function
|
|
13046
|
-
|
|
13047
|
-
|
|
12724
|
+
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
12725
|
+
if (sourceDetailCache.get(sourceId)) {
|
|
12726
|
+
return sourceDetailCache.get(sourceId);
|
|
12727
|
+
}
|
|
12728
|
+
const details = await graphqlQuery({
|
|
12729
|
+
query: getSourceDetailQuery,
|
|
12730
|
+
variables: {
|
|
12731
|
+
ids: [sourceId],
|
|
12732
|
+
},
|
|
12733
|
+
thoughtSpotHost,
|
|
13048
12734
|
});
|
|
12735
|
+
const souceDetails = details[0];
|
|
12736
|
+
if (souceDetails) {
|
|
12737
|
+
sourceDetailCache.set(sourceId, souceDetails);
|
|
12738
|
+
}
|
|
12739
|
+
return souceDetails;
|
|
13049
12740
|
}
|
|
13050
12741
|
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
}
|
|
12742
|
+
const bachSessionId = `
|
|
12743
|
+
id {
|
|
12744
|
+
sessionId
|
|
12745
|
+
genNo
|
|
12746
|
+
acSession {
|
|
12747
|
+
sessionId
|
|
12748
|
+
genNo
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
`;
|
|
12752
|
+
const getUnaggregatedAnswerSession = `
|
|
12753
|
+
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
12754
|
+
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
12755
|
+
${bachSessionId}
|
|
12756
|
+
answer {
|
|
12757
|
+
visualizations {
|
|
12758
|
+
... on TableViz {
|
|
12759
|
+
columns {
|
|
12760
|
+
column {
|
|
12761
|
+
id
|
|
12762
|
+
name
|
|
12763
|
+
referencedColumns {
|
|
12764
|
+
guid
|
|
12765
|
+
displayName
|
|
12766
|
+
}
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12774
|
+
`;
|
|
12775
|
+
const removeColumns = `
|
|
12776
|
+
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
12777
|
+
Answer__removeColumns(
|
|
12778
|
+
session: $session
|
|
12779
|
+
logicalColumnIds: $logicalColumnIds
|
|
12780
|
+
columnIds: $columnIds
|
|
12781
|
+
) {
|
|
12782
|
+
${bachSessionId}
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
`;
|
|
12786
|
+
const addColumns = `
|
|
12787
|
+
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
12788
|
+
Answer__addColumn(session: $session, columns: $columns) {
|
|
12789
|
+
${bachSessionId}
|
|
12790
|
+
}
|
|
12791
|
+
}
|
|
12792
|
+
`;
|
|
12793
|
+
const getAnswerData = `
|
|
12794
|
+
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
12795
|
+
getAnswer(session: $session) {
|
|
12796
|
+
${bachSessionId}
|
|
12797
|
+
answer {
|
|
12798
|
+
id
|
|
12799
|
+
visualizations {
|
|
12800
|
+
id
|
|
12801
|
+
... on TableViz {
|
|
12802
|
+
columns {
|
|
12803
|
+
column {
|
|
12804
|
+
id
|
|
12805
|
+
name
|
|
12806
|
+
type
|
|
12807
|
+
aggregationType
|
|
12808
|
+
dataType
|
|
12809
|
+
}
|
|
12810
|
+
}
|
|
12811
|
+
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
12812
|
+
}
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
12817
|
+
`;
|
|
12818
|
+
|
|
12819
|
+
// eslint-disable-next-line no-shadow
|
|
12820
|
+
var OperationType;
|
|
12821
|
+
(function (OperationType) {
|
|
12822
|
+
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
12823
|
+
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
12824
|
+
})(OperationType || (OperationType = {}));
|
|
13077
12825
|
/**
|
|
13078
|
-
*
|
|
12826
|
+
* Class representing the answer service provided with the
|
|
12827
|
+
* custom action payload. This service could be used to run
|
|
12828
|
+
* graphql queries in the context of the answer on which the
|
|
12829
|
+
* custom action was triggered.
|
|
13079
12830
|
*
|
|
13080
|
-
* @
|
|
12831
|
+
* @example
|
|
12832
|
+
* ```js
|
|
12833
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12834
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12835
|
+
* 'col name 1'
|
|
12836
|
+
* ]);
|
|
12837
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12838
|
+
* })
|
|
12839
|
+
* ```
|
|
12840
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12841
|
+
* @group Events
|
|
13081
12842
|
*/
|
|
13082
|
-
|
|
13083
|
-
(function (AuthStatus) {
|
|
13084
|
-
/**
|
|
13085
|
-
* Emits when the SDK fails to authenticate
|
|
13086
|
-
*/
|
|
13087
|
-
AuthStatus["FAILURE"] = "FAILURE";
|
|
13088
|
-
/**
|
|
13089
|
-
* Emits when the SDK authenticates successfully
|
|
13090
|
-
*/
|
|
13091
|
-
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
12843
|
+
class AnswerService {
|
|
13092
12844
|
/**
|
|
13093
|
-
*
|
|
12845
|
+
* Should not need to be called directly.
|
|
12846
|
+
*
|
|
12847
|
+
* @param session
|
|
12848
|
+
* @param answer
|
|
12849
|
+
* @param thoughtSpotHost
|
|
12850
|
+
* @param selectedPoints
|
|
13094
12851
|
*/
|
|
13095
|
-
|
|
12852
|
+
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
12853
|
+
this.session = session;
|
|
12854
|
+
this.answer = answer;
|
|
12855
|
+
this.thoughtSpotHost = thoughtSpotHost;
|
|
12856
|
+
this.selectedPoints = selectedPoints;
|
|
12857
|
+
this.session = removeTypename(session);
|
|
12858
|
+
}
|
|
13096
12859
|
/**
|
|
13097
|
-
*
|
|
12860
|
+
* Get the details about the source used in the answer.
|
|
12861
|
+
* This can be used to get the list of all columns in the data source for example.
|
|
13098
12862
|
*/
|
|
13099
|
-
|
|
12863
|
+
async getSourceDetail() {
|
|
12864
|
+
const sourceId = this.answer.sources[0].header.guid;
|
|
12865
|
+
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
12866
|
+
}
|
|
13100
12867
|
/**
|
|
13101
|
-
*
|
|
13102
|
-
* popup is waiting to be triggered either programmatically
|
|
13103
|
-
* or by the trigger button.
|
|
12868
|
+
* Remove columnIds and return updated answer session.
|
|
13104
12869
|
*
|
|
13105
|
-
* @
|
|
13106
|
-
|
|
13107
|
-
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
13108
|
-
})(AuthStatus || (AuthStatus = {}));
|
|
13109
|
-
/**
|
|
13110
|
-
* Events which can be triggered on the emitter returned from {@link init}.
|
|
13111
|
-
*
|
|
13112
|
-
* @group Authentication / Init
|
|
13113
|
-
*/
|
|
13114
|
-
var AuthEvent;
|
|
13115
|
-
(function (AuthEvent) {
|
|
13116
|
-
/**
|
|
13117
|
-
* Manually trigger the SSO popup. This is useful when
|
|
13118
|
-
* authStatus is SAMLRedirect/OIDCRedirect and inPopup is set to true
|
|
12870
|
+
* @param columnIds
|
|
12871
|
+
* @returns
|
|
13119
12872
|
*/
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
*/
|
|
13125
|
-
function notifyAuthSDKSuccess() {
|
|
13126
|
-
{
|
|
13127
|
-
logger.error('SDK not initialized');
|
|
13128
|
-
return;
|
|
13129
|
-
}
|
|
13130
|
-
}
|
|
13131
|
-
/**
|
|
13132
|
-
*
|
|
13133
|
-
*/
|
|
13134
|
-
function notifyAuthSuccess() {
|
|
13135
|
-
{
|
|
13136
|
-
logger.error('SDK not initialized');
|
|
13137
|
-
return;
|
|
13138
|
-
}
|
|
13139
|
-
}
|
|
13140
|
-
/**
|
|
13141
|
-
*
|
|
13142
|
-
* @param failureType
|
|
13143
|
-
*/
|
|
13144
|
-
function notifyAuthFailure(failureType) {
|
|
13145
|
-
{
|
|
13146
|
-
logger.error('SDK not initialized');
|
|
13147
|
-
return;
|
|
13148
|
-
}
|
|
13149
|
-
}
|
|
13150
|
-
/**
|
|
13151
|
-
*
|
|
13152
|
-
*/
|
|
13153
|
-
function notifyLogout() {
|
|
13154
|
-
{
|
|
13155
|
-
logger.error('SDK not initialized');
|
|
13156
|
-
return;
|
|
12873
|
+
async removeColumns(columnIds) {
|
|
12874
|
+
return this.executeQuery(removeColumns, {
|
|
12875
|
+
logicalColumnIds: columnIds,
|
|
12876
|
+
});
|
|
13157
12877
|
}
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
12878
|
+
/**
|
|
12879
|
+
* Add columnIds and return updated answer session.
|
|
12880
|
+
*
|
|
12881
|
+
* @param columnIds
|
|
12882
|
+
* @returns
|
|
12883
|
+
*/
|
|
12884
|
+
async addColumns(columnIds) {
|
|
12885
|
+
return this.executeQuery(addColumns, {
|
|
12886
|
+
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
12887
|
+
});
|
|
13167
12888
|
}
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
};
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
*/
|
|
13190
|
-
async function isLoggedIn(thoughtSpotHost) {
|
|
13191
|
-
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
13192
|
-
let response = null;
|
|
13193
|
-
try {
|
|
13194
|
-
response = await fetchSessionInfoService(authVerificationUrl);
|
|
13195
|
-
const sessionInfoResp = await response.json();
|
|
13196
|
-
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
13197
|
-
// Store user session details from session info
|
|
13198
|
-
initSession(sessionDetails);
|
|
13199
|
-
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12889
|
+
/**
|
|
12890
|
+
* Fetch data from the answer.
|
|
12891
|
+
*
|
|
12892
|
+
* @param offset
|
|
12893
|
+
* @param size
|
|
12894
|
+
* @returns
|
|
12895
|
+
*/
|
|
12896
|
+
async fetchData(offset = 0, size = 1000) {
|
|
12897
|
+
const { answer } = await this.executeQuery(getAnswerData, {
|
|
12898
|
+
deadline: 0,
|
|
12899
|
+
dataPaginationParams: {
|
|
12900
|
+
isClientPaginated: true,
|
|
12901
|
+
offset,
|
|
12902
|
+
size,
|
|
12903
|
+
},
|
|
12904
|
+
});
|
|
12905
|
+
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
12906
|
+
return {
|
|
12907
|
+
columns,
|
|
12908
|
+
data,
|
|
12909
|
+
};
|
|
13200
12910
|
}
|
|
13201
|
-
|
|
13202
|
-
|
|
12911
|
+
/**
|
|
12912
|
+
* Fetch the data for the answer as a CSV blob. This might be
|
|
12913
|
+
* quicker for larger data.
|
|
12914
|
+
*
|
|
12915
|
+
* @param userLocale
|
|
12916
|
+
* @param includeInfo Include the CSV header in the output
|
|
12917
|
+
* @returns Response
|
|
12918
|
+
*/
|
|
12919
|
+
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
12920
|
+
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
12921
|
+
return tokenizedFetch(fetchUrl, {
|
|
12922
|
+
credentials: 'include',
|
|
12923
|
+
});
|
|
13203
12924
|
}
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
*/
|
|
13215
|
-
function isAtSSORedirectUrl() {
|
|
13216
|
-
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
13217
|
-
}
|
|
13218
|
-
/**
|
|
13219
|
-
* Remove the SSO redirect URL marker
|
|
13220
|
-
*/
|
|
13221
|
-
function removeSSORedirectUrlMarker() {
|
|
13222
|
-
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
13223
|
-
// to begin with. Trying to remove the hash by changing window.location will
|
|
13224
|
-
// reload the page which we don't want. We'll live with adding an
|
|
13225
|
-
// unnecessary hash to the parent page URL until we find any use case where
|
|
13226
|
-
// that creates an issue.
|
|
13227
|
-
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
13228
|
-
}
|
|
13229
|
-
/**
|
|
13230
|
-
* Perform token based authentication
|
|
13231
|
-
*
|
|
13232
|
-
* @param embedConfig The embed configuration
|
|
13233
|
-
*/
|
|
13234
|
-
const doTokenAuth = async (embedConfig) => {
|
|
13235
|
-
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
13236
|
-
if (!authEndpoint && !getAuthToken) {
|
|
13237
|
-
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12925
|
+
/**
|
|
12926
|
+
* Just get the internal URL for this answer's data
|
|
12927
|
+
* as a CSV blob.
|
|
12928
|
+
*
|
|
12929
|
+
* @param userLocale
|
|
12930
|
+
* @param includeInfo
|
|
12931
|
+
* @returns
|
|
12932
|
+
*/
|
|
12933
|
+
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
12934
|
+
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
13238
12935
|
}
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
12936
|
+
/**
|
|
12937
|
+
* Get underlying data given a point and the output column names.
|
|
12938
|
+
* In case of a context menu action, the selectedPoints are
|
|
12939
|
+
* automatically passed.
|
|
12940
|
+
*
|
|
12941
|
+
* @param outputColumnNames
|
|
12942
|
+
* @param selectedPoints
|
|
12943
|
+
* @example
|
|
12944
|
+
* ```js
|
|
12945
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12946
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12947
|
+
* 'col name 1' // The column should exist in the data source.
|
|
12948
|
+
* ]);
|
|
12949
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12950
|
+
* })
|
|
12951
|
+
* ```
|
|
12952
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12953
|
+
*/
|
|
12954
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
12955
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
12956
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
13245
12957
|
}
|
|
13246
|
-
|
|
13247
|
-
|
|
12958
|
+
if (!selectedPoints) {
|
|
12959
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
13248
12960
|
}
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
12961
|
+
const sourceDetail = await this.getSourceDetail();
|
|
12962
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
12963
|
+
const unAggAnswer = await graphqlQuery({
|
|
12964
|
+
query: getUnaggregatedAnswerSession,
|
|
12965
|
+
variables: {
|
|
12966
|
+
session: this.session,
|
|
12967
|
+
columns: selectedPoints,
|
|
12968
|
+
},
|
|
12969
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12970
|
+
});
|
|
12971
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
12972
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
12973
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
12974
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
12975
|
+
if (columnsToAdd.length) {
|
|
12976
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
13255
12977
|
}
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
/**
|
|
13260
|
-
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
13261
|
-
*
|
|
13262
|
-
* @param embedConfig The embed configuration
|
|
13263
|
-
*/
|
|
13264
|
-
const doCookielessTokenAuth = async (embedConfig) => {
|
|
13265
|
-
const { authEndpoint, getAuthToken } = embedConfig;
|
|
13266
|
-
if (!authEndpoint && !getAuthToken) {
|
|
13267
|
-
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
13268
|
-
}
|
|
13269
|
-
let authSuccess = false;
|
|
13270
|
-
try {
|
|
13271
|
-
const authToken = await getAuthenticationToken(embedConfig);
|
|
13272
|
-
if (authToken) {
|
|
13273
|
-
authSuccess = true;
|
|
12978
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
12979
|
+
if (columnsToRemove.length) {
|
|
12980
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
13274
12981
|
}
|
|
12982
|
+
return unaggAnswerSession;
|
|
13275
12983
|
}
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
loggedInStatus = response.ok;
|
|
13296
|
-
if (embedConfig.detectCookieAccessSlow) {
|
|
13297
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13298
|
-
}
|
|
12984
|
+
/**
|
|
12985
|
+
* Execute a custom graphql query in the context of the answer.
|
|
12986
|
+
*
|
|
12987
|
+
* @param query graphql query
|
|
12988
|
+
* @param variables graphql variables
|
|
12989
|
+
* @returns
|
|
12990
|
+
*/
|
|
12991
|
+
async executeQuery(query, variables) {
|
|
12992
|
+
const data = await graphqlQuery({
|
|
12993
|
+
query,
|
|
12994
|
+
variables: {
|
|
12995
|
+
session: this.session,
|
|
12996
|
+
...variables,
|
|
12997
|
+
},
|
|
12998
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12999
|
+
isCompositeQuery: false,
|
|
13000
|
+
});
|
|
13001
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
13002
|
+
return data;
|
|
13299
13003
|
}
|
|
13300
|
-
|
|
13301
|
-
|
|
13004
|
+
/**
|
|
13005
|
+
* Get the internal session details for the answer.
|
|
13006
|
+
*
|
|
13007
|
+
* @returns
|
|
13008
|
+
*/
|
|
13009
|
+
getSession() {
|
|
13010
|
+
return this.session;
|
|
13302
13011
|
}
|
|
13303
|
-
|
|
13304
|
-
};
|
|
13012
|
+
}
|
|
13305
13013
|
/**
|
|
13306
13014
|
*
|
|
13307
|
-
* @param
|
|
13308
|
-
* @param
|
|
13309
|
-
* @param triggerText
|
|
13015
|
+
* @param sourceDetail
|
|
13016
|
+
* @param colNames
|
|
13310
13017
|
*/
|
|
13311
|
-
|
|
13312
|
-
const
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
};
|
|
13320
|
-
const containerEl = getDOMNode(triggerContainer);
|
|
13321
|
-
if (containerEl) {
|
|
13322
|
-
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
13323
|
-
const authElem = document.getElementById('ts-auth-btn');
|
|
13324
|
-
authElem.textContent = triggerText;
|
|
13325
|
-
authElem.addEventListener('click', openPopup, { once: true });
|
|
13326
|
-
}
|
|
13327
|
-
samlCompletionPromise = samlCompletionPromise
|
|
13328
|
-
|| new Promise((resolve, reject) => {
|
|
13329
|
-
window.addEventListener('message', (e) => {
|
|
13330
|
-
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
13331
|
-
e.source.close();
|
|
13332
|
-
resolve();
|
|
13333
|
-
}
|
|
13334
|
-
});
|
|
13335
|
-
});
|
|
13336
|
-
return samlCompletionPromise;
|
|
13018
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
13019
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
13020
|
+
colSet[col.name] = col;
|
|
13021
|
+
return colSet;
|
|
13022
|
+
}, {});
|
|
13023
|
+
return new Set(colNames.map((colName) => {
|
|
13024
|
+
const col = cols[colName];
|
|
13025
|
+
return col.id;
|
|
13026
|
+
}));
|
|
13337
13027
|
}
|
|
13338
13028
|
/**
|
|
13339
|
-
* Perform SAML authentication
|
|
13340
13029
|
*
|
|
13341
|
-
* @param
|
|
13342
|
-
* @param ssoEndPoint
|
|
13030
|
+
* @param selectedPoints
|
|
13343
13031
|
*/
|
|
13344
|
-
|
|
13345
|
-
const
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13032
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
13033
|
+
const underlyingDataPoint = [];
|
|
13034
|
+
/**
|
|
13035
|
+
*
|
|
13036
|
+
* @param colVal
|
|
13037
|
+
*/
|
|
13038
|
+
function addPointFromColVal(colVal) {
|
|
13039
|
+
var _a;
|
|
13040
|
+
const dataType = colVal.column.dataType;
|
|
13041
|
+
const id = colVal.column.id;
|
|
13042
|
+
let dataValue;
|
|
13043
|
+
if (dataType === 'DATE') {
|
|
13044
|
+
if (Number.isFinite(colVal.value)) {
|
|
13045
|
+
dataValue = [{
|
|
13046
|
+
epochRange: {
|
|
13047
|
+
startEpoch: colVal.value,
|
|
13048
|
+
},
|
|
13049
|
+
}];
|
|
13050
|
+
// Case for custom calendar.
|
|
13051
|
+
}
|
|
13052
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
13053
|
+
dataValue = [{
|
|
13054
|
+
epochRange: {
|
|
13055
|
+
startEpoch: colVal.value.v.s,
|
|
13056
|
+
endEpoch: colVal.value.v.e,
|
|
13057
|
+
},
|
|
13058
|
+
}];
|
|
13059
|
+
}
|
|
13350
13060
|
}
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
loggedInStatus = false;
|
|
13359
|
-
return;
|
|
13360
|
-
}
|
|
13361
|
-
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
13362
|
-
if (embedConfig.inPopup) {
|
|
13363
|
-
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
13364
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13365
|
-
return;
|
|
13366
|
-
}
|
|
13367
|
-
window.location.href = ssoURL;
|
|
13368
|
-
};
|
|
13369
|
-
const doSamlAuth = async (embedConfig) => {
|
|
13370
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13371
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13372
|
-
// loaded again and the same JS will execute again.
|
|
13373
|
-
const ssoRedirectUrl = embedConfig.inPopup
|
|
13374
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13375
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13376
|
-
// bring back the page to the same URL
|
|
13377
|
-
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13378
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13379
|
-
return loggedInStatus;
|
|
13380
|
-
};
|
|
13381
|
-
const doOIDCAuth = async (embedConfig) => {
|
|
13382
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13383
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13384
|
-
// loaded again and the same JS will execute again.
|
|
13385
|
-
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
13386
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13387
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13388
|
-
// bring back the page to the same URL
|
|
13389
|
-
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13390
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13391
|
-
return loggedInStatus;
|
|
13392
|
-
};
|
|
13393
|
-
/**
|
|
13394
|
-
* Perform authentication on the ThoughtSpot cluster
|
|
13395
|
-
*
|
|
13396
|
-
* @param embedConfig The embed configuration
|
|
13397
|
-
*/
|
|
13398
|
-
const authenticate = async (embedConfig) => {
|
|
13399
|
-
const { authType } = embedConfig;
|
|
13400
|
-
switch (authType) {
|
|
13401
|
-
case AuthType.SSO:
|
|
13402
|
-
case AuthType.SAMLRedirect:
|
|
13403
|
-
case AuthType.SAML:
|
|
13404
|
-
return doSamlAuth(embedConfig);
|
|
13405
|
-
case AuthType.OIDC:
|
|
13406
|
-
case AuthType.OIDCRedirect:
|
|
13407
|
-
return doOIDCAuth(embedConfig);
|
|
13408
|
-
case AuthType.AuthServer:
|
|
13409
|
-
case AuthType.TrustedAuthToken:
|
|
13410
|
-
return doTokenAuth(embedConfig);
|
|
13411
|
-
case AuthType.TrustedAuthTokenCookieless:
|
|
13412
|
-
return doCookielessTokenAuth(embedConfig);
|
|
13413
|
-
case AuthType.Basic:
|
|
13414
|
-
return doBasicAuth(embedConfig);
|
|
13415
|
-
default:
|
|
13416
|
-
return Promise.resolve(true);
|
|
13061
|
+
else {
|
|
13062
|
+
dataValue = [{ value: colVal.value }];
|
|
13063
|
+
}
|
|
13064
|
+
underlyingDataPoint.push({
|
|
13065
|
+
columnId: colVal.column.id,
|
|
13066
|
+
dataValue,
|
|
13067
|
+
});
|
|
13417
13068
|
}
|
|
13069
|
+
selectedPoints.forEach((p) => {
|
|
13070
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
13071
|
+
});
|
|
13072
|
+
return underlyingDataPoint;
|
|
13073
|
+
}
|
|
13074
|
+
|
|
13075
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
13076
|
+
|
|
13077
|
+
var has = Object.prototype.hasOwnProperty
|
|
13078
|
+
, prefix = '~';
|
|
13079
|
+
|
|
13080
|
+
/**
|
|
13081
|
+
* Constructor to create a storage for our `EE` objects.
|
|
13082
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
13083
|
+
*
|
|
13084
|
+
* @constructor
|
|
13085
|
+
* @private
|
|
13086
|
+
*/
|
|
13087
|
+
function Events() {}
|
|
13088
|
+
|
|
13089
|
+
//
|
|
13090
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
13091
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
13092
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
13093
|
+
// character to make sure that the built-in object properties are not
|
|
13094
|
+
// overridden or used as an attack vector.
|
|
13095
|
+
//
|
|
13096
|
+
if (Object.create) {
|
|
13097
|
+
Events.prototype = Object.create(null);
|
|
13098
|
+
|
|
13099
|
+
//
|
|
13100
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
13101
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
13102
|
+
//
|
|
13103
|
+
if (!new Events().__proto__) prefix = false;
|
|
13104
|
+
}
|
|
13105
|
+
|
|
13106
|
+
/**
|
|
13107
|
+
* Representation of a single event listener.
|
|
13108
|
+
*
|
|
13109
|
+
* @param {Function} fn The listener function.
|
|
13110
|
+
* @param {*} context The context to invoke the listener with.
|
|
13111
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
13112
|
+
* @constructor
|
|
13113
|
+
* @private
|
|
13114
|
+
*/
|
|
13115
|
+
function EE(fn, context, once) {
|
|
13116
|
+
this.fn = fn;
|
|
13117
|
+
this.context = context;
|
|
13118
|
+
this.once = once || false;
|
|
13119
|
+
}
|
|
13120
|
+
|
|
13121
|
+
/**
|
|
13122
|
+
* Add a listener for a given event.
|
|
13123
|
+
*
|
|
13124
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13125
|
+
* @param {(String|Symbol)} event The event name.
|
|
13126
|
+
* @param {Function} fn The listener function.
|
|
13127
|
+
* @param {*} context The context to invoke the listener with.
|
|
13128
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
13129
|
+
* @returns {EventEmitter}
|
|
13130
|
+
* @private
|
|
13131
|
+
*/
|
|
13132
|
+
function addListener(emitter, event, fn, context, once) {
|
|
13133
|
+
if (typeof fn !== 'function') {
|
|
13134
|
+
throw new TypeError('The listener must be a function');
|
|
13135
|
+
}
|
|
13136
|
+
|
|
13137
|
+
var listener = new EE(fn, context || emitter, once)
|
|
13138
|
+
, evt = prefix ? prefix + event : event;
|
|
13139
|
+
|
|
13140
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
13141
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
13142
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
13143
|
+
|
|
13144
|
+
return emitter;
|
|
13145
|
+
}
|
|
13146
|
+
|
|
13147
|
+
/**
|
|
13148
|
+
* Clear event by name.
|
|
13149
|
+
*
|
|
13150
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13151
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
13152
|
+
* @private
|
|
13153
|
+
*/
|
|
13154
|
+
function clearEvent(emitter, evt) {
|
|
13155
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
13156
|
+
else delete emitter._events[evt];
|
|
13157
|
+
}
|
|
13158
|
+
|
|
13159
|
+
/**
|
|
13160
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
13161
|
+
* `EventEmitter` interface.
|
|
13162
|
+
*
|
|
13163
|
+
* @constructor
|
|
13164
|
+
* @public
|
|
13165
|
+
*/
|
|
13166
|
+
function EventEmitter() {
|
|
13167
|
+
this._events = new Events();
|
|
13168
|
+
this._eventsCount = 0;
|
|
13169
|
+
}
|
|
13170
|
+
|
|
13171
|
+
/**
|
|
13172
|
+
* Return an array listing the events for which the emitter has registered
|
|
13173
|
+
* listeners.
|
|
13174
|
+
*
|
|
13175
|
+
* @returns {Array}
|
|
13176
|
+
* @public
|
|
13177
|
+
*/
|
|
13178
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
13179
|
+
var names = []
|
|
13180
|
+
, events
|
|
13181
|
+
, name;
|
|
13182
|
+
|
|
13183
|
+
if (this._eventsCount === 0) return names;
|
|
13184
|
+
|
|
13185
|
+
for (name in (events = this._events)) {
|
|
13186
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
13187
|
+
}
|
|
13188
|
+
|
|
13189
|
+
if (Object.getOwnPropertySymbols) {
|
|
13190
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
13191
|
+
}
|
|
13192
|
+
|
|
13193
|
+
return names;
|
|
13194
|
+
};
|
|
13195
|
+
|
|
13196
|
+
/**
|
|
13197
|
+
* Return the listeners registered for a given event.
|
|
13198
|
+
*
|
|
13199
|
+
* @param {(String|Symbol)} event The event name.
|
|
13200
|
+
* @returns {Array} The registered listeners.
|
|
13201
|
+
* @public
|
|
13202
|
+
*/
|
|
13203
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
13204
|
+
var evt = prefix ? prefix + event : event
|
|
13205
|
+
, handlers = this._events[evt];
|
|
13206
|
+
|
|
13207
|
+
if (!handlers) return [];
|
|
13208
|
+
if (handlers.fn) return [handlers.fn];
|
|
13209
|
+
|
|
13210
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
13211
|
+
ee[i] = handlers[i].fn;
|
|
13212
|
+
}
|
|
13213
|
+
|
|
13214
|
+
return ee;
|
|
13215
|
+
};
|
|
13216
|
+
|
|
13217
|
+
/**
|
|
13218
|
+
* Return the number of listeners listening to a given event.
|
|
13219
|
+
*
|
|
13220
|
+
* @param {(String|Symbol)} event The event name.
|
|
13221
|
+
* @returns {Number} The number of listeners.
|
|
13222
|
+
* @public
|
|
13223
|
+
*/
|
|
13224
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
13225
|
+
var evt = prefix ? prefix + event : event
|
|
13226
|
+
, listeners = this._events[evt];
|
|
13227
|
+
|
|
13228
|
+
if (!listeners) return 0;
|
|
13229
|
+
if (listeners.fn) return 1;
|
|
13230
|
+
return listeners.length;
|
|
13231
|
+
};
|
|
13232
|
+
|
|
13233
|
+
/**
|
|
13234
|
+
* Calls each of the listeners registered for a given event.
|
|
13235
|
+
*
|
|
13236
|
+
* @param {(String|Symbol)} event The event name.
|
|
13237
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
13238
|
+
* @public
|
|
13239
|
+
*/
|
|
13240
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
13241
|
+
var evt = prefix ? prefix + event : event;
|
|
13242
|
+
|
|
13243
|
+
if (!this._events[evt]) return false;
|
|
13244
|
+
|
|
13245
|
+
var listeners = this._events[evt]
|
|
13246
|
+
, len = arguments.length
|
|
13247
|
+
, args
|
|
13248
|
+
, i;
|
|
13249
|
+
|
|
13250
|
+
if (listeners.fn) {
|
|
13251
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
13252
|
+
|
|
13253
|
+
switch (len) {
|
|
13254
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
13255
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
13256
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
13257
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
13258
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
13259
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
13260
|
+
}
|
|
13261
|
+
|
|
13262
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
13263
|
+
args[i - 1] = arguments[i];
|
|
13264
|
+
}
|
|
13265
|
+
|
|
13266
|
+
listeners.fn.apply(listeners.context, args);
|
|
13267
|
+
} else {
|
|
13268
|
+
var length = listeners.length
|
|
13269
|
+
, j;
|
|
13270
|
+
|
|
13271
|
+
for (i = 0; i < length; i++) {
|
|
13272
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
13273
|
+
|
|
13274
|
+
switch (len) {
|
|
13275
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
13276
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
13277
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
13278
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
13279
|
+
default:
|
|
13280
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
13281
|
+
args[j - 1] = arguments[j];
|
|
13282
|
+
}
|
|
13283
|
+
|
|
13284
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
13285
|
+
}
|
|
13286
|
+
}
|
|
13287
|
+
}
|
|
13288
|
+
|
|
13289
|
+
return true;
|
|
13290
|
+
};
|
|
13291
|
+
|
|
13292
|
+
/**
|
|
13293
|
+
* Add a listener for a given event.
|
|
13294
|
+
*
|
|
13295
|
+
* @param {(String|Symbol)} event The event name.
|
|
13296
|
+
* @param {Function} fn The listener function.
|
|
13297
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13298
|
+
* @returns {EventEmitter} `this`.
|
|
13299
|
+
* @public
|
|
13300
|
+
*/
|
|
13301
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
13302
|
+
return addListener(this, event, fn, context, false);
|
|
13303
|
+
};
|
|
13304
|
+
|
|
13305
|
+
/**
|
|
13306
|
+
* Add a one-time listener for a given event.
|
|
13307
|
+
*
|
|
13308
|
+
* @param {(String|Symbol)} event The event name.
|
|
13309
|
+
* @param {Function} fn The listener function.
|
|
13310
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13311
|
+
* @returns {EventEmitter} `this`.
|
|
13312
|
+
* @public
|
|
13313
|
+
*/
|
|
13314
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
13315
|
+
return addListener(this, event, fn, context, true);
|
|
13316
|
+
};
|
|
13317
|
+
|
|
13318
|
+
/**
|
|
13319
|
+
* Remove the listeners of a given event.
|
|
13320
|
+
*
|
|
13321
|
+
* @param {(String|Symbol)} event The event name.
|
|
13322
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
13323
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
13324
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
13325
|
+
* @returns {EventEmitter} `this`.
|
|
13326
|
+
* @public
|
|
13327
|
+
*/
|
|
13328
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
13329
|
+
var evt = prefix ? prefix + event : event;
|
|
13330
|
+
|
|
13331
|
+
if (!this._events[evt]) return this;
|
|
13332
|
+
if (!fn) {
|
|
13333
|
+
clearEvent(this, evt);
|
|
13334
|
+
return this;
|
|
13335
|
+
}
|
|
13336
|
+
|
|
13337
|
+
var listeners = this._events[evt];
|
|
13338
|
+
|
|
13339
|
+
if (listeners.fn) {
|
|
13340
|
+
if (
|
|
13341
|
+
listeners.fn === fn &&
|
|
13342
|
+
(!once || listeners.once) &&
|
|
13343
|
+
(!context || listeners.context === context)
|
|
13344
|
+
) {
|
|
13345
|
+
clearEvent(this, evt);
|
|
13346
|
+
}
|
|
13347
|
+
} else {
|
|
13348
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
13349
|
+
if (
|
|
13350
|
+
listeners[i].fn !== fn ||
|
|
13351
|
+
(once && !listeners[i].once) ||
|
|
13352
|
+
(context && listeners[i].context !== context)
|
|
13353
|
+
) {
|
|
13354
|
+
events.push(listeners[i]);
|
|
13355
|
+
}
|
|
13356
|
+
}
|
|
13357
|
+
|
|
13358
|
+
//
|
|
13359
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
13360
|
+
//
|
|
13361
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
13362
|
+
else clearEvent(this, evt);
|
|
13363
|
+
}
|
|
13364
|
+
|
|
13365
|
+
return this;
|
|
13366
|
+
};
|
|
13367
|
+
|
|
13368
|
+
/**
|
|
13369
|
+
* Remove all listeners, or those of the specified event.
|
|
13370
|
+
*
|
|
13371
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
13372
|
+
* @returns {EventEmitter} `this`.
|
|
13373
|
+
* @public
|
|
13374
|
+
*/
|
|
13375
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
13376
|
+
var evt;
|
|
13377
|
+
|
|
13378
|
+
if (event) {
|
|
13379
|
+
evt = prefix ? prefix + event : event;
|
|
13380
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
13381
|
+
} else {
|
|
13382
|
+
this._events = new Events();
|
|
13383
|
+
this._eventsCount = 0;
|
|
13384
|
+
}
|
|
13385
|
+
|
|
13386
|
+
return this;
|
|
13387
|
+
};
|
|
13388
|
+
|
|
13389
|
+
//
|
|
13390
|
+
// Alias methods names because people roll like that.
|
|
13391
|
+
//
|
|
13392
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
13393
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
13394
|
+
|
|
13395
|
+
//
|
|
13396
|
+
// Expose the prefix.
|
|
13397
|
+
//
|
|
13398
|
+
EventEmitter.prefixed = prefix;
|
|
13399
|
+
|
|
13400
|
+
//
|
|
13401
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
13402
|
+
//
|
|
13403
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
13404
|
+
|
|
13405
|
+
//
|
|
13406
|
+
// Expose the module.
|
|
13407
|
+
//
|
|
13408
|
+
{
|
|
13409
|
+
module.exports = EventEmitter;
|
|
13410
|
+
}
|
|
13411
|
+
});
|
|
13412
|
+
|
|
13413
|
+
/** Used as references for various `Number` constants. */
|
|
13414
|
+
var INFINITY = 1 / 0;
|
|
13415
|
+
|
|
13416
|
+
/**
|
|
13417
|
+
* Creates a set object of `values`.
|
|
13418
|
+
*
|
|
13419
|
+
* @private
|
|
13420
|
+
* @param {Array} values The values to add to the set.
|
|
13421
|
+
* @returns {Object} Returns the new set.
|
|
13422
|
+
*/
|
|
13423
|
+
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
13424
|
+
return new _Set(values);
|
|
13418
13425
|
};
|
|
13419
13426
|
|
|
13420
13427
|
/* eslint-disable camelcase */
|
|
@@ -13630,8 +13637,6 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
13630
13637
|
});
|
|
13631
13638
|
}
|
|
13632
13639
|
|
|
13633
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.28.0-alpha.5";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",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-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","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","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"};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","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",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","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","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","@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/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","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","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-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:"2.30.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"};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,"size-limit":[{path:"dist/tsembed.js",limit:"44 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};
|
|
13634
|
-
|
|
13635
13640
|
/**
|
|
13636
13641
|
* Copyright (c) 2022
|
|
13637
13642
|
*
|
|
@@ -14864,7 +14869,7 @@ class SearchEmbed extends TsEmbed {
|
|
|
14864
14869
|
}
|
|
14865
14870
|
getEmbedParams() {
|
|
14866
14871
|
var _a;
|
|
14867
|
-
const { hideResults, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL = true, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
14872
|
+
const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL = true, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
14868
14873
|
const queryParams = this.getBaseQueryParams();
|
|
14869
14874
|
queryParams[Param.HideActions] = [
|
|
14870
14875
|
...((_a = queryParams[Param.HideActions]) !== null && _a !== void 0 ? _a : []),
|