@thoughtspot/visual-embed-sdk 1.26.0-token-cache.0 → 1.26.0-token-cache.2
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/cjs/package.json +2 -2
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +1 -1
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +3 -3
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/embed/base.d.ts +0 -8
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +21 -45
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +12 -13
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts +18 -0
- package/cjs/src/embed/embedConfig.d.ts.map +1 -0
- package/cjs/src/embed/embedConfig.js +25 -0
- package/cjs/src/embed/embedConfig.js.map +1 -0
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +3 -2
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +3 -2
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +2 -1
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +11 -13
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +2 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/tokenizedFetch.d.ts.map +1 -1
- package/cjs/src/tokenizedFetch.js +4 -4
- package/cjs/src/tokenizedFetch.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts +45 -0
- package/cjs/src/utils/authService/authService.d.ts.map +1 -0
- package/cjs/src/utils/authService/authService.js +115 -0
- package/cjs/src/utils/authService/authService.js.map +1 -0
- package/cjs/src/utils/authService/authService.spec.d.ts +2 -0
- package/cjs/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService/authService.spec.js +82 -0
- package/cjs/src/utils/authService/authService.spec.js.map +1 -0
- package/cjs/src/utils/authService/index.d.ts +3 -0
- package/cjs/src/utils/authService/index.d.ts.map +1 -0
- package/cjs/src/utils/authService/index.js +14 -0
- package/cjs/src/utils/authService/index.js.map +1 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.js +44 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +2 -2
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/processData.js +4 -3
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +8 -7
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +0 -8
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts +18 -0
- package/dist/src/embed/embedConfig.d.ts.map +1 -0
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/tokenizedFetch.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts +45 -0
- package/dist/src/utils/authService/authService.d.ts.map +1 -0
- package/dist/src/utils/authService/authService.spec.d.ts +2 -0
- package/dist/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/dist/src/utils/authService/index.d.ts +3 -0
- package/dist/src/utils/authService/index.d.ts.map +1 -0
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +1228 -1212
- package/dist/tsembed-react.js +1463 -1447
- package/dist/tsembed.es.js +1632 -1621
- package/dist/tsembed.js +1622 -1611
- package/dist/visual-embed-sdk-react-full.d.ts +17 -8
- package/dist/visual-embed-sdk-react.d.ts +17 -8
- package/dist/visual-embed-sdk.d.ts +17 -8
- package/lib/package.json +2 -2
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +1 -1
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +3 -3
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/embed/base.d.ts +0 -8
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +20 -43
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +12 -13
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts +18 -0
- package/lib/src/embed/embedConfig.d.ts.map +1 -0
- package/lib/src/embed/embedConfig.js +20 -0
- package/lib/src/embed/embedConfig.js.map +1 -0
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +2 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +3 -2
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +2 -1
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +11 -13
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/tokenizedFetch.d.ts.map +1 -1
- package/lib/src/tokenizedFetch.js +3 -3
- package/lib/src/tokenizedFetch.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts +45 -0
- package/lib/src/utils/authService/authService.d.ts.map +1 -0
- package/lib/src/utils/authService/authService.js +107 -0
- package/lib/src/utils/authService/authService.js.map +1 -0
- package/lib/src/utils/authService/authService.spec.d.ts +2 -0
- package/lib/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService/authService.spec.js +80 -0
- package/lib/src/utils/authService/authService.spec.js.map +1 -0
- package/lib/src/utils/authService/index.d.ts +3 -0
- package/lib/src/utils/authService/index.d.ts.map +1 -0
- package/lib/src/utils/authService/index.js +3 -0
- package/lib/src/utils/authService/index.js.map +1 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.js +39 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js +2 -2
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/processData.js +2 -1
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +8 -7
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +22 -9
- package/package.json +2 -2
- package/src/auth.spec.ts +29 -28
- package/src/auth.ts +1 -5
- package/src/authToken.ts +11 -3
- package/src/embed/base.spec.ts +13 -13
- package/src/embed/base.ts +26 -50
- package/src/embed/embedConfig.ts +23 -0
- package/src/embed/search.ts +9 -10
- package/src/embed/searchEmbed-basic-auth.spec.ts +3 -2
- package/src/embed/ts-embed.spec.ts +34 -36
- package/src/embed/ts-embed.ts +9 -19
- package/src/index.ts +8 -2
- package/src/tokenizedFetch.ts +6 -4
- package/src/utils/{authService.spec.ts → authService/authService.spec.ts} +1 -1
- package/src/utils/{authService.ts → authService/authService.ts} +0 -24
- package/src/utils/authService/index.ts +9 -0
- package/src/utils/authService/tokenisedAuthSerice.ts +40 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +2 -2
- package/src/utils/processData.spec.ts +19 -16
- package/src/utils/processData.ts +1 -1
package/dist/tsembed.js
CHANGED
|
@@ -4924,15 +4924,6 @@
|
|
|
4924
4924
|
return r;
|
|
4925
4925
|
});
|
|
4926
4926
|
}
|
|
4927
|
-
/**
|
|
4928
|
-
*
|
|
4929
|
-
* @param authVerificationUrl
|
|
4930
|
-
*/
|
|
4931
|
-
function fetchSessionInfoService(authVerificationUrl) {
|
|
4932
|
-
return failureLoggedFetch(authVerificationUrl, {
|
|
4933
|
-
credentials: 'include',
|
|
4934
|
-
});
|
|
4935
|
-
}
|
|
4936
4927
|
/**
|
|
4937
4928
|
* Service to validate a auth token against a ThoughtSpot host.
|
|
4938
4929
|
*
|
|
@@ -5013,13 +5004,70 @@
|
|
|
5013
5004
|
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
5014
5005
|
credentials: 'include',
|
|
5015
5006
|
});
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
let config = {};
|
|
5010
|
+
/**
|
|
5011
|
+
* Gets the configuration embed was initialized with.
|
|
5012
|
+
*
|
|
5013
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
5014
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
5015
|
+
* @group Global methods
|
|
5016
|
+
*/
|
|
5017
|
+
const getEmbedConfig = () => config;
|
|
5018
|
+
/**
|
|
5019
|
+
* Sets the configuration embed was initialized with.
|
|
5020
|
+
*
|
|
5021
|
+
* @param newConfig The configuration to set.
|
|
5022
|
+
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
5023
|
+
* @group Global methods
|
|
5024
|
+
*/
|
|
5025
|
+
const setEmbedConfig = (newConfig) => {
|
|
5026
|
+
config = newConfig;
|
|
5027
|
+
};
|
|
5028
|
+
|
|
5029
|
+
const tokenizedFetch = async (input, init) => {
|
|
5030
|
+
const embedConfig = getEmbedConfig();
|
|
5031
|
+
if (embedConfig.authType !== exports.AuthType.TrustedAuthTokenCookieless) {
|
|
5032
|
+
return fetch(input, init);
|
|
5033
|
+
}
|
|
5034
|
+
const req = new Request(input, init);
|
|
5035
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
5036
|
+
if (authToken) {
|
|
5037
|
+
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
5038
|
+
}
|
|
5039
|
+
return fetch(req);
|
|
5040
|
+
};
|
|
5041
|
+
|
|
5042
|
+
/**
|
|
5043
|
+
*
|
|
5044
|
+
* @param url
|
|
5045
|
+
* @param options
|
|
5046
|
+
*/
|
|
5047
|
+
function tokenisedFailureLoggedFetch(url, options = {}) {
|
|
5048
|
+
return tokenizedFetch(url, options).then(async (r) => {
|
|
5049
|
+
var _a;
|
|
5050
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
5051
|
+
console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
5052
|
+
}
|
|
5053
|
+
return r;
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
*
|
|
5058
|
+
* @param authVerificationUrl
|
|
5059
|
+
*/
|
|
5060
|
+
function fetchSessionInfoService(authVerificationUrl) {
|
|
5061
|
+
return tokenisedFailureLoggedFetch(authVerificationUrl, {
|
|
5062
|
+
credentials: 'include',
|
|
5063
|
+
});
|
|
5016
5064
|
}
|
|
5017
5065
|
/**
|
|
5018
5066
|
*
|
|
5019
5067
|
* @param thoughtSpotHost
|
|
5020
5068
|
*/
|
|
5021
5069
|
async function fetchLogoutService(thoughtSpotHost) {
|
|
5022
|
-
return
|
|
5070
|
+
return tokenisedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
5023
5071
|
credentials: 'include',
|
|
5024
5072
|
method: 'POST',
|
|
5025
5073
|
headers: {
|
|
@@ -5036,7 +5084,7 @@
|
|
|
5036
5084
|
const getAuthenticationToken = async (embedConfig) => {
|
|
5037
5085
|
if (cachedAuthToken) {
|
|
5038
5086
|
try {
|
|
5039
|
-
const isCachedTokenStillValid = await validateAuthToken(embedConfig, cachedAuthToken);
|
|
5087
|
+
const isCachedTokenStillValid = await validateAuthToken(embedConfig, cachedAuthToken, true);
|
|
5040
5088
|
if (isCachedTokenStillValid)
|
|
5041
5089
|
return cachedAuthToken;
|
|
5042
5090
|
}
|
|
@@ -5058,7 +5106,7 @@
|
|
|
5058
5106
|
cachedAuthToken = authToken;
|
|
5059
5107
|
return authToken;
|
|
5060
5108
|
};
|
|
5061
|
-
const validateAuthToken = async (embedConfig, authToken) => {
|
|
5109
|
+
const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
5062
5110
|
try {
|
|
5063
5111
|
const isTokenValid = await verifyTokenService(embedConfig.thoughtSpotHost, authToken);
|
|
5064
5112
|
if (isTokenValid)
|
|
@@ -5068,7 +5116,7 @@
|
|
|
5068
5116
|
return false;
|
|
5069
5117
|
}
|
|
5070
5118
|
if (cachedAuthToken && cachedAuthToken === authToken) {
|
|
5071
|
-
if (!embedConfig.suppressErrorAlerts) {
|
|
5119
|
+
if (!embedConfig.suppressErrorAlerts && !suppressAlert) {
|
|
5072
5120
|
// eslint-disable-next-line no-alert
|
|
5073
5121
|
alert(DUPLICATE_TOKEN_ERR);
|
|
5074
5122
|
}
|
|
@@ -5082,592 +5130,393 @@
|
|
|
5082
5130
|
cachedAuthToken = null;
|
|
5083
5131
|
};
|
|
5084
5132
|
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
*
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
*
|
|
5119
|
-
* @param {Function} fn The listener function.
|
|
5120
|
-
* @param {*} context The context to invoke the listener with.
|
|
5121
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
5122
|
-
* @constructor
|
|
5123
|
-
* @private
|
|
5124
|
-
*/
|
|
5125
|
-
function EE(fn, context, once) {
|
|
5126
|
-
this.fn = fn;
|
|
5127
|
-
this.context = context;
|
|
5128
|
-
this.once = once || false;
|
|
5129
|
-
}
|
|
5130
|
-
|
|
5131
|
-
/**
|
|
5132
|
-
* Add a listener for a given event.
|
|
5133
|
-
*
|
|
5134
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
5135
|
-
* @param {(String|Symbol)} event The event name.
|
|
5136
|
-
* @param {Function} fn The listener function.
|
|
5137
|
-
* @param {*} context The context to invoke the listener with.
|
|
5138
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
5139
|
-
* @returns {EventEmitter}
|
|
5140
|
-
* @private
|
|
5141
|
-
*/
|
|
5142
|
-
function addListener(emitter, event, fn, context, once) {
|
|
5143
|
-
if (typeof fn !== 'function') {
|
|
5144
|
-
throw new TypeError('The listener must be a function');
|
|
5145
|
-
}
|
|
5146
|
-
|
|
5147
|
-
var listener = new EE(fn, context || emitter, once)
|
|
5148
|
-
, evt = prefix ? prefix + event : event;
|
|
5149
|
-
|
|
5150
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
5151
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
5152
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
5153
|
-
|
|
5154
|
-
return emitter;
|
|
5133
|
+
/**
|
|
5134
|
+
*
|
|
5135
|
+
* @param root0
|
|
5136
|
+
* @param root0.query
|
|
5137
|
+
* @param root0.variables
|
|
5138
|
+
* @param root0.thoughtSpotHost
|
|
5139
|
+
* @param root0.isCompositeQuery
|
|
5140
|
+
*/
|
|
5141
|
+
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
5142
|
+
const operationName = getOperationNameFromQuery(query);
|
|
5143
|
+
try {
|
|
5144
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
5145
|
+
method: 'POST',
|
|
5146
|
+
headers: {
|
|
5147
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
5148
|
+
'x-requested-by': 'ThoughtSpot',
|
|
5149
|
+
accept: '*/*',
|
|
5150
|
+
'accept-language': 'en-us',
|
|
5151
|
+
},
|
|
5152
|
+
body: JSON.stringify({
|
|
5153
|
+
operationName,
|
|
5154
|
+
query,
|
|
5155
|
+
variables,
|
|
5156
|
+
}),
|
|
5157
|
+
credentials: 'include',
|
|
5158
|
+
});
|
|
5159
|
+
const result = await response.json();
|
|
5160
|
+
const dataValues = Object.values(result.data);
|
|
5161
|
+
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
5162
|
+
}
|
|
5163
|
+
catch (error) {
|
|
5164
|
+
return error;
|
|
5165
|
+
}
|
|
5155
5166
|
}
|
|
5156
5167
|
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5168
|
+
const getSourceDetailQuery = `
|
|
5169
|
+
query GetSourceDetail($ids: [GUID!]!) {
|
|
5170
|
+
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
5171
|
+
id
|
|
5172
|
+
name
|
|
5173
|
+
description
|
|
5174
|
+
authorName
|
|
5175
|
+
authorDisplayName
|
|
5176
|
+
isExternal
|
|
5177
|
+
type
|
|
5178
|
+
created
|
|
5179
|
+
modified
|
|
5180
|
+
columns {
|
|
5181
|
+
id
|
|
5182
|
+
name
|
|
5183
|
+
author
|
|
5184
|
+
authorDisplayName
|
|
5185
|
+
description
|
|
5186
|
+
dataType
|
|
5187
|
+
type
|
|
5188
|
+
modified
|
|
5189
|
+
ownerName
|
|
5190
|
+
owner
|
|
5191
|
+
dataRecency
|
|
5192
|
+
sources {
|
|
5193
|
+
tableId
|
|
5194
|
+
tableName
|
|
5195
|
+
columnId
|
|
5196
|
+
columnName
|
|
5197
|
+
__typename
|
|
5198
|
+
}
|
|
5199
|
+
synonyms
|
|
5200
|
+
cohortAnswerId
|
|
5201
|
+
__typename
|
|
5202
|
+
}
|
|
5203
|
+
relationships
|
|
5204
|
+
destinationRelationships
|
|
5205
|
+
dataSourceId
|
|
5206
|
+
__typename
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
5209
|
+
`;
|
|
5210
|
+
const sourceDetailCache = new Map();
|
|
5211
|
+
/**
|
|
5212
|
+
*
|
|
5213
|
+
* @param thoughtSpotHost
|
|
5214
|
+
* @param sourceId
|
|
5215
|
+
*/
|
|
5216
|
+
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
5217
|
+
if (sourceDetailCache.get(sourceId)) {
|
|
5218
|
+
return sourceDetailCache.get(sourceId);
|
|
5219
|
+
}
|
|
5220
|
+
const details = await graphqlQuery({
|
|
5221
|
+
query: getSourceDetailQuery,
|
|
5222
|
+
variables: {
|
|
5223
|
+
ids: [sourceId],
|
|
5224
|
+
},
|
|
5225
|
+
thoughtSpotHost,
|
|
5226
|
+
});
|
|
5227
|
+
const souceDetails = details[0];
|
|
5228
|
+
if (souceDetails) {
|
|
5229
|
+
sourceDetailCache.set(sourceId, souceDetails);
|
|
5230
|
+
}
|
|
5231
|
+
return souceDetails;
|
|
5167
5232
|
}
|
|
5168
5233
|
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
function EventEmitter() {
|
|
5177
|
-
this._events = new Events();
|
|
5178
|
-
this._eventsCount = 0;
|
|
5234
|
+
const bachSessionId = `
|
|
5235
|
+
id {
|
|
5236
|
+
sessionId
|
|
5237
|
+
genNo
|
|
5238
|
+
acSession {
|
|
5239
|
+
sessionId
|
|
5240
|
+
genNo
|
|
5179
5241
|
}
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
}
|
|
5202
|
-
|
|
5203
|
-
return names;
|
|
5204
|
-
};
|
|
5205
|
-
|
|
5206
|
-
/**
|
|
5207
|
-
* Return the listeners registered for a given event.
|
|
5208
|
-
*
|
|
5209
|
-
* @param {(String|Symbol)} event The event name.
|
|
5210
|
-
* @returns {Array} The registered listeners.
|
|
5211
|
-
* @public
|
|
5212
|
-
*/
|
|
5213
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
5214
|
-
var evt = prefix ? prefix + event : event
|
|
5215
|
-
, handlers = this._events[evt];
|
|
5216
|
-
|
|
5217
|
-
if (!handlers) return [];
|
|
5218
|
-
if (handlers.fn) return [handlers.fn];
|
|
5219
|
-
|
|
5220
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
5221
|
-
ee[i] = handlers[i].fn;
|
|
5222
|
-
}
|
|
5223
|
-
|
|
5224
|
-
return ee;
|
|
5225
|
-
};
|
|
5226
|
-
|
|
5227
|
-
/**
|
|
5228
|
-
* Return the number of listeners listening to a given event.
|
|
5229
|
-
*
|
|
5230
|
-
* @param {(String|Symbol)} event The event name.
|
|
5231
|
-
* @returns {Number} The number of listeners.
|
|
5232
|
-
* @public
|
|
5233
|
-
*/
|
|
5234
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
5235
|
-
var evt = prefix ? prefix + event : event
|
|
5236
|
-
, listeners = this._events[evt];
|
|
5237
|
-
|
|
5238
|
-
if (!listeners) return 0;
|
|
5239
|
-
if (listeners.fn) return 1;
|
|
5240
|
-
return listeners.length;
|
|
5241
|
-
};
|
|
5242
|
-
|
|
5243
|
-
/**
|
|
5244
|
-
* Calls each of the listeners registered for a given event.
|
|
5245
|
-
*
|
|
5246
|
-
* @param {(String|Symbol)} event The event name.
|
|
5247
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
5248
|
-
* @public
|
|
5249
|
-
*/
|
|
5250
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
5251
|
-
var evt = prefix ? prefix + event : event;
|
|
5252
|
-
|
|
5253
|
-
if (!this._events[evt]) return false;
|
|
5254
|
-
|
|
5255
|
-
var listeners = this._events[evt]
|
|
5256
|
-
, len = arguments.length
|
|
5257
|
-
, args
|
|
5258
|
-
, i;
|
|
5259
|
-
|
|
5260
|
-
if (listeners.fn) {
|
|
5261
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
5262
|
-
|
|
5263
|
-
switch (len) {
|
|
5264
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
5265
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
5266
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
5267
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
5268
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
5269
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
5270
|
-
}
|
|
5271
|
-
|
|
5272
|
-
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
5273
|
-
args[i - 1] = arguments[i];
|
|
5274
|
-
}
|
|
5275
|
-
|
|
5276
|
-
listeners.fn.apply(listeners.context, args);
|
|
5277
|
-
} else {
|
|
5278
|
-
var length = listeners.length
|
|
5279
|
-
, j;
|
|
5280
|
-
|
|
5281
|
-
for (i = 0; i < length; i++) {
|
|
5282
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
5283
|
-
|
|
5284
|
-
switch (len) {
|
|
5285
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
5286
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
5287
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
5288
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
5289
|
-
default:
|
|
5290
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
5291
|
-
args[j - 1] = arguments[j];
|
|
5292
|
-
}
|
|
5293
|
-
|
|
5294
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
5295
|
-
}
|
|
5242
|
+
}
|
|
5243
|
+
`;
|
|
5244
|
+
const getUnaggregatedAnswerSession = `
|
|
5245
|
+
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
5246
|
+
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
5247
|
+
${bachSessionId}
|
|
5248
|
+
answer {
|
|
5249
|
+
visualizations {
|
|
5250
|
+
... on TableViz {
|
|
5251
|
+
columns {
|
|
5252
|
+
column {
|
|
5253
|
+
id
|
|
5254
|
+
name
|
|
5255
|
+
referencedColumns {
|
|
5256
|
+
guid
|
|
5257
|
+
displayName
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5296
5263
|
}
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
* @param {Function} fn The listener function.
|
|
5307
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
5308
|
-
* @returns {EventEmitter} `this`.
|
|
5309
|
-
* @public
|
|
5310
|
-
*/
|
|
5311
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
5312
|
-
return addListener(this, event, fn, context, false);
|
|
5313
|
-
};
|
|
5314
|
-
|
|
5315
|
-
/**
|
|
5316
|
-
* Add a one-time listener for a given event.
|
|
5317
|
-
*
|
|
5318
|
-
* @param {(String|Symbol)} event The event name.
|
|
5319
|
-
* @param {Function} fn The listener function.
|
|
5320
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
5321
|
-
* @returns {EventEmitter} `this`.
|
|
5322
|
-
* @public
|
|
5323
|
-
*/
|
|
5324
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
5325
|
-
return addListener(this, event, fn, context, true);
|
|
5326
|
-
};
|
|
5327
|
-
|
|
5328
|
-
/**
|
|
5329
|
-
* Remove the listeners of a given event.
|
|
5330
|
-
*
|
|
5331
|
-
* @param {(String|Symbol)} event The event name.
|
|
5332
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
5333
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
5334
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
5335
|
-
* @returns {EventEmitter} `this`.
|
|
5336
|
-
* @public
|
|
5337
|
-
*/
|
|
5338
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
5339
|
-
var evt = prefix ? prefix + event : event;
|
|
5340
|
-
|
|
5341
|
-
if (!this._events[evt]) return this;
|
|
5342
|
-
if (!fn) {
|
|
5343
|
-
clearEvent(this, evt);
|
|
5344
|
-
return this;
|
|
5345
|
-
}
|
|
5346
|
-
|
|
5347
|
-
var listeners = this._events[evt];
|
|
5348
|
-
|
|
5349
|
-
if (listeners.fn) {
|
|
5350
|
-
if (
|
|
5351
|
-
listeners.fn === fn &&
|
|
5352
|
-
(!once || listeners.once) &&
|
|
5353
|
-
(!context || listeners.context === context)
|
|
5264
|
+
}
|
|
5265
|
+
}
|
|
5266
|
+
`;
|
|
5267
|
+
const removeColumns = `
|
|
5268
|
+
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
5269
|
+
Answer__removeColumns(
|
|
5270
|
+
session: $session
|
|
5271
|
+
logicalColumnIds: $logicalColumnIds
|
|
5272
|
+
columnIds: $columnIds
|
|
5354
5273
|
) {
|
|
5355
|
-
|
|
5274
|
+
${bachSessionId}
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
`;
|
|
5278
|
+
const addColumns = `
|
|
5279
|
+
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
5280
|
+
Answer__addColumn(session: $session, columns: $columns) {
|
|
5281
|
+
${bachSessionId}
|
|
5356
5282
|
}
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5283
|
+
}
|
|
5284
|
+
`;
|
|
5285
|
+
const getAnswerData = `
|
|
5286
|
+
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
5287
|
+
getAnswer(session: $session) {
|
|
5288
|
+
${bachSessionId}
|
|
5289
|
+
answer {
|
|
5290
|
+
id
|
|
5291
|
+
visualizations {
|
|
5292
|
+
id
|
|
5293
|
+
... on TableViz {
|
|
5294
|
+
columns {
|
|
5295
|
+
column {
|
|
5296
|
+
id
|
|
5297
|
+
name
|
|
5298
|
+
type
|
|
5299
|
+
aggregationType
|
|
5300
|
+
dataType
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
5304
|
+
}
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5366
5307
|
}
|
|
5308
|
+
}
|
|
5309
|
+
`;
|
|
5367
5310
|
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
*
|
|
5380
|
-
*
|
|
5381
|
-
*
|
|
5382
|
-
*
|
|
5383
|
-
*
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5311
|
+
// eslint-disable-next-line no-shadow
|
|
5312
|
+
var OperationType;
|
|
5313
|
+
(function (OperationType) {
|
|
5314
|
+
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
5315
|
+
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
5316
|
+
})(OperationType || (OperationType = {}));
|
|
5317
|
+
/**
|
|
5318
|
+
* Class representing the answer service provided with the
|
|
5319
|
+
* custom action payload. This service could be used to run
|
|
5320
|
+
* graphql queries in the context of the answer on which the
|
|
5321
|
+
* custom action was triggered.
|
|
5322
|
+
*
|
|
5323
|
+
* @example
|
|
5324
|
+
* ```js
|
|
5325
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
5326
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
5327
|
+
* 'col name 1'
|
|
5328
|
+
* ]);
|
|
5329
|
+
* const data = await underlying.fetchData(0, 100);
|
|
5330
|
+
* })
|
|
5331
|
+
* ```
|
|
5332
|
+
* @version
|
|
5333
|
+
* ThoughtSpot: 9.9.0.cl / SDK: 1.25.0
|
|
5334
|
+
* @group Events
|
|
5335
|
+
*/
|
|
5336
|
+
class AnswerService {
|
|
5337
|
+
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
5338
|
+
this.session = session;
|
|
5339
|
+
this.answer = answer;
|
|
5340
|
+
this.thoughtSpotHost = thoughtSpotHost;
|
|
5341
|
+
this.selectedPoints = selectedPoints;
|
|
5342
|
+
this.session = removeTypename(session);
|
|
5343
|
+
}
|
|
5344
|
+
async getSourceDetail() {
|
|
5345
|
+
const sourceId = this.answer.sources[0].header.guid;
|
|
5346
|
+
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
5347
|
+
}
|
|
5348
|
+
async removeColumns(columnIds) {
|
|
5349
|
+
return this.executeQuery(removeColumns, {
|
|
5350
|
+
logicalColumnIds: columnIds,
|
|
5351
|
+
});
|
|
5352
|
+
}
|
|
5353
|
+
async addColumns(columnIds) {
|
|
5354
|
+
return this.executeQuery(addColumns, {
|
|
5355
|
+
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5358
|
+
async fetchData(offset = 0, size = 1000) {
|
|
5359
|
+
const { answer } = await this.executeQuery(getAnswerData, {
|
|
5360
|
+
deadline: 0,
|
|
5361
|
+
dataPaginationParams: {
|
|
5362
|
+
isClientPaginated: true,
|
|
5363
|
+
offset,
|
|
5364
|
+
size,
|
|
5365
|
+
},
|
|
5366
|
+
});
|
|
5367
|
+
const { columns, data } = answer.visualizations[0];
|
|
5368
|
+
return {
|
|
5369
|
+
columns,
|
|
5370
|
+
data,
|
|
5371
|
+
};
|
|
5372
|
+
}
|
|
5373
|
+
/**
|
|
5374
|
+
*
|
|
5375
|
+
* @param userLocale
|
|
5376
|
+
* @param includeInfo Include the CSV header in the output
|
|
5377
|
+
* @returns Response
|
|
5378
|
+
*/
|
|
5379
|
+
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
5380
|
+
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
5381
|
+
return tokenizedFetch(fetchUrl, {
|
|
5382
|
+
credentials: 'include',
|
|
5383
|
+
});
|
|
5384
|
+
}
|
|
5385
|
+
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
5386
|
+
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
5387
|
+
}
|
|
5388
|
+
/**
|
|
5389
|
+
* Get underlying data given a point and the output column names.
|
|
5390
|
+
*
|
|
5391
|
+
* @param outputColumnNames
|
|
5392
|
+
* @param selectedPoints
|
|
5393
|
+
* @example
|
|
5394
|
+
* ```js
|
|
5395
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
5396
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
5397
|
+
* 'col name 1' // The column should exist in the data source.
|
|
5398
|
+
* ]);
|
|
5399
|
+
* const data = await underlying.fetchData(0, 100);
|
|
5400
|
+
* })
|
|
5401
|
+
* ```
|
|
5402
|
+
* @version
|
|
5403
|
+
* ThoughtSpot: 9.9.0.cl / SDK: 1.25.0
|
|
5404
|
+
*/
|
|
5405
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
5406
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
5407
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
5408
|
+
}
|
|
5409
|
+
if (!selectedPoints) {
|
|
5410
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
5411
|
+
}
|
|
5412
|
+
const sourceDetail = await this.getSourceDetail();
|
|
5413
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
5414
|
+
const unAggAnswer = await graphqlQuery({
|
|
5415
|
+
query: getUnaggregatedAnswerSession,
|
|
5416
|
+
variables: {
|
|
5417
|
+
session: this.session,
|
|
5418
|
+
columns: selectedPoints,
|
|
5419
|
+
},
|
|
5420
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
5421
|
+
});
|
|
5422
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
5423
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
5424
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
5425
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
5426
|
+
if (columnsToAdd.length) {
|
|
5427
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
5428
|
+
}
|
|
5429
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
5430
|
+
if (columnsToRemove.length) {
|
|
5431
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
5432
|
+
}
|
|
5433
|
+
return unaggAnswerSession;
|
|
5434
|
+
}
|
|
5435
|
+
async executeQuery(query, variables) {
|
|
5436
|
+
const data = await graphqlQuery({
|
|
5437
|
+
query,
|
|
5438
|
+
variables: {
|
|
5439
|
+
session: this.session,
|
|
5440
|
+
...variables,
|
|
5441
|
+
},
|
|
5442
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
5443
|
+
isCompositeQuery: false,
|
|
5444
|
+
});
|
|
5445
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
5446
|
+
return data;
|
|
5447
|
+
}
|
|
5448
|
+
getSession() {
|
|
5449
|
+
return this.session;
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
/**
|
|
5453
|
+
*
|
|
5454
|
+
* @param sourceDetail
|
|
5455
|
+
* @param colNames
|
|
5456
|
+
*/
|
|
5457
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
5458
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
5459
|
+
colSet[col.name] = col;
|
|
5460
|
+
return colSet;
|
|
5461
|
+
}, {});
|
|
5462
|
+
return new Set(colNames.map((colName) => {
|
|
5463
|
+
const col = cols[colName];
|
|
5464
|
+
return col.id;
|
|
5465
|
+
}));
|
|
5466
|
+
}
|
|
5467
|
+
/**
|
|
5468
|
+
*
|
|
5469
|
+
* @param selectedPoints
|
|
5470
|
+
*/
|
|
5471
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
5472
|
+
const underlyingDataPoint = [];
|
|
5473
|
+
/**
|
|
5474
|
+
*
|
|
5475
|
+
* @param colVal
|
|
5476
|
+
*/
|
|
5477
|
+
function addPointFromColVal(colVal) {
|
|
5478
|
+
var _a;
|
|
5479
|
+
const dataType = colVal.column.dataType;
|
|
5480
|
+
const id = colVal.column.id;
|
|
5481
|
+
let dataValue;
|
|
5482
|
+
if (dataType === 'DATE') {
|
|
5483
|
+
if (Number.isFinite(colVal.value)) {
|
|
5484
|
+
dataValue = [{
|
|
5485
|
+
epochRange: {
|
|
5486
|
+
startEpoch: colVal.value,
|
|
5487
|
+
},
|
|
5488
|
+
}];
|
|
5489
|
+
// Case for custom calendar.
|
|
5490
|
+
}
|
|
5491
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
5492
|
+
dataValue = [{
|
|
5493
|
+
epochRange: {
|
|
5494
|
+
startEpoch: colVal.value.v.s,
|
|
5495
|
+
endEpoch: colVal.value.v.e,
|
|
5496
|
+
},
|
|
5497
|
+
}];
|
|
5498
|
+
}
|
|
5499
|
+
}
|
|
5500
|
+
else {
|
|
5501
|
+
dataValue = [{ value: colVal.value }];
|
|
5502
|
+
}
|
|
5503
|
+
underlyingDataPoint.push({
|
|
5504
|
+
columnId: colVal.column.id,
|
|
5505
|
+
dataValue,
|
|
5506
|
+
});
|
|
5507
|
+
}
|
|
5508
|
+
selectedPoints.forEach((p) => {
|
|
5509
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
5510
|
+
});
|
|
5511
|
+
return underlyingDataPoint;
|
|
5512
|
+
}
|
|
5395
5513
|
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
5403
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
5404
|
-
|
|
5405
|
-
//
|
|
5406
|
-
// Expose the prefix.
|
|
5407
|
-
//
|
|
5408
|
-
EventEmitter.prefixed = prefix;
|
|
5409
|
-
|
|
5410
|
-
//
|
|
5411
|
-
// Allow `EventEmitter` to be imported as module namespace.
|
|
5412
|
-
//
|
|
5413
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
5414
|
-
|
|
5415
|
-
//
|
|
5416
|
-
// Expose the module.
|
|
5417
|
-
//
|
|
5418
|
-
{
|
|
5419
|
-
module.exports = EventEmitter;
|
|
5420
|
-
}
|
|
5421
|
-
});
|
|
5422
|
-
|
|
5423
|
-
/**
|
|
5424
|
-
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
5425
|
-
* support for iteratee shorthands.
|
|
5426
|
-
*
|
|
5427
|
-
* @private
|
|
5428
|
-
* @param {Array} array The array to inspect.
|
|
5429
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
5430
|
-
* @param {number} fromIndex The index to search from.
|
|
5431
|
-
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
5432
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
5433
|
-
*/
|
|
5434
|
-
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
5435
|
-
var length = array.length,
|
|
5436
|
-
index = fromIndex + (fromRight ? 1 : -1);
|
|
5437
|
-
|
|
5438
|
-
while ((fromRight ? index-- : ++index < length)) {
|
|
5439
|
-
if (predicate(array[index], index, array)) {
|
|
5440
|
-
return index;
|
|
5441
|
-
}
|
|
5442
|
-
}
|
|
5443
|
-
return -1;
|
|
5444
|
-
}
|
|
5445
|
-
|
|
5446
|
-
var _baseFindIndex = baseFindIndex;
|
|
5447
|
-
|
|
5448
|
-
/**
|
|
5449
|
-
* The base implementation of `_.isNaN` without support for number objects.
|
|
5450
|
-
*
|
|
5451
|
-
* @private
|
|
5452
|
-
* @param {*} value The value to check.
|
|
5453
|
-
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
5454
|
-
*/
|
|
5455
|
-
function baseIsNaN(value) {
|
|
5456
|
-
return value !== value;
|
|
5457
|
-
}
|
|
5458
|
-
|
|
5459
|
-
var _baseIsNaN = baseIsNaN;
|
|
5460
|
-
|
|
5461
|
-
/**
|
|
5462
|
-
* A specialized version of `_.indexOf` which performs strict equality
|
|
5463
|
-
* comparisons of values, i.e. `===`.
|
|
5464
|
-
*
|
|
5465
|
-
* @private
|
|
5466
|
-
* @param {Array} array The array to inspect.
|
|
5467
|
-
* @param {*} value The value to search for.
|
|
5468
|
-
* @param {number} fromIndex The index to search from.
|
|
5469
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
5470
|
-
*/
|
|
5471
|
-
function strictIndexOf(array, value, fromIndex) {
|
|
5472
|
-
var index = fromIndex - 1,
|
|
5473
|
-
length = array.length;
|
|
5474
|
-
|
|
5475
|
-
while (++index < length) {
|
|
5476
|
-
if (array[index] === value) {
|
|
5477
|
-
return index;
|
|
5478
|
-
}
|
|
5479
|
-
}
|
|
5480
|
-
return -1;
|
|
5481
|
-
}
|
|
5482
|
-
|
|
5483
|
-
var _strictIndexOf = strictIndexOf;
|
|
5484
|
-
|
|
5485
|
-
/**
|
|
5486
|
-
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
5487
|
-
*
|
|
5488
|
-
* @private
|
|
5489
|
-
* @param {Array} array The array to inspect.
|
|
5490
|
-
* @param {*} value The value to search for.
|
|
5491
|
-
* @param {number} fromIndex The index to search from.
|
|
5492
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
5493
|
-
*/
|
|
5494
|
-
function baseIndexOf(array, value, fromIndex) {
|
|
5495
|
-
return value === value
|
|
5496
|
-
? _strictIndexOf(array, value, fromIndex)
|
|
5497
|
-
: _baseFindIndex(array, _baseIsNaN, fromIndex);
|
|
5498
|
-
}
|
|
5499
|
-
|
|
5500
|
-
var _baseIndexOf = baseIndexOf;
|
|
5501
|
-
|
|
5502
|
-
/**
|
|
5503
|
-
* A specialized version of `_.includes` for arrays without support for
|
|
5504
|
-
* specifying an index to search from.
|
|
5505
|
-
*
|
|
5506
|
-
* @private
|
|
5507
|
-
* @param {Array} [array] The array to inspect.
|
|
5508
|
-
* @param {*} target The value to search for.
|
|
5509
|
-
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
5510
|
-
*/
|
|
5511
|
-
function arrayIncludes(array, value) {
|
|
5512
|
-
var length = array == null ? 0 : array.length;
|
|
5513
|
-
return !!length && _baseIndexOf(array, value, 0) > -1;
|
|
5514
|
-
}
|
|
5515
|
-
|
|
5516
|
-
var _arrayIncludes = arrayIncludes;
|
|
5517
|
-
|
|
5518
|
-
/**
|
|
5519
|
-
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
5520
|
-
*
|
|
5521
|
-
* @private
|
|
5522
|
-
* @param {Array} [array] The array to inspect.
|
|
5523
|
-
* @param {*} target The value to search for.
|
|
5524
|
-
* @param {Function} comparator The comparator invoked per element.
|
|
5525
|
-
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
5526
|
-
*/
|
|
5527
|
-
function arrayIncludesWith(array, value, comparator) {
|
|
5528
|
-
var index = -1,
|
|
5529
|
-
length = array == null ? 0 : array.length;
|
|
5530
|
-
|
|
5531
|
-
while (++index < length) {
|
|
5532
|
-
if (comparator(value, array[index])) {
|
|
5533
|
-
return true;
|
|
5534
|
-
}
|
|
5535
|
-
}
|
|
5536
|
-
return false;
|
|
5537
|
-
}
|
|
5538
|
-
|
|
5539
|
-
var _arrayIncludesWith = arrayIncludesWith;
|
|
5540
|
-
|
|
5541
|
-
/**
|
|
5542
|
-
* This method returns `undefined`.
|
|
5543
|
-
*
|
|
5544
|
-
* @static
|
|
5545
|
-
* @memberOf _
|
|
5546
|
-
* @since 2.3.0
|
|
5547
|
-
* @category Util
|
|
5548
|
-
* @example
|
|
5549
|
-
*
|
|
5550
|
-
* _.times(2, _.noop);
|
|
5551
|
-
* // => [undefined, undefined]
|
|
5552
|
-
*/
|
|
5553
|
-
function noop() {
|
|
5554
|
-
// No operation performed.
|
|
5555
|
-
}
|
|
5556
|
-
|
|
5557
|
-
var noop_1 = noop;
|
|
5558
|
-
|
|
5559
|
-
/** Used as references for various `Number` constants. */
|
|
5560
|
-
var INFINITY = 1 / 0;
|
|
5561
|
-
|
|
5562
|
-
/**
|
|
5563
|
-
* Creates a set object of `values`.
|
|
5564
|
-
*
|
|
5565
|
-
* @private
|
|
5566
|
-
* @param {Array} values The values to add to the set.
|
|
5567
|
-
* @returns {Object} Returns the new set.
|
|
5568
|
-
*/
|
|
5569
|
-
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
5570
|
-
return new _Set(values);
|
|
5571
|
-
};
|
|
5572
|
-
|
|
5573
|
-
var _createSet = createSet;
|
|
5574
|
-
|
|
5575
|
-
/** Used as the size to enable large array optimizations. */
|
|
5576
|
-
var LARGE_ARRAY_SIZE$1 = 200;
|
|
5577
|
-
|
|
5578
|
-
/**
|
|
5579
|
-
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
5580
|
-
*
|
|
5581
|
-
* @private
|
|
5582
|
-
* @param {Array} array The array to inspect.
|
|
5583
|
-
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
5584
|
-
* @param {Function} [comparator] The comparator invoked per element.
|
|
5585
|
-
* @returns {Array} Returns the new duplicate free array.
|
|
5586
|
-
*/
|
|
5587
|
-
function baseUniq(array, iteratee, comparator) {
|
|
5588
|
-
var index = -1,
|
|
5589
|
-
includes = _arrayIncludes,
|
|
5590
|
-
length = array.length,
|
|
5591
|
-
isCommon = true,
|
|
5592
|
-
result = [],
|
|
5593
|
-
seen = result;
|
|
5594
|
-
|
|
5595
|
-
if (comparator) {
|
|
5596
|
-
isCommon = false;
|
|
5597
|
-
includes = _arrayIncludesWith;
|
|
5598
|
-
}
|
|
5599
|
-
else if (length >= LARGE_ARRAY_SIZE$1) {
|
|
5600
|
-
var set = iteratee ? null : _createSet(array);
|
|
5601
|
-
if (set) {
|
|
5602
|
-
return _setToArray(set);
|
|
5603
|
-
}
|
|
5604
|
-
isCommon = false;
|
|
5605
|
-
includes = _cacheHas;
|
|
5606
|
-
seen = new _SetCache;
|
|
5607
|
-
}
|
|
5608
|
-
else {
|
|
5609
|
-
seen = iteratee ? [] : result;
|
|
5610
|
-
}
|
|
5611
|
-
outer:
|
|
5612
|
-
while (++index < length) {
|
|
5613
|
-
var value = array[index],
|
|
5614
|
-
computed = iteratee ? iteratee(value) : value;
|
|
5615
|
-
|
|
5616
|
-
value = (comparator || value !== 0) ? value : 0;
|
|
5617
|
-
if (isCommon && computed === computed) {
|
|
5618
|
-
var seenIndex = seen.length;
|
|
5619
|
-
while (seenIndex--) {
|
|
5620
|
-
if (seen[seenIndex] === computed) {
|
|
5621
|
-
continue outer;
|
|
5622
|
-
}
|
|
5623
|
-
}
|
|
5624
|
-
if (iteratee) {
|
|
5625
|
-
seen.push(computed);
|
|
5626
|
-
}
|
|
5627
|
-
result.push(value);
|
|
5628
|
-
}
|
|
5629
|
-
else if (!includes(seen, computed, comparator)) {
|
|
5630
|
-
if (seen !== result) {
|
|
5631
|
-
seen.push(computed);
|
|
5632
|
-
}
|
|
5633
|
-
result.push(value);
|
|
5634
|
-
}
|
|
5635
|
-
}
|
|
5636
|
-
return result;
|
|
5637
|
-
}
|
|
5638
|
-
|
|
5639
|
-
var _baseUniq = baseUniq;
|
|
5640
|
-
|
|
5641
|
-
/**
|
|
5642
|
-
* Creates a duplicate-free version of an array, using
|
|
5643
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
5644
|
-
* for equality comparisons, in which only the first occurrence of each element
|
|
5645
|
-
* is kept. The order of result values is determined by the order they occur
|
|
5646
|
-
* in the array.
|
|
5647
|
-
*
|
|
5648
|
-
* @static
|
|
5649
|
-
* @memberOf _
|
|
5650
|
-
* @since 0.1.0
|
|
5651
|
-
* @category Array
|
|
5652
|
-
* @param {Array} array The array to inspect.
|
|
5653
|
-
* @returns {Array} Returns the new duplicate free array.
|
|
5654
|
-
* @example
|
|
5655
|
-
*
|
|
5656
|
-
* _.uniq([2, 1, 2]);
|
|
5657
|
-
* // => [2, 1]
|
|
5658
|
-
*/
|
|
5659
|
-
function uniq(array) {
|
|
5660
|
-
return (array && array.length) ? _baseUniq(array) : [];
|
|
5661
|
-
}
|
|
5662
|
-
|
|
5663
|
-
var uniq_1 = uniq;
|
|
5664
|
-
|
|
5665
|
-
const ERROR_MESSAGE = {
|
|
5666
|
-
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
5667
|
-
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
5668
|
-
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
5669
|
-
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
5670
|
-
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
5514
|
+
const ERROR_MESSAGE = {
|
|
5515
|
+
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
5516
|
+
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
5517
|
+
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
5518
|
+
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
5519
|
+
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
5671
5520
|
};
|
|
5672
5521
|
|
|
5673
5522
|
/**
|
|
@@ -11793,1099 +11642,1261 @@
|
|
|
11793
11642
|
}
|
|
11794
11643
|
}
|
|
11795
11644
|
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
}
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
*
|
|
11851
|
-
* @
|
|
11852
|
-
*/
|
|
11853
|
-
function
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
return
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
*
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
*
|
|
11944
|
-
*/
|
|
11945
|
-
function
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
*
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
*
|
|
12028
|
-
*
|
|
12029
|
-
*
|
|
12030
|
-
*
|
|
12031
|
-
* @param
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12101
|
-
if (
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
11645
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
11646
|
+
|
|
11647
|
+
var has = Object.prototype.hasOwnProperty
|
|
11648
|
+
, prefix = '~';
|
|
11649
|
+
|
|
11650
|
+
/**
|
|
11651
|
+
* Constructor to create a storage for our `EE` objects.
|
|
11652
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
11653
|
+
*
|
|
11654
|
+
* @constructor
|
|
11655
|
+
* @private
|
|
11656
|
+
*/
|
|
11657
|
+
function Events() {}
|
|
11658
|
+
|
|
11659
|
+
//
|
|
11660
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
11661
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
11662
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
11663
|
+
// character to make sure that the built-in object properties are not
|
|
11664
|
+
// overridden or used as an attack vector.
|
|
11665
|
+
//
|
|
11666
|
+
if (Object.create) {
|
|
11667
|
+
Events.prototype = Object.create(null);
|
|
11668
|
+
|
|
11669
|
+
//
|
|
11670
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
11671
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
11672
|
+
//
|
|
11673
|
+
if (!new Events().__proto__) prefix = false;
|
|
11674
|
+
}
|
|
11675
|
+
|
|
11676
|
+
/**
|
|
11677
|
+
* Representation of a single event listener.
|
|
11678
|
+
*
|
|
11679
|
+
* @param {Function} fn The listener function.
|
|
11680
|
+
* @param {*} context The context to invoke the listener with.
|
|
11681
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
11682
|
+
* @constructor
|
|
11683
|
+
* @private
|
|
11684
|
+
*/
|
|
11685
|
+
function EE(fn, context, once) {
|
|
11686
|
+
this.fn = fn;
|
|
11687
|
+
this.context = context;
|
|
11688
|
+
this.once = once || false;
|
|
11689
|
+
}
|
|
11690
|
+
|
|
11691
|
+
/**
|
|
11692
|
+
* Add a listener for a given event.
|
|
11693
|
+
*
|
|
11694
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
11695
|
+
* @param {(String|Symbol)} event The event name.
|
|
11696
|
+
* @param {Function} fn The listener function.
|
|
11697
|
+
* @param {*} context The context to invoke the listener with.
|
|
11698
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
11699
|
+
* @returns {EventEmitter}
|
|
11700
|
+
* @private
|
|
11701
|
+
*/
|
|
11702
|
+
function addListener(emitter, event, fn, context, once) {
|
|
11703
|
+
if (typeof fn !== 'function') {
|
|
11704
|
+
throw new TypeError('The listener must be a function');
|
|
11705
|
+
}
|
|
11706
|
+
|
|
11707
|
+
var listener = new EE(fn, context || emitter, once)
|
|
11708
|
+
, evt = prefix ? prefix + event : event;
|
|
11709
|
+
|
|
11710
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
11711
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
11712
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
11713
|
+
|
|
11714
|
+
return emitter;
|
|
11715
|
+
}
|
|
11716
|
+
|
|
11717
|
+
/**
|
|
11718
|
+
* Clear event by name.
|
|
11719
|
+
*
|
|
11720
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
11721
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
11722
|
+
* @private
|
|
11723
|
+
*/
|
|
11724
|
+
function clearEvent(emitter, evt) {
|
|
11725
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
11726
|
+
else delete emitter._events[evt];
|
|
11727
|
+
}
|
|
11728
|
+
|
|
11729
|
+
/**
|
|
11730
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
11731
|
+
* `EventEmitter` interface.
|
|
11732
|
+
*
|
|
11733
|
+
* @constructor
|
|
11734
|
+
* @public
|
|
11735
|
+
*/
|
|
11736
|
+
function EventEmitter() {
|
|
11737
|
+
this._events = new Events();
|
|
11738
|
+
this._eventsCount = 0;
|
|
11739
|
+
}
|
|
11740
|
+
|
|
11741
|
+
/**
|
|
11742
|
+
* Return an array listing the events for which the emitter has registered
|
|
11743
|
+
* listeners.
|
|
11744
|
+
*
|
|
11745
|
+
* @returns {Array}
|
|
11746
|
+
* @public
|
|
11747
|
+
*/
|
|
11748
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
11749
|
+
var names = []
|
|
11750
|
+
, events
|
|
11751
|
+
, name;
|
|
11752
|
+
|
|
11753
|
+
if (this._eventsCount === 0) return names;
|
|
11754
|
+
|
|
11755
|
+
for (name in (events = this._events)) {
|
|
11756
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
11757
|
+
}
|
|
11758
|
+
|
|
11759
|
+
if (Object.getOwnPropertySymbols) {
|
|
11760
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
11761
|
+
}
|
|
11762
|
+
|
|
11763
|
+
return names;
|
|
11764
|
+
};
|
|
11765
|
+
|
|
11766
|
+
/**
|
|
11767
|
+
* Return the listeners registered for a given event.
|
|
11768
|
+
*
|
|
11769
|
+
* @param {(String|Symbol)} event The event name.
|
|
11770
|
+
* @returns {Array} The registered listeners.
|
|
11771
|
+
* @public
|
|
11772
|
+
*/
|
|
11773
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
11774
|
+
var evt = prefix ? prefix + event : event
|
|
11775
|
+
, handlers = this._events[evt];
|
|
11776
|
+
|
|
11777
|
+
if (!handlers) return [];
|
|
11778
|
+
if (handlers.fn) return [handlers.fn];
|
|
11779
|
+
|
|
11780
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
11781
|
+
ee[i] = handlers[i].fn;
|
|
11782
|
+
}
|
|
11783
|
+
|
|
11784
|
+
return ee;
|
|
11785
|
+
};
|
|
11786
|
+
|
|
11787
|
+
/**
|
|
11788
|
+
* Return the number of listeners listening to a given event.
|
|
11789
|
+
*
|
|
11790
|
+
* @param {(String|Symbol)} event The event name.
|
|
11791
|
+
* @returns {Number} The number of listeners.
|
|
11792
|
+
* @public
|
|
11793
|
+
*/
|
|
11794
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
11795
|
+
var evt = prefix ? prefix + event : event
|
|
11796
|
+
, listeners = this._events[evt];
|
|
11797
|
+
|
|
11798
|
+
if (!listeners) return 0;
|
|
11799
|
+
if (listeners.fn) return 1;
|
|
11800
|
+
return listeners.length;
|
|
11801
|
+
};
|
|
11802
|
+
|
|
11803
|
+
/**
|
|
11804
|
+
* Calls each of the listeners registered for a given event.
|
|
11805
|
+
*
|
|
11806
|
+
* @param {(String|Symbol)} event The event name.
|
|
11807
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
11808
|
+
* @public
|
|
11809
|
+
*/
|
|
11810
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
11811
|
+
var evt = prefix ? prefix + event : event;
|
|
11812
|
+
|
|
11813
|
+
if (!this._events[evt]) return false;
|
|
11814
|
+
|
|
11815
|
+
var listeners = this._events[evt]
|
|
11816
|
+
, len = arguments.length
|
|
11817
|
+
, args
|
|
11818
|
+
, i;
|
|
11819
|
+
|
|
11820
|
+
if (listeners.fn) {
|
|
11821
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
11822
|
+
|
|
11823
|
+
switch (len) {
|
|
11824
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
11825
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
11826
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
11827
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
11828
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
11829
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
11830
|
+
}
|
|
11831
|
+
|
|
11832
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
11833
|
+
args[i - 1] = arguments[i];
|
|
11834
|
+
}
|
|
11835
|
+
|
|
11836
|
+
listeners.fn.apply(listeners.context, args);
|
|
11837
|
+
} else {
|
|
11838
|
+
var length = listeners.length
|
|
11839
|
+
, j;
|
|
11840
|
+
|
|
11841
|
+
for (i = 0; i < length; i++) {
|
|
11842
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
11843
|
+
|
|
11844
|
+
switch (len) {
|
|
11845
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
11846
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
11847
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
11848
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
11849
|
+
default:
|
|
11850
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
11851
|
+
args[j - 1] = arguments[j];
|
|
11852
|
+
}
|
|
11853
|
+
|
|
11854
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
11855
|
+
}
|
|
11856
|
+
}
|
|
11857
|
+
}
|
|
11858
|
+
|
|
11859
|
+
return true;
|
|
11860
|
+
};
|
|
11861
|
+
|
|
11862
|
+
/**
|
|
11863
|
+
* Add a listener for a given event.
|
|
11864
|
+
*
|
|
11865
|
+
* @param {(String|Symbol)} event The event name.
|
|
11866
|
+
* @param {Function} fn The listener function.
|
|
11867
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
11868
|
+
* @returns {EventEmitter} `this`.
|
|
11869
|
+
* @public
|
|
11870
|
+
*/
|
|
11871
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
11872
|
+
return addListener(this, event, fn, context, false);
|
|
11873
|
+
};
|
|
11874
|
+
|
|
11875
|
+
/**
|
|
11876
|
+
* Add a one-time listener for a given event.
|
|
11877
|
+
*
|
|
11878
|
+
* @param {(String|Symbol)} event The event name.
|
|
11879
|
+
* @param {Function} fn The listener function.
|
|
11880
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
11881
|
+
* @returns {EventEmitter} `this`.
|
|
11882
|
+
* @public
|
|
11883
|
+
*/
|
|
11884
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
11885
|
+
return addListener(this, event, fn, context, true);
|
|
11886
|
+
};
|
|
11887
|
+
|
|
11888
|
+
/**
|
|
11889
|
+
* Remove the listeners of a given event.
|
|
11890
|
+
*
|
|
11891
|
+
* @param {(String|Symbol)} event The event name.
|
|
11892
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
11893
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
11894
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
11895
|
+
* @returns {EventEmitter} `this`.
|
|
11896
|
+
* @public
|
|
11897
|
+
*/
|
|
11898
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
11899
|
+
var evt = prefix ? prefix + event : event;
|
|
11900
|
+
|
|
11901
|
+
if (!this._events[evt]) return this;
|
|
11902
|
+
if (!fn) {
|
|
11903
|
+
clearEvent(this, evt);
|
|
11904
|
+
return this;
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11907
|
+
var listeners = this._events[evt];
|
|
11908
|
+
|
|
11909
|
+
if (listeners.fn) {
|
|
11910
|
+
if (
|
|
11911
|
+
listeners.fn === fn &&
|
|
11912
|
+
(!once || listeners.once) &&
|
|
11913
|
+
(!context || listeners.context === context)
|
|
11914
|
+
) {
|
|
11915
|
+
clearEvent(this, evt);
|
|
11916
|
+
}
|
|
11917
|
+
} else {
|
|
11918
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
11919
|
+
if (
|
|
11920
|
+
listeners[i].fn !== fn ||
|
|
11921
|
+
(once && !listeners[i].once) ||
|
|
11922
|
+
(context && listeners[i].context !== context)
|
|
11923
|
+
) {
|
|
11924
|
+
events.push(listeners[i]);
|
|
11925
|
+
}
|
|
11926
|
+
}
|
|
11927
|
+
|
|
11928
|
+
//
|
|
11929
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
11930
|
+
//
|
|
11931
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
11932
|
+
else clearEvent(this, evt);
|
|
11933
|
+
}
|
|
11934
|
+
|
|
11935
|
+
return this;
|
|
11936
|
+
};
|
|
11937
|
+
|
|
11938
|
+
/**
|
|
11939
|
+
* Remove all listeners, or those of the specified event.
|
|
11940
|
+
*
|
|
11941
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
11942
|
+
* @returns {EventEmitter} `this`.
|
|
11943
|
+
* @public
|
|
11944
|
+
*/
|
|
11945
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
11946
|
+
var evt;
|
|
11947
|
+
|
|
11948
|
+
if (event) {
|
|
11949
|
+
evt = prefix ? prefix + event : event;
|
|
11950
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
11951
|
+
} else {
|
|
11952
|
+
this._events = new Events();
|
|
11953
|
+
this._eventsCount = 0;
|
|
11954
|
+
}
|
|
11955
|
+
|
|
11956
|
+
return this;
|
|
11957
|
+
};
|
|
11958
|
+
|
|
11959
|
+
//
|
|
11960
|
+
// Alias methods names because people roll like that.
|
|
11961
|
+
//
|
|
11962
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
11963
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
11964
|
+
|
|
11965
|
+
//
|
|
11966
|
+
// Expose the prefix.
|
|
11967
|
+
//
|
|
11968
|
+
EventEmitter.prefixed = prefix;
|
|
11969
|
+
|
|
11970
|
+
//
|
|
11971
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
11972
|
+
//
|
|
11973
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
11974
|
+
|
|
11975
|
+
//
|
|
11976
|
+
// Expose the module.
|
|
11977
|
+
//
|
|
11978
|
+
{
|
|
11979
|
+
module.exports = EventEmitter;
|
|
11980
|
+
}
|
|
11981
|
+
});
|
|
11982
|
+
|
|
11983
|
+
/**
|
|
11984
|
+
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
11985
|
+
* support for iteratee shorthands.
|
|
11986
|
+
*
|
|
11987
|
+
* @private
|
|
11988
|
+
* @param {Array} array The array to inspect.
|
|
11989
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
11990
|
+
* @param {number} fromIndex The index to search from.
|
|
11991
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
11992
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
11993
|
+
*/
|
|
11994
|
+
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
11995
|
+
var length = array.length,
|
|
11996
|
+
index = fromIndex + (fromRight ? 1 : -1);
|
|
11997
|
+
|
|
11998
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
11999
|
+
if (predicate(array[index], index, array)) {
|
|
12000
|
+
return index;
|
|
12001
|
+
}
|
|
12002
|
+
}
|
|
12003
|
+
return -1;
|
|
12004
|
+
}
|
|
12005
|
+
|
|
12006
|
+
var _baseFindIndex = baseFindIndex;
|
|
12007
|
+
|
|
12008
|
+
/**
|
|
12009
|
+
* The base implementation of `_.isNaN` without support for number objects.
|
|
12010
|
+
*
|
|
12011
|
+
* @private
|
|
12012
|
+
* @param {*} value The value to check.
|
|
12013
|
+
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
12014
|
+
*/
|
|
12015
|
+
function baseIsNaN(value) {
|
|
12016
|
+
return value !== value;
|
|
12017
|
+
}
|
|
12018
|
+
|
|
12019
|
+
var _baseIsNaN = baseIsNaN;
|
|
12020
|
+
|
|
12021
|
+
/**
|
|
12022
|
+
* A specialized version of `_.indexOf` which performs strict equality
|
|
12023
|
+
* comparisons of values, i.e. `===`.
|
|
12024
|
+
*
|
|
12025
|
+
* @private
|
|
12026
|
+
* @param {Array} array The array to inspect.
|
|
12027
|
+
* @param {*} value The value to search for.
|
|
12028
|
+
* @param {number} fromIndex The index to search from.
|
|
12029
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
12030
|
+
*/
|
|
12031
|
+
function strictIndexOf(array, value, fromIndex) {
|
|
12032
|
+
var index = fromIndex - 1,
|
|
12033
|
+
length = array.length;
|
|
12034
|
+
|
|
12035
|
+
while (++index < length) {
|
|
12036
|
+
if (array[index] === value) {
|
|
12037
|
+
return index;
|
|
12038
|
+
}
|
|
12039
|
+
}
|
|
12040
|
+
return -1;
|
|
12041
|
+
}
|
|
12042
|
+
|
|
12043
|
+
var _strictIndexOf = strictIndexOf;
|
|
12044
|
+
|
|
12045
|
+
/**
|
|
12046
|
+
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
12047
|
+
*
|
|
12048
|
+
* @private
|
|
12049
|
+
* @param {Array} array The array to inspect.
|
|
12050
|
+
* @param {*} value The value to search for.
|
|
12051
|
+
* @param {number} fromIndex The index to search from.
|
|
12052
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
12053
|
+
*/
|
|
12054
|
+
function baseIndexOf(array, value, fromIndex) {
|
|
12055
|
+
return value === value
|
|
12056
|
+
? _strictIndexOf(array, value, fromIndex)
|
|
12057
|
+
: _baseFindIndex(array, _baseIsNaN, fromIndex);
|
|
12058
|
+
}
|
|
12059
|
+
|
|
12060
|
+
var _baseIndexOf = baseIndexOf;
|
|
12061
|
+
|
|
12062
|
+
/**
|
|
12063
|
+
* A specialized version of `_.includes` for arrays without support for
|
|
12064
|
+
* specifying an index to search from.
|
|
12065
|
+
*
|
|
12066
|
+
* @private
|
|
12067
|
+
* @param {Array} [array] The array to inspect.
|
|
12068
|
+
* @param {*} target The value to search for.
|
|
12069
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
12070
|
+
*/
|
|
12071
|
+
function arrayIncludes(array, value) {
|
|
12072
|
+
var length = array == null ? 0 : array.length;
|
|
12073
|
+
return !!length && _baseIndexOf(array, value, 0) > -1;
|
|
12074
|
+
}
|
|
12075
|
+
|
|
12076
|
+
var _arrayIncludes = arrayIncludes;
|
|
12077
|
+
|
|
12078
|
+
/**
|
|
12079
|
+
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
12080
|
+
*
|
|
12081
|
+
* @private
|
|
12082
|
+
* @param {Array} [array] The array to inspect.
|
|
12083
|
+
* @param {*} target The value to search for.
|
|
12084
|
+
* @param {Function} comparator The comparator invoked per element.
|
|
12085
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
12086
|
+
*/
|
|
12087
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
12088
|
+
var index = -1,
|
|
12089
|
+
length = array == null ? 0 : array.length;
|
|
12090
|
+
|
|
12091
|
+
while (++index < length) {
|
|
12092
|
+
if (comparator(value, array[index])) {
|
|
12093
|
+
return true;
|
|
12094
|
+
}
|
|
12095
|
+
}
|
|
12096
|
+
return false;
|
|
12097
|
+
}
|
|
12098
|
+
|
|
12099
|
+
var _arrayIncludesWith = arrayIncludesWith;
|
|
12100
|
+
|
|
12101
|
+
/**
|
|
12102
|
+
* This method returns `undefined`.
|
|
12103
|
+
*
|
|
12104
|
+
* @static
|
|
12105
|
+
* @memberOf _
|
|
12106
|
+
* @since 2.3.0
|
|
12107
|
+
* @category Util
|
|
12108
|
+
* @example
|
|
12109
|
+
*
|
|
12110
|
+
* _.times(2, _.noop);
|
|
12111
|
+
* // => [undefined, undefined]
|
|
12112
|
+
*/
|
|
12113
|
+
function noop() {
|
|
12114
|
+
// No operation performed.
|
|
12115
|
+
}
|
|
12116
|
+
|
|
12117
|
+
var noop_1 = noop;
|
|
12118
|
+
|
|
12119
|
+
/** Used as references for various `Number` constants. */
|
|
12120
|
+
var INFINITY = 1 / 0;
|
|
12121
|
+
|
|
12122
|
+
/**
|
|
12123
|
+
* Creates a set object of `values`.
|
|
12124
|
+
*
|
|
12125
|
+
* @private
|
|
12126
|
+
* @param {Array} values The values to add to the set.
|
|
12127
|
+
* @returns {Object} Returns the new set.
|
|
12128
|
+
*/
|
|
12129
|
+
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
12130
|
+
return new _Set(values);
|
|
12170
12131
|
};
|
|
12171
12132
|
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
*
|
|
12182
|
-
*
|
|
12183
|
-
* @
|
|
12184
|
-
* @
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
[
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
*
|
|
12245
|
-
*
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12133
|
+
var _createSet = createSet;
|
|
12134
|
+
|
|
12135
|
+
/** Used as the size to enable large array optimizations. */
|
|
12136
|
+
var LARGE_ARRAY_SIZE$1 = 200;
|
|
12137
|
+
|
|
12138
|
+
/**
|
|
12139
|
+
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
12140
|
+
*
|
|
12141
|
+
* @private
|
|
12142
|
+
* @param {Array} array The array to inspect.
|
|
12143
|
+
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
12144
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
12145
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
12146
|
+
*/
|
|
12147
|
+
function baseUniq(array, iteratee, comparator) {
|
|
12148
|
+
var index = -1,
|
|
12149
|
+
includes = _arrayIncludes,
|
|
12150
|
+
length = array.length,
|
|
12151
|
+
isCommon = true,
|
|
12152
|
+
result = [],
|
|
12153
|
+
seen = result;
|
|
12154
|
+
|
|
12155
|
+
if (comparator) {
|
|
12156
|
+
isCommon = false;
|
|
12157
|
+
includes = _arrayIncludesWith;
|
|
12158
|
+
}
|
|
12159
|
+
else if (length >= LARGE_ARRAY_SIZE$1) {
|
|
12160
|
+
var set = iteratee ? null : _createSet(array);
|
|
12161
|
+
if (set) {
|
|
12162
|
+
return _setToArray(set);
|
|
12163
|
+
}
|
|
12164
|
+
isCommon = false;
|
|
12165
|
+
includes = _cacheHas;
|
|
12166
|
+
seen = new _SetCache;
|
|
12167
|
+
}
|
|
12168
|
+
else {
|
|
12169
|
+
seen = iteratee ? [] : result;
|
|
12170
|
+
}
|
|
12171
|
+
outer:
|
|
12172
|
+
while (++index < length) {
|
|
12173
|
+
var value = array[index],
|
|
12174
|
+
computed = iteratee ? iteratee(value) : value;
|
|
12175
|
+
|
|
12176
|
+
value = (comparator || value !== 0) ? value : 0;
|
|
12177
|
+
if (isCommon && computed === computed) {
|
|
12178
|
+
var seenIndex = seen.length;
|
|
12179
|
+
while (seenIndex--) {
|
|
12180
|
+
if (seen[seenIndex] === computed) {
|
|
12181
|
+
continue outer;
|
|
12182
|
+
}
|
|
12183
|
+
}
|
|
12184
|
+
if (iteratee) {
|
|
12185
|
+
seen.push(computed);
|
|
12186
|
+
}
|
|
12187
|
+
result.push(value);
|
|
12188
|
+
}
|
|
12189
|
+
else if (!includes(seen, computed, comparator)) {
|
|
12190
|
+
if (seen !== result) {
|
|
12191
|
+
seen.push(computed);
|
|
12192
|
+
}
|
|
12193
|
+
result.push(value);
|
|
12194
|
+
}
|
|
12195
|
+
}
|
|
12196
|
+
return result;
|
|
12197
|
+
}
|
|
12198
|
+
|
|
12199
|
+
var _baseUniq = baseUniq;
|
|
12200
|
+
|
|
12201
|
+
/**
|
|
12202
|
+
* Creates a duplicate-free version of an array, using
|
|
12203
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
12204
|
+
* for equality comparisons, in which only the first occurrence of each element
|
|
12205
|
+
* is kept. The order of result values is determined by the order they occur
|
|
12206
|
+
* in the array.
|
|
12207
|
+
*
|
|
12208
|
+
* @static
|
|
12209
|
+
* @memberOf _
|
|
12210
|
+
* @since 0.1.0
|
|
12211
|
+
* @category Array
|
|
12212
|
+
* @param {Array} array The array to inspect.
|
|
12213
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
12214
|
+
* @example
|
|
12215
|
+
*
|
|
12216
|
+
* _.uniq([2, 1, 2]);
|
|
12217
|
+
* // => [2, 1]
|
|
12218
|
+
*/
|
|
12219
|
+
function uniq(array) {
|
|
12220
|
+
return (array && array.length) ? _baseUniq(array) : [];
|
|
12221
|
+
}
|
|
12222
|
+
|
|
12223
|
+
var uniq_1 = uniq;
|
|
12224
|
+
|
|
12225
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12226
|
+
let loggedInStatus = false;
|
|
12227
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12228
|
+
let samlAuthWindow = null;
|
|
12229
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12230
|
+
let samlCompletionPromise = null;
|
|
12231
|
+
let sessionInfo = null;
|
|
12232
|
+
let sessionInfoResolver = null;
|
|
12233
|
+
const sessionInfoPromise = new Promise((resolve) => {
|
|
12234
|
+
sessionInfoResolver = resolve;
|
|
12235
|
+
});
|
|
12236
|
+
let releaseVersion = '';
|
|
12237
|
+
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
12238
|
+
(function (AuthFailureType) {
|
|
12239
|
+
AuthFailureType["SDK"] = "SDK";
|
|
12240
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
12241
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
12242
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
12243
|
+
})(exports.AuthFailureType || (exports.AuthFailureType = {}));
|
|
12244
|
+
(function (AuthStatus) {
|
|
12245
|
+
/**
|
|
12246
|
+
* Emits when the SDK fails to authenticate
|
|
12247
|
+
*/
|
|
12248
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
12249
|
+
/**
|
|
12250
|
+
* Emits when the SDK authenticates successfully
|
|
12251
|
+
*/
|
|
12252
|
+
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
12253
|
+
/**
|
|
12254
|
+
* Emits when the app sends an authentication success message
|
|
12255
|
+
*/
|
|
12256
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
12257
|
+
/**
|
|
12258
|
+
* Emits when a user logs out
|
|
12259
|
+
*/
|
|
12260
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
12261
|
+
/**
|
|
12262
|
+
* Emitted when inPopup: true in the SAMLRedirect flow.
|
|
12263
|
+
* And, we are waiting for popup to be triggered either programatically
|
|
12264
|
+
* or by the trigger button.
|
|
12265
|
+
*
|
|
12266
|
+
* @version SDK: 1.19.0
|
|
12267
|
+
*/
|
|
12268
|
+
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
12269
|
+
})(exports.AuthStatus || (exports.AuthStatus = {}));
|
|
12270
|
+
(function (AuthEvent) {
|
|
12271
|
+
/**
|
|
12272
|
+
* Manually trigger the SSO popup. This is useful with
|
|
12273
|
+
* authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
|
|
12274
|
+
*/
|
|
12275
|
+
AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
|
|
12276
|
+
})(exports.AuthEvent || (exports.AuthEvent = {}));
|
|
12277
|
+
let authEE;
|
|
12271
12278
|
/**
|
|
12272
|
-
* Initializes the Visual Embed SDK globally and perform
|
|
12273
|
-
* authentication if applicable. This function needs to be called before any ThoughtSpot
|
|
12274
|
-
* component like liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
|
|
12275
|
-
* to actually embed. That is handled internally.
|
|
12276
12279
|
*
|
|
12277
|
-
* @param
|
|
12278
|
-
* authentication mechanism and so on.
|
|
12279
|
-
* @example
|
|
12280
|
-
* ```js
|
|
12281
|
-
* const authStatus = init({
|
|
12282
|
-
* thoughtSpotHost: 'https://my.thoughtspot.cloud',
|
|
12283
|
-
* authType: AuthType.None,
|
|
12284
|
-
* });
|
|
12285
|
-
* authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
|
|
12286
|
-
* ```
|
|
12287
|
-
* @returns {@link AuthEventEmitter} event emitter which emits events on authentication success,
|
|
12288
|
-
* failure and logout. See {@link AuthStatus}
|
|
12289
|
-
* @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
|
|
12290
|
-
* @group Authentication / Init
|
|
12280
|
+
* @param eventEmitter
|
|
12291
12281
|
*/
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
config = {
|
|
12296
|
-
...CONFIG_DEFAULTS,
|
|
12297
|
-
...embedConfig,
|
|
12298
|
-
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
12299
|
-
};
|
|
12300
|
-
config = backwardCompat(config);
|
|
12301
|
-
const authEE = new eventemitter3();
|
|
12302
|
-
setAuthEE(authEE);
|
|
12303
|
-
handleAuth();
|
|
12304
|
-
const { password, ...configToTrack } = config;
|
|
12305
|
-
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
12306
|
-
...configToTrack,
|
|
12307
|
-
usedCustomizationSheet: ((_b = (_a = embedConfig.customizations) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.customCSSUrl) != null,
|
|
12308
|
-
usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
|
|
12309
|
-
usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) != null,
|
|
12310
|
-
usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
|
|
12311
|
-
usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
|
|
12312
|
-
});
|
|
12313
|
-
if (config.callPrefetch) {
|
|
12314
|
-
prefetch(config.thoughtSpotHost);
|
|
12315
|
-
}
|
|
12316
|
-
return authEE;
|
|
12317
|
-
};
|
|
12282
|
+
function setAuthEE(eventEmitter) {
|
|
12283
|
+
authEE = eventEmitter;
|
|
12284
|
+
}
|
|
12318
12285
|
/**
|
|
12319
12286
|
*
|
|
12320
12287
|
*/
|
|
12321
|
-
function
|
|
12322
|
-
|
|
12288
|
+
function notifyAuthSDKSuccess() {
|
|
12289
|
+
if (!authEE) {
|
|
12290
|
+
console.error('SDK not initialized');
|
|
12291
|
+
return;
|
|
12292
|
+
}
|
|
12293
|
+
authEE.emit(exports.AuthStatus.SDK_SUCCESS);
|
|
12323
12294
|
}
|
|
12324
12295
|
/**
|
|
12325
|
-
* Logs out from ThoughtSpot. This also sets the autoLogin flag to false, to
|
|
12326
|
-
* prevent the SDK from automatically logging in again.
|
|
12327
12296
|
*
|
|
12328
|
-
* You can call the `init` method again to re login, if autoLogin is set to
|
|
12329
|
-
* true in this second call it will be honored.
|
|
12330
|
-
*
|
|
12331
|
-
* @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
|
|
12332
|
-
* @returns Promise which resolves when logout completes.
|
|
12333
|
-
* @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
|
|
12334
|
-
* @group Global methods
|
|
12335
12297
|
*/
|
|
12336
|
-
|
|
12337
|
-
if (!
|
|
12338
|
-
|
|
12298
|
+
function notifyAuthSuccess() {
|
|
12299
|
+
if (!authEE) {
|
|
12300
|
+
console.error('SDK not initialized');
|
|
12301
|
+
return;
|
|
12339
12302
|
}
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
return isLoggedIn;
|
|
12343
|
-
});
|
|
12344
|
-
};
|
|
12345
|
-
let renderQueue = Promise.resolve();
|
|
12303
|
+
authEE.emit(exports.AuthStatus.SUCCESS, sessionInfo);
|
|
12304
|
+
}
|
|
12346
12305
|
/**
|
|
12347
|
-
* Renders functions in a queue, resolves to next function only after the callback next
|
|
12348
|
-
* is called
|
|
12349
12306
|
*
|
|
12350
|
-
* @param
|
|
12307
|
+
* @param failureType
|
|
12351
12308
|
*/
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
return renderQueue;
|
|
12309
|
+
function notifyAuthFailure(failureType) {
|
|
12310
|
+
if (!authEE) {
|
|
12311
|
+
console.error('SDK not initialized');
|
|
12312
|
+
return;
|
|
12357
12313
|
}
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
};
|
|
12314
|
+
authEE.emit(exports.AuthStatus.FAILURE, failureType);
|
|
12315
|
+
}
|
|
12361
12316
|
/**
|
|
12362
|
-
* Imports TML representation of the metadata objects into ThoughtSpot.
|
|
12363
|
-
*
|
|
12364
|
-
* @param data
|
|
12365
|
-
* @example
|
|
12366
|
-
* ```js
|
|
12367
|
-
* executeTML({
|
|
12368
|
-
* //Array of metadata Tmls
|
|
12369
|
-
metadata_tmls: [
|
|
12370
|
-
"'\''{\"guid\":\"9bd202f5-d431-44bf-9a07-b4f7be372125\",
|
|
12371
|
-
\"liveboard\":{\"name\":\"Parameters Liveboard\"}}'\''"
|
|
12372
|
-
],
|
|
12373
|
-
import_policy: 'PARTIAL', // Specifies the import policy for the TML import.
|
|
12374
|
-
create_new: false, // If selected, creates TML objects with new GUIDs.
|
|
12375
|
-
}).then(result => {
|
|
12376
|
-
console.log(result);
|
|
12377
|
-
}).catch(error => {
|
|
12378
|
-
console.error(error);
|
|
12379
|
-
});
|
|
12380
12317
|
*
|
|
12381
|
-
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
12382
|
-
* @group Global methods
|
|
12383
12318
|
*/
|
|
12384
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
}
|
|
12389
|
-
catch (err) {
|
|
12390
|
-
return Promise.reject(err);
|
|
12391
|
-
}
|
|
12392
|
-
let authToken = '';
|
|
12393
|
-
if (authType === exports.AuthType.TrustedAuthTokenCookieless) {
|
|
12394
|
-
authToken = await getAuthenticationToken(config);
|
|
12319
|
+
function notifyLogout() {
|
|
12320
|
+
if (!authEE) {
|
|
12321
|
+
console.error('SDK not initialized');
|
|
12322
|
+
return;
|
|
12395
12323
|
}
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12324
|
+
authEE.emit(exports.AuthStatus.LOGOUT);
|
|
12325
|
+
}
|
|
12326
|
+
const initSession = (sessionDetails) => {
|
|
12327
|
+
if (sessionInfo == null) {
|
|
12328
|
+
sessionInfo = sessionDetails;
|
|
12329
|
+
initMixpanel(sessionInfo);
|
|
12330
|
+
sessionInfoResolver(sessionInfo);
|
|
12402
12331
|
}
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12332
|
+
};
|
|
12333
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
12334
|
+
console.log('helloooo');
|
|
12335
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
12336
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
12337
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
12338
|
+
? prodMixpanelToken
|
|
12339
|
+
: devMixpanelToken;
|
|
12340
|
+
return {
|
|
12341
|
+
userGUID: sessionInfoResp.userGUID,
|
|
12342
|
+
mixpanelToken,
|
|
12343
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
12344
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
12345
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
12346
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
12347
|
+
...sessionInfoResp,
|
|
12407
12348
|
};
|
|
12408
|
-
return fetch(`${thoughtSpotHost}${EndPoints.EXECUTE_TML}`, {
|
|
12409
|
-
method: 'POST',
|
|
12410
|
-
headers,
|
|
12411
|
-
body: JSON.stringify(payload),
|
|
12412
|
-
credentials: 'include',
|
|
12413
|
-
})
|
|
12414
|
-
.then((response) => {
|
|
12415
|
-
if (!response.ok) {
|
|
12416
|
-
throw new Error(`Failed to import TML data: ${response.status} - ${response.statusText}`);
|
|
12417
|
-
}
|
|
12418
|
-
return response.json();
|
|
12419
|
-
})
|
|
12420
|
-
.catch((error) => {
|
|
12421
|
-
throw error;
|
|
12422
|
-
});
|
|
12423
12349
|
};
|
|
12424
12350
|
/**
|
|
12425
|
-
*
|
|
12426
|
-
* format.
|
|
12351
|
+
* Check if we are logged into the ThoughtSpot cluster
|
|
12427
12352
|
*
|
|
12428
|
-
* @param
|
|
12429
|
-
* @example
|
|
12430
|
-
* ```js
|
|
12431
|
-
exportTML({
|
|
12432
|
-
metadata: [
|
|
12433
|
-
{
|
|
12434
|
-
type: "LIVEBOARD", //Metadata Type
|
|
12435
|
-
identifier: "9bd202f5-d431-44bf-9a07-b4f7be372125" //Metadata Id
|
|
12436
|
-
}
|
|
12437
|
-
],
|
|
12438
|
-
export_associated: false,//indicates whether to export associated metadata objects
|
|
12439
|
-
export_fqn: false, //Adds FQNs of the referenced objects.For example, if you are
|
|
12440
|
-
//exporting a Liveboard and its associated objects, the API
|
|
12441
|
-
//returns the Liveboard TML data with the FQNs of the referenced
|
|
12442
|
-
//worksheet. If the exported TML data includes FQNs, you don't need
|
|
12443
|
-
//to manually add FQNs of the referenced objects during TML import.
|
|
12444
|
-
edoc_format: "JSON" //It takes JSON or YAML value
|
|
12445
|
-
}).then(result => {
|
|
12446
|
-
console.log(result);
|
|
12447
|
-
}).catch(error => {
|
|
12448
|
-
console.error(error);
|
|
12449
|
-
});
|
|
12450
|
-
* ```
|
|
12451
|
-
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
12452
|
-
* @group Global methods
|
|
12353
|
+
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
12453
12354
|
*/
|
|
12454
|
-
|
|
12455
|
-
const {
|
|
12355
|
+
async function isLoggedIn(thoughtSpotHost) {
|
|
12356
|
+
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
12357
|
+
let response = null;
|
|
12456
12358
|
try {
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
12460
|
-
|
|
12359
|
+
response = await fetchSessionInfoService(authVerificationUrl);
|
|
12360
|
+
const sessionInfoResp = await response.json();
|
|
12361
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
12362
|
+
// Store user session details from session info
|
|
12363
|
+
initSession(sessionDetails);
|
|
12364
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12461
12365
|
}
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
export_associated: data.export_associated || false,
|
|
12465
|
-
export_fqn: data.export_fqn || false,
|
|
12466
|
-
edoc_format: data.edoc_format || 'YAML',
|
|
12467
|
-
};
|
|
12468
|
-
let authToken = '';
|
|
12469
|
-
if (authType === exports.AuthType.TrustedAuthTokenCookieless) {
|
|
12470
|
-
authToken = await getAuthenticationToken(config);
|
|
12366
|
+
catch (e) {
|
|
12367
|
+
return false;
|
|
12471
12368
|
}
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12369
|
+
return response.status === 200;
|
|
12370
|
+
}
|
|
12371
|
+
/**
|
|
12372
|
+
* Return releaseVersion if available
|
|
12373
|
+
*/
|
|
12374
|
+
function getReleaseVersion() {
|
|
12375
|
+
return releaseVersion;
|
|
12376
|
+
}
|
|
12377
|
+
/**
|
|
12378
|
+
* Return a promise that resolves with the session information when
|
|
12379
|
+
* authentication is successful. And info is available.
|
|
12380
|
+
*
|
|
12381
|
+
* @group Global methods
|
|
12382
|
+
*/
|
|
12383
|
+
function getSessionInfo() {
|
|
12384
|
+
return sessionInfoPromise;
|
|
12385
|
+
}
|
|
12386
|
+
/**
|
|
12387
|
+
* Check if we are stuck at the SSO redirect URL
|
|
12388
|
+
*/
|
|
12389
|
+
function isAtSSORedirectUrl() {
|
|
12390
|
+
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
12391
|
+
}
|
|
12392
|
+
/**
|
|
12393
|
+
* Remove the SSO redirect URL marker
|
|
12394
|
+
*/
|
|
12395
|
+
function removeSSORedirectUrlMarker() {
|
|
12396
|
+
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
12397
|
+
// to begin with. Trying to remove the hash by changing window.location will
|
|
12398
|
+
// reload the page which we don't want. We'll live with adding an
|
|
12399
|
+
// unnecessary hash to the parent page URL until we find any use case where
|
|
12400
|
+
// that creates an issue.
|
|
12401
|
+
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
12402
|
+
}
|
|
12403
|
+
/**
|
|
12404
|
+
* Perform token based authentication
|
|
12405
|
+
*
|
|
12406
|
+
* @param embedConfig The embed configuration
|
|
12407
|
+
*/
|
|
12408
|
+
const doTokenAuth = async (embedConfig) => {
|
|
12409
|
+
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
12410
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12411
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12478
12412
|
}
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12413
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12414
|
+
if (!loggedInStatus) {
|
|
12415
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12416
|
+
let resp;
|
|
12417
|
+
try {
|
|
12418
|
+
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
12419
|
+
}
|
|
12420
|
+
catch (e) {
|
|
12421
|
+
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
12422
|
+
}
|
|
12423
|
+
// token login issues a 302 when successful
|
|
12424
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
12425
|
+
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
12426
|
+
// When 3rd party cookie access is blocked, this will fail because
|
|
12427
|
+
// cookies will not be sent with the call.
|
|
12428
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12488
12429
|
}
|
|
12489
|
-
return response.json();
|
|
12490
|
-
})
|
|
12491
|
-
.catch((error) => {
|
|
12492
|
-
throw error;
|
|
12493
|
-
});
|
|
12494
|
-
};
|
|
12495
|
-
|
|
12496
|
-
const tokenizedFetch = async (input, init) => {
|
|
12497
|
-
const req = new Request(input, init);
|
|
12498
|
-
const embedConfig = getEmbedConfig();
|
|
12499
|
-
if (embedConfig.authType !== exports.AuthType.TrustedAuthTokenCookieless) {
|
|
12500
|
-
return fetch(req);
|
|
12501
|
-
}
|
|
12502
|
-
const authToken = await getAuthenticationToken(embedConfig);
|
|
12503
|
-
if (authToken) {
|
|
12504
|
-
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
12505
12430
|
}
|
|
12506
|
-
return
|
|
12507
|
-
};
|
|
12508
|
-
|
|
12431
|
+
return loggedInStatus;
|
|
12432
|
+
};
|
|
12509
12433
|
/**
|
|
12434
|
+
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
12510
12435
|
*
|
|
12511
|
-
* @param
|
|
12512
|
-
* @param root0.query
|
|
12513
|
-
* @param root0.variables
|
|
12514
|
-
* @param root0.thoughtSpotHost
|
|
12515
|
-
* @param root0.isCompositeQuery
|
|
12436
|
+
* @param embedConfig The embed configuration
|
|
12516
12437
|
*/
|
|
12517
|
-
|
|
12518
|
-
const
|
|
12438
|
+
const doCookielessTokenAuth = async (embedConfig) => {
|
|
12439
|
+
const { authEndpoint, getAuthToken } = embedConfig;
|
|
12440
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12441
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12442
|
+
}
|
|
12519
12443
|
try {
|
|
12520
|
-
const
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
'content-type': 'application/json;charset=UTF-8',
|
|
12524
|
-
'x-requested-by': 'ThoughtSpot',
|
|
12525
|
-
accept: '*/*',
|
|
12526
|
-
'accept-language': 'en-us',
|
|
12527
|
-
},
|
|
12528
|
-
body: JSON.stringify({
|
|
12529
|
-
operationName,
|
|
12530
|
-
query,
|
|
12531
|
-
variables,
|
|
12532
|
-
}),
|
|
12533
|
-
credentials: 'include',
|
|
12534
|
-
});
|
|
12535
|
-
const result = await response.json();
|
|
12536
|
-
const dataValues = Object.values(result.data);
|
|
12537
|
-
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
12444
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12445
|
+
if (authToken)
|
|
12446
|
+
return true;
|
|
12538
12447
|
}
|
|
12539
|
-
catch
|
|
12540
|
-
return
|
|
12448
|
+
catch {
|
|
12449
|
+
// return false if getAuthenticationToken fails
|
|
12541
12450
|
}
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
const getSourceDetailQuery = `
|
|
12545
|
-
query GetSourceDetail($ids: [GUID!]!) {
|
|
12546
|
-
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
12547
|
-
id
|
|
12548
|
-
name
|
|
12549
|
-
description
|
|
12550
|
-
authorName
|
|
12551
|
-
authorDisplayName
|
|
12552
|
-
isExternal
|
|
12553
|
-
type
|
|
12554
|
-
created
|
|
12555
|
-
modified
|
|
12556
|
-
columns {
|
|
12557
|
-
id
|
|
12558
|
-
name
|
|
12559
|
-
author
|
|
12560
|
-
authorDisplayName
|
|
12561
|
-
description
|
|
12562
|
-
dataType
|
|
12563
|
-
type
|
|
12564
|
-
modified
|
|
12565
|
-
ownerName
|
|
12566
|
-
owner
|
|
12567
|
-
dataRecency
|
|
12568
|
-
sources {
|
|
12569
|
-
tableId
|
|
12570
|
-
tableName
|
|
12571
|
-
columnId
|
|
12572
|
-
columnName
|
|
12573
|
-
__typename
|
|
12574
|
-
}
|
|
12575
|
-
synonyms
|
|
12576
|
-
cohortAnswerId
|
|
12577
|
-
__typename
|
|
12578
|
-
}
|
|
12579
|
-
relationships
|
|
12580
|
-
destinationRelationships
|
|
12581
|
-
dataSourceId
|
|
12582
|
-
__typename
|
|
12583
|
-
}
|
|
12584
|
-
}
|
|
12585
|
-
`;
|
|
12586
|
-
const sourceDetailCache = new Map();
|
|
12451
|
+
return false;
|
|
12452
|
+
};
|
|
12587
12453
|
/**
|
|
12454
|
+
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
12455
|
+
* credentials.
|
|
12588
12456
|
*
|
|
12589
|
-
*
|
|
12590
|
-
*
|
|
12457
|
+
* Warning: This feature is primarily intended for developer testing. It is
|
|
12458
|
+
* strongly advised not to use this authentication method in production.
|
|
12459
|
+
*
|
|
12460
|
+
* @param embedConfig The embed configuration
|
|
12591
12461
|
*/
|
|
12592
|
-
async
|
|
12593
|
-
|
|
12594
|
-
|
|
12462
|
+
const doBasicAuth = async (embedConfig) => {
|
|
12463
|
+
const { thoughtSpotHost, username, password } = embedConfig;
|
|
12464
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12465
|
+
if (!loggedIn) {
|
|
12466
|
+
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
12467
|
+
loggedInStatus = response.ok;
|
|
12468
|
+
if (embedConfig.detectCookieAccessSlow) {
|
|
12469
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12470
|
+
}
|
|
12595
12471
|
}
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
variables: {
|
|
12599
|
-
ids: [sourceId],
|
|
12600
|
-
},
|
|
12601
|
-
thoughtSpotHost,
|
|
12602
|
-
});
|
|
12603
|
-
const souceDetails = details[0];
|
|
12604
|
-
if (souceDetails) {
|
|
12605
|
-
sourceDetailCache.set(sourceId, souceDetails);
|
|
12472
|
+
else {
|
|
12473
|
+
loggedInStatus = true;
|
|
12606
12474
|
}
|
|
12607
|
-
return
|
|
12608
|
-
}
|
|
12609
|
-
|
|
12610
|
-
const bachSessionId = `
|
|
12611
|
-
id {
|
|
12612
|
-
sessionId
|
|
12613
|
-
genNo
|
|
12614
|
-
acSession {
|
|
12615
|
-
sessionId
|
|
12616
|
-
genNo
|
|
12617
|
-
}
|
|
12618
|
-
}
|
|
12619
|
-
`;
|
|
12620
|
-
const getUnaggregatedAnswerSession = `
|
|
12621
|
-
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
12622
|
-
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
12623
|
-
${bachSessionId}
|
|
12624
|
-
answer {
|
|
12625
|
-
visualizations {
|
|
12626
|
-
... on TableViz {
|
|
12627
|
-
columns {
|
|
12628
|
-
column {
|
|
12629
|
-
id
|
|
12630
|
-
name
|
|
12631
|
-
referencedColumns {
|
|
12632
|
-
guid
|
|
12633
|
-
displayName
|
|
12634
|
-
}
|
|
12635
|
-
}
|
|
12636
|
-
}
|
|
12637
|
-
}
|
|
12638
|
-
}
|
|
12639
|
-
}
|
|
12640
|
-
}
|
|
12641
|
-
}
|
|
12642
|
-
`;
|
|
12643
|
-
const removeColumns = `
|
|
12644
|
-
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
12645
|
-
Answer__removeColumns(
|
|
12646
|
-
session: $session
|
|
12647
|
-
logicalColumnIds: $logicalColumnIds
|
|
12648
|
-
columnIds: $columnIds
|
|
12649
|
-
) {
|
|
12650
|
-
${bachSessionId}
|
|
12651
|
-
}
|
|
12652
|
-
}
|
|
12653
|
-
`;
|
|
12654
|
-
const addColumns = `
|
|
12655
|
-
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
12656
|
-
Answer__addColumn(session: $session, columns: $columns) {
|
|
12657
|
-
${bachSessionId}
|
|
12658
|
-
}
|
|
12659
|
-
}
|
|
12660
|
-
`;
|
|
12661
|
-
const getAnswerData = `
|
|
12662
|
-
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
12663
|
-
getAnswer(session: $session) {
|
|
12664
|
-
${bachSessionId}
|
|
12665
|
-
answer {
|
|
12666
|
-
id
|
|
12667
|
-
visualizations {
|
|
12668
|
-
id
|
|
12669
|
-
... on TableViz {
|
|
12670
|
-
columns {
|
|
12671
|
-
column {
|
|
12672
|
-
id
|
|
12673
|
-
name
|
|
12674
|
-
type
|
|
12675
|
-
aggregationType
|
|
12676
|
-
dataType
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
12680
|
-
}
|
|
12681
|
-
}
|
|
12682
|
-
}
|
|
12683
|
-
}
|
|
12684
|
-
}
|
|
12685
|
-
`;
|
|
12686
|
-
|
|
12687
|
-
// eslint-disable-next-line no-shadow
|
|
12688
|
-
var OperationType;
|
|
12689
|
-
(function (OperationType) {
|
|
12690
|
-
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
12691
|
-
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
12692
|
-
})(OperationType || (OperationType = {}));
|
|
12475
|
+
return loggedInStatus;
|
|
12476
|
+
};
|
|
12693
12477
|
/**
|
|
12694
|
-
* Class representing the answer service provided with the
|
|
12695
|
-
* custom action payload. This service could be used to run
|
|
12696
|
-
* graphql queries in the context of the answer on which the
|
|
12697
|
-
* custom action was triggered.
|
|
12698
12478
|
*
|
|
12699
|
-
* @
|
|
12700
|
-
*
|
|
12701
|
-
*
|
|
12702
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12703
|
-
* 'col name 1'
|
|
12704
|
-
* ]);
|
|
12705
|
-
* const data = await underlying.fetchData(0, 100);
|
|
12706
|
-
* })
|
|
12707
|
-
* ```
|
|
12708
|
-
* @version
|
|
12709
|
-
* ThoughtSpot: 9.9.0.cl / SDK: 1.25.0
|
|
12710
|
-
* @group Events
|
|
12479
|
+
* @param ssoURL
|
|
12480
|
+
* @param triggerContainer
|
|
12481
|
+
* @param triggerText
|
|
12711
12482
|
*/
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
});
|
|
12483
|
+
async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
12484
|
+
const openPopup = () => {
|
|
12485
|
+
if (samlAuthWindow === null || samlAuthWindow.closed) {
|
|
12486
|
+
samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
|
|
12487
|
+
}
|
|
12488
|
+
else {
|
|
12489
|
+
samlAuthWindow.focus();
|
|
12490
|
+
}
|
|
12491
|
+
};
|
|
12492
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.emit(exports.AuthStatus.WAITING_FOR_POPUP);
|
|
12493
|
+
const containerEl = getDOMNode(triggerContainer);
|
|
12494
|
+
if (containerEl) {
|
|
12495
|
+
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
12496
|
+
const authElem = document.getElementById('ts-auth-btn');
|
|
12497
|
+
authElem.textContent = triggerText;
|
|
12498
|
+
authElem.addEventListener('click', openPopup, { once: true });
|
|
12728
12499
|
}
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12500
|
+
samlCompletionPromise = samlCompletionPromise
|
|
12501
|
+
|| new Promise((resolve, reject) => {
|
|
12502
|
+
window.addEventListener('message', (e) => {
|
|
12503
|
+
if (e.data.type === exports.EmbedEvent.SAMLComplete) {
|
|
12504
|
+
e.source.close();
|
|
12505
|
+
resolve();
|
|
12506
|
+
}
|
|
12507
|
+
});
|
|
12732
12508
|
});
|
|
12509
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.once(exports.AuthEvent.TRIGGER_SSO_POPUP, openPopup);
|
|
12510
|
+
return samlCompletionPromise;
|
|
12511
|
+
}
|
|
12512
|
+
/**
|
|
12513
|
+
* Perform SAML authentication
|
|
12514
|
+
*
|
|
12515
|
+
* @param embedConfig The embed configuration
|
|
12516
|
+
* @param ssoEndPoint
|
|
12517
|
+
*/
|
|
12518
|
+
const doSSOAuth = async (embedConfig, ssoEndPoint) => {
|
|
12519
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12520
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12521
|
+
if (loggedIn) {
|
|
12522
|
+
if (isAtSSORedirectUrl()) {
|
|
12523
|
+
removeSSORedirectUrlMarker();
|
|
12524
|
+
}
|
|
12525
|
+
loggedInStatus = true;
|
|
12526
|
+
return;
|
|
12733
12527
|
}
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
size,
|
|
12741
|
-
},
|
|
12742
|
-
});
|
|
12743
|
-
const { columns, data } = answer.visualizations[0];
|
|
12744
|
-
return {
|
|
12745
|
-
columns,
|
|
12746
|
-
data,
|
|
12747
|
-
};
|
|
12528
|
+
// we have already tried authentication and it did not succeed, restore
|
|
12529
|
+
// the current URL to the original one and invoke the callback.
|
|
12530
|
+
if (isAtSSORedirectUrl()) {
|
|
12531
|
+
removeSSORedirectUrlMarker();
|
|
12532
|
+
loggedInStatus = false;
|
|
12533
|
+
return;
|
|
12748
12534
|
}
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
*/
|
|
12755
|
-
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
12756
|
-
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
12757
|
-
return tokenizedFetch(fetchUrl, {
|
|
12758
|
-
credentials: 'include',
|
|
12759
|
-
});
|
|
12535
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
12536
|
+
if (embedConfig.inPopup) {
|
|
12537
|
+
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
12538
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12539
|
+
return;
|
|
12760
12540
|
}
|
|
12761
|
-
|
|
12762
|
-
|
|
12541
|
+
window.location.href = ssoURL;
|
|
12542
|
+
};
|
|
12543
|
+
const doSamlAuth = async (embedConfig) => {
|
|
12544
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12545
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12546
|
+
// loaded again and the same JS will execute again.
|
|
12547
|
+
const ssoRedirectUrl = embedConfig.inPopup
|
|
12548
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12549
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12550
|
+
// bring back the page to the same URL
|
|
12551
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12552
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12553
|
+
return loggedInStatus;
|
|
12554
|
+
};
|
|
12555
|
+
const doOIDCAuth = async (embedConfig) => {
|
|
12556
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12557
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12558
|
+
// loaded again and the same JS will execute again.
|
|
12559
|
+
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
12560
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12561
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12562
|
+
// bring back the page to the same URL
|
|
12563
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12564
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12565
|
+
return loggedInStatus;
|
|
12566
|
+
};
|
|
12567
|
+
const logout = async (embedConfig) => {
|
|
12568
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12569
|
+
await fetchLogoutService(thoughtSpotHost);
|
|
12570
|
+
resetCachedAuthToken();
|
|
12571
|
+
loggedInStatus = false;
|
|
12572
|
+
return loggedInStatus;
|
|
12573
|
+
};
|
|
12574
|
+
/**
|
|
12575
|
+
* Perform authentication on the ThoughtSpot cluster
|
|
12576
|
+
*
|
|
12577
|
+
* @param embedConfig The embed configuration
|
|
12578
|
+
*/
|
|
12579
|
+
const authenticate = async (embedConfig) => {
|
|
12580
|
+
const { authType } = embedConfig;
|
|
12581
|
+
switch (authType) {
|
|
12582
|
+
case exports.AuthType.SSO:
|
|
12583
|
+
case exports.AuthType.SAMLRedirect:
|
|
12584
|
+
case exports.AuthType.SAML:
|
|
12585
|
+
return doSamlAuth(embedConfig);
|
|
12586
|
+
case exports.AuthType.OIDC:
|
|
12587
|
+
case exports.AuthType.OIDCRedirect:
|
|
12588
|
+
return doOIDCAuth(embedConfig);
|
|
12589
|
+
case exports.AuthType.AuthServer:
|
|
12590
|
+
case exports.AuthType.TrustedAuthToken:
|
|
12591
|
+
return doTokenAuth(embedConfig);
|
|
12592
|
+
case exports.AuthType.TrustedAuthTokenCookieless:
|
|
12593
|
+
return doCookielessTokenAuth(embedConfig);
|
|
12594
|
+
case exports.AuthType.Basic:
|
|
12595
|
+
return doBasicAuth(embedConfig);
|
|
12596
|
+
default:
|
|
12597
|
+
return Promise.resolve(true);
|
|
12763
12598
|
}
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
12783
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
12784
|
-
}
|
|
12785
|
-
if (!selectedPoints) {
|
|
12786
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
12787
|
-
}
|
|
12788
|
-
const sourceDetail = await this.getSourceDetail();
|
|
12789
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
12790
|
-
const unAggAnswer = await graphqlQuery({
|
|
12791
|
-
query: getUnaggregatedAnswerSession,
|
|
12792
|
-
variables: {
|
|
12793
|
-
session: this.session,
|
|
12794
|
-
columns: selectedPoints,
|
|
12795
|
-
},
|
|
12796
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
12797
|
-
});
|
|
12798
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
12799
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
12800
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
12801
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
12802
|
-
if (columnsToAdd.length) {
|
|
12803
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
12599
|
+
};
|
|
12600
|
+
|
|
12601
|
+
/* eslint-disable camelcase */
|
|
12602
|
+
const CONFIG_DEFAULTS = {
|
|
12603
|
+
loginFailedMessage: 'Not logged in',
|
|
12604
|
+
authTriggerText: 'Authorize',
|
|
12605
|
+
authType: exports.AuthType.None,
|
|
12606
|
+
};
|
|
12607
|
+
let authPromise;
|
|
12608
|
+
const getAuthPromise = () => authPromise;
|
|
12609
|
+
/**
|
|
12610
|
+
* Perform authentication on the ThoughtSpot app as applicable.
|
|
12611
|
+
*/
|
|
12612
|
+
const handleAuth = () => {
|
|
12613
|
+
authPromise = authenticate(getEmbedConfig());
|
|
12614
|
+
authPromise.then((isLoggedIn) => {
|
|
12615
|
+
if (!isLoggedIn) {
|
|
12616
|
+
notifyAuthFailure(exports.AuthFailureType.SDK);
|
|
12804
12617
|
}
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
12618
|
+
else {
|
|
12619
|
+
notifyAuthSDKSuccess();
|
|
12808
12620
|
}
|
|
12809
|
-
|
|
12621
|
+
}, () => {
|
|
12622
|
+
notifyAuthFailure(exports.AuthFailureType.SDK);
|
|
12623
|
+
});
|
|
12624
|
+
return authPromise;
|
|
12625
|
+
};
|
|
12626
|
+
const hostUrlToFeatureUrl = {
|
|
12627
|
+
[exports.PrefetchFeatures.SearchEmbed]: (url) => `${url}v2/#/embed/answer`,
|
|
12628
|
+
[exports.PrefetchFeatures.LiveboardEmbed]: (url) => url,
|
|
12629
|
+
[exports.PrefetchFeatures.FullApp]: (url) => url,
|
|
12630
|
+
[exports.PrefetchFeatures.VizEmbed]: (url) => url,
|
|
12631
|
+
};
|
|
12632
|
+
/**
|
|
12633
|
+
* Prefetches static resources from the specified URL. Web browsers can then cache the
|
|
12634
|
+
* prefetched resources and serve them from the user's local disk to provide faster access
|
|
12635
|
+
* to your app.
|
|
12636
|
+
*
|
|
12637
|
+
* @param url The URL provided for prefetch
|
|
12638
|
+
* @param prefetchFeatures Specify features which needs to be prefetched.
|
|
12639
|
+
* @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
|
|
12640
|
+
* @group Global methods
|
|
12641
|
+
*/
|
|
12642
|
+
const prefetch = (url, prefetchFeatures) => {
|
|
12643
|
+
if (url === '') {
|
|
12644
|
+
// eslint-disable-next-line no-console
|
|
12645
|
+
console.warn('The prefetch method does not have a valid URL');
|
|
12810
12646
|
}
|
|
12811
|
-
|
|
12812
|
-
const
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12647
|
+
else {
|
|
12648
|
+
const features = prefetchFeatures || [exports.PrefetchFeatures.FullApp];
|
|
12649
|
+
let hostUrl = url || getEmbedConfig().thoughtSpotHost;
|
|
12650
|
+
hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
|
|
12651
|
+
uniq_1(features.map((feature) => hostUrlToFeatureUrl[feature](hostUrl))).forEach((prefetchUrl, index) => {
|
|
12652
|
+
const iFrame = document.createElement('iframe');
|
|
12653
|
+
iFrame.src = prefetchUrl;
|
|
12654
|
+
iFrame.style.width = '0';
|
|
12655
|
+
iFrame.style.height = '0';
|
|
12656
|
+
iFrame.style.border = '0';
|
|
12657
|
+
iFrame.classList.add('prefetchIframe');
|
|
12658
|
+
iFrame.classList.add(`prefetchIframeNum-${index}`);
|
|
12659
|
+
document.body.appendChild(iFrame);
|
|
12820
12660
|
});
|
|
12821
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
12822
|
-
return data;
|
|
12823
12661
|
}
|
|
12824
|
-
|
|
12825
|
-
|
|
12662
|
+
};
|
|
12663
|
+
/**
|
|
12664
|
+
*
|
|
12665
|
+
* @param embedConfig
|
|
12666
|
+
*/
|
|
12667
|
+
function sanity(embedConfig) {
|
|
12668
|
+
if (embedConfig.thoughtSpotHost === undefined) {
|
|
12669
|
+
throw new Error('ThoughtSpot host not provided');
|
|
12670
|
+
}
|
|
12671
|
+
if (embedConfig.authType === exports.AuthType.TrustedAuthToken) {
|
|
12672
|
+
if (!embedConfig.username) {
|
|
12673
|
+
throw new Error('Username not provided with Trusted auth');
|
|
12674
|
+
}
|
|
12675
|
+
if (!embedConfig.authEndpoint && typeof embedConfig.getAuthToken !== 'function') {
|
|
12676
|
+
throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
|
|
12677
|
+
}
|
|
12826
12678
|
}
|
|
12827
12679
|
}
|
|
12828
12680
|
/**
|
|
12829
12681
|
*
|
|
12830
|
-
* @param
|
|
12831
|
-
* @param colNames
|
|
12682
|
+
* @param embedConfig
|
|
12832
12683
|
*/
|
|
12833
|
-
function
|
|
12834
|
-
const
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
}
|
|
12838
|
-
return
|
|
12839
|
-
|
|
12840
|
-
|
|
12684
|
+
function backwardCompat(embedConfig) {
|
|
12685
|
+
const newConfig = { ...embedConfig };
|
|
12686
|
+
if (embedConfig.noRedirect !== undefined && embedConfig.inPopup === undefined) {
|
|
12687
|
+
newConfig.inPopup = embedConfig.noRedirect;
|
|
12688
|
+
}
|
|
12689
|
+
return newConfig;
|
|
12690
|
+
}
|
|
12691
|
+
/**
|
|
12692
|
+
* Initializes the Visual Embed SDK globally and perform
|
|
12693
|
+
* authentication if applicable. This function needs to be called before any ThoughtSpot
|
|
12694
|
+
* component like liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
|
|
12695
|
+
* to actually embed. That is handled internally.
|
|
12696
|
+
*
|
|
12697
|
+
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
12698
|
+
* authentication mechanism and so on.
|
|
12699
|
+
* @example
|
|
12700
|
+
* ```js
|
|
12701
|
+
* const authStatus = init({
|
|
12702
|
+
* thoughtSpotHost: 'https://my.thoughtspot.cloud',
|
|
12703
|
+
* authType: AuthType.None,
|
|
12704
|
+
* });
|
|
12705
|
+
* authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
|
|
12706
|
+
* ```
|
|
12707
|
+
* @returns {@link AuthEventEmitter} event emitter which emits events on authentication success,
|
|
12708
|
+
* failure and logout. See {@link AuthStatus}
|
|
12709
|
+
* @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
|
|
12710
|
+
* @group Authentication / Init
|
|
12711
|
+
*/
|
|
12712
|
+
const init = (embedConfig) => {
|
|
12713
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
12714
|
+
sanity(embedConfig);
|
|
12715
|
+
setEmbedConfig(backwardCompat({
|
|
12716
|
+
...CONFIG_DEFAULTS,
|
|
12717
|
+
...embedConfig,
|
|
12718
|
+
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
12841
12719
|
}));
|
|
12720
|
+
const authEE = new eventemitter3();
|
|
12721
|
+
setAuthEE(authEE);
|
|
12722
|
+
handleAuth();
|
|
12723
|
+
const { password, ...configToTrack } = getEmbedConfig();
|
|
12724
|
+
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
12725
|
+
...configToTrack,
|
|
12726
|
+
usedCustomizationSheet: ((_b = (_a = embedConfig.customizations) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.customCSSUrl) != null,
|
|
12727
|
+
usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
|
|
12728
|
+
usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) != null,
|
|
12729
|
+
usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
|
|
12730
|
+
usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
|
|
12731
|
+
});
|
|
12732
|
+
if (getEmbedConfig().callPrefetch) {
|
|
12733
|
+
prefetch(getEmbedConfig().thoughtSpotHost);
|
|
12734
|
+
}
|
|
12735
|
+
return authEE;
|
|
12736
|
+
};
|
|
12737
|
+
/**
|
|
12738
|
+
*
|
|
12739
|
+
*/
|
|
12740
|
+
function disableAutoLogin() {
|
|
12741
|
+
getEmbedConfig().autoLogin = false;
|
|
12842
12742
|
}
|
|
12843
12743
|
/**
|
|
12744
|
+
* Logs out from ThoughtSpot. This also sets the autoLogin flag to false, to
|
|
12745
|
+
* prevent the SDK from automatically logging in again.
|
|
12844
12746
|
*
|
|
12845
|
-
*
|
|
12747
|
+
* You can call the `init` method again to re login, if autoLogin is set to
|
|
12748
|
+
* true in this second call it will be honored.
|
|
12749
|
+
*
|
|
12750
|
+
* @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
|
|
12751
|
+
* @returns Promise which resolves when logout completes.
|
|
12752
|
+
* @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
|
|
12753
|
+
* @group Global methods
|
|
12846
12754
|
*/
|
|
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
|
-
|
|
12755
|
+
const logout$1 = (doNotDisableAutoLogin = false) => {
|
|
12756
|
+
if (!doNotDisableAutoLogin) {
|
|
12757
|
+
disableAutoLogin();
|
|
12758
|
+
}
|
|
12759
|
+
return logout(getEmbedConfig()).then((isLoggedIn) => {
|
|
12760
|
+
notifyLogout();
|
|
12761
|
+
return isLoggedIn;
|
|
12762
|
+
});
|
|
12763
|
+
};
|
|
12764
|
+
let renderQueue = Promise.resolve();
|
|
12765
|
+
/**
|
|
12766
|
+
* Renders functions in a queue, resolves to next function only after the callback next
|
|
12767
|
+
* is called
|
|
12768
|
+
*
|
|
12769
|
+
* @param fn The function being registered
|
|
12770
|
+
*/
|
|
12771
|
+
const renderInQueue = (fn) => {
|
|
12772
|
+
const { queueMultiRenders = false } = getEmbedConfig();
|
|
12773
|
+
if (queueMultiRenders) {
|
|
12774
|
+
renderQueue = renderQueue.then(() => new Promise((res) => fn(res)));
|
|
12775
|
+
return renderQueue;
|
|
12776
|
+
}
|
|
12777
|
+
// Sending an empty function to keep it consistent with the above usage.
|
|
12778
|
+
return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
|
|
12779
|
+
};
|
|
12780
|
+
/**
|
|
12781
|
+
* Imports TML representation of the metadata objects into ThoughtSpot.
|
|
12782
|
+
*
|
|
12783
|
+
* @param data
|
|
12784
|
+
* @example
|
|
12785
|
+
* ```js
|
|
12786
|
+
* executeTML({
|
|
12787
|
+
* //Array of metadata Tmls
|
|
12788
|
+
metadata_tmls: [
|
|
12789
|
+
"'\''{\"guid\":\"9bd202f5-d431-44bf-9a07-b4f7be372125\",
|
|
12790
|
+
\"liveboard\":{\"name\":\"Parameters Liveboard\"}}'\''"
|
|
12791
|
+
],
|
|
12792
|
+
import_policy: 'PARTIAL', // Specifies the import policy for the TML import.
|
|
12793
|
+
create_new: false, // If selected, creates TML objects with new GUIDs.
|
|
12794
|
+
}).then(result => {
|
|
12795
|
+
console.log(result);
|
|
12796
|
+
}).catch(error => {
|
|
12797
|
+
console.error(error);
|
|
12798
|
+
});
|
|
12799
|
+
*
|
|
12800
|
+
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
12801
|
+
* @group Global methods
|
|
12802
|
+
*/
|
|
12803
|
+
const executeTML = async (data) => {
|
|
12804
|
+
try {
|
|
12805
|
+
sanity(getEmbedConfig());
|
|
12806
|
+
}
|
|
12807
|
+
catch (err) {
|
|
12808
|
+
return Promise.reject(err);
|
|
12809
|
+
}
|
|
12810
|
+
const { thoughtSpotHost, authType } = getEmbedConfig();
|
|
12811
|
+
const headers = {
|
|
12812
|
+
'Content-Type': 'application/json',
|
|
12813
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12814
|
+
};
|
|
12815
|
+
const payload = {
|
|
12816
|
+
metadata_tmls: data.metadata_tmls,
|
|
12817
|
+
import_policy: data.import_policy || 'PARTIAL',
|
|
12818
|
+
create_new: data.create_new || false,
|
|
12819
|
+
};
|
|
12820
|
+
return tokenizedFetch(`${thoughtSpotHost}${EndPoints.EXECUTE_TML}`, {
|
|
12821
|
+
method: 'POST',
|
|
12822
|
+
headers,
|
|
12823
|
+
body: JSON.stringify(payload),
|
|
12824
|
+
credentials: 'include',
|
|
12825
|
+
})
|
|
12826
|
+
.then((response) => {
|
|
12827
|
+
if (!response.ok) {
|
|
12828
|
+
throw new Error(`Failed to import TML data: ${response.status} - ${response.statusText}`);
|
|
12878
12829
|
}
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12830
|
+
return response.json();
|
|
12831
|
+
})
|
|
12832
|
+
.catch((error) => {
|
|
12833
|
+
throw error;
|
|
12834
|
+
});
|
|
12835
|
+
};
|
|
12836
|
+
/**
|
|
12837
|
+
* Exports TML representation of the metadata objects from ThoughtSpot in JSON or YAML
|
|
12838
|
+
* format.
|
|
12839
|
+
*
|
|
12840
|
+
* @param data
|
|
12841
|
+
* @example
|
|
12842
|
+
* ```js
|
|
12843
|
+
exportTML({
|
|
12844
|
+
metadata: [
|
|
12845
|
+
{
|
|
12846
|
+
type: "LIVEBOARD", //Metadata Type
|
|
12847
|
+
identifier: "9bd202f5-d431-44bf-9a07-b4f7be372125" //Metadata Id
|
|
12848
|
+
}
|
|
12849
|
+
],
|
|
12850
|
+
export_associated: false,//indicates whether to export associated metadata objects
|
|
12851
|
+
export_fqn: false, //Adds FQNs of the referenced objects.For example, if you are
|
|
12852
|
+
//exporting a Liveboard and its associated objects, the API
|
|
12853
|
+
//returns the Liveboard TML data with the FQNs of the referenced
|
|
12854
|
+
//worksheet. If the exported TML data includes FQNs, you don't need
|
|
12855
|
+
//to manually add FQNs of the referenced objects during TML import.
|
|
12856
|
+
edoc_format: "JSON" //It takes JSON or YAML value
|
|
12857
|
+
}).then(result => {
|
|
12858
|
+
console.log(result);
|
|
12859
|
+
}).catch(error => {
|
|
12860
|
+
console.error(error);
|
|
12861
|
+
});
|
|
12862
|
+
* ```
|
|
12863
|
+
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
12864
|
+
* @group Global methods
|
|
12865
|
+
*/
|
|
12866
|
+
const exportTML = async (data) => {
|
|
12867
|
+
const { thoughtSpotHost, authType } = getEmbedConfig();
|
|
12868
|
+
try {
|
|
12869
|
+
sanity(getEmbedConfig());
|
|
12883
12870
|
}
|
|
12884
|
-
|
|
12885
|
-
|
|
12871
|
+
catch (err) {
|
|
12872
|
+
return Promise.reject(err);
|
|
12873
|
+
}
|
|
12874
|
+
const payload = {
|
|
12875
|
+
metadata: data.metadata,
|
|
12876
|
+
export_associated: data.export_associated || false,
|
|
12877
|
+
export_fqn: data.export_fqn || false,
|
|
12878
|
+
edoc_format: data.edoc_format || 'YAML',
|
|
12879
|
+
};
|
|
12880
|
+
const headers = {
|
|
12881
|
+
'Content-Type': 'application/json',
|
|
12882
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12883
|
+
};
|
|
12884
|
+
return tokenizedFetch(`${thoughtSpotHost}${EndPoints.EXPORT_TML}`, {
|
|
12885
|
+
method: 'POST',
|
|
12886
|
+
headers,
|
|
12887
|
+
body: JSON.stringify(payload),
|
|
12888
|
+
credentials: 'include',
|
|
12889
|
+
})
|
|
12890
|
+
.then((response) => {
|
|
12891
|
+
if (!response.ok) {
|
|
12892
|
+
throw new Error(`Failed to export TML: ${response.status} - ${response.statusText}`);
|
|
12893
|
+
}
|
|
12894
|
+
return response.json();
|
|
12895
|
+
})
|
|
12896
|
+
.catch((error) => {
|
|
12897
|
+
throw error;
|
|
12886
12898
|
});
|
|
12887
|
-
|
|
12888
|
-
}
|
|
12899
|
+
};
|
|
12889
12900
|
|
|
12890
12901
|
/**
|
|
12891
12902
|
*
|
|
@@ -13043,7 +13054,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
|
|
|
13043
13054
|
});
|
|
13044
13055
|
}
|
|
13045
13056
|
|
|
13046
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.26.0-token-cache.
|
|
13057
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.26.0-token-cache.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",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":"^40.1.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$1,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};
|
|
13047
13058
|
|
|
13048
13059
|
/**
|
|
13049
13060
|
* Copyright (c) 2022
|