@thoughtspot/visual-embed-sdk 1.50.0 → 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 +122 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +176 -24
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +86 -38
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +672 -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 +401 -2
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +32 -16
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +346 -17
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +638 -0
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/host-events.spec.js +187 -0
- package/cjs/src/embed/host-events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +51 -14
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js +11 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +2 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +9 -0
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +236 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.d.ts +2 -0
- package/cjs/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.js +32 -2
- package/cjs/src/embed/hostEventClient/utils.js.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.spec.js +178 -0
- package/cjs/src/embed/hostEventClient/utils.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +81 -13
- 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 +37 -4
- 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/spotter-viz-utils.spec.js +17 -0
- package/cjs/src/embed/spotter-viz-utils.spec.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 +96 -37
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +683 -3
- package/cjs/src/embed/ts-embed.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 +3 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +4 -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/react/util.spec.js +251 -0
- package/cjs/src/react/util.spec.js.map +1 -1
- package/cjs/src/types.d.ts +902 -28
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +701 -14
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +93 -0
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/processTrigger.spec.js +61 -0
- package/cjs/src/utils/processTrigger.spec.js.map +1 -1
- package/cjs/src/utils.spec.js +4 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-B5xoN6Cp.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 +122 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +176 -24
- 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 +401 -2
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +51 -14
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +2 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/utils.d.ts +2 -0
- package/dist/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +81 -13
- 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 +37 -4
- 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/errors.d.ts +1 -0
- package/dist/src/errors.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 +902 -28
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1269 -206
- package/dist/tsembed-react.js +1268 -205
- package/dist/tsembed.es.js +1364 -304
- package/dist/tsembed.js +1362 -302
- package/dist/visual-embed-sdk-react-full.d.ts +1867 -157
- package/dist/visual-embed-sdk-react.d.ts +1872 -161
- package/dist/visual-embed-sdk.d.ts +1815 -127
- 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 +122 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +176 -24
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +87 -39
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +673 -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 +401 -2
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +33 -17
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +347 -18
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +638 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/host-events.spec.js +188 -1
- package/lib/src/embed/host-events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +51 -14
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js +10 -0
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +2 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +10 -1
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +236 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/utils.d.ts +2 -0
- package/lib/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/utils.js +28 -1
- package/lib/src/embed/hostEventClient/utils.js.map +1 -1
- package/lib/src/embed/hostEventClient/utils.spec.js +179 -1
- package/lib/src/embed/hostEventClient/utils.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +81 -13
- 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 +37 -4
- 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/spotter-viz-utils.spec.js +17 -0
- package/lib/src/embed/spotter-viz-utils.spec.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 +96 -37
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +683 -3
- package/lib/src/embed/ts-embed.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 +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +3 -3
- 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/react/util.spec.js +251 -0
- package/lib/src/react/util.spec.js.map +1 -1
- package/lib/src/types.d.ts +902 -28
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +701 -14
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processData.spec.js +93 -0
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js +61 -0
- package/lib/src/utils/processTrigger.spec.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 +1815 -127
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/css-variables.ts +150 -0
- package/src/embed/app.spec.ts +877 -196
- package/src/embed/app.ts +276 -75
- package/src/embed/base.ts +1 -1
- package/src/embed/conversation.spec.ts +411 -21
- package/src/embed/conversation.ts +441 -18
- package/src/embed/events.spec.ts +761 -1
- package/src/embed/host-events.spec.ts +242 -0
- package/src/embed/hostEventClient/contracts.ts +57 -14
- package/src/embed/hostEventClient/host-event-client.spec.ts +372 -0
- package/src/embed/hostEventClient/host-event-client.ts +18 -2
- package/src/embed/hostEventClient/utils.spec.ts +204 -0
- package/src/embed/hostEventClient/utils.ts +37 -10
- package/src/embed/liveboard.spec.ts +565 -4
- package/src/embed/liveboard.ts +155 -28
- package/src/embed/spotter-utils.spec.ts +140 -1
- package/src/embed/spotter-utils.ts +36 -1
- package/src/embed/spotter-viz-utils.spec.ts +17 -0
- package/src/embed/spotter-viz-utils.ts +37 -4
- package/src/embed/ts-embed.spec.ts +885 -3
- package/src/embed/ts-embed.ts +111 -39
- package/src/errors.ts +1 -0
- package/src/index.ts +45 -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/react/util.spec.tsx +255 -0
- package/src/types.ts +904 -24
- package/src/utils/processData.spec.ts +97 -0
- package/src/utils/processTrigger.spec.ts +91 -0
- 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,12 +624,17 @@ 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
|
* ],
|
|
633
|
+
* liveboardBrandName: 'Reports',
|
|
634
|
+
* spotterBrandName: 'Analyst',
|
|
635
|
+
* insightTileBrandName: 'Insight card',
|
|
636
|
+
* insightTileViewPlanLabel: 'View plan',
|
|
637
|
+
* insightTileLoaderText: 'Generating insight',
|
|
583
638
|
* },
|
|
584
639
|
* })
|
|
585
640
|
* ```
|
|
@@ -598,6 +653,21 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
598
653
|
* ```
|
|
599
654
|
*/
|
|
600
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;
|
|
601
671
|
}
|
|
602
672
|
|
|
603
673
|
/**
|
|
@@ -634,6 +704,16 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
634
704
|
'Using full height with vizId might lead to unexpected behavior.');
|
|
635
705
|
}
|
|
636
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
|
+
|
|
637
717
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
|
638
718
|
this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
|
|
639
719
|
this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
|
|
@@ -643,7 +723,8 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
643
723
|
|
|
644
724
|
protected async getAppInitData(): Promise<LiveboardEmbedAppInitData> {
|
|
645
725
|
const defaultAppInitData = await super.getAppInitData();
|
|
646
|
-
|
|
726
|
+
const vizInitData = buildSpotterVizAppInitData(defaultAppInitData, this.viewConfig);
|
|
727
|
+
return buildStarterPromptsAppInitData(vizInitData, this.viewConfig);
|
|
647
728
|
}
|
|
648
729
|
|
|
649
730
|
/**
|
|
@@ -673,34 +754,39 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
673
754
|
showLiveboardDescription,
|
|
674
755
|
showLiveboardTitle,
|
|
675
756
|
isLiveboardHeaderSticky = true,
|
|
676
|
-
isLiveboardCompactHeaderEnabled
|
|
757
|
+
isLiveboardCompactHeaderEnabled,
|
|
677
758
|
showLiveboardVerifiedBadge = true,
|
|
678
759
|
showLiveboardReverifyBanner = true,
|
|
679
|
-
hideIrrelevantChipsInLiveboardTabs
|
|
760
|
+
hideIrrelevantChipsInLiveboardTabs,
|
|
680
761
|
showMaskedFilterChip = false,
|
|
681
|
-
isLiveboardMasterpiecesEnabled
|
|
762
|
+
isLiveboardMasterpiecesEnabled,
|
|
682
763
|
newChartsLibrary,
|
|
683
|
-
isEnhancedFilterInteractivityEnabled
|
|
764
|
+
isEnhancedFilterInteractivityEnabled,
|
|
684
765
|
enableAskSage,
|
|
685
766
|
enable2ColumnLayout,
|
|
767
|
+
isLiveboardAlwaysOn12ColLayout,
|
|
686
768
|
dataPanelV2 = true,
|
|
769
|
+
updatedSpotterExperience,
|
|
687
770
|
enableCustomColumnGroups = false,
|
|
688
771
|
oAuthPollingInterval,
|
|
689
772
|
isForceRedirect,
|
|
690
773
|
dataSourceId,
|
|
691
|
-
coverAndFilterOptionInPDF
|
|
774
|
+
coverAndFilterOptionInPDF,
|
|
692
775
|
isLiveboardStylingAndGroupingEnabled,
|
|
776
|
+
liveboardGutter,
|
|
693
777
|
isPNGInScheduledEmailsEnabled = false,
|
|
694
|
-
isLiveboardXLSXCSVDownloadEnabled
|
|
695
|
-
isGranularXLSXCSVSchedulesEnabled
|
|
778
|
+
isLiveboardXLSXCSVDownloadEnabled,
|
|
779
|
+
isGranularXLSXCSVSchedulesEnabled,
|
|
696
780
|
showSpotterLimitations,
|
|
697
781
|
isCentralizedLiveboardFilterUXEnabled = false,
|
|
782
|
+
isScopedLiveboardFilteringEnabled,
|
|
698
783
|
isLinkParametersEnabled,
|
|
699
784
|
updatedSpotterChatPrompt,
|
|
785
|
+
showSpotterRadiance,
|
|
700
786
|
enableStopAnswerGenerationEmbed,
|
|
701
787
|
spotterChatConfig,
|
|
702
788
|
isThisPeriodInDateFiltersEnabled,
|
|
703
|
-
isContinuousLiveboardPDFEnabled
|
|
789
|
+
isContinuousLiveboardPDFEnabled,
|
|
704
790
|
enableLiveboardDataCache,
|
|
705
791
|
} = this.viewConfig;
|
|
706
792
|
|
|
@@ -726,6 +812,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
726
812
|
if (!isUndefined(updatedSpotterChatPrompt)) {
|
|
727
813
|
params[Param.UpdatedSpotterChatPrompt] = !!updatedSpotterChatPrompt;
|
|
728
814
|
}
|
|
815
|
+
if (!isUndefined(showSpotterRadiance)) {
|
|
816
|
+
params[Param.ShowSpotterRadiance] = !!showSpotterRadiance;
|
|
817
|
+
}
|
|
729
818
|
if (!isUndefined(enableStopAnswerGenerationEmbed)) {
|
|
730
819
|
params[Param.EnableStopAnswerGenerationEmbed] = !!enableStopAnswerGenerationEmbed;
|
|
731
820
|
}
|
|
@@ -742,6 +831,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
742
831
|
if (enable2ColumnLayout !== undefined) {
|
|
743
832
|
params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
|
|
744
833
|
}
|
|
834
|
+
if (isLiveboardAlwaysOn12ColLayout !== undefined) {
|
|
835
|
+
params[Param.IsLiveboardAlwaysOn12ColLayout] = isLiveboardAlwaysOn12ColLayout;
|
|
836
|
+
}
|
|
745
837
|
if (hideTabPanel) {
|
|
746
838
|
params[Param.HideTabPanel] = hideTabPanel;
|
|
747
839
|
}
|
|
@@ -774,6 +866,10 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
774
866
|
params[Param.IsLiveboardStylingAndGroupingEnabled] = isLiveboardStylingAndGroupingEnabled;
|
|
775
867
|
}
|
|
776
868
|
|
|
869
|
+
if (liveboardGutter !== undefined) {
|
|
870
|
+
params[Param.LiveboardGutter] = liveboardGutter;
|
|
871
|
+
}
|
|
872
|
+
|
|
777
873
|
if (isPNGInScheduledEmailsEnabled !== undefined) {
|
|
778
874
|
params[Param.isPNGInScheduledEmailsEnabled] = isPNGInScheduledEmailsEnabled;
|
|
779
875
|
}
|
|
@@ -790,6 +886,10 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
790
886
|
params[Param.ShowSpotterLimitations] = showSpotterLimitations;
|
|
791
887
|
}
|
|
792
888
|
|
|
889
|
+
if (!isUndefined(updatedSpotterExperience)) {
|
|
890
|
+
params[Param.UpdatedSpotterExperience] = !!updatedSpotterExperience;
|
|
891
|
+
}
|
|
892
|
+
|
|
793
893
|
// Handle spotterChatConfig params
|
|
794
894
|
if (spotterChatConfig) {
|
|
795
895
|
const {
|
|
@@ -798,6 +898,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
798
898
|
spotterFileUploadEnabled,
|
|
799
899
|
spotterFileUploadFileTypes,
|
|
800
900
|
enableStarterPrompts,
|
|
901
|
+
openSpotterOnLiveboardByDefault,
|
|
801
902
|
} = spotterChatConfig;
|
|
802
903
|
|
|
803
904
|
setParamIfDefined(params, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
|
|
@@ -808,6 +909,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
808
909
|
if (enableStarterPrompts !== undefined) {
|
|
809
910
|
params[Param.IsStarterPromptsEnabled] = enableStarterPrompts;
|
|
810
911
|
}
|
|
912
|
+
if (openSpotterOnLiveboardByDefault !== undefined) {
|
|
913
|
+
params[Param.OpenSpotterOnLiveboardByDefault] = openSpotterOnLiveboardByDefault;
|
|
914
|
+
}
|
|
811
915
|
if (spotterFileUploadFileTypes !== undefined) {
|
|
812
916
|
params[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
|
|
813
917
|
}
|
|
@@ -823,6 +927,12 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
823
927
|
] = isCentralizedLiveboardFilterUXEnabled;
|
|
824
928
|
}
|
|
825
929
|
|
|
930
|
+
if (isScopedLiveboardFilteringEnabled !== undefined) {
|
|
931
|
+
params[
|
|
932
|
+
Param.isScopedLiveboardFilteringEnabled
|
|
933
|
+
] = isScopedLiveboardFilteringEnabled;
|
|
934
|
+
}
|
|
935
|
+
|
|
826
936
|
if (isThisPeriodInDateFiltersEnabled !== undefined) {
|
|
827
937
|
params[Param.IsThisPeriodInDateFiltersEnabled] = isThisPeriodInDateFiltersEnabled;
|
|
828
938
|
}
|
|
@@ -840,16 +950,27 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
840
950
|
}
|
|
841
951
|
|
|
842
952
|
params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
|
|
843
|
-
|
|
953
|
+
if (!isUndefined(isLiveboardCompactHeaderEnabled)) {
|
|
954
|
+
params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
|
|
955
|
+
}
|
|
844
956
|
params[Param.ShowLiveboardVerifiedBadge] = showLiveboardVerifiedBadge;
|
|
845
957
|
params[Param.ShowLiveboardReverifyBanner] = showLiveboardReverifyBanner;
|
|
846
|
-
|
|
958
|
+
if (!isUndefined(hideIrrelevantChipsInLiveboardTabs)) {
|
|
959
|
+
params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
|
|
960
|
+
}
|
|
847
961
|
params[Param.ShowMaskedFilterChip] = showMaskedFilterChip;
|
|
848
|
-
|
|
849
|
-
|
|
962
|
+
if (!isUndefined(isLiveboardMasterpiecesEnabled)) {
|
|
963
|
+
params[Param.IsLiveboardMasterpiecesEnabled] = isLiveboardMasterpiecesEnabled;
|
|
964
|
+
}
|
|
965
|
+
if (!isUndefined(isEnhancedFilterInteractivityEnabled)) {
|
|
966
|
+
params[Param.IsEnhancedFilterInteractivityEnabled] =
|
|
967
|
+
isEnhancedFilterInteractivityEnabled;
|
|
968
|
+
}
|
|
850
969
|
params[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
851
970
|
params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
852
|
-
|
|
971
|
+
if (!isUndefined(coverAndFilterOptionInPDF)) {
|
|
972
|
+
params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
|
|
973
|
+
}
|
|
853
974
|
|
|
854
975
|
const queryParams = getQueryParamString(params, true);
|
|
855
976
|
|
|
@@ -1073,7 +1194,13 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1073
1194
|
* @param {any} data The payload to send with the message
|
|
1074
1195
|
* @returns A promise that resolves with the response from the embedded app
|
|
1075
1196
|
*/
|
|
1076
|
-
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
|
+
>(
|
|
1077
1204
|
messageType: HostEventT,
|
|
1078
1205
|
data: TriggerPayload<PayloadT, HostEventT> = ({} as any),
|
|
1079
1206
|
context?: ContextT,
|
|
@@ -1172,7 +1299,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
1172
1299
|
this.viewConfig.personalizedViewId = personalizedViewId;
|
|
1173
1300
|
if (this.isRendered) {
|
|
1174
1301
|
this.trigger(HostEvent.Navigate, path.substring(1));
|
|
1175
|
-
} else if (this.
|
|
1302
|
+
} else if (this.getPreRenderConfig().preRenderId) {
|
|
1176
1303
|
this.preRender(true);
|
|
1177
1304
|
} else {
|
|
1178
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
|
+
}
|
|
@@ -20,6 +20,23 @@ describe('buildSpotterVizAppInitData', () => {
|
|
|
20
20
|
expect(result.embedParams?.spotterVizConfig?.brandHeadline).toBe("Hi, there! I'm");
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
it('passes liveboardBrandName, spotterBrandName, insightTileBrandName, insightTileViewPlanLabel and insightTileLoaderText through spotterVizConfig', () => {
|
|
24
|
+
const spotterViz = {
|
|
25
|
+
brandName: 'MyBrand',
|
|
26
|
+
liveboardBrandName: 'Reports',
|
|
27
|
+
spotterBrandName: 'Analyst',
|
|
28
|
+
insightTileBrandName: 'Insight card',
|
|
29
|
+
insightTileViewPlanLabel: 'View plan',
|
|
30
|
+
insightTileLoaderText: 'Generating insight',
|
|
31
|
+
};
|
|
32
|
+
const result = buildSpotterVizAppInitData(base, { spotterViz });
|
|
33
|
+
expect(result.embedParams?.spotterVizConfig?.liveboardBrandName).toBe('Reports');
|
|
34
|
+
expect(result.embedParams?.spotterVizConfig?.spotterBrandName).toBe('Analyst');
|
|
35
|
+
expect(result.embedParams?.spotterVizConfig?.insightTileBrandName).toBe('Insight card');
|
|
36
|
+
expect(result.embedParams?.spotterVizConfig?.insightTileViewPlanLabel).toBe('View plan');
|
|
37
|
+
expect(result.embedParams?.spotterVizConfig?.insightTileLoaderText).toBe('Generating insight');
|
|
38
|
+
});
|
|
39
|
+
|
|
23
40
|
it('preserves existing embedParams when adding spotterVizConfig', () => {
|
|
24
41
|
const existing = { ...base, embedParams: { spotterSidebarConfig: { enablePastConversationsSidebar: true } } };
|
|
25
42
|
const spotterViz = { brandName: 'MyBrand' };
|