@thoughtspot/visual-embed-sdk 1.39.2-alpha.1 → 1.39.2-alpha.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 +1 -1
- package/cjs/src/config.spec.js +9 -0
- package/cjs/src/config.spec.js.map +1 -1
- package/cjs/src/embed/app.d.ts +75 -15
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +68 -9
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +356 -4
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.d.ts +19 -7
- package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/cjs/src/embed/bodyless-conversation.js +24 -4
- package/cjs/src/embed/bodyless-conversation.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +8 -190
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +2 -60
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +1 -9
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +0 -102
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +56 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +46 -0
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +203 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +1 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +1 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- 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/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +3 -2
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/index.d.ts +71 -20
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +79 -42
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +436 -100
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +46 -4
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +28 -0
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
- package/cjs/src/utils/graphql/nlsService/conversation-service.js +2 -0
- package/cjs/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
- package/cjs/src/utils/processTrigger.js +2 -1
- package/cjs/src/utils/processTrigger.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 +23 -3
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +237 -1
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/index-e3Uw3YFO.js +7371 -0
- package/dist/src/embed/app.d.ts +75 -15
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/bodyless-conversation.d.ts +19 -7
- package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +2 -60
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +56 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +71 -20
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +46 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/graphql/nlsService/conversation-service.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 +276 -74
- package/dist/tsembed-react.js +276 -72
- package/dist/tsembed.es.js +194 -27
- package/dist/tsembed.js +192 -25
- package/dist/visual-embed-sdk-react-full.d.ts +246 -105
- package/dist/visual-embed-sdk-react.d.ts +246 -105
- package/dist/visual-embed-sdk.d.ts +176 -86
- package/lib/package.json +1 -1
- package/lib/src/config.spec.js +9 -0
- package/lib/src/config.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +75 -15
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +68 -9
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +357 -5
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.d.ts +19 -7
- package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/lib/src/embed/bodyless-conversation.js +23 -4
- package/lib/src/embed/bodyless-conversation.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +9 -191
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +2 -60
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +2 -10
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +2 -104
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +56 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +47 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +203 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/errors.d.ts +1 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +1 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/index.d.ts +71 -20
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +79 -43
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +439 -103
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +46 -4
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +28 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
- package/lib/src/utils/graphql/nlsService/conversation-service.js +2 -0
- package/lib/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
- package/lib/src/utils/processTrigger.js +2 -1
- package/lib/src/utils/processTrigger.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 +21 -2
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +238 -2
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +178 -88
- package/package.json +1 -1
- package/src/config.spec.ts +11 -0
- package/src/embed/app.spec.ts +444 -4
- package/src/embed/app.ts +131 -27
- package/src/embed/bodyless-conversation.spec.ts +9 -203
- package/src/embed/bodyless-conversation.ts +24 -10
- package/src/embed/conversation.spec.ts +5 -131
- package/src/embed/conversation.ts +10 -82
- package/src/embed/liveboard.spec.ts +251 -1
- package/src/embed/liveboard.ts +97 -5
- package/src/errors.ts +1 -0
- package/src/index.ts +2 -0
- package/src/react/all-types-export.ts +2 -1
- package/src/react/index.spec.tsx +556 -157
- package/src/react/index.tsx +117 -51
- package/src/types.ts +42 -0
- package/src/utils/graphql/nlsService/conversation-service.ts +2 -0
- package/src/utils/processTrigger.ts +1 -1
- package/src/utils.spec.ts +279 -2
- package/src/utils.ts +28 -2
package/dist/tsembed-react.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* @thoughtspot/visual-embed-sdk version 1.39.2-alpha.
|
|
1
|
+
/* @thoughtspot/visual-embed-sdk version 1.39.2-alpha.2 */
|
|
2
2
|
'use client';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { useRef } from 'react';
|
|
4
|
+
import React__default, { useRef, useCallback } from 'react';
|
|
5
5
|
|
|
6
6
|
function _mergeNamespaces(n, m) {
|
|
7
7
|
m.forEach(function (e) {
|
|
@@ -399,6 +399,12 @@ var HomeLeftNavItem;
|
|
|
399
399
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
|
|
400
400
|
*/
|
|
401
401
|
HomeLeftNavItem["Spotter"] = "spotter";
|
|
402
|
+
/**
|
|
403
|
+
* Favorites option in the insights left navigation,
|
|
404
|
+
* available when new navigation V3 is enabled.
|
|
405
|
+
* @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
|
|
406
|
+
*/
|
|
407
|
+
HomeLeftNavItem["Favorites"] = "favorites";
|
|
402
408
|
})(HomeLeftNavItem || (HomeLeftNavItem = {}));
|
|
403
409
|
/**
|
|
404
410
|
* A map of the supported runtime filter operations
|
|
@@ -1585,6 +1591,12 @@ var EmbedEvent;
|
|
|
1585
1591
|
* @version SDK : 1.40.0 | ThoughtSpot: 10.11.0.cl
|
|
1586
1592
|
*/
|
|
1587
1593
|
EmbedEvent["ExitPresentMode"] = "exitPresentMode";
|
|
1594
|
+
/**
|
|
1595
|
+
* Emitted when a user requests the full height lazy load data.
|
|
1596
|
+
* @version SDK : 1.39.0 | ThoughtSpot : 10.10.0.cl
|
|
1597
|
+
* @hidden
|
|
1598
|
+
*/
|
|
1599
|
+
EmbedEvent["RequestVisibleEmbedCoordinates"] = "requestVisibleEmbedCoordinates";
|
|
1588
1600
|
})(EmbedEvent || (EmbedEvent = {}));
|
|
1589
1601
|
/**
|
|
1590
1602
|
* Event types that can be triggered by the host application
|
|
@@ -2669,6 +2681,19 @@ var HostEvent;
|
|
|
2669
2681
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
|
|
2670
2682
|
*/
|
|
2671
2683
|
HostEvent["ExitPresentMode"] = "exitPresentMode";
|
|
2684
|
+
/**
|
|
2685
|
+
* Triggers the full height lazy load data.
|
|
2686
|
+
* @example
|
|
2687
|
+
* ```js
|
|
2688
|
+
* liveboardEmbed.on(EmbedEvent.RequestVisibleEmbedCoordinates, (payload) => {
|
|
2689
|
+
* console.log(payload);
|
|
2690
|
+
* });
|
|
2691
|
+
* ```
|
|
2692
|
+
* @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
|
|
2693
|
+
*
|
|
2694
|
+
* @hidden
|
|
2695
|
+
*/
|
|
2696
|
+
HostEvent["VisibleEmbedCoordinates"] = "visibleEmbedCoordinates";
|
|
2672
2697
|
})(HostEvent || (HostEvent = {}));
|
|
2673
2698
|
/**
|
|
2674
2699
|
* The different visual modes that the data sources panel within
|
|
@@ -2774,6 +2799,7 @@ var Param;
|
|
|
2774
2799
|
Param["Query"] = "query";
|
|
2775
2800
|
Param["HideHomepageLeftNav"] = "hideHomepageLeftNav";
|
|
2776
2801
|
Param["ModularHomeExperienceEnabled"] = "modularHomeExperience";
|
|
2802
|
+
Param["ListPageVersion"] = "listpageVersion";
|
|
2777
2803
|
Param["PendoTrackingKey"] = "additionalPendoKey";
|
|
2778
2804
|
Param["LiveboardHeaderSticky"] = "isLiveboardHeaderSticky";
|
|
2779
2805
|
Param["IsProductTour"] = "isProductTour";
|
|
@@ -2812,6 +2838,8 @@ var Param;
|
|
|
2812
2838
|
Param["PrimaryAction"] = "primaryAction";
|
|
2813
2839
|
Param["isSpotterAgentEmbed"] = "isSpotterAgentEmbed";
|
|
2814
2840
|
Param["IsLiveboardStylingAndGroupingEnabled"] = "isLiveboardStylingAndGroupingEnabled";
|
|
2841
|
+
Param["IsLazyLoadingForEmbedEnabled"] = "isLazyLoadingForEmbedEnabled";
|
|
2842
|
+
Param["RootMarginForLazyLoad"] = "rootMarginForLazyLoad";
|
|
2815
2843
|
})(Param || (Param = {}));
|
|
2816
2844
|
/**
|
|
2817
2845
|
* ThoughtSpot application pages include actions and menu commands
|
|
@@ -4433,7 +4461,6 @@ const getOperationNameFromQuery = (query) => {
|
|
|
4433
4461
|
function removeTypename(obj) {
|
|
4434
4462
|
if (!obj || typeof obj !== 'object')
|
|
4435
4463
|
return obj;
|
|
4436
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
4437
4464
|
for (const key in obj) {
|
|
4438
4465
|
if (key === '__typename') {
|
|
4439
4466
|
delete obj[key];
|
|
@@ -4462,7 +4489,11 @@ const setStyleProperties = (element, styleProperties) => {
|
|
|
4462
4489
|
if (!(element === null || element === void 0 ? void 0 : element.style))
|
|
4463
4490
|
return;
|
|
4464
4491
|
Object.keys(styleProperties).forEach((styleProperty) => {
|
|
4465
|
-
|
|
4492
|
+
const styleKey = styleProperty;
|
|
4493
|
+
const value = styleProperties[styleKey];
|
|
4494
|
+
if (value !== undefined) {
|
|
4495
|
+
element.style[styleKey] = value.toString();
|
|
4496
|
+
}
|
|
4466
4497
|
});
|
|
4467
4498
|
};
|
|
4468
4499
|
/**
|
|
@@ -4590,6 +4621,22 @@ const handleExitPresentMode = async () => {
|
|
|
4590
4621
|
}
|
|
4591
4622
|
}
|
|
4592
4623
|
logger$3.warn('Exit fullscreen API is not supported by this browser.');
|
|
4624
|
+
};
|
|
4625
|
+
const calculateVisibleElementData = (element) => {
|
|
4626
|
+
const rect = element.getBoundingClientRect();
|
|
4627
|
+
const windowHeight = window.innerHeight;
|
|
4628
|
+
const windowWidth = window.innerWidth;
|
|
4629
|
+
const frameRelativeTop = Math.max(rect.top, 0);
|
|
4630
|
+
const frameRelativeLeft = Math.max(rect.left, 0);
|
|
4631
|
+
const frameRelativeBottom = Math.min(windowHeight, rect.bottom);
|
|
4632
|
+
const frameRelativeRight = Math.min(windowWidth, rect.right);
|
|
4633
|
+
const data = {
|
|
4634
|
+
top: Math.max(0, rect.top * -1),
|
|
4635
|
+
height: Math.max(0, frameRelativeBottom - frameRelativeTop),
|
|
4636
|
+
left: Math.max(0, rect.left * -1),
|
|
4637
|
+
width: Math.max(0, frameRelativeRight - frameRelativeLeft),
|
|
4638
|
+
};
|
|
4639
|
+
return data;
|
|
4593
4640
|
};
|
|
4594
4641
|
|
|
4595
4642
|
/**
|
|
@@ -6885,6 +6932,7 @@ const ERROR_MESSAGE = {
|
|
|
6885
6932
|
CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE: 'Please set up CSP correctly for the application to start working. For more information, see https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts. \n If the issue persists, refer to https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts',
|
|
6886
6933
|
MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
|
|
6887
6934
|
RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
|
|
6935
|
+
SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
|
|
6888
6936
|
};
|
|
6889
6937
|
|
|
6890
6938
|
const EndPoints = {
|
|
@@ -7775,7 +7823,7 @@ class AnswerService {
|
|
|
7775
7823
|
async getTML() {
|
|
7776
7824
|
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
7777
7825
|
const edoc = object[0].edoc;
|
|
7778
|
-
const YAML = await import('./index-
|
|
7826
|
+
const YAML = await import('./index-e3Uw3YFO.js');
|
|
7779
7827
|
const parsedDoc = YAML.parse(edoc);
|
|
7780
7828
|
return {
|
|
7781
7829
|
answer: {
|
|
@@ -15509,7 +15557,7 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
|
15509
15557
|
return e;
|
|
15510
15558
|
}
|
|
15511
15559
|
|
|
15512
|
-
var name="@thoughtspot/visual-embed-sdk";var version$1="1.39.2-alpha.
|
|
15560
|
+
var name="@thoughtspot/visual-embed-sdk";var version$1="1.39.2-alpha.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","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",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",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",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={classnames:"^2.3.1",eventemitter3:"^4.0.7",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.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/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.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",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^9.23.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^10.1.1","eslint-import-resolver-typescript":"^4.2.5","eslint-plugin-comment-length":"2.2.1","eslint-plugin-import":"^2.31.0","eslint-plugin-jsdoc":"^50.6.9","eslint-plugin-prettier":"^5.2.5","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^5.2.0","fs-extra":"^10.0.0","gh-pages":"6.3.0",globals:"^16.0.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",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:"4.24.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","typescript-eslint":"^8.29.1","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^6.3.5"};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","embedded","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$1,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 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};
|
|
15513
15561
|
|
|
15514
15562
|
/**
|
|
15515
15563
|
* Reloads the ThoughtSpot iframe.
|
|
@@ -15532,7 +15580,8 @@ const reload = (iFrame) => {
|
|
|
15532
15580
|
* @param channel
|
|
15533
15581
|
*/
|
|
15534
15582
|
function postIframeMessage(iFrame, message, thoughtSpotHost, channel) {
|
|
15535
|
-
|
|
15583
|
+
var _a;
|
|
15584
|
+
return (_a = iFrame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, thoughtSpotHost, [channel === null || channel === void 0 ? void 0 : channel.port2]);
|
|
15536
15585
|
}
|
|
15537
15586
|
const TRIGGER_TIMEOUT = 30000;
|
|
15538
15587
|
/**
|
|
@@ -17245,7 +17294,6 @@ let SearchEmbed$1 = class SearchEmbed extends TsEmbed {
|
|
|
17245
17294
|
/**
|
|
17246
17295
|
* Pages within the ThoughtSpot app that can be embedded.
|
|
17247
17296
|
*/
|
|
17248
|
-
// eslint-disable-next-line no-shadow
|
|
17249
17297
|
var Page;
|
|
17250
17298
|
(function (Page) {
|
|
17251
17299
|
/**
|
|
@@ -17331,16 +17379,46 @@ var HomePage;
|
|
|
17331
17379
|
*/
|
|
17332
17380
|
HomePage["Modular"] = "v2";
|
|
17333
17381
|
})(HomePage || (HomePage = {}));
|
|
17382
|
+
/**
|
|
17383
|
+
* Define the version of the list page
|
|
17384
|
+
* @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
|
|
17385
|
+
*/
|
|
17386
|
+
var ListPage;
|
|
17387
|
+
(function (ListPage) {
|
|
17388
|
+
/**
|
|
17389
|
+
* List (v2) is the traditional List Experience.
|
|
17390
|
+
* It serves as the foundational version of the list page.
|
|
17391
|
+
*/
|
|
17392
|
+
ListPage["List"] = "v2";
|
|
17393
|
+
/**
|
|
17394
|
+
* ListWithUXChanges (v3) introduces the new updated list page with UX changes.
|
|
17395
|
+
*/
|
|
17396
|
+
ListPage["ListWithUXChanges"] = "v3";
|
|
17397
|
+
})(ListPage || (ListPage = {}));
|
|
17334
17398
|
/**
|
|
17335
17399
|
* Embeds full ThoughtSpot experience in a host application.
|
|
17336
17400
|
* @group Embed components
|
|
17337
17401
|
*/
|
|
17338
17402
|
let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
17339
|
-
// eslint-disable-next-line no-useless-constructor
|
|
17340
17403
|
constructor(domSelector, viewConfig) {
|
|
17341
17404
|
viewConfig.embedComponentType = 'AppEmbed';
|
|
17342
17405
|
super(domSelector, viewConfig);
|
|
17343
17406
|
this.defaultHeight = '100%';
|
|
17407
|
+
this.sendFullHeightLazyLoadData = () => {
|
|
17408
|
+
const data = calculateVisibleElementData(this.iFrame);
|
|
17409
|
+
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
|
|
17410
|
+
};
|
|
17411
|
+
/**
|
|
17412
|
+
* This is a handler for the RequestVisibleEmbedCoordinates event.
|
|
17413
|
+
* It is used to send the visible coordinates data to the host application.
|
|
17414
|
+
* @param data The event payload
|
|
17415
|
+
* @param responder The responder function
|
|
17416
|
+
*/
|
|
17417
|
+
this.requestVisibleEmbedCoordinatesHandler = (data, responder) => {
|
|
17418
|
+
logger$3.info('Sending RequestVisibleEmbedCoordinates', data);
|
|
17419
|
+
const visibleCoordinatesData = calculateVisibleElementData(this.iFrame);
|
|
17420
|
+
responder({ type: EmbedEvent.RequestVisibleEmbedCoordinates, data: visibleCoordinatesData });
|
|
17421
|
+
};
|
|
17344
17422
|
/**
|
|
17345
17423
|
* Set the iframe height as per the computed height received
|
|
17346
17424
|
* from the ThoughtSpot app.
|
|
@@ -17349,6 +17427,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17349
17427
|
this.updateIFrameHeight = (data) => {
|
|
17350
17428
|
var _a;
|
|
17351
17429
|
this.setIFrameHeight(Math.max(data.data, (_a = this.iFrame) === null || _a === void 0 ? void 0 : _a.scrollHeight));
|
|
17430
|
+
this.sendFullHeightLazyLoadData();
|
|
17352
17431
|
};
|
|
17353
17432
|
this.embedIframeCenter = (data, responder) => {
|
|
17354
17433
|
const obj = this.getIframeCenter();
|
|
@@ -17378,6 +17457,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17378
17457
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
|
17379
17458
|
this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
|
|
17380
17459
|
this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
|
|
17460
|
+
this.on(EmbedEvent.RequestVisibleEmbedCoordinates, this.requestVisibleEmbedCoordinatesHandler);
|
|
17381
17461
|
}
|
|
17382
17462
|
}
|
|
17383
17463
|
/**
|
|
@@ -17385,9 +17465,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17385
17465
|
* embedded Liveboard or visualization.
|
|
17386
17466
|
*/
|
|
17387
17467
|
getEmbedParams() {
|
|
17388
|
-
const { tag, hideObjects, liveboardV2, showPrimaryNavbar, disableProfileAndHelp, hideHamburger, hideObjectSearch, hideNotification, hideApplicationSwitcher, hideOrgSwitcher, enableSearchAssist, fullHeight, dataPanelV2 = false, hideLiveboardHeader = false, showLiveboardTitle = true, showLiveboardDescription = true, hideHomepageLeftNav = false, modularHomeExperience = false, isLiveboardHeaderSticky = true, enableAskSage, collapseSearchBarInitially = false, enable2ColumnLayout, enableCustomColumnGroups = false, isOnBeforeGetVizDataInterceptEnabled = false,
|
|
17389
|
-
/* eslint-disable-next-line max-len */
|
|
17390
|
-
dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL, collapseSearchBar = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, homePageSearchBarMode, isUnifiedSearchExperienceEnabled = true, enablePendoHelp = true, discoveryExperience, coverAndFilterOptionInPDF = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
17468
|
+
const { tag, hideObjects, liveboardV2, showPrimaryNavbar, disableProfileAndHelp, hideHamburger, hideObjectSearch, hideNotification, hideApplicationSwitcher, hideOrgSwitcher, enableSearchAssist, fullHeight, dataPanelV2 = false, hideLiveboardHeader = false, showLiveboardTitle = true, showLiveboardDescription = true, hideHomepageLeftNav = false, modularHomeExperience = false, isLiveboardHeaderSticky = true, enableAskSage, collapseSearchBarInitially = false, enable2ColumnLayout, enableCustomColumnGroups = false, isOnBeforeGetVizDataInterceptEnabled = false, dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL, collapseSearchBar = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, homePageSearchBarMode, isUnifiedSearchExperienceEnabled = true, enablePendoHelp = true, discoveryExperience, coverAndFilterOptionInPDF = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
17391
17469
|
let params = {};
|
|
17392
17470
|
params[Param.PrimaryNavHidden] = !showPrimaryNavbar;
|
|
17393
17471
|
params[Param.HideProfleAndHelp] = !!disableProfileAndHelp;
|
|
@@ -17416,6 +17494,10 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17416
17494
|
}
|
|
17417
17495
|
if (fullHeight === true) {
|
|
17418
17496
|
params[Param.fullHeight] = true;
|
|
17497
|
+
if (this.viewConfig.lazyLoadingForFullHeight) {
|
|
17498
|
+
params[Param.IsLazyLoadingForEmbedEnabled] = true;
|
|
17499
|
+
params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
|
|
17500
|
+
}
|
|
17419
17501
|
}
|
|
17420
17502
|
if (tag) {
|
|
17421
17503
|
params[Param.Tag] = tag;
|
|
@@ -17436,7 +17518,6 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17436
17518
|
params[Param.enableAskSage] = enableAskSage;
|
|
17437
17519
|
}
|
|
17438
17520
|
if (isOnBeforeGetVizDataInterceptEnabled) {
|
|
17439
|
-
/* eslint-disable-next-line max-len */
|
|
17440
17521
|
params[Param.IsOnBeforeGetVizDataInterceptEnabled] = isOnBeforeGetVizDataInterceptEnabled;
|
|
17441
17522
|
}
|
|
17442
17523
|
if (homePageSearchBarMode) {
|
|
@@ -17457,11 +17538,9 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17457
17538
|
=== DataPanelCustomColumnGroupsAccordionState.COLLAPSE_ALL
|
|
17458
17539
|
|| dataPanelCustomGroupsAccordionInitialState
|
|
17459
17540
|
=== DataPanelCustomColumnGroupsAccordionState.EXPAND_FIRST) {
|
|
17460
|
-
/* eslint-disable-next-line max-len */
|
|
17461
17541
|
params[Param.DataPanelCustomGroupsAccordionInitialState] = dataPanelCustomGroupsAccordionInitialState;
|
|
17462
17542
|
}
|
|
17463
17543
|
else {
|
|
17464
|
-
/* eslint-disable-next-line max-len */
|
|
17465
17544
|
params[Param.DataPanelCustomGroupsAccordionInitialState] = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL;
|
|
17466
17545
|
}
|
|
17467
17546
|
if (discoveryExperience) {
|
|
@@ -17474,6 +17553,10 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17474
17553
|
if (discoveryExperience.homePage === HomePage.Modular) {
|
|
17475
17554
|
params[Param.ModularHomeExperienceEnabled] = true;
|
|
17476
17555
|
}
|
|
17556
|
+
// listPageVersion v3 will enable the new list page
|
|
17557
|
+
if (discoveryExperience.listPageVersion === ListPage.ListWithUXChanges) {
|
|
17558
|
+
params[Param.ListPageVersion] = discoveryExperience.listPageVersion;
|
|
17559
|
+
}
|
|
17477
17560
|
}
|
|
17478
17561
|
const queryParams = getQueryParamString(params, true);
|
|
17479
17562
|
return queryParams;
|
|
@@ -17561,6 +17644,30 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17561
17644
|
this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
17562
17645
|
}
|
|
17563
17646
|
}
|
|
17647
|
+
/**
|
|
17648
|
+
* Destroys the ThoughtSpot embed, and remove any nodes from the DOM.
|
|
17649
|
+
* @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
|
|
17650
|
+
*/
|
|
17651
|
+
destroy() {
|
|
17652
|
+
super.destroy();
|
|
17653
|
+
this.unregisterLazyLoadEvents();
|
|
17654
|
+
}
|
|
17655
|
+
postRender() {
|
|
17656
|
+
this.registerLazyLoadEvents();
|
|
17657
|
+
}
|
|
17658
|
+
registerLazyLoadEvents() {
|
|
17659
|
+
if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
|
|
17660
|
+
// TODO: Use passive: true, install modernizr to check for passive
|
|
17661
|
+
window.addEventListener('resize', this.sendFullHeightLazyLoadData);
|
|
17662
|
+
window.addEventListener('scroll', this.sendFullHeightLazyLoadData);
|
|
17663
|
+
}
|
|
17664
|
+
}
|
|
17665
|
+
unregisterLazyLoadEvents() {
|
|
17666
|
+
if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
|
|
17667
|
+
window.removeEventListener('resize', this.sendFullHeightLazyLoadData);
|
|
17668
|
+
window.removeEventListener('scroll', this.sendFullHeightLazyLoadData);
|
|
17669
|
+
}
|
|
17670
|
+
}
|
|
17564
17671
|
/**
|
|
17565
17672
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
17566
17673
|
* @param renderOptions An object containing the page ID
|
|
@@ -17570,6 +17677,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17570
17677
|
await super.render();
|
|
17571
17678
|
const src = this.getIFrameSrc();
|
|
17572
17679
|
await this.renderV1Embed(src);
|
|
17680
|
+
this.postRender();
|
|
17573
17681
|
return this;
|
|
17574
17682
|
}
|
|
17575
17683
|
};
|
|
@@ -17674,6 +17782,21 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17674
17782
|
viewConfig.embedComponentType = 'LiveboardEmbed';
|
|
17675
17783
|
super(domSelector, viewConfig);
|
|
17676
17784
|
this.defaultHeight = 500;
|
|
17785
|
+
this.sendFullHeightLazyLoadData = () => {
|
|
17786
|
+
const data = calculateVisibleElementData(this.iFrame);
|
|
17787
|
+
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
|
|
17788
|
+
};
|
|
17789
|
+
/**
|
|
17790
|
+
* This is a handler for the RequestVisibleEmbedCoordinates event.
|
|
17791
|
+
* It is used to send the visible coordinates data to the host application.
|
|
17792
|
+
* @param data The event payload
|
|
17793
|
+
* @param responder The responder function
|
|
17794
|
+
*/
|
|
17795
|
+
this.requestVisibleEmbedCoordinatesHandler = (data, responder) => {
|
|
17796
|
+
logger$3.info('Sending RequestVisibleEmbedCoordinates', data);
|
|
17797
|
+
const visibleCoordinatesData = calculateVisibleElementData(this.iFrame);
|
|
17798
|
+
responder({ type: EmbedEvent.RequestVisibleEmbedCoordinates, data: visibleCoordinatesData });
|
|
17799
|
+
};
|
|
17677
17800
|
/**
|
|
17678
17801
|
* Set the iframe height as per the computed height received
|
|
17679
17802
|
* from the ThoughtSpot app.
|
|
@@ -17681,6 +17804,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17681
17804
|
*/
|
|
17682
17805
|
this.updateIFrameHeight = (data) => {
|
|
17683
17806
|
this.setIFrameHeight(Math.max(data.data, this.defaultHeight));
|
|
17807
|
+
this.sendFullHeightLazyLoadData();
|
|
17684
17808
|
};
|
|
17685
17809
|
this.embedIframeCenter = (data, responder) => {
|
|
17686
17810
|
const obj = this.getIframeCenter();
|
|
@@ -17714,6 +17838,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17714
17838
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
|
17715
17839
|
this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
|
|
17716
17840
|
this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
|
|
17841
|
+
this.on(EmbedEvent.RequestVisibleEmbedCoordinates, this.requestVisibleEmbedCoordinatesHandler);
|
|
17717
17842
|
}
|
|
17718
17843
|
}
|
|
17719
17844
|
/**
|
|
@@ -17728,6 +17853,10 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17728
17853
|
|| this.viewConfig.preventPinboardFilterRemoval;
|
|
17729
17854
|
if (fullHeight === true) {
|
|
17730
17855
|
params[Param.fullHeight] = true;
|
|
17856
|
+
if (this.viewConfig.lazyLoadingForFullHeight) {
|
|
17857
|
+
params[Param.IsLazyLoadingForEmbedEnabled] = true;
|
|
17858
|
+
params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
|
|
17859
|
+
}
|
|
17731
17860
|
}
|
|
17732
17861
|
if (defaultHeight) {
|
|
17733
17862
|
this.defaultHeight = defaultHeight;
|
|
@@ -17883,6 +18012,30 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17883
18012
|
}
|
|
17884
18013
|
return super.trigger(messageType, dataWithVizId);
|
|
17885
18014
|
}
|
|
18015
|
+
/**
|
|
18016
|
+
* Destroys the ThoughtSpot embed, and remove any nodes from the DOM.
|
|
18017
|
+
* @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
|
|
18018
|
+
*/
|
|
18019
|
+
destroy() {
|
|
18020
|
+
super.destroy();
|
|
18021
|
+
this.unregisterLazyLoadEvents();
|
|
18022
|
+
}
|
|
18023
|
+
postRender() {
|
|
18024
|
+
this.registerLazyLoadEvents();
|
|
18025
|
+
}
|
|
18026
|
+
registerLazyLoadEvents() {
|
|
18027
|
+
if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
|
|
18028
|
+
// TODO: Use passive: true, install modernizr to check for passive
|
|
18029
|
+
window.addEventListener('resize', this.sendFullHeightLazyLoadData);
|
|
18030
|
+
window.addEventListener('scroll', this.sendFullHeightLazyLoadData);
|
|
18031
|
+
}
|
|
18032
|
+
}
|
|
18033
|
+
unregisterLazyLoadEvents() {
|
|
18034
|
+
if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
|
|
18035
|
+
window.removeEventListener('resize', this.sendFullHeightLazyLoadData);
|
|
18036
|
+
window.removeEventListener('scroll', this.sendFullHeightLazyLoadData);
|
|
18037
|
+
}
|
|
18038
|
+
}
|
|
17886
18039
|
/**
|
|
17887
18040
|
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
17888
18041
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
@@ -17893,6 +18046,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17893
18046
|
const src = this.getIFrameSrc();
|
|
17894
18047
|
await this.renderV1Embed(src);
|
|
17895
18048
|
this.showPreviewLoader();
|
|
18049
|
+
this.postRender();
|
|
17896
18050
|
return this;
|
|
17897
18051
|
}
|
|
17898
18052
|
navigateToLiveboard(liveboardId, vizId, activeTabId) {
|
|
@@ -18289,6 +18443,8 @@ class Conversation {
|
|
|
18289
18443
|
});
|
|
18290
18444
|
const data = responses[0].data;
|
|
18291
18445
|
return {
|
|
18446
|
+
convId: this.conversationId,
|
|
18447
|
+
messageId: responses[0].msgId,
|
|
18292
18448
|
data: data.asstRespData.nlsAnsData.sageQuerySuggestions[0],
|
|
18293
18449
|
error: null,
|
|
18294
18450
|
};
|
|
@@ -18307,7 +18463,7 @@ class Conversation {
|
|
|
18307
18463
|
}
|
|
18308
18464
|
}
|
|
18309
18465
|
|
|
18310
|
-
class ConversationMessage extends TsEmbed {
|
|
18466
|
+
let ConversationMessage$1 = class ConversationMessage extends TsEmbed {
|
|
18311
18467
|
constructor(container, viewConfig) {
|
|
18312
18468
|
viewConfig.embedComponentType = 'bodyless-conversation';
|
|
18313
18469
|
super(container, viewConfig);
|
|
@@ -18339,7 +18495,7 @@ class ConversationMessage extends TsEmbed {
|
|
|
18339
18495
|
await this.renderIFrame(src);
|
|
18340
18496
|
return this;
|
|
18341
18497
|
}
|
|
18342
|
-
}
|
|
18498
|
+
};
|
|
18343
18499
|
/**
|
|
18344
18500
|
* Create a conversation embed, which can be integrated inside
|
|
18345
18501
|
* chatbots or other conversational interfaces.
|
|
@@ -18359,7 +18515,7 @@ class ConversationMessage extends TsEmbed {
|
|
|
18359
18515
|
* @group Embed components
|
|
18360
18516
|
* @version SDK: 1.37.0 | ThoughtSpot: 10.9.0.cl
|
|
18361
18517
|
*/
|
|
18362
|
-
|
|
18518
|
+
class SpotterAgentEmbed {
|
|
18363
18519
|
constructor(viewConfig) {
|
|
18364
18520
|
this.viewConfig = viewConfig;
|
|
18365
18521
|
const embedConfig = getEmbedConfig();
|
|
@@ -18371,10 +18527,7 @@ let SpotterAgentEmbed$1 = class SpotterAgentEmbed {
|
|
|
18371
18527
|
return { error };
|
|
18372
18528
|
}
|
|
18373
18529
|
const container = document.createElement('div');
|
|
18374
|
-
|
|
18375
|
-
container.className = this.viewConfig.containerClassName;
|
|
18376
|
-
}
|
|
18377
|
-
const embed = new ConversationMessage(container, {
|
|
18530
|
+
const embed = new ConversationMessage$1(container, {
|
|
18378
18531
|
...this.viewConfig,
|
|
18379
18532
|
sessionId: data.sessionId,
|
|
18380
18533
|
genNo: data.genNo,
|
|
@@ -18384,7 +18537,29 @@ let SpotterAgentEmbed$1 = class SpotterAgentEmbed {
|
|
|
18384
18537
|
await embed.render();
|
|
18385
18538
|
return { container, viz: embed };
|
|
18386
18539
|
}
|
|
18387
|
-
|
|
18540
|
+
/**
|
|
18541
|
+
* Send a message to the conversation service and return only the data.
|
|
18542
|
+
* @param userMessage - The message to send to the conversation service.
|
|
18543
|
+
* @returns The data from the conversation service.
|
|
18544
|
+
*/
|
|
18545
|
+
async sendMessageData(userMessage) {
|
|
18546
|
+
try {
|
|
18547
|
+
const { data, error } = await this.conversationService.sendMessage(userMessage);
|
|
18548
|
+
if (error) {
|
|
18549
|
+
return { error };
|
|
18550
|
+
}
|
|
18551
|
+
return { data: {
|
|
18552
|
+
sessionId: data.sessionId,
|
|
18553
|
+
genNo: data.genNo,
|
|
18554
|
+
acSessionId: data.stateKey.transactionId,
|
|
18555
|
+
acGenNo: data.stateKey.generationNumber,
|
|
18556
|
+
} };
|
|
18557
|
+
}
|
|
18558
|
+
catch (error) {
|
|
18559
|
+
return { error: error };
|
|
18560
|
+
}
|
|
18561
|
+
}
|
|
18562
|
+
}
|
|
18388
18563
|
|
|
18389
18564
|
/**
|
|
18390
18565
|
*
|
|
@@ -18451,7 +18626,7 @@ let SpotterEmbed$1 = class SpotterEmbed extends TsEmbed {
|
|
|
18451
18626
|
this.viewConfig = viewConfig;
|
|
18452
18627
|
}
|
|
18453
18628
|
getIframeSrc() {
|
|
18454
|
-
const { worksheetId, searchOptions, disableSourceSelection, hideSourceSelection, dataPanelV2, showSpotterLimitations, hideSampleQuestions,
|
|
18629
|
+
const { worksheetId, searchOptions, disableSourceSelection, hideSourceSelection, dataPanelV2, showSpotterLimitations, hideSampleQuestions, } = this.viewConfig;
|
|
18455
18630
|
const path = 'insights/conv-assist';
|
|
18456
18631
|
if (!worksheetId) {
|
|
18457
18632
|
this.handleError(ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND);
|
|
@@ -18478,14 +18653,6 @@ let SpotterEmbed$1 = class SpotterEmbed extends TsEmbed {
|
|
|
18478
18653
|
if (queryParamsString) {
|
|
18479
18654
|
query = `?${queryParamsString}`;
|
|
18480
18655
|
}
|
|
18481
|
-
const filterQuery = getFilterQuery(runtimeFilters || []);
|
|
18482
|
-
if (filterQuery && !excludeRuntimeFiltersfromURL) {
|
|
18483
|
-
query += `&${filterQuery}`;
|
|
18484
|
-
}
|
|
18485
|
-
const parameterQuery = getRuntimeParameters(runtimeParameters || []);
|
|
18486
|
-
if (parameterQuery && !excludeRuntimeParametersfromURL) {
|
|
18487
|
-
query += `&${parameterQuery}`;
|
|
18488
|
-
}
|
|
18489
18656
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams({
|
|
18490
18657
|
worksheet: worksheetId,
|
|
18491
18658
|
query: (searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.searchQuery) || '',
|
|
@@ -18767,55 +18934,34 @@ const SpotterEmbed = componentFactory(SpotterEmbed$1);
|
|
|
18767
18934
|
* ```
|
|
18768
18935
|
*/
|
|
18769
18936
|
const ConversationEmbed = componentFactory(ConversationEmbed$1);
|
|
18937
|
+
const ConversationMessage = componentFactory(ConversationMessage$1);
|
|
18770
18938
|
/**
|
|
18771
|
-
* React component for
|
|
18772
|
-
*
|
|
18939
|
+
* React component for displaying individual conversation messages from SpotterAgent.
|
|
18940
|
+
*
|
|
18941
|
+
* This component renders a single message response from your ThoughtSpot conversation,
|
|
18942
|
+
* showing charts, visualizations, or text responses based on the user's query.
|
|
18943
|
+
*
|
|
18773
18944
|
* @example
|
|
18774
18945
|
* ```tsx
|
|
18775
|
-
*
|
|
18776
|
-
*
|
|
18946
|
+
* const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
|
|
18947
|
+
* const result = await sendMessage('show me sales by region');
|
|
18777
18948
|
*
|
|
18778
|
-
*
|
|
18779
|
-
*
|
|
18780
|
-
*
|
|
18781
|
-
* document.body.appendChild(container);
|
|
18782
|
-
* }
|
|
18783
|
-
* };
|
|
18949
|
+
* if (!result.error) {
|
|
18950
|
+
* // Simple usage - just pass the message data
|
|
18951
|
+
* <SpotterMessage message={result.message} />
|
|
18784
18952
|
*
|
|
18785
|
-
*
|
|
18786
|
-
*
|
|
18787
|
-
*
|
|
18788
|
-
*
|
|
18789
|
-
*
|
|
18790
|
-
* );
|
|
18953
|
+
* // With optional query for context
|
|
18954
|
+
* <SpotterMessage
|
|
18955
|
+
* message={result.message}
|
|
18956
|
+
* query={result.query}
|
|
18957
|
+
* />
|
|
18791
18958
|
* }
|
|
18792
18959
|
* ```
|
|
18960
|
+
* @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
|
|
18793
18961
|
*/
|
|
18794
|
-
const
|
|
18795
|
-
const {
|
|
18796
|
-
|
|
18797
|
-
useDeepCompareEffect(() => {
|
|
18798
|
-
if (serviceRef.current) {
|
|
18799
|
-
serviceRef.current = null;
|
|
18800
|
-
}
|
|
18801
|
-
const configProps = {
|
|
18802
|
-
...restProps,
|
|
18803
|
-
...(className ? { containerClassName: className } : {})
|
|
18804
|
-
};
|
|
18805
|
-
serviceRef.current = new SpotterAgentEmbed$1(configProps);
|
|
18806
|
-
if (ref) {
|
|
18807
|
-
if (typeof ref === 'function') {
|
|
18808
|
-
ref(serviceRef.current);
|
|
18809
|
-
}
|
|
18810
|
-
else {
|
|
18811
|
-
ref.current = serviceRef.current;
|
|
18812
|
-
}
|
|
18813
|
-
}
|
|
18814
|
-
return () => {
|
|
18815
|
-
serviceRef.current = null;
|
|
18816
|
-
};
|
|
18817
|
-
}, [props]);
|
|
18818
|
-
return null;
|
|
18962
|
+
const SpotterMessage = React__default.forwardRef((props, ref) => {
|
|
18963
|
+
const { message, query: _, ...otherProps } = props;
|
|
18964
|
+
return (React__default.createElement(ConversationMessage, { ref: ref, ...message, ...otherProps }));
|
|
18819
18965
|
});
|
|
18820
18966
|
/**
|
|
18821
18967
|
* React component for PreRendered Conversation embed.
|
|
@@ -18875,6 +19021,62 @@ function useInit(config) {
|
|
|
18875
19021
|
ref.current = authEE;
|
|
18876
19022
|
}, [config]);
|
|
18877
19023
|
return ref;
|
|
19024
|
+
}
|
|
19025
|
+
/**
|
|
19026
|
+
* React hook for interacting with SpotterAgent AI conversations.
|
|
19027
|
+
*
|
|
19028
|
+
* This hook provides a sendMessage function that allows you to send natural language
|
|
19029
|
+
* queries to your data and get back AI-generated responses with visualizations.
|
|
19030
|
+
*
|
|
19031
|
+
* @param config - Configuration object containing worksheetId and other options
|
|
19032
|
+
* @returns Object with sendMessage function that returns conversation results
|
|
19033
|
+
* @example
|
|
19034
|
+
* ```tsx
|
|
19035
|
+
* const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
|
|
19036
|
+
*
|
|
19037
|
+
* const handleQuery = async () => {
|
|
19038
|
+
* const result = await sendMessage('show me sales by region');
|
|
19039
|
+
*
|
|
19040
|
+
* if (!result.error) {
|
|
19041
|
+
* // Display the message response
|
|
19042
|
+
* <SpotterMessage message={result.message} />
|
|
19043
|
+
* } else {
|
|
19044
|
+
* console.error('Error:', result.error);
|
|
19045
|
+
* }
|
|
19046
|
+
* };
|
|
19047
|
+
* ```
|
|
19048
|
+
* @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
|
|
19049
|
+
*/
|
|
19050
|
+
function useSpotterAgent(config) {
|
|
19051
|
+
const serviceRef = useRef(null);
|
|
19052
|
+
useDeepCompareEffect(() => {
|
|
19053
|
+
if (serviceRef.current) {
|
|
19054
|
+
serviceRef.current = null;
|
|
19055
|
+
}
|
|
19056
|
+
serviceRef.current = new SpotterAgentEmbed(config);
|
|
19057
|
+
return () => {
|
|
19058
|
+
serviceRef.current = null;
|
|
19059
|
+
};
|
|
19060
|
+
}, [config]);
|
|
19061
|
+
const sendMessage = useCallback(async (query) => {
|
|
19062
|
+
if (!serviceRef.current) {
|
|
19063
|
+
return { error: new Error(ERROR_MESSAGE.SPOTTER_AGENT_NOT_INITIALIZED) };
|
|
19064
|
+
}
|
|
19065
|
+
const result = await serviceRef.current.sendMessageData(query);
|
|
19066
|
+
if (result.error) {
|
|
19067
|
+
return { error: result.error };
|
|
19068
|
+
}
|
|
19069
|
+
return {
|
|
19070
|
+
query: query,
|
|
19071
|
+
message: {
|
|
19072
|
+
...result.data,
|
|
19073
|
+
worksheetId: config.worksheetId,
|
|
19074
|
+
},
|
|
19075
|
+
};
|
|
19076
|
+
}, [config.worksheetId]);
|
|
19077
|
+
return {
|
|
19078
|
+
sendMessage,
|
|
19079
|
+
};
|
|
18878
19080
|
}
|
|
18879
19081
|
|
|
18880
|
-
export { Action, AppEmbed, ConversationEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, ListPageColumns, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed,
|
|
19082
|
+
export { Action, AppEmbed, ConversationEmbed, ConversationMessage, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, ListPageColumns, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, SpotterEmbed, SpotterMessage, getSessionInfo, useEmbedRef, useInit, useSpotterAgent };
|