@thoughtspot/visual-embed-sdk 1.51.0 → 1.51.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.d.ts +1 -0
- package/cjs/src/config.d.ts.map +1 -1
- package/cjs/src/config.js +2 -1
- package/cjs/src/config.js.map +1 -1
- package/cjs/src/css-variables.d.ts +27 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +43 -12
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +29 -3
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +253 -1
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.js +1 -1
- package/cjs/src/embed/conversation.d.ts +171 -1
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +4 -2
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +125 -0
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +3 -0
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/host-events.spec.js +36 -0
- package/cjs/src/embed/host-events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +18 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +40 -13
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +25 -4
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +349 -2
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +28 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/spotter-utils.d.ts +8 -1
- package/cjs/src/embed/spotter-utils.d.ts.map +1 -1
- package/cjs/src/embed/spotter-utils.js +15 -1
- package/cjs/src/embed/spotter-utils.js.map +1 -1
- package/cjs/src/embed/spotter-utils.spec.js +68 -0
- package/cjs/src/embed/spotter-utils.spec.js.map +1 -1
- package/cjs/src/embed/spotter-viz-utils.d.ts +9 -10
- package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/cjs/src/embed/spotter-viz-utils.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +97 -9
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +76 -35
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +537 -3
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +3 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -2
- 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 +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/all-types-export.parity.spec.d.ts +2 -0
- package/cjs/src/react/all-types-export.parity.spec.d.ts.map +1 -0
- package/cjs/src/react/all-types-export.parity.spec.js +194 -0
- package/cjs/src/react/all-types-export.parity.spec.js.map +1 -0
- package/cjs/src/react/index.d.ts +66 -32
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +5 -3
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +101 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +330 -18
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +182 -12
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils.d.ts +5 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +19 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +37 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-aBzH5ZwF.js → index-D8_Zs-Nr.js} +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/css-variables.d.ts +27 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +43 -12
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/conversation.d.ts +171 -1
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +40 -13
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/spotter-utils.d.ts +8 -1
- package/dist/src/embed/spotter-utils.d.ts.map +1 -1
- package/dist/src/embed/spotter-viz-utils.d.ts +9 -10
- package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +97 -9
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- 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/all-types-export.parity.spec.d.ts +2 -0
- package/dist/src/react/all-types-export.parity.spec.d.ts.map +1 -0
- package/dist/src/react/index.d.ts +66 -32
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +330 -18
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +5 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +354 -64
- package/dist/tsembed-react.js +353 -63
- package/dist/tsembed.es.js +414 -126
- package/dist/tsembed.js +416 -128
- package/dist/visual-embed-sdk-react-full.d.ts +777 -90
- package/dist/visual-embed-sdk-react.d.ts +773 -89
- package/dist/visual-embed-sdk.d.ts +713 -60
- package/lib/package.json +1 -1
- package/lib/src/config.d.ts +1 -0
- package/lib/src/config.d.ts.map +1 -1
- package/lib/src/config.js +1 -0
- package/lib/src/config.js.map +1 -1
- package/lib/src/css-variables.d.ts +27 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +43 -12
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +30 -4
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +253 -1
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.js +1 -1
- package/lib/src/embed/conversation.d.ts +171 -1
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +5 -3
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +125 -0
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +3 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/host-events.spec.js +36 -0
- package/lib/src/embed/host-events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +18 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +40 -13
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +25 -4
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +349 -2
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +28 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/spotter-utils.d.ts +8 -1
- package/lib/src/embed/spotter-utils.d.ts.map +1 -1
- package/lib/src/embed/spotter-utils.js +13 -0
- package/lib/src/embed/spotter-utils.js.map +1 -1
- package/lib/src/embed/spotter-utils.spec.js +69 -1
- package/lib/src/embed/spotter-utils.spec.js.map +1 -1
- package/lib/src/embed/spotter-viz-utils.d.ts +9 -10
- package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/lib/src/embed/spotter-viz-utils.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +97 -9
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +77 -36
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +537 -3
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- 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/all-types-export.parity.spec.d.ts +2 -0
- package/lib/src/react/all-types-export.parity.spec.d.ts.map +1 -0
- package/lib/src/react/all-types-export.parity.spec.js +191 -0
- package/lib/src/react/all-types-export.parity.spec.js.map +1 -0
- package/lib/src/react/index.d.ts +66 -32
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +5 -3
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +102 -1
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +330 -18
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +182 -12
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.d.ts +5 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +17 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +38 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +713 -60
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/css-variables.ts +32 -0
- package/src/embed/app.spec.ts +335 -1
- package/src/embed/app.ts +71 -13
- package/src/embed/base.ts +1 -1
- package/src/embed/conversation.spec.ts +136 -0
- package/src/embed/conversation.ts +181 -3
- package/src/embed/events.spec.ts +4 -0
- package/src/embed/host-events.spec.ts +48 -0
- package/src/embed/hostEventClient/host-event-client.spec.ts +34 -0
- package/src/embed/hostEventClient/host-event-client.ts +2 -2
- package/src/embed/liveboard.spec.ts +457 -2
- package/src/embed/liveboard.ts +74 -15
- package/src/embed/search.spec.ts +31 -0
- package/src/embed/spotter-utils.spec.ts +72 -0
- package/src/embed/spotter-utils.ts +21 -1
- package/src/embed/spotter-viz-utils.ts +9 -10
- package/src/embed/ts-embed.spec.ts +699 -3
- package/src/embed/ts-embed.ts +91 -41
- package/src/index.ts +43 -2
- package/src/react/all-types-export.parity.spec.ts +208 -0
- package/src/react/all-types-export.ts +22 -0
- package/src/react/index.spec.tsx +158 -0
- package/src/react/index.tsx +70 -33
- package/src/types.ts +329 -16
- package/src/utils.spec.ts +49 -0
- package/src/utils.ts +16 -0
package/src/embed/liveboard.ts
CHANGED
|
@@ -26,12 +26,14 @@ import {
|
|
|
26
26
|
DefaultAppInitData,
|
|
27
27
|
} from '../types';
|
|
28
28
|
import { calculateVisibleElementData, getEffectiveClippingAncestors, getQueryParamString, getScrollableAncestors, isUndefined, isValidCssMargin, setParamIfDefined } from '../utils';
|
|
29
|
+
import { DEFAULT_LAZY_LOADING_MARGIN } from '../config';
|
|
29
30
|
import { getAuthPromise } from './base';
|
|
30
31
|
import { TsEmbed, V1Embed } from './ts-embed';
|
|
31
32
|
import { addPreviewStylesIfNotPresent } from '../utils/global-styles';
|
|
32
|
-
import { TriggerPayload, TriggerResponse } from './hostEventClient/contracts';
|
|
33
|
+
import { HostEventRequest, TriggerPayload, TriggerResponse } from './hostEventClient/contracts';
|
|
33
34
|
import { logger } from '../utils/logger';
|
|
34
|
-
import { SpotterChatViewConfig } from './conversation';
|
|
35
|
+
import { SpotterChatViewConfig, StarterPromptsConfig } from './conversation';
|
|
36
|
+
import { buildStarterPromptsAppInitData } from './spotter-utils';
|
|
35
37
|
import { SpotterVizConfig, buildSpotterVizAppInitData } from './spotter-viz-utils';
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -41,6 +43,7 @@ import { SpotterVizConfig, buildSpotterVizAppInitData } from './spotter-viz-util
|
|
|
41
43
|
export interface LiveboardEmbedAppInitData extends DefaultAppInitData {
|
|
42
44
|
embedParams?: {
|
|
43
45
|
spotterVizConfig?: SpotterVizConfig;
|
|
46
|
+
starterPrompts?: StarterPromptsConfig;
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -61,6 +64,11 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
61
64
|
* Setting `fullHeight` to `false` fetches visualizations
|
|
62
65
|
* incrementally as users scroll the page to view the charts and tables.
|
|
63
66
|
*
|
|
67
|
+
* From SDK 1.52.0, enabling `fullHeight` also turns on
|
|
68
|
+
* {@link lazyLoadingForFullHeight} and
|
|
69
|
+
* {@link enableScrollableContainerLazyLoading}, so visualizations load as
|
|
70
|
+
* they scroll into view. Set either flag to `false` to opt out.
|
|
71
|
+
*
|
|
64
72
|
*
|
|
65
73
|
* Supported embed types: `LiveboardEmbed`
|
|
66
74
|
* @version SDK: 1.1.0 | ThoughtSpot: ts7.may.cl, 7.2.1
|
|
@@ -455,11 +463,17 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
455
463
|
*/
|
|
456
464
|
isGranularXLSXCSVSchedulesEnabled?: boolean;
|
|
457
465
|
/**
|
|
458
|
-
*
|
|
466
|
+
* Loads visualizations only as they scroll into the viewport, instead of
|
|
467
|
+
* loading the whole full-height Liveboard at once.
|
|
468
|
+
*
|
|
469
|
+
* From SDK 1.52.0 this is enabled automatically whenever `fullHeight` is
|
|
470
|
+
* `true`. On SDK 1.51.0 and earlier it defaulted to `false` and had to be
|
|
471
|
+
* set explicitly. Set it to `false` to load every visualization upfront.
|
|
472
|
+
* The flag has no effect unless `fullHeight` is enabled.
|
|
459
473
|
*
|
|
460
474
|
* @type {boolean}
|
|
461
475
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
|
|
462
|
-
* @default
|
|
476
|
+
* @default true when `fullHeight` is enabled, from SDK 1.52.0
|
|
463
477
|
* @example
|
|
464
478
|
* ```js
|
|
465
479
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -471,26 +485,42 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
471
485
|
*/
|
|
472
486
|
lazyLoadingForFullHeight?: boolean;
|
|
473
487
|
/**
|
|
474
|
-
*
|
|
488
|
+
* Computes the visible region of the embed against its scrollable and
|
|
489
|
+
* clipping ancestors, instead of treating the browser window as the only
|
|
490
|
+
* viewport, and tracks scroll and resize on those ancestors.
|
|
475
491
|
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
492
|
+
* From SDK 1.52.0 this is enabled automatically whenever `fullHeight` is
|
|
493
|
+
* `true`. On SDK 1.51.0 and earlier it defaulted to `false` and had to be
|
|
494
|
+
* set explicitly. Set it to `false` when the page scrolls with the window
|
|
495
|
+
* and the embed has no clipping ancestor, to skip the extra ancestor
|
|
496
|
+
* tracking.
|
|
478
497
|
*
|
|
479
498
|
* @type {boolean}
|
|
480
|
-
* @default
|
|
499
|
+
* @default true when `fullHeight` is enabled, from SDK 1.52.0
|
|
481
500
|
*/
|
|
482
501
|
enableScrollableContainerLazyLoading?: boolean;
|
|
483
502
|
/**
|
|
484
|
-
*
|
|
503
|
+
* How far outside the viewport a visualization starts loading, when
|
|
504
|
+
* {@link lazyLoadingForFullHeight} is enabled.
|
|
485
505
|
*
|
|
486
506
|
* For example, if the margin is set to '10px',
|
|
487
507
|
* the visualization will be loaded 10px before its top edge is visible in the
|
|
488
508
|
* viewport.
|
|
489
509
|
*
|
|
490
|
-
* The format is similar to CSS margin
|
|
510
|
+
* The format is similar to CSS margin, so `'500px 0px'` extends the
|
|
511
|
+
* prefetch 500px above and below the viewport and not sideways. Accepted
|
|
512
|
+
* units are `px`, `em`, `rem`, `%`, `vh` and `vw`, plus bare `0` and
|
|
513
|
+
* `auto`; an invalid value is logged and ignored.
|
|
514
|
+
*
|
|
515
|
+
* From SDK 1.52.0 this defaults to `'500px 0px'` — roughly one
|
|
516
|
+
* visualization ahead of the scroll position, so a chart has usually
|
|
517
|
+
* finished loading by the time it scrolls into view. Use a smaller margin
|
|
518
|
+
* to cut warehouse queries further, or `'0px'` to load a visualization
|
|
519
|
+
* only once it is actually visible.
|
|
491
520
|
*
|
|
492
521
|
* @type {string}
|
|
493
522
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
|
|
523
|
+
* @default '500px 0px' when `fullHeight` is enabled, from SDK 1.52.0
|
|
494
524
|
* @example
|
|
495
525
|
* ```js
|
|
496
526
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -594,13 +624,12 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
594
624
|
* inputChatPlaceholder: 'Ask a question...',
|
|
595
625
|
* hideStarterPrompts: false,
|
|
596
626
|
* customStarterPrompts: [{ id: '1', displayText: 'Top products', fullPrompt: 'What are the top products by revenue?' }],
|
|
597
|
-
* //
|
|
627
|
+
* // The options below require SDK: 1.51.0
|
|
598
628
|
* loaderHeadline: 'Crunching the numbers...',
|
|
599
629
|
* loaderTips: [
|
|
600
630
|
* { label: 'Tip', text: 'try asking about revenue by region' },
|
|
601
631
|
* { label: 'Tip', text: 'use natural language' },
|
|
602
632
|
* ],
|
|
603
|
-
* // liveboardBrandName, spotterBrandName, insightTileBrandName, insightTileViewPlanLabel and insightTileLoaderText require SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl
|
|
604
633
|
* liveboardBrandName: 'Reports',
|
|
605
634
|
* spotterBrandName: 'Analyst',
|
|
606
635
|
* insightTileBrandName: 'Insight card',
|
|
@@ -675,6 +704,16 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
675
704
|
'Using full height with vizId might lead to unexpected behavior.');
|
|
676
705
|
}
|
|
677
706
|
|
|
707
|
+
if (this.viewConfig.lazyLoadingForFullHeight === undefined) {
|
|
708
|
+
this.viewConfig.lazyLoadingForFullHeight = true;
|
|
709
|
+
}
|
|
710
|
+
if (this.viewConfig.enableScrollableContainerLazyLoading === undefined) {
|
|
711
|
+
this.viewConfig.enableScrollableContainerLazyLoading = true;
|
|
712
|
+
}
|
|
713
|
+
if (this.viewConfig.lazyLoadingMargin === undefined) {
|
|
714
|
+
this.viewConfig.lazyLoadingMargin = DEFAULT_LAZY_LOADING_MARGIN;
|
|
715
|
+
}
|
|
716
|
+
|
|
678
717
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
|
679
718
|
this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
|
|
680
719
|
this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
|
|
@@ -684,7 +723,8 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
684
723
|
|
|
685
724
|
protected async getAppInitData(): Promise<LiveboardEmbedAppInitData> {
|
|
686
725
|
const defaultAppInitData = await super.getAppInitData();
|
|
687
|
-
|
|
726
|
+
const vizInitData = buildSpotterVizAppInitData(defaultAppInitData, this.viewConfig);
|
|
727
|
+
return buildStarterPromptsAppInitData(vizInitData, this.viewConfig);
|
|
688
728
|
}
|
|
689
729
|
|
|
690
730
|
/**
|
|
@@ -724,6 +764,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
724
764
|
isEnhancedFilterInteractivityEnabled,
|
|
725
765
|
enableAskSage,
|
|
726
766
|
enable2ColumnLayout,
|
|
767
|
+
isLiveboardAlwaysOn12ColLayout,
|
|
727
768
|
dataPanelV2 = true,
|
|
728
769
|
updatedSpotterExperience,
|
|
729
770
|
enableCustomColumnGroups = false,
|
|
@@ -732,6 +773,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
732
773
|
dataSourceId,
|
|
733
774
|
coverAndFilterOptionInPDF,
|
|
734
775
|
isLiveboardStylingAndGroupingEnabled,
|
|
776
|
+
liveboardGutter,
|
|
735
777
|
isPNGInScheduledEmailsEnabled = false,
|
|
736
778
|
isLiveboardXLSXCSVDownloadEnabled,
|
|
737
779
|
isGranularXLSXCSVSchedulesEnabled,
|
|
@@ -789,6 +831,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
789
831
|
if (enable2ColumnLayout !== undefined) {
|
|
790
832
|
params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
|
|
791
833
|
}
|
|
834
|
+
if (isLiveboardAlwaysOn12ColLayout !== undefined) {
|
|
835
|
+
params[Param.IsLiveboardAlwaysOn12ColLayout] = isLiveboardAlwaysOn12ColLayout;
|
|
836
|
+
}
|
|
792
837
|
if (hideTabPanel) {
|
|
793
838
|
params[Param.HideTabPanel] = hideTabPanel;
|
|
794
839
|
}
|
|
@@ -821,6 +866,10 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
821
866
|
params[Param.IsLiveboardStylingAndGroupingEnabled] = isLiveboardStylingAndGroupingEnabled;
|
|
822
867
|
}
|
|
823
868
|
|
|
869
|
+
if (liveboardGutter !== undefined) {
|
|
870
|
+
params[Param.LiveboardGutter] = liveboardGutter;
|
|
871
|
+
}
|
|
872
|
+
|
|
824
873
|
if (isPNGInScheduledEmailsEnabled !== undefined) {
|
|
825
874
|
params[Param.isPNGInScheduledEmailsEnabled] = isPNGInScheduledEmailsEnabled;
|
|
826
875
|
}
|
|
@@ -849,6 +898,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
849
898
|
spotterFileUploadEnabled,
|
|
850
899
|
spotterFileUploadFileTypes,
|
|
851
900
|
enableStarterPrompts,
|
|
901
|
+
openSpotterOnLiveboardByDefault,
|
|
852
902
|
} = spotterChatConfig;
|
|
853
903
|
|
|
854
904
|
setParamIfDefined(params, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
|
|
@@ -859,6 +909,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
859
909
|
if (enableStarterPrompts !== undefined) {
|
|
860
910
|
params[Param.IsStarterPromptsEnabled] = enableStarterPrompts;
|
|
861
911
|
}
|
|
912
|
+
if (openSpotterOnLiveboardByDefault !== undefined) {
|
|
913
|
+
params[Param.OpenSpotterOnLiveboardByDefault] = openSpotterOnLiveboardByDefault;
|
|
914
|
+
}
|
|
862
915
|
if (spotterFileUploadFileTypes !== undefined) {
|
|
863
916
|
params[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
|
|
864
917
|
}
|
|
@@ -1141,7 +1194,13 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1141
1194
|
* @param {any} data The payload to send with the message
|
|
1142
1195
|
* @returns A promise that resolves with the response from the embedded app
|
|
1143
1196
|
*/
|
|
1144
|
-
public trigger<
|
|
1197
|
+
public trigger<
|
|
1198
|
+
HostEventT extends HostEvent,
|
|
1199
|
+
// Must mirror TsEmbed.trigger: without the default, no-payload calls
|
|
1200
|
+
// through LiveboardEmbed lose the typed response and collapse to `any`.
|
|
1201
|
+
PayloadT = HostEventRequest<HostEventT>,
|
|
1202
|
+
ContextT extends ContextType = ContextType,
|
|
1203
|
+
>(
|
|
1145
1204
|
messageType: HostEventT,
|
|
1146
1205
|
data: TriggerPayload<PayloadT, HostEventT> = ({} as any),
|
|
1147
1206
|
context?: ContextT,
|
|
@@ -1240,7 +1299,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1240
1299
|
this.viewConfig.personalizedViewId = personalizedViewId;
|
|
1241
1300
|
if (this.isRendered) {
|
|
1242
1301
|
this.trigger(HostEvent.Navigate, path.substring(1));
|
|
1243
|
-
} else if (this.
|
|
1302
|
+
} else if (this.getPreRenderConfig().preRenderId) {
|
|
1244
1303
|
this.preRender(true);
|
|
1245
1304
|
} else {
|
|
1246
1305
|
this.render();
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -77,6 +77,37 @@ describe('Search embed tests', () => {
|
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
test('getUpdateEmbedParamsObject sends dataSources as a real ARRAY, not the URL-encoded string', async () => {
|
|
81
|
+
// The iframe URL correctly carries dataSources as a JSON-encoded
|
|
82
|
+
// string (asserted above), but the UpdateEmbedParams postMessage
|
|
83
|
+
// payload is spread into app state unparsed — a string there reaches
|
|
84
|
+
// the $sources GraphQL variable ([GUID!]) and fails GUID coercion
|
|
85
|
+
// (SCAL-334713, fired from beforePrerenderVisible on prerender-show).
|
|
86
|
+
const dataSources = ['4dd30af7-9ed7-4847-8f28-b65b44a841d8'];
|
|
87
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
88
|
+
...defaultViewConfig,
|
|
89
|
+
dataSources,
|
|
90
|
+
});
|
|
91
|
+
const params = await (searchEmbed as any).getUpdateEmbedParamsObject();
|
|
92
|
+
expect(params.dataSources).toEqual(dataSources);
|
|
93
|
+
|
|
94
|
+
// Single-GUID `dataSource` prop (the customer's shape) normalizes to
|
|
95
|
+
// a one-element array the same way the app's URL parser would.
|
|
96
|
+
const singleSourceEmbed = new SearchEmbed(getRootEl(), {
|
|
97
|
+
...defaultViewConfig,
|
|
98
|
+
dataSource: '4dd30af7-9ed7-4847-8f28-b65b44a841d8',
|
|
99
|
+
});
|
|
100
|
+
const singleParams = await (singleSourceEmbed as any).getUpdateEmbedParamsObject();
|
|
101
|
+
expect(singleParams.dataSources).toEqual([
|
|
102
|
+
'4dd30af7-9ed7-4847-8f28-b65b44a841d8',
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
// The normalization only reverses JSON serialization: non-JSON
|
|
106
|
+
// strings and already-structured values pass through untouched.
|
|
107
|
+
expect(singleParams.embedApp).toBe(true);
|
|
108
|
+
expect(singleParams.authType).toBe('None');
|
|
109
|
+
});
|
|
110
|
+
|
|
80
111
|
test('should pass in search query', async () => {
|
|
81
112
|
const dataSources = ['data-source-1'];
|
|
82
113
|
const searchOptions = {
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
resolveEnablePastConversationsSidebar,
|
|
3
3
|
buildSpotterSidebarAppInitData,
|
|
4
4
|
buildSpotterShareConversationAppInitData,
|
|
5
|
+
buildStarterPromptsAppInitData,
|
|
5
6
|
} from './spotter-utils';
|
|
6
7
|
import { ErrorDetailsTypes, EmbedErrorCodes } from '../types';
|
|
7
8
|
import { ERROR_MESSAGE } from '../errors';
|
|
@@ -173,3 +174,74 @@ describe('buildSpotterShareConversationAppInitData', () => {
|
|
|
173
174
|
expect(result.embedParams?.spotterShareConversationConfig?.enableShareConversation).toBe(true);
|
|
174
175
|
});
|
|
175
176
|
});
|
|
177
|
+
|
|
178
|
+
describe('buildStarterPromptsAppInitData', () => {
|
|
179
|
+
const base = { type: 'APP_INIT' } as any;
|
|
180
|
+
|
|
181
|
+
it('returns the payload unchanged when starterPrompts is absent', () => {
|
|
182
|
+
expect(buildStarterPromptsAppInitData(base, {})).toBe(base);
|
|
183
|
+
expect(buildStarterPromptsAppInitData(base, { spotterChatConfig: {} })).toBe(base);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('nests starterPrompts under embedParams', () => {
|
|
187
|
+
const result = buildStarterPromptsAppInitData(base, {
|
|
188
|
+
spotterChatConfig: { starterPrompts: { quick: { label: 'Quick' } } },
|
|
189
|
+
});
|
|
190
|
+
expect(result.embedParams?.starterPrompts).toEqual({ quick: { label: 'Quick' } });
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('forwards the enable feature flag', () => {
|
|
194
|
+
const enabled = buildStarterPromptsAppInitData(base, {
|
|
195
|
+
spotterChatConfig: { starterPrompts: { enable: true, quick: { label: 'Quick' } } },
|
|
196
|
+
});
|
|
197
|
+
expect(enabled.embedParams?.starterPrompts).toEqual({ enable: true, quick: { label: 'Quick' } });
|
|
198
|
+
|
|
199
|
+
const disabled = buildStarterPromptsAppInitData(base, {
|
|
200
|
+
spotterChatConfig: { starterPrompts: { enable: false } },
|
|
201
|
+
});
|
|
202
|
+
expect(disabled.embedParams?.starterPrompts).toEqual({ enable: false });
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('preserves existing embedParams keys', () => {
|
|
206
|
+
const withExisting = {
|
|
207
|
+
...base,
|
|
208
|
+
embedParams: { spotterSidebarConfig: { enablePastConversationsSidebar: true } },
|
|
209
|
+
} as any;
|
|
210
|
+
const result = buildStarterPromptsAppInitData(withExisting, {
|
|
211
|
+
spotterChatConfig: { starterPrompts: { quick: { label: 'Quick' } } },
|
|
212
|
+
});
|
|
213
|
+
expect(result.embedParams?.spotterSidebarConfig).toEqual({ enablePastConversationsSidebar: true });
|
|
214
|
+
expect(result.embedParams?.starterPrompts).toEqual({ quick: { label: 'Quick' } });
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('forwards every category as configured', () => {
|
|
218
|
+
const starterPrompts = {
|
|
219
|
+
enable: true,
|
|
220
|
+
quick: {
|
|
221
|
+
label: 'Quick',
|
|
222
|
+
questions: Array.from({ length: 6 }, (_, i) => ({
|
|
223
|
+
label: `q${i}`,
|
|
224
|
+
prompt: `prompt ${i}`,
|
|
225
|
+
})),
|
|
226
|
+
},
|
|
227
|
+
research: { label: 'Research', questions: [{ prompt: 'Why did revenue drop?' }] },
|
|
228
|
+
previewData: { label: 'Explore' },
|
|
229
|
+
liveboard: [
|
|
230
|
+
{ label: 'Top products', prompt: 'What are the top products by revenue?' },
|
|
231
|
+
{ prompt: 'How did revenue trend last quarter?' },
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
const result = buildStarterPromptsAppInitData(base, {
|
|
235
|
+
spotterChatConfig: { starterPrompts },
|
|
236
|
+
});
|
|
237
|
+
expect(result.embedParams?.starterPrompts).toEqual(starterPrompts);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('forwards the liveboard questions on their own', () => {
|
|
241
|
+
const liveboard = [{ label: 'Top products', prompt: 'What are the top products by revenue?' }];
|
|
242
|
+
const result = buildStarterPromptsAppInitData(base, {
|
|
243
|
+
spotterChatConfig: { starterPrompts: { enable: true, liveboard } },
|
|
244
|
+
});
|
|
245
|
+
expect(result.embedParams?.starterPrompts).toEqual({ enable: true, liveboard });
|
|
246
|
+
});
|
|
247
|
+
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { DefaultAppInitData, ErrorDetailsTypes, EmbedErrorCodes } from '../types';
|
|
2
2
|
import { validateHttpUrl } from '../utils';
|
|
3
3
|
import { ERROR_MESSAGE } from '../errors';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
SpotterSidebarViewConfig,
|
|
6
|
+
SpotterShareConversationConfig,
|
|
7
|
+
SpotterChatViewConfig,
|
|
8
|
+
StarterPromptsConfig,
|
|
9
|
+
} from './conversation';
|
|
5
10
|
import type { VisualizationOverrides } from '../types';
|
|
6
11
|
|
|
7
12
|
/**
|
|
@@ -94,3 +99,18 @@ export function buildSpotterShareConversationAppInitData<T extends DefaultAppIni
|
|
|
94
99
|
},
|
|
95
100
|
};
|
|
96
101
|
}
|
|
102
|
+
|
|
103
|
+
export function buildStarterPromptsAppInitData<T extends DefaultAppInitData>(
|
|
104
|
+
initData: T,
|
|
105
|
+
viewConfig: { spotterChatConfig?: SpotterChatViewConfig },
|
|
106
|
+
): T & { embedParams?: { starterPrompts?: StarterPromptsConfig } } {
|
|
107
|
+
const starterPrompts = viewConfig.spotterChatConfig?.starterPrompts;
|
|
108
|
+
if (!starterPrompts) return initData;
|
|
109
|
+
return {
|
|
110
|
+
...initData,
|
|
111
|
+
embedParams: {
|
|
112
|
+
...((initData as T & { embedParams?: Record<string, unknown> }).embedParams || {}),
|
|
113
|
+
starterPrompts,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -32,13 +32,12 @@ export interface SpotterVizStarterPrompt {
|
|
|
32
32
|
* customStarterPrompts: [
|
|
33
33
|
* { id: '1', displayText: 'Top products', fullPrompt: 'What are the top products by revenue?' }
|
|
34
34
|
* ],
|
|
35
|
-
* //
|
|
35
|
+
* // The options below require SDK: 1.51.0
|
|
36
36
|
* loaderHeadline: 'Crunching the numbers...',
|
|
37
37
|
* loaderTips: [
|
|
38
38
|
* { label: 'Tip', text: 'try asking about revenue by region' },
|
|
39
39
|
* { label: 'Tip', text: 'use natural language' },
|
|
40
40
|
* ],
|
|
41
|
-
* // liveboardBrandName, spotterBrandName, insightTileBrandName, insightTileViewPlanLabel and insightTileLoaderText require SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl
|
|
42
41
|
* liveboardBrandName: 'Reports',
|
|
43
42
|
* spotterBrandName: 'Analyst',
|
|
44
43
|
* insightTileBrandName: 'Insight card',
|
|
@@ -91,48 +90,48 @@ export interface SpotterVizConfig {
|
|
|
91
90
|
/**
|
|
92
91
|
* Custom headline text shown in the SpotterViz loading state.
|
|
93
92
|
* Replaces the default loading headline.
|
|
94
|
-
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.
|
|
93
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
95
94
|
*/
|
|
96
95
|
loaderHeadline?: string;
|
|
97
96
|
/**
|
|
98
97
|
* Custom tips shown in the SpotterViz loading state.
|
|
99
98
|
* Replaces the default loading tips with the provided list.
|
|
100
|
-
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.
|
|
99
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
101
100
|
*/
|
|
102
101
|
loaderTips?: SpotterVizLoaderTip[];
|
|
103
102
|
/**
|
|
104
103
|
* Custom term used to replace "Liveboard" in the agent's responses.
|
|
105
|
-
* @version SDK: 1.
|
|
104
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
106
105
|
* @default ''
|
|
107
106
|
*/
|
|
108
107
|
liveboardBrandName?: string;
|
|
109
108
|
/**
|
|
110
109
|
* Custom term used to replace "Spotter" in the agent's responses.
|
|
111
|
-
* @version SDK: 1.
|
|
110
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
112
111
|
* @default ''
|
|
113
112
|
*/
|
|
114
113
|
spotterBrandName?: string;
|
|
115
114
|
/**
|
|
116
115
|
* Custom term used to replace "Insight tile" in the UI and in the agent's responses.
|
|
117
|
-
* @version SDK: 1.
|
|
116
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
118
117
|
* @default ''
|
|
119
118
|
*/
|
|
120
119
|
insightTileBrandName?: string;
|
|
121
120
|
/**
|
|
122
121
|
* Custom term used to replace "View plan" in the insight tile menu.
|
|
123
|
-
* @version SDK: 1.
|
|
122
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
124
123
|
*/
|
|
125
124
|
insightTileViewPlanLabel?: string;
|
|
126
125
|
/**
|
|
127
126
|
* Custom loader text shown on the insight tile.
|
|
128
|
-
* @version SDK: 1.
|
|
127
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
129
128
|
*/
|
|
130
129
|
insightTileLoaderText?: string;
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
/**
|
|
134
133
|
* A single tip shown in the SpotterViz loading state.
|
|
135
|
-
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.
|
|
134
|
+
* @version SDK: 1.51.0 | ThoughtSpot Cloud: 26.7.0.cl
|
|
136
135
|
* @group Embed components
|
|
137
136
|
*/
|
|
138
137
|
export interface SpotterVizLoaderTip {
|