@thoughtspot/visual-embed-sdk 1.24.0-dev → 1.24.0-preRender.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/package.json +2 -3
- package/cjs/src/embed/app.d.ts +3 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +8 -2
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/base.d.ts +2 -0
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +2 -0
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +3 -2
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +6 -5
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +4 -1
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +9 -2
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +1 -0
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +1 -0
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +5 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +10 -2
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +9 -3
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +50 -20
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +47 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +3 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +2 -0
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +1 -0
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +5 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +8 -8
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/types.d.ts +46 -18
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +7 -13
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +5 -0
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -0
- package/cjs/src/utils/graphql/answerService/answer-queries.js +80 -0
- package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +61 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.js +182 -0
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.d.ts +2 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.d.ts.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +201 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -0
- package/cjs/src/utils/graphql/graphql-request.d.ts +15 -0
- package/cjs/src/utils/graphql/graphql-request.d.ts.map +1 -0
- package/cjs/src/utils/graphql/graphql-request.js +40 -0
- package/cjs/src/utils/graphql/graphql-request.js.map +1 -0
- package/cjs/src/utils/graphql/sourceService.d.ts +8 -0
- package/cjs/src/utils/graphql/sourceService.d.ts.map +1 -0
- package/cjs/src/utils/graphql/sourceService.js +69 -0
- package/cjs/src/utils/graphql/sourceService.js.map +1 -0
- package/cjs/src/utils/graphql/sourceService.spec.d.ts +2 -0
- package/cjs/src/utils/graphql/sourceService.spec.d.ts.map +1 -0
- package/cjs/src/utils/graphql/sourceService.spec.js +12 -0
- package/cjs/src/utils/graphql/sourceService.spec.js.map +1 -0
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +7 -11
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +13 -17
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +6 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +26 -1
- package/cjs/src/utils.js.map +1 -1
- package/dist/src/embed/app.d.ts +3 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +2 -0
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +3 -2
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +4 -1
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +1 -0
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +5 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +9 -3
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +5 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +46 -18
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts +5 -0
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts +61 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -0
- package/dist/src/utils/graphql/answerService/answerService.spec.d.ts +2 -0
- package/dist/src/utils/graphql/answerService/answerService.spec.d.ts.map +1 -0
- package/dist/src/utils/graphql/graphql-request.d.ts +15 -0
- package/dist/src/utils/graphql/graphql-request.d.ts.map +1 -0
- package/dist/src/utils/graphql/sourceService.d.ts +8 -0
- package/dist/src/utils/graphql/sourceService.d.ts.map +1 -0
- package/dist/src/utils/graphql/sourceService.spec.d.ts +2 -0
- package/dist/src/utils/graphql/sourceService.spec.d.ts.map +1 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +468 -107
- package/dist/tsembed-react.js +471 -106
- package/dist/tsembed.es.js +511 -103
- package/dist/tsembed.js +511 -102
- package/dist/visual-embed-sdk-react-full.d.ts +132 -28
- package/dist/visual-embed-sdk-react.d.ts +132 -28
- package/dist/visual-embed-sdk.d.ts +127 -27
- package/lib/package.json +2 -3
- package/lib/src/embed/app.d.ts +3 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +8 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +2 -0
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +2 -0
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +3 -2
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +6 -5
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/sage.d.ts +4 -1
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +9 -2
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +1 -0
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +1 -0
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +5 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +10 -2
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +9 -3
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +50 -20
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +47 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- 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/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +2 -0
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +1 -0
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +5 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +7 -7
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/types.d.ts +46 -18
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +6 -12
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts +5 -0
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -0
- package/lib/src/utils/graphql/answerService/answer-queries.js +77 -0
- package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts +61 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.js +177 -0
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.d.ts +2 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.d.ts.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js +199 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -0
- package/lib/src/utils/graphql/graphql-request.d.ts +15 -0
- package/lib/src/utils/graphql/graphql-request.d.ts.map +1 -0
- package/lib/src/utils/graphql/graphql-request.js +36 -0
- package/lib/src/utils/graphql/graphql-request.js.map +1 -0
- package/lib/src/utils/graphql/sourceService.d.ts +8 -0
- package/lib/src/utils/graphql/sourceService.d.ts.map +1 -0
- package/lib/src/utils/graphql/sourceService.js +65 -0
- package/lib/src/utils/graphql/sourceService.js.map +1 -0
- package/lib/src/utils/graphql/sourceService.spec.d.ts +2 -0
- package/lib/src/utils/graphql/sourceService.spec.d.ts.map +1 -0
- package/lib/src/utils/graphql/sourceService.spec.js +10 -0
- package/lib/src/utils/graphql/sourceService.spec.js.map +1 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +8 -12
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +14 -18
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +6 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +23 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +133 -28
- package/package.json +2 -3
- package/src/embed/app.ts +12 -2
- package/src/embed/base.ts +2 -0
- package/src/embed/liveboard.ts +7 -5
- package/src/embed/sage.ts +13 -2
- package/src/embed/search-bar.tsx +2 -0
- package/src/embed/search.ts +14 -2
- package/src/embed/ts-embed.spec.ts +49 -0
- package/src/embed/ts-embed.ts +61 -22
- package/src/index.ts +5 -0
- package/src/mixpanel-service.spec.ts +1 -0
- package/src/mixpanel-service.ts +1 -0
- package/src/react/index.tsx +40 -37
- package/src/types.ts +50 -19
- package/src/utils/graphql/answerService/answer-queries.ts +80 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +231 -0
- package/src/utils/graphql/answerService/answerService.ts +234 -0
- package/src/utils/graphql/graphql-request.ts +45 -0
- package/src/utils/graphql/sourceService.spec.ts +10 -0
- package/src/utils/graphql/sourceService.ts +71 -0
- package/src/utils/processData.spec.ts +15 -25
- package/src/utils/processData.ts +13 -15
- package/src/utils.ts +25 -0
- package/src/utils/answerService.spec.ts +0 -41
- package/src/utils/answerService.ts +0 -63
package/dist/tsembed.js
CHANGED
|
@@ -4,6 +4,50 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.tsembed = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
// istanbul ignore next
|
|
8
|
+
const isObject = (obj) => {
|
|
9
|
+
if (typeof obj === "object" && obj !== null) {
|
|
10
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
11
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
12
|
+
return prototype === Object.prototype || prototype === null;
|
|
13
|
+
}
|
|
14
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
const merge = (...objects) => objects.reduce((result, current) => {
|
|
19
|
+
if (Array.isArray(current)) {
|
|
20
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
21
|
+
}
|
|
22
|
+
Object.keys(current).forEach((key) => {
|
|
23
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
27
|
+
result[key] = merge.options.mergeArrays
|
|
28
|
+
? Array.from(new Set(result[key].concat(current[key])))
|
|
29
|
+
: current[key];
|
|
30
|
+
}
|
|
31
|
+
else if (isObject(result[key]) && isObject(current[key])) {
|
|
32
|
+
result[key] = merge(result[key], current[key]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
result[key] = current[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}, {});
|
|
40
|
+
const defaultOptions = {
|
|
41
|
+
mergeArrays: true,
|
|
42
|
+
};
|
|
43
|
+
merge.options = defaultOptions;
|
|
44
|
+
merge.withOptions = (options, ...objects) => {
|
|
45
|
+
merge.options = Object.assign({ mergeArrays: true }, options);
|
|
46
|
+
const result = merge(...objects);
|
|
47
|
+
merge.options = defaultOptions;
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
|
|
7
51
|
/**
|
|
8
52
|
* Copyright (c) 2023
|
|
9
53
|
*
|
|
@@ -200,6 +244,25 @@
|
|
|
200
244
|
function getDOMNode(domSelector) {
|
|
201
245
|
return typeof domSelector === 'string' ? document.querySelector(domSelector) : domSelector;
|
|
202
246
|
}
|
|
247
|
+
const deepMerge = (target, source) => merge(target, source);
|
|
248
|
+
/**
|
|
249
|
+
*
|
|
250
|
+
* @param obj
|
|
251
|
+
*/
|
|
252
|
+
function removeTypename(obj) {
|
|
253
|
+
if (!obj || typeof obj !== 'object')
|
|
254
|
+
return obj;
|
|
255
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
256
|
+
for (const key in obj) {
|
|
257
|
+
if (key === '__typename') {
|
|
258
|
+
delete obj[key];
|
|
259
|
+
}
|
|
260
|
+
else if (typeof obj[key] === 'object') {
|
|
261
|
+
removeTypename(obj[key]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return obj;
|
|
265
|
+
}
|
|
203
266
|
const setStyleProperties = (element, styleProperties) => {
|
|
204
267
|
if (!element || !styleProperties)
|
|
205
268
|
return;
|
|
@@ -213,6 +276,11 @@
|
|
|
213
276
|
styleProperties.forEach((styleProperty) => {
|
|
214
277
|
element.style.removeProperty(styleProperty);
|
|
215
278
|
});
|
|
279
|
+
};
|
|
280
|
+
const getOperationNameFromQuery = (query) => {
|
|
281
|
+
const regex = /(?:query|mutation)\s+(\w+)/;
|
|
282
|
+
const matches = query.match(regex);
|
|
283
|
+
return matches === null || matches === void 0 ? void 0 : matches[1];
|
|
216
284
|
};
|
|
217
285
|
|
|
218
286
|
/**
|
|
@@ -457,27 +525,27 @@
|
|
|
457
525
|
/**
|
|
458
526
|
* Search bar
|
|
459
527
|
*/
|
|
460
|
-
HomepageModule["Search"] = "
|
|
528
|
+
HomepageModule["Search"] = "SEARCH";
|
|
461
529
|
/**
|
|
462
530
|
* kPI watchlist module
|
|
463
531
|
*/
|
|
464
|
-
HomepageModule["Watchlist"] = "
|
|
532
|
+
HomepageModule["Watchlist"] = "WATCHLIST";
|
|
465
533
|
/**
|
|
466
534
|
* favorite objects
|
|
467
535
|
*/
|
|
468
|
-
HomepageModule["Favorite"] = "
|
|
536
|
+
HomepageModule["Favorite"] = "FAVORITE";
|
|
469
537
|
/**
|
|
470
538
|
* List of answers and liveboards
|
|
471
539
|
*/
|
|
472
|
-
HomepageModule["MyLibrary"] = "
|
|
540
|
+
HomepageModule["MyLibrary"] = "MY_LIBRARY";
|
|
473
541
|
/**
|
|
474
542
|
* Trending list
|
|
475
543
|
*/
|
|
476
|
-
HomepageModule["Trending"] = "
|
|
544
|
+
HomepageModule["Trending"] = "TRENDING";
|
|
477
545
|
/**
|
|
478
546
|
* Learning videos
|
|
479
547
|
*/
|
|
480
|
-
HomepageModule["Learning"] = "
|
|
548
|
+
HomepageModule["Learning"] = "LEARNING";
|
|
481
549
|
})(exports.HomepageModule || (exports.HomepageModule = {}));
|
|
482
550
|
(function (EmbedEvent) {
|
|
483
551
|
/**
|
|
@@ -2544,12 +2612,6 @@
|
|
|
2544
2612
|
*/
|
|
2545
2613
|
Action["PersonalisedViewsDropdown"] = "personalisedViewsDropdown";
|
|
2546
2614
|
})(exports.Action || (exports.Action = {}));
|
|
2547
|
-
// eslint-disable-next-line no-shadow
|
|
2548
|
-
var OperationType;
|
|
2549
|
-
(function (OperationType) {
|
|
2550
|
-
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
2551
|
-
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
2552
|
-
})(OperationType || (OperationType = {}));
|
|
2553
2615
|
(function (PrefetchFeatures) {
|
|
2554
2616
|
PrefetchFeatures["FullApp"] = "FullApp";
|
|
2555
2617
|
PrefetchFeatures["SearchEmbed"] = "SearchEmbed";
|
|
@@ -8660,6 +8722,7 @@
|
|
|
8660
8722
|
* @param sessionInfo
|
|
8661
8723
|
*/
|
|
8662
8724
|
function initMixpanel(sessionInfo) {
|
|
8725
|
+
var _a;
|
|
8663
8726
|
if (!sessionInfo || !sessionInfo.mixpanelToken) {
|
|
8664
8727
|
return;
|
|
8665
8728
|
}
|
|
@@ -8677,6 +8740,7 @@
|
|
|
8677
8740
|
clusterId: sessionInfo.clusterId,
|
|
8678
8741
|
clusterName: sessionInfo.clusterName,
|
|
8679
8742
|
releaseVersion: sessionInfo.releaseVersion,
|
|
8743
|
+
hostAppUrl: ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) || '',
|
|
8680
8744
|
});
|
|
8681
8745
|
isMixpanelInitialized = true;
|
|
8682
8746
|
emptyQueue();
|
|
@@ -9169,12 +9233,12 @@
|
|
|
9169
9233
|
* _.isObject(null);
|
|
9170
9234
|
* // => false
|
|
9171
9235
|
*/
|
|
9172
|
-
function isObject(value) {
|
|
9236
|
+
function isObject$1(value) {
|
|
9173
9237
|
var type = typeof value;
|
|
9174
9238
|
return value != null && (type == 'object' || type == 'function');
|
|
9175
9239
|
}
|
|
9176
9240
|
|
|
9177
|
-
var isObject_1 = isObject;
|
|
9241
|
+
var isObject_1 = isObject$1;
|
|
9178
9242
|
|
|
9179
9243
|
/** `Object#toString` result references. */
|
|
9180
9244
|
var asyncTag = '[object AsyncFunction]',
|
|
@@ -10005,9 +10069,9 @@
|
|
|
10005
10069
|
var _cacheHas = cacheHas;
|
|
10006
10070
|
|
|
10007
10071
|
/* Built-in method references that are verified to be native. */
|
|
10008
|
-
var Set = _getNative(_root, 'Set');
|
|
10072
|
+
var Set$1 = _getNative(_root, 'Set');
|
|
10009
10073
|
|
|
10010
|
-
var _Set = Set;
|
|
10074
|
+
var _Set = Set$1;
|
|
10011
10075
|
|
|
10012
10076
|
/**
|
|
10013
10077
|
* This method returns `undefined`.
|
|
@@ -10846,6 +10910,7 @@
|
|
|
10846
10910
|
*
|
|
10847
10911
|
* @param data
|
|
10848
10912
|
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
10913
|
+
* @group Global methods
|
|
10849
10914
|
*/
|
|
10850
10915
|
const executeTML = async (data) => {
|
|
10851
10916
|
const { thoughtSpotHost, authType } = config;
|
|
@@ -10893,6 +10958,7 @@
|
|
|
10893
10958
|
*
|
|
10894
10959
|
* @param data
|
|
10895
10960
|
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
10961
|
+
* @group Global methods
|
|
10896
10962
|
*/
|
|
10897
10963
|
const exportTML = async (data) => {
|
|
10898
10964
|
const { thoughtSpotHost, authType } = config;
|
|
@@ -10938,58 +11004,351 @@
|
|
|
10938
11004
|
|
|
10939
11005
|
/**
|
|
10940
11006
|
*
|
|
10941
|
-
* @param
|
|
10942
|
-
* @param query
|
|
10943
|
-
* @param
|
|
11007
|
+
* @param root0
|
|
11008
|
+
* @param root0.query
|
|
11009
|
+
* @param root0.variables
|
|
11010
|
+
* @param root0.thoughtSpotHost
|
|
11011
|
+
* @param root0.isCompositeQuery
|
|
11012
|
+
*/
|
|
11013
|
+
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
11014
|
+
const operationName = getOperationNameFromQuery(query);
|
|
11015
|
+
try {
|
|
11016
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
11017
|
+
method: 'POST',
|
|
11018
|
+
headers: {
|
|
11019
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
11020
|
+
'x-requested-by': 'ThoughtSpot',
|
|
11021
|
+
accept: '*/*',
|
|
11022
|
+
'accept-language': 'en-us',
|
|
11023
|
+
},
|
|
11024
|
+
body: JSON.stringify({
|
|
11025
|
+
operationName,
|
|
11026
|
+
query,
|
|
11027
|
+
variables,
|
|
11028
|
+
}),
|
|
11029
|
+
credentials: 'include',
|
|
11030
|
+
});
|
|
11031
|
+
const result = await response.json();
|
|
11032
|
+
const dataValues = Object.values(result.data);
|
|
11033
|
+
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
11034
|
+
}
|
|
11035
|
+
catch (error) {
|
|
11036
|
+
return error;
|
|
11037
|
+
}
|
|
11038
|
+
}
|
|
11039
|
+
|
|
11040
|
+
const getSourceDetailQuery = `
|
|
11041
|
+
query GetSourceDetail($ids: [GUID!]!) {
|
|
11042
|
+
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
11043
|
+
id
|
|
11044
|
+
name
|
|
11045
|
+
description
|
|
11046
|
+
authorName
|
|
11047
|
+
authorDisplayName
|
|
11048
|
+
isExternal
|
|
11049
|
+
type
|
|
11050
|
+
created
|
|
11051
|
+
modified
|
|
11052
|
+
columns {
|
|
11053
|
+
id
|
|
11054
|
+
name
|
|
11055
|
+
author
|
|
11056
|
+
authorDisplayName
|
|
11057
|
+
description
|
|
11058
|
+
dataType
|
|
11059
|
+
type
|
|
11060
|
+
modified
|
|
11061
|
+
ownerName
|
|
11062
|
+
owner
|
|
11063
|
+
dataRecency
|
|
11064
|
+
sources {
|
|
11065
|
+
tableId
|
|
11066
|
+
tableName
|
|
11067
|
+
columnId
|
|
11068
|
+
columnName
|
|
11069
|
+
__typename
|
|
11070
|
+
}
|
|
11071
|
+
synonyms
|
|
11072
|
+
cohortAnswerId
|
|
11073
|
+
__typename
|
|
11074
|
+
}
|
|
11075
|
+
relationships
|
|
11076
|
+
destinationRelationships
|
|
11077
|
+
dataSourceId
|
|
11078
|
+
__typename
|
|
11079
|
+
}
|
|
11080
|
+
}
|
|
11081
|
+
`;
|
|
11082
|
+
const sourceDetailCache = new Map();
|
|
11083
|
+
/**
|
|
11084
|
+
*
|
|
10944
11085
|
* @param thoughtSpotHost
|
|
11086
|
+
* @param sourceId
|
|
10945
11087
|
*/
|
|
10946
|
-
function
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
11088
|
+
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
11089
|
+
if (sourceDetailCache.has(sourceId)) {
|
|
11090
|
+
return sourceDetailCache.get(sourceId);
|
|
11091
|
+
}
|
|
11092
|
+
const details = await graphqlQuery({
|
|
11093
|
+
query: getSourceDetailQuery,
|
|
11094
|
+
variables: {
|
|
11095
|
+
ids: [sourceId],
|
|
11096
|
+
},
|
|
11097
|
+
thoughtSpotHost,
|
|
11098
|
+
});
|
|
11099
|
+
const souceDetails = details[0];
|
|
11100
|
+
sourceDetailCache.set(sourceId, souceDetails);
|
|
11101
|
+
return souceDetails;
|
|
11102
|
+
}
|
|
11103
|
+
|
|
11104
|
+
const bachSessionId = `
|
|
11105
|
+
id {
|
|
11106
|
+
sessionId
|
|
11107
|
+
genNo
|
|
11108
|
+
acSession {
|
|
11109
|
+
sessionId
|
|
11110
|
+
genNo
|
|
11111
|
+
}
|
|
11112
|
+
}
|
|
11113
|
+
`;
|
|
11114
|
+
const getUnaggregatedAnswerSession = `
|
|
11115
|
+
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
11116
|
+
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
11117
|
+
${bachSessionId}
|
|
11118
|
+
answer {
|
|
11119
|
+
visualizations {
|
|
11120
|
+
... on TableViz {
|
|
11121
|
+
columns {
|
|
11122
|
+
column {
|
|
11123
|
+
id
|
|
11124
|
+
name
|
|
11125
|
+
referencedColumns {
|
|
11126
|
+
guid
|
|
11127
|
+
displayName
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
}
|
|
11131
|
+
}
|
|
11132
|
+
}
|
|
11133
|
+
}
|
|
11134
|
+
}
|
|
11135
|
+
}
|
|
11136
|
+
`;
|
|
11137
|
+
const removeColumns = `
|
|
11138
|
+
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
11139
|
+
Answer__removeColumns(
|
|
11140
|
+
session: $session
|
|
11141
|
+
logicalColumnIds: $logicalColumnIds
|
|
11142
|
+
columnIds: $columnIds
|
|
11143
|
+
) {
|
|
11144
|
+
${bachSessionId}
|
|
11145
|
+
}
|
|
11146
|
+
}
|
|
11147
|
+
`;
|
|
11148
|
+
const addColumns = `
|
|
11149
|
+
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
11150
|
+
Answer__addColumn(session: $session, columns: $columns) {
|
|
11151
|
+
${bachSessionId}
|
|
11152
|
+
}
|
|
11153
|
+
}
|
|
11154
|
+
`;
|
|
11155
|
+
const getAnswerData = `
|
|
11156
|
+
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
11157
|
+
getAnswer(session: $session) {
|
|
11158
|
+
${bachSessionId}
|
|
11159
|
+
answer {
|
|
11160
|
+
id
|
|
11161
|
+
visualizations {
|
|
11162
|
+
id
|
|
11163
|
+
... on TableViz {
|
|
11164
|
+
columns {
|
|
11165
|
+
column {
|
|
11166
|
+
id
|
|
11167
|
+
name
|
|
11168
|
+
type
|
|
11169
|
+
aggregationType
|
|
11170
|
+
dataType
|
|
11171
|
+
}
|
|
11172
|
+
}
|
|
11173
|
+
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
11174
|
+
}
|
|
11175
|
+
}
|
|
11176
|
+
}
|
|
11177
|
+
}
|
|
11178
|
+
}
|
|
11179
|
+
`;
|
|
11180
|
+
|
|
11181
|
+
// eslint-disable-next-line no-shadow
|
|
11182
|
+
var OperationType;
|
|
11183
|
+
(function (OperationType) {
|
|
11184
|
+
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
11185
|
+
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
11186
|
+
})(OperationType || (OperationType = {}));
|
|
11187
|
+
/**
|
|
11188
|
+
* Class representing the answer service provided with the
|
|
11189
|
+
* custom action payload. This service could be used to run
|
|
11190
|
+
* graphql queries in the context of the answer on which the
|
|
11191
|
+
* custom action was triggered.
|
|
11192
|
+
*
|
|
11193
|
+
* @example
|
|
11194
|
+
* ```js
|
|
11195
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
11196
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
11197
|
+
* 'col name 1'
|
|
11198
|
+
* ]);
|
|
11199
|
+
* const data = await underlying.fetchData(0, 100);
|
|
11200
|
+
* })
|
|
11201
|
+
* ```
|
|
11202
|
+
* @version
|
|
11203
|
+
* ThoughtSpot: 9.9.0.cl / SDK: 1.25.0
|
|
11204
|
+
*/
|
|
11205
|
+
class AnswerService {
|
|
11206
|
+
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
11207
|
+
this.session = session;
|
|
11208
|
+
this.answer = answer;
|
|
11209
|
+
this.thoughtSpotHost = thoughtSpotHost;
|
|
11210
|
+
this.selectedPoints = selectedPoints;
|
|
11211
|
+
this.session = removeTypename(session);
|
|
11212
|
+
}
|
|
11213
|
+
async getSourceDetail() {
|
|
11214
|
+
const sourceId = this.answer.sources[0].header.guid;
|
|
11215
|
+
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
11216
|
+
}
|
|
11217
|
+
async removeColumns(columnIds) {
|
|
11218
|
+
return this.executeQuery(removeColumns, {
|
|
11219
|
+
logicalColumnIds: columnIds,
|
|
11220
|
+
});
|
|
11221
|
+
}
|
|
11222
|
+
async addColumns(columnIds) {
|
|
11223
|
+
return this.executeQuery(addColumns, {
|
|
11224
|
+
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
11225
|
+
});
|
|
11226
|
+
}
|
|
11227
|
+
async fetchData(offset = 0, size = 1000) {
|
|
11228
|
+
const { answer } = await this.executeQuery(getAnswerData, {
|
|
11229
|
+
deadline: 0,
|
|
11230
|
+
dataPaginationParams: {
|
|
11231
|
+
isClientPaginated: true,
|
|
11232
|
+
offset,
|
|
11233
|
+
size,
|
|
11234
|
+
},
|
|
11235
|
+
});
|
|
11236
|
+
const { columns, data } = answer.visualizations[0];
|
|
11237
|
+
return {
|
|
11238
|
+
columns,
|
|
11239
|
+
data,
|
|
11240
|
+
};
|
|
11241
|
+
}
|
|
11242
|
+
/**
|
|
11243
|
+
*
|
|
11244
|
+
* @param userLocale
|
|
11245
|
+
* @param omitInfo Omit the download Info on top of the CSV
|
|
11246
|
+
* @returns Response
|
|
11247
|
+
*/
|
|
11248
|
+
async fetchCSVBlob(userLocale = 'en-us', omitInfo = false) {
|
|
11249
|
+
if (omitInfo) {
|
|
11250
|
+
console.warn('omitInfo not supported yet.');
|
|
10967
11251
|
}
|
|
10968
|
-
|
|
10969
|
-
|
|
11252
|
+
const fetchUrl = `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&omitInfo=${omitInfo}`;
|
|
11253
|
+
return fetch(fetchUrl, {
|
|
11254
|
+
credentials: 'include',
|
|
11255
|
+
});
|
|
11256
|
+
}
|
|
11257
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
11258
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
11259
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
10970
11260
|
}
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
11261
|
+
if (!selectedPoints) {
|
|
11262
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
11263
|
+
}
|
|
11264
|
+
const sourceDetail = await this.getSourceDetail();
|
|
11265
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
11266
|
+
const unAggAnswer = await graphqlQuery({
|
|
11267
|
+
query: getUnaggregatedAnswerSession,
|
|
11268
|
+
variables: {
|
|
11269
|
+
session: this.session,
|
|
11270
|
+
columns: selectedPoints,
|
|
11271
|
+
},
|
|
11272
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
11273
|
+
});
|
|
11274
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
11275
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
11276
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
11277
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
11278
|
+
if (columnsToAdd.length) {
|
|
11279
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
11280
|
+
}
|
|
11281
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
11282
|
+
if (columnsToRemove.length) {
|
|
11283
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
11284
|
+
}
|
|
11285
|
+
return unaggAnswerSession;
|
|
11286
|
+
}
|
|
11287
|
+
async executeQuery(query, variables) {
|
|
11288
|
+
const data = await graphqlQuery({
|
|
11289
|
+
query,
|
|
11290
|
+
variables: {
|
|
11291
|
+
session: this.session,
|
|
11292
|
+
...variables,
|
|
11293
|
+
},
|
|
11294
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
11295
|
+
isCompositeQuery: false,
|
|
11296
|
+
});
|
|
11297
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
11298
|
+
return data;
|
|
11299
|
+
}
|
|
11300
|
+
getSession() {
|
|
11301
|
+
return this.session;
|
|
11302
|
+
}
|
|
11303
|
+
}
|
|
11304
|
+
/**
|
|
11305
|
+
*
|
|
11306
|
+
* @param sourceDetail
|
|
11307
|
+
* @param colNames
|
|
11308
|
+
*/
|
|
11309
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
11310
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
11311
|
+
colSet[col.name] = col;
|
|
11312
|
+
return colSet;
|
|
11313
|
+
}, {});
|
|
11314
|
+
return new Set(colNames.map((colName) => {
|
|
11315
|
+
const col = cols[colName];
|
|
11316
|
+
return col.id;
|
|
11317
|
+
}));
|
|
11318
|
+
}
|
|
11319
|
+
/**
|
|
11320
|
+
*
|
|
11321
|
+
* @param selectedPoints
|
|
11322
|
+
*/
|
|
11323
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
11324
|
+
const underlyingDataPoint = [];
|
|
11325
|
+
/**
|
|
11326
|
+
*
|
|
11327
|
+
* @param colVal
|
|
11328
|
+
*/
|
|
11329
|
+
function addPointFromColVal(colVal) {
|
|
11330
|
+
const dataType = colVal.column.dataType;
|
|
11331
|
+
const id = colVal.column.id;
|
|
11332
|
+
let dataValue;
|
|
11333
|
+
if (dataType === 'DATE') {
|
|
11334
|
+
dataValue = [{
|
|
11335
|
+
epochRange: {
|
|
11336
|
+
startEpoch: colVal.value,
|
|
11337
|
+
},
|
|
11338
|
+
}];
|
|
10975
11339
|
}
|
|
10976
11340
|
else {
|
|
10977
|
-
|
|
10978
|
-
dataPaginationParams: {
|
|
10979
|
-
isClientPaginated: true,
|
|
10980
|
-
offset: offset * batchSize,
|
|
10981
|
-
size: batchSize,
|
|
10982
|
-
},
|
|
10983
|
-
};
|
|
11341
|
+
dataValue = [{ value: colVal.value }];
|
|
10984
11342
|
}
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
11343
|
+
underlyingDataPoint.push({
|
|
11344
|
+
columnId: colVal.column.id,
|
|
11345
|
+
dataValue,
|
|
10988
11346
|
});
|
|
10989
|
-
}
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
};
|
|
11347
|
+
}
|
|
11348
|
+
selectedPoints.forEach((p) => {
|
|
11349
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
11350
|
+
});
|
|
11351
|
+
return underlyingDataPoint;
|
|
10993
11352
|
}
|
|
10994
11353
|
|
|
10995
11354
|
/**
|
|
@@ -10998,16 +11357,12 @@
|
|
|
10998
11357
|
* @param thoughtSpotHost
|
|
10999
11358
|
*/
|
|
11000
11359
|
function processCustomAction(e, thoughtSpotHost) {
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
answerService,
|
|
11008
|
-
};
|
|
11009
|
-
}
|
|
11010
|
-
return e;
|
|
11360
|
+
const { session, embedAnswerData, contextMenuPoints } = e.data;
|
|
11361
|
+
const answerService = new AnswerService(session, embedAnswerData, thoughtSpotHost, contextMenuPoints === null || contextMenuPoints === void 0 ? void 0 : contextMenuPoints.selectedPoints);
|
|
11362
|
+
return {
|
|
11363
|
+
...e,
|
|
11364
|
+
answerService,
|
|
11365
|
+
};
|
|
11011
11366
|
}
|
|
11012
11367
|
/**
|
|
11013
11368
|
*
|
|
@@ -11152,7 +11507,7 @@
|
|
|
11152
11507
|
});
|
|
11153
11508
|
}
|
|
11154
11509
|
|
|
11155
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-
|
|
11510
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-preRender.0";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$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 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:"40 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};
|
|
11156
11511
|
|
|
11157
11512
|
/**
|
|
11158
11513
|
* Copyright (c) 2022
|
|
@@ -11184,6 +11539,7 @@
|
|
|
11184
11539
|
class TsEmbed {
|
|
11185
11540
|
constructor(domSelector, viewConfig) {
|
|
11186
11541
|
this.isAppInitialized = false;
|
|
11542
|
+
this.embedComponentType = 'TsEmbed';
|
|
11187
11543
|
/**
|
|
11188
11544
|
* Should we encode URL Query Params using base64 encoding which thoughtspot
|
|
11189
11545
|
* will generate for embedding. This provides additional security to
|
|
@@ -11193,6 +11549,7 @@
|
|
|
11193
11549
|
*/
|
|
11194
11550
|
this.shouldEncodeUrlQueryParams = false;
|
|
11195
11551
|
this.defaultHiddenActions = [exports.Action.ReportError];
|
|
11552
|
+
this.subscribedListeners = {};
|
|
11196
11553
|
/**
|
|
11197
11554
|
* Send Custom style as part of payload of APP_INIT
|
|
11198
11555
|
*
|
|
@@ -11215,6 +11572,7 @@
|
|
|
11215
11572
|
? getRuntimeFilters(this.viewConfig.runtimeFilters)
|
|
11216
11573
|
: null,
|
|
11217
11574
|
hiddenHomepageModules: this.viewConfig.hiddenHomepageModules || [],
|
|
11575
|
+
reorderedHomepageModules: this.viewConfig.reorderedHomepageModules || [],
|
|
11218
11576
|
hostConfig: this.embedConfig.hostConfig,
|
|
11219
11577
|
hiddenHomeLeftNavItems: ((_a = this.viewConfig) === null || _a === void 0 ? void 0 : _a.hiddenHomeLeftNavItems)
|
|
11220
11578
|
? (_b = this.viewConfig) === null || _b === void 0 ? void 0 : _b.hiddenHomeLeftNavItems
|
|
@@ -11264,6 +11622,7 @@
|
|
|
11264
11622
|
this.registerAppInit();
|
|
11265
11623
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
|
|
11266
11624
|
...viewConfig,
|
|
11625
|
+
embedComponentType: this.embedComponentType,
|
|
11267
11626
|
});
|
|
11268
11627
|
}
|
|
11269
11628
|
/**
|
|
@@ -11332,23 +11691,36 @@
|
|
|
11332
11691
|
* and executes the registered callbacks accordingly.
|
|
11333
11692
|
*/
|
|
11334
11693
|
subscribeToEvents() {
|
|
11335
|
-
|
|
11694
|
+
const messageEventListener = (event) => {
|
|
11336
11695
|
const eventType = this.getEventType(event);
|
|
11337
11696
|
const eventPort = this.getEventPort(event);
|
|
11338
11697
|
const eventData = this.formatEventData(event, eventType);
|
|
11339
11698
|
if (event.source === this.iFrame.contentWindow) {
|
|
11340
11699
|
this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
|
|
11341
11700
|
}
|
|
11342
|
-
}
|
|
11343
|
-
window.addEventListener('
|
|
11701
|
+
};
|
|
11702
|
+
window.addEventListener('message', messageEventListener);
|
|
11703
|
+
const onlineEventListener = (e) => {
|
|
11344
11704
|
this.trigger(exports.HostEvent.Reload);
|
|
11345
|
-
}
|
|
11346
|
-
window.addEventListener('
|
|
11705
|
+
};
|
|
11706
|
+
window.addEventListener('online', onlineEventListener);
|
|
11707
|
+
const offlineEventListener = (e) => {
|
|
11347
11708
|
const offlineWarning = 'Network not Detected. Embed is offline. Please reconnect and refresh';
|
|
11348
11709
|
this.executeCallbacks(exports.EmbedEvent.Error, {
|
|
11349
11710
|
offlineWarning,
|
|
11350
11711
|
});
|
|
11351
11712
|
console.warn(offlineWarning);
|
|
11713
|
+
};
|
|
11714
|
+
window.addEventListener('offline', offlineEventListener);
|
|
11715
|
+
this.subscribedListeners = {
|
|
11716
|
+
message: messageEventListener,
|
|
11717
|
+
online: onlineEventListener,
|
|
11718
|
+
offline: offlineEventListener,
|
|
11719
|
+
};
|
|
11720
|
+
}
|
|
11721
|
+
unsubscribeToEvents() {
|
|
11722
|
+
Object.keys(this.subscribedListeners).forEach((key) => {
|
|
11723
|
+
window.removeEventListener(key, this.subscribedListeners[key]);
|
|
11352
11724
|
});
|
|
11353
11725
|
}
|
|
11354
11726
|
/**
|
|
@@ -11526,8 +11898,10 @@
|
|
|
11526
11898
|
*
|
|
11527
11899
|
* @param url
|
|
11528
11900
|
* @param frameOptions
|
|
11901
|
+
* @param showPreRender
|
|
11902
|
+
* @param showPreRenderByDefault
|
|
11529
11903
|
*/
|
|
11530
|
-
async renderIFrame(url) {
|
|
11904
|
+
async renderIFrame(url, showPreRenderByDefault = false) {
|
|
11531
11905
|
if (this.isError) {
|
|
11532
11906
|
return null;
|
|
11533
11907
|
}
|
|
@@ -11576,6 +11950,9 @@
|
|
|
11576
11950
|
});
|
|
11577
11951
|
if (this.isPreRendered) {
|
|
11578
11952
|
this.insertIntoDOMForPreRender(this.iFrame);
|
|
11953
|
+
if (showPreRenderByDefault) {
|
|
11954
|
+
this.showPreRender();
|
|
11955
|
+
}
|
|
11579
11956
|
}
|
|
11580
11957
|
else {
|
|
11581
11958
|
this.insertIntoDOM(this.iFrame);
|
|
@@ -11614,11 +11991,10 @@
|
|
|
11614
11991
|
throw new Error('Pre render id is required');
|
|
11615
11992
|
}
|
|
11616
11993
|
const preRenderIds = this.getPreRenderIds();
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
}
|
|
11994
|
+
[preRenderIds.wrapper, preRenderIds.shield, preRenderIds.child]
|
|
11995
|
+
.map((id) => document.getElementById(id))
|
|
11996
|
+
.filter((element) => element)
|
|
11997
|
+
.forEach((existingElement) => existingElement.remove());
|
|
11622
11998
|
const preRenderWrapper = document.createElement('div');
|
|
11623
11999
|
preRenderWrapper.id = preRenderIds.wrapper;
|
|
11624
12000
|
setStyleProperties(preRenderWrapper, { position: 'absolute', width: '100vw', height: '100vh' });
|
|
@@ -11633,7 +12009,7 @@
|
|
|
11633
12009
|
this.preRenderChild = child;
|
|
11634
12010
|
return preRenderWrapper;
|
|
11635
12011
|
}
|
|
11636
|
-
|
|
12012
|
+
connectPreRendered() {
|
|
11637
12013
|
const preRenderIds = this.getPreRenderIds();
|
|
11638
12014
|
this.preRenderWrapper = this.preRenderWrapper
|
|
11639
12015
|
|| document.getElementById(preRenderIds.wrapper);
|
|
@@ -11641,6 +12017,10 @@
|
|
|
11641
12017
|
|| document.getElementById(preRenderIds.shield);
|
|
11642
12018
|
this.preRenderChild = this.preRenderChild
|
|
11643
12019
|
|| document.getElementById(preRenderIds.child);
|
|
12020
|
+
this.iFrame = this.preRenderChild;
|
|
12021
|
+
return this.isPreRenderAvailable();
|
|
12022
|
+
}
|
|
12023
|
+
isPreRenderAvailable() {
|
|
11644
12024
|
return !!this.preRenderWrapper && !!this.preRenderShield
|
|
11645
12025
|
&& !!this.preRenderChild;
|
|
11646
12026
|
}
|
|
@@ -11683,18 +12063,23 @@
|
|
|
11683
12063
|
top: '0',
|
|
11684
12064
|
left: '0',
|
|
11685
12065
|
});
|
|
12066
|
+
this.unsubscribeToEvents();
|
|
11686
12067
|
}
|
|
11687
12068
|
showPreRender() {
|
|
11688
12069
|
if (!this.isPreRenderAvailable()) {
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
12070
|
+
const isAvailable = this.connectPreRendered();
|
|
12071
|
+
if (!isAvailable) {
|
|
12072
|
+
// if the Embed component is nor preRendered , Render it now and
|
|
12073
|
+
// show it (hide is defalt behaviour)
|
|
12074
|
+
console.log('No preRender found, creating new ');
|
|
12075
|
+
this.preRender(true);
|
|
12076
|
+
return;
|
|
12077
|
+
}
|
|
11694
12078
|
}
|
|
11695
12079
|
this.syncPreRenderStyle();
|
|
11696
12080
|
removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
|
|
11697
12081
|
setStyleProperties(this.preRenderShield, { zIndex: '-1' });
|
|
12082
|
+
this.subscribeToEvents();
|
|
11698
12083
|
}
|
|
11699
12084
|
syncPreRenderStyle() {
|
|
11700
12085
|
if (!this.el) {
|
|
@@ -11922,7 +12307,7 @@
|
|
|
11922
12307
|
/**
|
|
11923
12308
|
* Creates the preRender shell
|
|
11924
12309
|
*/
|
|
11925
|
-
preRender() {
|
|
12310
|
+
preRender(showPreRenderByDefault = false) {
|
|
11926
12311
|
this.isPreRendered = true;
|
|
11927
12312
|
return this;
|
|
11928
12313
|
}
|
|
@@ -11999,8 +12384,8 @@
|
|
|
11999
12384
|
*
|
|
12000
12385
|
* @param iframeSrc
|
|
12001
12386
|
*/
|
|
12002
|
-
renderV1Embed(iframeSrc) {
|
|
12003
|
-
return this.renderIFrame(iframeSrc);
|
|
12387
|
+
renderV1Embed(iframeSrc, showPreRenderByDefault = false) {
|
|
12388
|
+
return this.renderIFrame(iframeSrc, showPreRenderByDefault);
|
|
12004
12389
|
}
|
|
12005
12390
|
getRootIframeSrc() {
|
|
12006
12391
|
const queryParams = this.getEmbedParams();
|
|
@@ -12087,6 +12472,7 @@
|
|
|
12087
12472
|
constructor(domSelector, viewConfig) {
|
|
12088
12473
|
super(domSelector, viewConfig);
|
|
12089
12474
|
this.defaultHeight = '100%';
|
|
12475
|
+
this.embedComponentType = 'AppEmbed';
|
|
12090
12476
|
/**
|
|
12091
12477
|
* Set the iframe height as per the computed height received
|
|
12092
12478
|
* from the ThoughtSpot app.
|
|
@@ -12238,10 +12624,15 @@
|
|
|
12238
12624
|
* @param renderOptions An object containing the page ID
|
|
12239
12625
|
* to be embedded.
|
|
12240
12626
|
*/
|
|
12241
|
-
render() {
|
|
12627
|
+
render(showPreRenderByDefault = false) {
|
|
12242
12628
|
super.render();
|
|
12243
12629
|
const src = this.getIFrameSrc();
|
|
12244
|
-
this.renderV1Embed(src);
|
|
12630
|
+
this.renderV1Embed(src, showPreRenderByDefault);
|
|
12631
|
+
return this;
|
|
12632
|
+
}
|
|
12633
|
+
preRender(showPreRenderByDefault = false) {
|
|
12634
|
+
super.preRender(showPreRenderByDefault);
|
|
12635
|
+
this.render(showPreRenderByDefault);
|
|
12245
12636
|
return this;
|
|
12246
12637
|
}
|
|
12247
12638
|
}
|
|
@@ -12276,6 +12667,7 @@
|
|
|
12276
12667
|
constructor(domSelector, viewConfig) {
|
|
12277
12668
|
super(domSelector, viewConfig);
|
|
12278
12669
|
this.defaultHeight = 500;
|
|
12670
|
+
this.embedComponentType = 'LiveboardEmbed';
|
|
12279
12671
|
/**
|
|
12280
12672
|
* Set the iframe height as per the computed height received
|
|
12281
12673
|
* from the ThoughtSpot app.
|
|
@@ -12397,15 +12789,15 @@
|
|
|
12397
12789
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
12398
12790
|
* visualization ID and the runtime filters.
|
|
12399
12791
|
*/
|
|
12400
|
-
render() {
|
|
12792
|
+
render(showPreRenderByDefault = false) {
|
|
12401
12793
|
super.render();
|
|
12402
12794
|
const src = this.getIFrameSrc();
|
|
12403
|
-
this.renderV1Embed(src);
|
|
12795
|
+
this.renderV1Embed(src, showPreRenderByDefault);
|
|
12404
12796
|
return this;
|
|
12405
12797
|
}
|
|
12406
|
-
preRender() {
|
|
12407
|
-
super.preRender();
|
|
12408
|
-
this.render();
|
|
12798
|
+
preRender(showPreRenderByDefault = false) {
|
|
12799
|
+
super.preRender(showPreRenderByDefault);
|
|
12800
|
+
this.render(showPreRenderByDefault);
|
|
12409
12801
|
return this;
|
|
12410
12802
|
}
|
|
12411
12803
|
navigateToLiveboard(liveboardId, vizId, activeTabId) {
|
|
@@ -12450,6 +12842,7 @@
|
|
|
12450
12842
|
class SearchEmbed extends TsEmbed {
|
|
12451
12843
|
constructor(domSelector, viewConfig) {
|
|
12452
12844
|
super(domSelector);
|
|
12845
|
+
this.embedComponentType = 'SearchEmbed';
|
|
12453
12846
|
this.viewConfig = viewConfig;
|
|
12454
12847
|
}
|
|
12455
12848
|
/**
|
|
@@ -12530,12 +12923,14 @@
|
|
|
12530
12923
|
}
|
|
12531
12924
|
/**
|
|
12532
12925
|
* Render the embedded ThoughtSpot search
|
|
12926
|
+
*
|
|
12927
|
+
* @param showPreRenderByDefault
|
|
12533
12928
|
*/
|
|
12534
|
-
render() {
|
|
12929
|
+
render(showPreRenderByDefault = false) {
|
|
12535
12930
|
super.render();
|
|
12536
12931
|
const { answerId } = this.viewConfig;
|
|
12537
12932
|
const src = this.getIFrameSrc(answerId);
|
|
12538
|
-
this.renderIFrame(src);
|
|
12933
|
+
this.renderIFrame(src, showPreRenderByDefault);
|
|
12539
12934
|
getAuthPromise().then(() => {
|
|
12540
12935
|
if (checkReleaseVersionInBeta(getReleaseVersion(), getEmbedConfig().suppressSearchEmbedBetaWarning)) {
|
|
12541
12936
|
alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
|
|
@@ -12543,6 +12938,11 @@
|
|
|
12543
12938
|
});
|
|
12544
12939
|
return this;
|
|
12545
12940
|
}
|
|
12941
|
+
preRender(showPreRenderByDefault = false) {
|
|
12942
|
+
super.preRender(showPreRenderByDefault);
|
|
12943
|
+
this.render(showPreRenderByDefault);
|
|
12944
|
+
return this;
|
|
12945
|
+
}
|
|
12546
12946
|
}
|
|
12547
12947
|
|
|
12548
12948
|
/**
|
|
@@ -12554,6 +12954,7 @@
|
|
|
12554
12954
|
class SearchBarEmbed extends TsEmbed {
|
|
12555
12955
|
constructor(domSelector, viewConfig) {
|
|
12556
12956
|
super(domSelector);
|
|
12957
|
+
this.embedComponentType = 'SearchBarEmbed';
|
|
12557
12958
|
this.viewConfig = viewConfig;
|
|
12558
12959
|
}
|
|
12559
12960
|
/**
|
|
@@ -12632,6 +13033,7 @@
|
|
|
12632
13033
|
// eslint-disable-next-line no-useless-constructor
|
|
12633
13034
|
constructor(domSelector, viewConfig) {
|
|
12634
13035
|
super(domSelector, viewConfig);
|
|
13036
|
+
this.embedComponentType = 'SageEmbed';
|
|
12635
13037
|
}
|
|
12636
13038
|
/**
|
|
12637
13039
|
* Constructs a map of parameters to be passed on to the
|
|
@@ -12683,16 +13085,23 @@
|
|
|
12683
13085
|
/**
|
|
12684
13086
|
* Render the embedded ThoughtSpot Sage
|
|
12685
13087
|
*
|
|
13088
|
+
* @param showPreRenderByDefault
|
|
12686
13089
|
* @returns {SageEmbed} Eureka/Sage embed
|
|
12687
13090
|
*/
|
|
12688
|
-
render() {
|
|
13091
|
+
render(showPreRenderByDefault = false) {
|
|
12689
13092
|
super.render();
|
|
12690
13093
|
const src = this.getIFrameSrc();
|
|
12691
|
-
this.renderV1Embed(src);
|
|
13094
|
+
this.renderV1Embed(src, showPreRenderByDefault);
|
|
13095
|
+
return this;
|
|
13096
|
+
}
|
|
13097
|
+
preRender(showPreRenderByDefault = false) {
|
|
13098
|
+
super.preRender(showPreRenderByDefault);
|
|
13099
|
+
this.render(showPreRenderByDefault);
|
|
12692
13100
|
return this;
|
|
12693
13101
|
}
|
|
12694
13102
|
}
|
|
12695
13103
|
|
|
13104
|
+
exports.AnswerService = AnswerService;
|
|
12696
13105
|
exports.AppEmbed = AppEmbed;
|
|
12697
13106
|
exports.LiveboardEmbed = LiveboardEmbed;
|
|
12698
13107
|
exports.PinboardEmbed = PinboardEmbed;
|