@thoughtspot/visual-embed-sdk 1.50.1 → 1.51.0-test
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 +63 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +148 -25
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +74 -37
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +571 -150
- 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 +375 -2
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +21 -15
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +323 -17
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +45 -0
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/host-events.spec.js +81 -0
- package/cjs/src/embed/host-events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +15 -0
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js +1 -0
- package/cjs/src/embed/hostEventClient/contracts.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.js +1 -0
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +27 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +76 -14
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +50 -9
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +432 -4
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/spotter-utils.d.ts +15 -1
- package/cjs/src/embed/spotter-utils.d.ts.map +1 -1
- package/cjs/src/embed/spotter-utils.js +28 -1
- package/cjs/src/embed/spotter-utils.js.map +1 -1
- package/cjs/src/embed/spotter-utils.spec.js +129 -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 +16 -8
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +82 -30
- 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/mixpanel-service.d.ts +4 -0
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +4 -0
- package/cjs/src/mixpanel-service.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 +789 -32
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +610 -20
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils.spec.js +4 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-fCne7kmU.js → index-Bivg-mDx.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 +63 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +148 -25
- 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 +375 -2
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +15 -0
- package/dist/src/embed/hostEventClient/contracts.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 +76 -14
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/spotter-utils.d.ts +15 -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 +16 -8
- 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/mixpanel-service.d.ts +4 -0
- package/dist/src/mixpanel-service.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 +789 -32
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +878 -120
- package/dist/tsembed-react.js +877 -119
- package/dist/tsembed.es.js +936 -181
- package/dist/tsembed.js +938 -183
- package/dist/visual-embed-sdk-react-full.d.ts +1553 -128
- package/dist/visual-embed-sdk-react.d.ts +1555 -129
- package/dist/visual-embed-sdk.d.ts +1499 -100
- 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 +63 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +148 -25
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +75 -38
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +572 -151
- 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 +375 -2
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +23 -17
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +323 -17
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +45 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/host-events.spec.js +81 -0
- package/lib/src/embed/host-events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +15 -0
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js +1 -0
- package/lib/src/embed/hostEventClient/contracts.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.js +1 -0
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +27 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +76 -14
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +50 -9
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +432 -4
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/spotter-utils.d.ts +15 -1
- package/lib/src/embed/spotter-utils.d.ts.map +1 -1
- package/lib/src/embed/spotter-utils.js +25 -0
- package/lib/src/embed/spotter-utils.js.map +1 -1
- package/lib/src/embed/spotter-utils.spec.js +130 -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 +16 -8
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +82 -30
- 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/mixpanel-service.d.ts +4 -0
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +4 -0
- package/lib/src/mixpanel-service.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 +789 -32
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +610 -20
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.spec.js +4 -0
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +1499 -100
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/css-variables.ts +77 -0
- package/src/embed/app.spec.ts +729 -188
- package/src/embed/app.ts +240 -75
- package/src/embed/base.ts +1 -1
- package/src/embed/conversation.spec.ts +379 -20
- package/src/embed/conversation.ts +412 -18
- package/src/embed/events.spec.ts +56 -0
- package/src/embed/host-events.spec.ts +118 -0
- package/src/embed/hostEventClient/contracts.ts +16 -0
- package/src/embed/hostEventClient/host-event-client.spec.ts +46 -0
- package/src/embed/hostEventClient/host-event-client.ts +3 -2
- package/src/embed/liveboard.spec.ts +565 -4
- package/src/embed/liveboard.ts +150 -29
- package/src/embed/spotter-utils.spec.ts +140 -1
- package/src/embed/spotter-utils.ts +36 -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 +99 -35
- package/src/index.ts +44 -2
- package/src/mixpanel-service.ts +4 -0
- 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 +791 -30
- package/src/utils.spec.ts +5 -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
|
|
@@ -402,11 +410,12 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
402
410
|
/**
|
|
403
411
|
* Enables the 'what you see is what you get' PDF export for Liveboards. Each tab is rendered on a single page
|
|
404
412
|
* following the exact UI layout, instead of splitting visualizations across multiple A4 pages.
|
|
405
|
-
* This feature is GA from version
|
|
413
|
+
* This feature is GA from SDK version 1.51.0 and ThoughtSpot version 26.8.0.cl.
|
|
406
414
|
*
|
|
407
415
|
* Supported embed types: `AppEmbed`, `LiveboardEmbed`
|
|
408
416
|
* @type {boolean}
|
|
409
417
|
* @version SDK: 1.48.0 | ThoughtSpot: 26.5.0.cl
|
|
418
|
+
* @default true
|
|
410
419
|
* @example
|
|
411
420
|
* ```js
|
|
412
421
|
* // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
|
|
@@ -419,10 +428,12 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
419
428
|
isContinuousLiveboardPDFEnabled?: boolean;
|
|
420
429
|
/**
|
|
421
430
|
* This flag is used to enable/disable the XLSX/CSV download option for Liveboards
|
|
431
|
+
* This feature is GA from SDK version 1.51.0 and ThoughtSpot version 26.6.0.cl.
|
|
422
432
|
*
|
|
423
433
|
* Supported embed types: `AppEmbed`, `LiveboardEmbed`
|
|
424
434
|
* @type {boolean}
|
|
425
435
|
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
436
|
+
* @default true
|
|
426
437
|
* @example
|
|
427
438
|
* ```js
|
|
428
439
|
* // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
|
|
@@ -435,10 +446,12 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
435
446
|
isLiveboardXLSXCSVDownloadEnabled?: boolean;
|
|
436
447
|
/**
|
|
437
448
|
* This flag is used to enable/disable the granular XLSX/CSV schedules feature
|
|
449
|
+
* This feature is GA from SDK version 1.51.0 and ThoughtSpot version 26.6.0.cl.
|
|
438
450
|
*
|
|
439
451
|
* Supported embed types: `AppEmbed`, `LiveboardEmbed`
|
|
440
452
|
* @type {boolean}
|
|
441
453
|
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
454
|
+
* @default true
|
|
442
455
|
* @example
|
|
443
456
|
* ```js
|
|
444
457
|
* // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
|
|
@@ -450,11 +463,17 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
450
463
|
*/
|
|
451
464
|
isGranularXLSXCSVSchedulesEnabled?: boolean;
|
|
452
465
|
/**
|
|
453
|
-
*
|
|
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.
|
|
454
473
|
*
|
|
455
474
|
* @type {boolean}
|
|
456
475
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
|
|
457
|
-
* @default
|
|
476
|
+
* @default true when `fullHeight` is enabled, from SDK 1.52.0
|
|
458
477
|
* @example
|
|
459
478
|
* ```js
|
|
460
479
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -466,26 +485,42 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
466
485
|
*/
|
|
467
486
|
lazyLoadingForFullHeight?: boolean;
|
|
468
487
|
/**
|
|
469
|
-
*
|
|
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.
|
|
470
491
|
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
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.
|
|
473
497
|
*
|
|
474
498
|
* @type {boolean}
|
|
475
|
-
* @default
|
|
499
|
+
* @default true when `fullHeight` is enabled, from SDK 1.52.0
|
|
476
500
|
*/
|
|
477
501
|
enableScrollableContainerLazyLoading?: boolean;
|
|
478
502
|
/**
|
|
479
|
-
*
|
|
503
|
+
* How far outside the viewport a visualization starts loading, when
|
|
504
|
+
* {@link lazyLoadingForFullHeight} is enabled.
|
|
480
505
|
*
|
|
481
506
|
* For example, if the margin is set to '10px',
|
|
482
507
|
* the visualization will be loaded 10px before its top edge is visible in the
|
|
483
508
|
* viewport.
|
|
484
509
|
*
|
|
485
|
-
* 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.
|
|
486
520
|
*
|
|
487
521
|
* @type {string}
|
|
488
522
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
|
|
523
|
+
* @default '500px 0px' when `fullHeight` is enabled, from SDK 1.52.0
|
|
489
524
|
* @example
|
|
490
525
|
* ```js
|
|
491
526
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -529,6 +564,21 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
529
564
|
* ```
|
|
530
565
|
*/
|
|
531
566
|
updatedSpotterChatPrompt?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* showSpotterRadiance : Controls the radiance on the Spotter page.
|
|
569
|
+
*
|
|
570
|
+
* Supported embed types: `LiveboardEmbed`
|
|
571
|
+
* @version SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl
|
|
572
|
+
* @default false
|
|
573
|
+
* @example
|
|
574
|
+
* ```js
|
|
575
|
+
* const embed = new LiveboardEmbed('#tsEmbed', {
|
|
576
|
+
* ... //other embed view config
|
|
577
|
+
* showSpotterRadiance : true,
|
|
578
|
+
* })
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
showSpotterRadiance?: boolean;
|
|
532
582
|
/**
|
|
533
583
|
* Enables the stop answer generation button in the Spotter embed UI,
|
|
534
584
|
* allowing users to interrupt an ongoing answer generation.
|
|
@@ -574,13 +624,12 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
574
624
|
* inputChatPlaceholder: 'Ask a question...',
|
|
575
625
|
* hideStarterPrompts: false,
|
|
576
626
|
* customStarterPrompts: [{ id: '1', displayText: 'Top products', fullPrompt: 'What are the top products by revenue?' }],
|
|
577
|
-
* //
|
|
627
|
+
* // The options below require SDK: 1.51.0
|
|
578
628
|
* loaderHeadline: 'Crunching the numbers...',
|
|
579
629
|
* loaderTips: [
|
|
580
630
|
* { label: 'Tip', text: 'try asking about revenue by region' },
|
|
581
631
|
* { label: 'Tip', text: 'use natural language' },
|
|
582
632
|
* ],
|
|
583
|
-
* // liveboardBrandName, spotterBrandName, insightTileBrandName, insightTileViewPlanLabel and insightTileLoaderText require SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl
|
|
584
633
|
* liveboardBrandName: 'Reports',
|
|
585
634
|
* spotterBrandName: 'Analyst',
|
|
586
635
|
* insightTileBrandName: 'Insight card',
|
|
@@ -604,6 +653,21 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
604
653
|
* ```
|
|
605
654
|
*/
|
|
606
655
|
enableLiveboardDataCache?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* updatedSpotterExperience : Controls the updated Spotter experience.
|
|
658
|
+
*
|
|
659
|
+
* Supported embed types: `LiveboardEmbed`
|
|
660
|
+
* @version SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl
|
|
661
|
+
* @default false
|
|
662
|
+
* @example
|
|
663
|
+
* ```js
|
|
664
|
+
* const embed = new LiveboardEmbed('#tsEmbed', {
|
|
665
|
+
* ... //other embed view config
|
|
666
|
+
* updatedSpotterExperience : true,
|
|
667
|
+
* })
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
updatedSpotterExperience?: boolean;
|
|
607
671
|
}
|
|
608
672
|
|
|
609
673
|
/**
|
|
@@ -640,6 +704,16 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
640
704
|
'Using full height with vizId might lead to unexpected behavior.');
|
|
641
705
|
}
|
|
642
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
|
+
|
|
643
717
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
|
644
718
|
this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
|
|
645
719
|
this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
|
|
@@ -649,7 +723,8 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
649
723
|
|
|
650
724
|
protected async getAppInitData(): Promise<LiveboardEmbedAppInitData> {
|
|
651
725
|
const defaultAppInitData = await super.getAppInitData();
|
|
652
|
-
|
|
726
|
+
const vizInitData = buildSpotterVizAppInitData(defaultAppInitData, this.viewConfig);
|
|
727
|
+
return buildStarterPromptsAppInitData(vizInitData, this.viewConfig);
|
|
653
728
|
}
|
|
654
729
|
|
|
655
730
|
/**
|
|
@@ -679,34 +754,39 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
679
754
|
showLiveboardDescription,
|
|
680
755
|
showLiveboardTitle,
|
|
681
756
|
isLiveboardHeaderSticky = true,
|
|
682
|
-
isLiveboardCompactHeaderEnabled
|
|
757
|
+
isLiveboardCompactHeaderEnabled,
|
|
683
758
|
showLiveboardVerifiedBadge = true,
|
|
684
759
|
showLiveboardReverifyBanner = true,
|
|
685
|
-
hideIrrelevantChipsInLiveboardTabs
|
|
760
|
+
hideIrrelevantChipsInLiveboardTabs,
|
|
686
761
|
showMaskedFilterChip = false,
|
|
687
|
-
isLiveboardMasterpiecesEnabled
|
|
762
|
+
isLiveboardMasterpiecesEnabled,
|
|
688
763
|
newChartsLibrary,
|
|
689
|
-
isEnhancedFilterInteractivityEnabled
|
|
764
|
+
isEnhancedFilterInteractivityEnabled,
|
|
690
765
|
enableAskSage,
|
|
691
766
|
enable2ColumnLayout,
|
|
767
|
+
isLiveboardAlwaysOn12ColLayout,
|
|
692
768
|
dataPanelV2 = true,
|
|
769
|
+
updatedSpotterExperience,
|
|
693
770
|
enableCustomColumnGroups = false,
|
|
694
771
|
oAuthPollingInterval,
|
|
695
772
|
isForceRedirect,
|
|
696
773
|
dataSourceId,
|
|
697
|
-
coverAndFilterOptionInPDF
|
|
774
|
+
coverAndFilterOptionInPDF,
|
|
698
775
|
isLiveboardStylingAndGroupingEnabled,
|
|
776
|
+
liveboardGutter,
|
|
699
777
|
isPNGInScheduledEmailsEnabled = false,
|
|
700
|
-
isLiveboardXLSXCSVDownloadEnabled
|
|
701
|
-
isGranularXLSXCSVSchedulesEnabled
|
|
778
|
+
isLiveboardXLSXCSVDownloadEnabled,
|
|
779
|
+
isGranularXLSXCSVSchedulesEnabled,
|
|
702
780
|
showSpotterLimitations,
|
|
703
781
|
isCentralizedLiveboardFilterUXEnabled = false,
|
|
782
|
+
isScopedLiveboardFilteringEnabled,
|
|
704
783
|
isLinkParametersEnabled,
|
|
705
784
|
updatedSpotterChatPrompt,
|
|
785
|
+
showSpotterRadiance,
|
|
706
786
|
enableStopAnswerGenerationEmbed,
|
|
707
787
|
spotterChatConfig,
|
|
708
788
|
isThisPeriodInDateFiltersEnabled,
|
|
709
|
-
isContinuousLiveboardPDFEnabled
|
|
789
|
+
isContinuousLiveboardPDFEnabled,
|
|
710
790
|
enableLiveboardDataCache,
|
|
711
791
|
} = this.viewConfig;
|
|
712
792
|
|
|
@@ -732,6 +812,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
732
812
|
if (!isUndefined(updatedSpotterChatPrompt)) {
|
|
733
813
|
params[Param.UpdatedSpotterChatPrompt] = !!updatedSpotterChatPrompt;
|
|
734
814
|
}
|
|
815
|
+
if (!isUndefined(showSpotterRadiance)) {
|
|
816
|
+
params[Param.ShowSpotterRadiance] = !!showSpotterRadiance;
|
|
817
|
+
}
|
|
735
818
|
if (!isUndefined(enableStopAnswerGenerationEmbed)) {
|
|
736
819
|
params[Param.EnableStopAnswerGenerationEmbed] = !!enableStopAnswerGenerationEmbed;
|
|
737
820
|
}
|
|
@@ -748,6 +831,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
748
831
|
if (enable2ColumnLayout !== undefined) {
|
|
749
832
|
params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
|
|
750
833
|
}
|
|
834
|
+
if (isLiveboardAlwaysOn12ColLayout !== undefined) {
|
|
835
|
+
params[Param.IsLiveboardAlwaysOn12ColLayout] = isLiveboardAlwaysOn12ColLayout;
|
|
836
|
+
}
|
|
751
837
|
if (hideTabPanel) {
|
|
752
838
|
params[Param.HideTabPanel] = hideTabPanel;
|
|
753
839
|
}
|
|
@@ -780,6 +866,10 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
780
866
|
params[Param.IsLiveboardStylingAndGroupingEnabled] = isLiveboardStylingAndGroupingEnabled;
|
|
781
867
|
}
|
|
782
868
|
|
|
869
|
+
if (liveboardGutter !== undefined) {
|
|
870
|
+
params[Param.LiveboardGutter] = liveboardGutter;
|
|
871
|
+
}
|
|
872
|
+
|
|
783
873
|
if (isPNGInScheduledEmailsEnabled !== undefined) {
|
|
784
874
|
params[Param.isPNGInScheduledEmailsEnabled] = isPNGInScheduledEmailsEnabled;
|
|
785
875
|
}
|
|
@@ -796,6 +886,10 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
796
886
|
params[Param.ShowSpotterLimitations] = showSpotterLimitations;
|
|
797
887
|
}
|
|
798
888
|
|
|
889
|
+
if (!isUndefined(updatedSpotterExperience)) {
|
|
890
|
+
params[Param.UpdatedSpotterExperience] = !!updatedSpotterExperience;
|
|
891
|
+
}
|
|
892
|
+
|
|
799
893
|
// Handle spotterChatConfig params
|
|
800
894
|
if (spotterChatConfig) {
|
|
801
895
|
const {
|
|
@@ -804,6 +898,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
804
898
|
spotterFileUploadEnabled,
|
|
805
899
|
spotterFileUploadFileTypes,
|
|
806
900
|
enableStarterPrompts,
|
|
901
|
+
openSpotterOnLiveboardByDefault,
|
|
807
902
|
} = spotterChatConfig;
|
|
808
903
|
|
|
809
904
|
setParamIfDefined(params, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
|
|
@@ -814,6 +909,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
814
909
|
if (enableStarterPrompts !== undefined) {
|
|
815
910
|
params[Param.IsStarterPromptsEnabled] = enableStarterPrompts;
|
|
816
911
|
}
|
|
912
|
+
if (openSpotterOnLiveboardByDefault !== undefined) {
|
|
913
|
+
params[Param.OpenSpotterOnLiveboardByDefault] = openSpotterOnLiveboardByDefault;
|
|
914
|
+
}
|
|
817
915
|
if (spotterFileUploadFileTypes !== undefined) {
|
|
818
916
|
params[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
|
|
819
917
|
}
|
|
@@ -829,6 +927,12 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
829
927
|
] = isCentralizedLiveboardFilterUXEnabled;
|
|
830
928
|
}
|
|
831
929
|
|
|
930
|
+
if (isScopedLiveboardFilteringEnabled !== undefined) {
|
|
931
|
+
params[
|
|
932
|
+
Param.isScopedLiveboardFilteringEnabled
|
|
933
|
+
] = isScopedLiveboardFilteringEnabled;
|
|
934
|
+
}
|
|
935
|
+
|
|
832
936
|
if (isThisPeriodInDateFiltersEnabled !== undefined) {
|
|
833
937
|
params[Param.IsThisPeriodInDateFiltersEnabled] = isThisPeriodInDateFiltersEnabled;
|
|
834
938
|
}
|
|
@@ -846,16 +950,27 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
846
950
|
}
|
|
847
951
|
|
|
848
952
|
params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
|
|
849
|
-
|
|
953
|
+
if (!isUndefined(isLiveboardCompactHeaderEnabled)) {
|
|
954
|
+
params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
|
|
955
|
+
}
|
|
850
956
|
params[Param.ShowLiveboardVerifiedBadge] = showLiveboardVerifiedBadge;
|
|
851
957
|
params[Param.ShowLiveboardReverifyBanner] = showLiveboardReverifyBanner;
|
|
852
|
-
|
|
958
|
+
if (!isUndefined(hideIrrelevantChipsInLiveboardTabs)) {
|
|
959
|
+
params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
|
|
960
|
+
}
|
|
853
961
|
params[Param.ShowMaskedFilterChip] = showMaskedFilterChip;
|
|
854
|
-
|
|
855
|
-
|
|
962
|
+
if (!isUndefined(isLiveboardMasterpiecesEnabled)) {
|
|
963
|
+
params[Param.IsLiveboardMasterpiecesEnabled] = isLiveboardMasterpiecesEnabled;
|
|
964
|
+
}
|
|
965
|
+
if (!isUndefined(isEnhancedFilterInteractivityEnabled)) {
|
|
966
|
+
params[Param.IsEnhancedFilterInteractivityEnabled] =
|
|
967
|
+
isEnhancedFilterInteractivityEnabled;
|
|
968
|
+
}
|
|
856
969
|
params[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
857
970
|
params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
858
|
-
|
|
971
|
+
if (!isUndefined(coverAndFilterOptionInPDF)) {
|
|
972
|
+
params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
|
|
973
|
+
}
|
|
859
974
|
|
|
860
975
|
const queryParams = getQueryParamString(params, true);
|
|
861
976
|
|
|
@@ -1079,7 +1194,13 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1079
1194
|
* @param {any} data The payload to send with the message
|
|
1080
1195
|
* @returns A promise that resolves with the response from the embedded app
|
|
1081
1196
|
*/
|
|
1082
|
-
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
|
+
>(
|
|
1083
1204
|
messageType: HostEventT,
|
|
1084
1205
|
data: TriggerPayload<PayloadT, HostEventT> = ({} as any),
|
|
1085
1206
|
context?: ContextT,
|
|
@@ -1178,7 +1299,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1178
1299
|
this.viewConfig.personalizedViewId = personalizedViewId;
|
|
1179
1300
|
if (this.isRendered) {
|
|
1180
1301
|
this.trigger(HostEvent.Navigate, path.substring(1));
|
|
1181
|
-
} else if (this.
|
|
1302
|
+
} else if (this.getPreRenderConfig().preRenderId) {
|
|
1182
1303
|
this.preRender(true);
|
|
1183
1304
|
} else {
|
|
1184
1305
|
this.render();
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
resolveEnablePastConversationsSidebar,
|
|
3
|
+
buildSpotterSidebarAppInitData,
|
|
4
|
+
buildSpotterShareConversationAppInitData,
|
|
5
|
+
buildStarterPromptsAppInitData,
|
|
6
|
+
} from './spotter-utils';
|
|
2
7
|
import { ErrorDetailsTypes, EmbedErrorCodes } from '../types';
|
|
3
8
|
import { ERROR_MESSAGE } from '../errors';
|
|
4
9
|
|
|
@@ -36,6 +41,22 @@ describe('buildSpotterSidebarAppInitData', () => {
|
|
|
36
41
|
});
|
|
37
42
|
});
|
|
38
43
|
|
|
44
|
+
it('forwards a nested spotterChatPinConfig object through untouched', () => {
|
|
45
|
+
const spotterChatPinConfig = {
|
|
46
|
+
enabled: true,
|
|
47
|
+
pinLabel: 'Pin to top',
|
|
48
|
+
unpinLabel: 'Unpin',
|
|
49
|
+
};
|
|
50
|
+
const result = buildSpotterSidebarAppInitData(base, {
|
|
51
|
+
spotterSidebarConfig: {
|
|
52
|
+
enablePastConversationsSidebar: true,
|
|
53
|
+
spotterChatPinConfig,
|
|
54
|
+
},
|
|
55
|
+
}, noopError);
|
|
56
|
+
expect(result.embedParams?.spotterSidebarConfig?.spotterChatPinConfig)
|
|
57
|
+
.toEqual(spotterChatPinConfig);
|
|
58
|
+
});
|
|
59
|
+
|
|
39
60
|
it('promotes standalone flag into spotterSidebarConfig.enablePastConversationsSidebar', () => {
|
|
40
61
|
const result = buildSpotterSidebarAppInitData(base, { enablePastConversationsSidebar: true }, noopError);
|
|
41
62
|
expect(result.embedParams?.spotterSidebarConfig?.enablePastConversationsSidebar).toBe(true);
|
|
@@ -106,3 +127,121 @@ describe('buildSpotterSidebarAppInitData', () => {
|
|
|
106
127
|
expect(result.embedParams?.spotterSidebarConfig?.enablePastConversationsSidebar).toBe(true);
|
|
107
128
|
});
|
|
108
129
|
});
|
|
130
|
+
|
|
131
|
+
describe('buildSpotterShareConversationAppInitData', () => {
|
|
132
|
+
const base = { type: 'APP_INIT' } as any;
|
|
133
|
+
|
|
134
|
+
it('returns base unchanged when no spotterShareConversationConfig', () => {
|
|
135
|
+
const result = buildSpotterShareConversationAppInitData(base, {});
|
|
136
|
+
expect(result).toBe(base);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('nests spotterShareConversationConfig under embedParams', () => {
|
|
140
|
+
const result = buildSpotterShareConversationAppInitData(base, {
|
|
141
|
+
spotterShareConversationConfig: { enableShareConversation: true },
|
|
142
|
+
});
|
|
143
|
+
expect(result.embedParams?.spotterShareConversationConfig).toEqual({
|
|
144
|
+
enableShareConversation: true,
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('passes label override fields through untouched', () => {
|
|
149
|
+
const spotterShareConversationConfig = {
|
|
150
|
+
enableShareConversation: true,
|
|
151
|
+
spotterShareLabel: 'Share',
|
|
152
|
+
spotterShareModalTitle: 'Share conversation',
|
|
153
|
+
spotterShareConfirmLabel: 'Share',
|
|
154
|
+
spotterShareCancelLabel: 'Cancel',
|
|
155
|
+
spotterShareAddUsersLabel: 'Add users or groups',
|
|
156
|
+
spotterShareEmptyTitle: 'No users added yet',
|
|
157
|
+
spotterShareEmptySubtitle: 'Not shared with any user',
|
|
158
|
+
spotterShareIncludeNewMessagesLabel: 'Include new messages',
|
|
159
|
+
spotterShareUpToCurrentLabel: 'Share up to current moment',
|
|
160
|
+
spotterShareStaleInfoLabel: 'This snapshot may be stale',
|
|
161
|
+
};
|
|
162
|
+
const result = buildSpotterShareConversationAppInitData(base, {
|
|
163
|
+
spotterShareConversationConfig,
|
|
164
|
+
});
|
|
165
|
+
expect(result.embedParams?.spotterShareConversationConfig).toEqual(spotterShareConversationConfig);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('preserves existing embedParams when nesting the share config', () => {
|
|
169
|
+
const withParams = { type: 'APP_INIT', embedParams: { existing: 'keep' } } as any;
|
|
170
|
+
const result = buildSpotterShareConversationAppInitData(withParams, {
|
|
171
|
+
spotterShareConversationConfig: { enableShareConversation: true },
|
|
172
|
+
});
|
|
173
|
+
expect(result.embedParams?.existing).toBe('keep');
|
|
174
|
+
expect(result.embedParams?.spotterShareConversationConfig?.enableShareConversation).toBe(true);
|
|
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
|
/**
|
|
@@ -79,3 +84,33 @@ export function buildSpotterSidebarAppInitData<T extends DefaultAppInitData>(
|
|
|
79
84
|
},
|
|
80
85
|
};
|
|
81
86
|
}
|
|
87
|
+
|
|
88
|
+
export function buildSpotterShareConversationAppInitData<T extends DefaultAppInitData>(
|
|
89
|
+
initData: T,
|
|
90
|
+
viewConfig: { spotterShareConversationConfig?: SpotterShareConversationConfig },
|
|
91
|
+
): T & { embedParams?: { spotterShareConversationConfig?: SpotterShareConversationConfig } } {
|
|
92
|
+
const { spotterShareConversationConfig } = viewConfig;
|
|
93
|
+
if (!spotterShareConversationConfig) return initData;
|
|
94
|
+
return {
|
|
95
|
+
...initData,
|
|
96
|
+
embedParams: {
|
|
97
|
+
...((initData as T & { embedParams?: Record<string, unknown> }).embedParams || {}),
|
|
98
|
+
spotterShareConversationConfig,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
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
|
+
}
|