@thoughtspot/visual-embed-sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/src/embed/app.d.ts +14 -3
- package/dist/src/embed/liveboard.d.ts +101 -0
- package/dist/src/embed/liveboard.spec.d.ts +1 -0
- package/dist/src/embed/ts-embed.d.ts +2 -11
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/react/index.d.ts +4 -3
- package/dist/src/types.d.ts +24 -22
- package/dist/tsembed.es.js +83 -74
- package/dist/tsembed.js +82 -72
- package/lib/package.json +4 -1
- package/lib/src/embed/app.d.ts +14 -3
- package/lib/src/embed/app.js +25 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +32 -0
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +55 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +101 -0
- package/lib/src/embed/{pinboard.js → liveboard.js} +34 -29
- package/lib/src/embed/liveboard.js.map +1 -0
- package/lib/src/embed/liveboard.spec.d.ts +1 -0
- package/lib/src/embed/liveboard.spec.js +159 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -0
- package/lib/src/embed/pinboard.spec.js +1 -1
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +2 -11
- package/lib/src/embed/ts-embed.js +2 -22
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +63 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +1 -1
- package/lib/src/errors.js +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.d.ts +4 -3
- package/lib/src/react/index.js +3 -2
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/types.d.ts +24 -22
- package/lib/src/types.js +20 -19
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +79 -65
- package/package.json +4 -1
- package/src/embed/app.spec.ts +41 -0
- package/src/embed/app.ts +28 -3
- package/src/embed/events.spec.ts +64 -5
- package/src/embed/liveboard.spec.ts +199 -0
- package/src/embed/{pinboard.ts → liveboard.ts} +59 -51
- package/src/embed/pinboard.spec.ts +11 -11
- package/src/embed/ts-embed.spec.ts +81 -8
- package/src/embed/ts-embed.ts +3 -24
- package/src/errors.ts +2 -2
- package/src/index.ts +7 -2
- package/src/react/index.tsx +14 -8
- package/src/types.ts +23 -21
- package/dist/src/embed/pinboard.d.ts +0 -91
- package/dist/src/v1/api.d.ts +0 -19
- package/lib/src/embed/pinboard.d.ts +0 -91
- package/lib/src/embed/pinboard.js.map +0 -1
|
@@ -12,10 +12,10 @@ declare module '@thoughtspot/visual-embed-sdk' {
|
|
|
12
12
|
*/
|
|
13
13
|
import { AppEmbed, Page, AppViewConfig } from '@thoughtspot/visual-embed-sdk/embed/app';
|
|
14
14
|
import { init, prefetch } from '@thoughtspot/visual-embed-sdk/embed/base';
|
|
15
|
-
import { PinboardEmbed,
|
|
15
|
+
import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from '@thoughtspot/visual-embed-sdk/embed/liveboard';
|
|
16
16
|
import { SearchEmbed, SearchViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search';
|
|
17
17
|
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
18
|
-
export { init, prefetch, SearchEmbed, PinboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig,
|
|
18
|
+
export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
@@ -48,7 +48,11 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
48
48
|
*/
|
|
49
49
|
Answers = "answers",
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Liveboards listing page
|
|
52
|
+
*/
|
|
53
|
+
Liveboards = "liveboards",
|
|
54
|
+
/**
|
|
55
|
+
* @hidden
|
|
52
56
|
*/
|
|
53
57
|
Pinboards = "pinboards",
|
|
54
58
|
/**
|
|
@@ -84,7 +88,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
84
88
|
pageId?: Page;
|
|
85
89
|
/**
|
|
86
90
|
* This puts a filter tag on the application. All metadata lists in the application, such as
|
|
87
|
-
*
|
|
91
|
+
* Liveboards and answers, would be filtered by this tag.
|
|
88
92
|
*/
|
|
89
93
|
tag?: string;
|
|
90
94
|
/**
|
|
@@ -99,6 +103,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
99
103
|
export class AppEmbed extends V1Embed {
|
|
100
104
|
protected viewConfig: AppViewConfig;
|
|
101
105
|
constructor(domSelector: DOMSelector, viewConfig: AppViewConfig);
|
|
106
|
+
/**
|
|
107
|
+
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
108
|
+
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
109
|
+
* @param path The string, set to iframe src and navigate to new page
|
|
110
|
+
* eg: appEmbed.navigateToPage('pinboards')
|
|
111
|
+
*/
|
|
112
|
+
navigateToPage(path: string): void;
|
|
102
113
|
/**
|
|
103
114
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
104
115
|
* @param renderOptions An object containing the page ID
|
|
@@ -136,35 +147,35 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
|
136
147
|
export const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
|
|
137
148
|
}
|
|
138
149
|
|
|
139
|
-
declare module '@thoughtspot/visual-embed-sdk/embed/
|
|
150
|
+
declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
140
151
|
/**
|
|
141
152
|
* Copyright (c) 2021
|
|
142
153
|
*
|
|
143
|
-
* Embed a ThoughtSpot
|
|
154
|
+
* Embed a ThoughtSpot Liveboard or visualization
|
|
144
155
|
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
145
156
|
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
|
|
146
157
|
*
|
|
147
|
-
* @summary
|
|
158
|
+
* @summary Liveboard & visualization embed
|
|
148
159
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
149
160
|
*/
|
|
150
161
|
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
|
|
151
162
|
import { V1Embed, ViewConfig } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
152
163
|
/**
|
|
153
|
-
* The configuration for the embedded
|
|
154
|
-
* @Category
|
|
164
|
+
* The configuration for the embedded Liveboard or visualization page view.
|
|
165
|
+
* @Category Liveboards and Charts
|
|
155
166
|
*/
|
|
156
|
-
export interface
|
|
167
|
+
export interface LiveboardViewConfig extends ViewConfig {
|
|
157
168
|
/**
|
|
158
169
|
* If set to true, the embedded object container dynamically resizes
|
|
159
|
-
* according to the height of the
|
|
170
|
+
* according to the height of the Liveboard.
|
|
160
171
|
*/
|
|
161
172
|
fullHeight?: boolean;
|
|
162
173
|
/**
|
|
163
|
-
* This is the minimum height(in pixels) for a full height
|
|
164
|
-
* Setting this height helps resolves issues with empty
|
|
165
|
-
* other screens navigable from a
|
|
174
|
+
* This is the minimum height(in pixels) for a full height Liveboard.
|
|
175
|
+
* Setting this height helps resolves issues with empty Liveboards and
|
|
176
|
+
* other screens navigable from a Liveboard.
|
|
177
|
+
* *_since 1.5.0_
|
|
166
178
|
* @default 500
|
|
167
|
-
* * _since 1.5.0_
|
|
168
179
|
*/
|
|
169
180
|
defaultHeight?: number;
|
|
170
181
|
/**
|
|
@@ -172,38 +183,48 @@ declare module '@thoughtspot/visual-embed-sdk/embed/pinboard' {
|
|
|
172
183
|
*/
|
|
173
184
|
enableVizTransformations?: boolean;
|
|
174
185
|
/**
|
|
175
|
-
* The
|
|
186
|
+
* The Liveboard to display in the embedded view.
|
|
187
|
+
* Use either of liveboardId or pinboardId to reference the Liveboard to embed.
|
|
176
188
|
*/
|
|
177
|
-
|
|
189
|
+
liveboardId?: string;
|
|
178
190
|
/**
|
|
179
|
-
*
|
|
191
|
+
* To support backward compatibilty
|
|
192
|
+
* @hidden
|
|
193
|
+
*/
|
|
194
|
+
pinboardId?: string;
|
|
195
|
+
/**
|
|
196
|
+
* The visualization within the Liveboard to display.
|
|
180
197
|
*/
|
|
181
198
|
vizId?: string;
|
|
182
199
|
/**
|
|
183
200
|
* If set to true, all filter chips from a
|
|
184
|
-
*
|
|
201
|
+
* Liveboard page will be read-only (no X buttons)
|
|
185
202
|
*/
|
|
186
|
-
|
|
203
|
+
preventLiveboardFilterRemoval?: boolean;
|
|
187
204
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* _since: 1.6.0_
|
|
205
|
+
* To support backward compatibilty
|
|
206
|
+
* @hidden
|
|
191
207
|
*/
|
|
192
|
-
|
|
208
|
+
preventPinboardFilterRemoval?: boolean;
|
|
193
209
|
}
|
|
194
210
|
/**
|
|
195
|
-
* Embed a ThoughtSpot
|
|
196
|
-
* @Category
|
|
211
|
+
* Embed a ThoughtSpot Liveboard or visualization
|
|
212
|
+
* @Category Liveboards and Charts
|
|
197
213
|
*/
|
|
198
|
-
export class
|
|
199
|
-
protected viewConfig:
|
|
200
|
-
constructor(domSelector: DOMSelector, viewConfig:
|
|
214
|
+
export class LiveboardEmbed extends V1Embed {
|
|
215
|
+
protected viewConfig: LiveboardViewConfig;
|
|
216
|
+
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig);
|
|
201
217
|
/**
|
|
202
|
-
* Render an embedded ThoughtSpot
|
|
203
|
-
* @param renderOptions An object specifying the
|
|
218
|
+
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
219
|
+
* @param renderOptions An object specifying the Liveboard ID,
|
|
204
220
|
* visualization ID and the runtime filters.
|
|
205
221
|
*/
|
|
206
|
-
render():
|
|
222
|
+
render(): LiveboardEmbed;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
export class PinboardEmbed extends LiveboardEmbed {
|
|
207
228
|
}
|
|
208
229
|
}
|
|
209
230
|
|
|
@@ -411,12 +432,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
411
432
|
* When there are multiple embeds, queue the render of embed to start
|
|
412
433
|
* after the previous embed's render is complete. This helps in the load performance
|
|
413
434
|
* by decreasing the load on the browser.
|
|
435
|
+
* @version 1.5.0 or later
|
|
414
436
|
* @default false
|
|
415
437
|
*/
|
|
416
438
|
queueMultiRenders?: boolean;
|
|
417
439
|
/**
|
|
418
440
|
* Dynamic CSS Url to be injected in the loaded application.
|
|
419
|
-
*
|
|
441
|
+
* @version 1.6.0 or later
|
|
420
442
|
* @default ''
|
|
421
443
|
*/
|
|
422
444
|
customCssUrl?: string;
|
|
@@ -492,7 +514,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
492
514
|
IN = "IN"
|
|
493
515
|
}
|
|
494
516
|
/**
|
|
495
|
-
* A filter that can be applied to ThoughtSpot answers,
|
|
517
|
+
* A filter that can be applied to ThoughtSpot answers, Liveboards, or
|
|
496
518
|
* visualizations at runtime.
|
|
497
519
|
*/
|
|
498
520
|
export interface RuntimeFilter {
|
|
@@ -530,12 +552,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
530
552
|
*/
|
|
531
553
|
Load = "load",
|
|
532
554
|
/**
|
|
533
|
-
* Data pertaining to answer or
|
|
534
|
-
* @return data - The answer or
|
|
555
|
+
* Data pertaining to answer or Liveboard is received
|
|
556
|
+
* @return data - The answer or Liveboard data
|
|
535
557
|
*/
|
|
536
558
|
Data = "data",
|
|
537
559
|
/**
|
|
538
|
-
* Search/answer/
|
|
560
|
+
* Search/answer/Liveboard filters have been applied/updated
|
|
539
561
|
* @hidden
|
|
540
562
|
*/
|
|
541
563
|
FiltersChanged = "filtersChanged",
|
|
@@ -558,13 +580,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
558
580
|
/**
|
|
559
581
|
* A custom action has been triggered
|
|
560
582
|
* @return actionId - The id of the custom action
|
|
561
|
-
* @return data - The answer or
|
|
583
|
+
* @return data - The answer or Liveboard data
|
|
562
584
|
*/
|
|
563
585
|
CustomAction = "customAction",
|
|
564
586
|
/**
|
|
565
587
|
* A double click has been triggered on table/chart
|
|
566
588
|
* @return ContextMenuInputPoints - data point that is double clicked
|
|
567
|
-
*
|
|
589
|
+
* @version 1.5.0 or later
|
|
568
590
|
*/
|
|
569
591
|
VizPointDoubleClick = "vizPointDoubleClick",
|
|
570
592
|
/**
|
|
@@ -582,8 +604,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
582
604
|
*/
|
|
583
605
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
584
606
|
/**
|
|
585
|
-
* The height of the embedded
|
|
586
|
-
* @return data - The height of the embedded
|
|
607
|
+
* The height of the embedded Liveboard or visualization has been computed.
|
|
608
|
+
* @return data - The height of the embedded Liveboard or visualization
|
|
587
609
|
* @hidden
|
|
588
610
|
*/
|
|
589
611
|
EmbedHeight = "EMBED_HEIGHT",
|
|
@@ -595,7 +617,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
595
617
|
EmbedIframeCenter = "EmbedIframeCenter",
|
|
596
618
|
/**
|
|
597
619
|
* Detects the route change.
|
|
598
|
-
* @hidden
|
|
599
620
|
*/
|
|
600
621
|
RouteChange = "ROUTE_CHANGE",
|
|
601
622
|
/**
|
|
@@ -607,7 +628,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
607
628
|
* Emitted when the embed does not have cookie access. This
|
|
608
629
|
* happens on Safari where third-party cookies are blocked by default.
|
|
609
630
|
*
|
|
610
|
-
* @version 1.1.0
|
|
631
|
+
* @version 1.1.0 or later
|
|
611
632
|
*/
|
|
612
633
|
NoCookieAccess = "noCookieAccess",
|
|
613
634
|
/**
|
|
@@ -618,12 +639,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
618
639
|
SAMLComplete = "samlComplete",
|
|
619
640
|
/**
|
|
620
641
|
* Emitted when any modal is opened in the app
|
|
621
|
-
*
|
|
642
|
+
* @version 1.6.0 or later
|
|
622
643
|
*/
|
|
623
644
|
DialogOpen = "dialog-open",
|
|
624
645
|
/**
|
|
625
646
|
* Emitted when any modal is closed in the app
|
|
626
|
-
*
|
|
647
|
+
* @version 1.6.0 or later
|
|
627
648
|
*/
|
|
628
649
|
DialogClose = "dialog-close"
|
|
629
650
|
}
|
|
@@ -644,7 +665,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
644
665
|
* eg. { selectedPoints: []}
|
|
645
666
|
* @param columnGuid - a string guid of the column to drill by. This is optional,
|
|
646
667
|
* if not provided it will auto drill by the configured column. \
|
|
647
|
-
*
|
|
668
|
+
* @version 1.5.0 or later
|
|
648
669
|
*/
|
|
649
670
|
DrillDown = "triggerDrillDown",
|
|
650
671
|
/**
|
|
@@ -658,10 +679,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
658
679
|
*/
|
|
659
680
|
Reload = "reload",
|
|
660
681
|
/**
|
|
661
|
-
* Set the visible
|
|
662
|
-
* @param - an array of ids of
|
|
682
|
+
* Set the visible visualizations on a Liveboard.
|
|
683
|
+
* @param - an array of ids of visualizations to show, the ids not passed
|
|
663
684
|
* will be hidden.
|
|
664
|
-
*
|
|
685
|
+
* @version 1.6.0 or later
|
|
665
686
|
*/
|
|
666
687
|
SetVisibleVizs = "SetPinboardVisibleVizs"
|
|
667
688
|
}
|
|
@@ -694,7 +715,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
694
715
|
DisableActions = "disableAction",
|
|
695
716
|
DisableActionReason = "disableHint",
|
|
696
717
|
ForceTable = "forceTable",
|
|
697
|
-
|
|
718
|
+
preventLiveboardFilterRemoval = "preventPinboardFilterRemoval",
|
|
698
719
|
SearchQuery = "searchQuery",
|
|
699
720
|
HideActions = "hideAction",
|
|
700
721
|
HideObjects = "hideObjects",
|
|
@@ -712,12 +733,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
712
733
|
ViewPortHeight = "viewPortHeight",
|
|
713
734
|
ViewPortWidth = "viewPortWidth",
|
|
714
735
|
VisibleActions = "visibleAction",
|
|
715
|
-
CustomCSSUrl = "customCssUrl"
|
|
716
|
-
PinboardVisibleVizs = "pinboardVisibleVizs"
|
|
736
|
+
CustomCSSUrl = "customCssUrl"
|
|
717
737
|
}
|
|
718
738
|
/**
|
|
719
739
|
* The list of actions that can be performed on visual ThoughtSpot
|
|
720
|
-
* entities, such as answers and
|
|
740
|
+
* entities, such as answers and Liveboards.
|
|
721
741
|
*/
|
|
722
742
|
export enum Action {
|
|
723
743
|
Save = "save",
|
|
@@ -727,7 +747,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
727
747
|
MakeACopy = "makeACopy",
|
|
728
748
|
EditACopy = "editACopy",
|
|
729
749
|
CopyLink = "embedDocument",
|
|
730
|
-
PinboardSnapshot = "pinboardSnapshot",
|
|
731
750
|
ResetLayout = "resetLayout",
|
|
732
751
|
Schedule = "schedule",
|
|
733
752
|
SchedulesList = "schedule-list",
|
|
@@ -760,7 +779,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
760
779
|
Describe = "describe",
|
|
761
780
|
Relate = "relate",
|
|
762
781
|
CustomizeHeadlines = "customizeHeadlines",
|
|
782
|
+
/**
|
|
783
|
+
* @hidden
|
|
784
|
+
*/
|
|
763
785
|
PinboardInfo = "pinboardInfo",
|
|
786
|
+
LiveboardInfo = "pinboardInfo",
|
|
764
787
|
SendAnswerFeedback = "sendFeedback",
|
|
765
788
|
/**
|
|
766
789
|
* @deprecated Will be removed in next version
|
|
@@ -865,7 +888,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
865
888
|
visibleActions?: Action[];
|
|
866
889
|
/**
|
|
867
890
|
* The list of runtime filters to apply to a search answer,
|
|
868
|
-
* visualization, or
|
|
891
|
+
* visualization, or Liveboard.
|
|
869
892
|
*/
|
|
870
893
|
runtimeFilters?: RuntimeFilter[];
|
|
871
894
|
}
|
|
@@ -904,7 +927,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
904
927
|
protected getBaseQueryParams(): {};
|
|
905
928
|
/**
|
|
906
929
|
* Constructs the base URL string to load v1 of the ThoughtSpot app.
|
|
907
|
-
* This is used for embedding
|
|
930
|
+
* This is used for embedding Liveboards, visualizations, and full application.
|
|
908
931
|
* @param queryString The query string to append to the URL.
|
|
909
932
|
* @param isAppEmbed A Boolean parameter to specify if you are embedding
|
|
910
933
|
* the full application.
|
|
@@ -963,15 +986,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
963
986
|
* @param callback A callback function
|
|
964
987
|
*/
|
|
965
988
|
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
966
|
-
/**
|
|
967
|
-
* Navigates users to the specified application page.
|
|
968
|
-
* Use this method to navigate users from the embedded
|
|
969
|
-
* ThoughtSpot context to a specific page in your app.
|
|
970
|
-
* @param path The page path string.
|
|
971
|
-
* For example, to navigate users to a pinboard page,
|
|
972
|
-
* define the method as navigateToPage('pinboard/<pinboardId>').
|
|
973
|
-
*/
|
|
974
|
-
navigateToPage(path: string): void;
|
|
975
989
|
/**
|
|
976
990
|
* Triggers an event to the embedded app
|
|
977
991
|
* @param messageType The event type
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -127,6 +127,9 @@
|
|
|
127
127
|
"type": "git",
|
|
128
128
|
"url": "git+https://github.com/thoughtspot/visual-embed-sdk.git"
|
|
129
129
|
},
|
|
130
|
+
"publishConfig": {
|
|
131
|
+
"registry": "https://registry.npmjs.org"
|
|
132
|
+
},
|
|
130
133
|
"keywords": [
|
|
131
134
|
"thoughtspot",
|
|
132
135
|
"everywhere",
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getRootEl,
|
|
9
9
|
} from '../test/test-utils';
|
|
10
10
|
import { version } from '../../package.json';
|
|
11
|
+
import * as config from '../config';
|
|
11
12
|
|
|
12
13
|
const defaultViewConfig = {
|
|
13
14
|
frameParams: {
|
|
@@ -17,6 +18,7 @@ const defaultViewConfig = {
|
|
|
17
18
|
};
|
|
18
19
|
const thoughtSpotHost = 'tshost';
|
|
19
20
|
const defaultParams = `&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
21
|
+
const defaultParamsForPinboardEmbed = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
20
22
|
|
|
21
23
|
beforeAll(() => {
|
|
22
24
|
init({
|
|
@@ -76,6 +78,7 @@ describe('App embed tests', () => {
|
|
|
76
78
|
[Page.Search]: 'answer',
|
|
77
79
|
[Page.Answers]: 'answers',
|
|
78
80
|
[Page.Pinboards]: 'pinboards',
|
|
81
|
+
[Page.Liveboards]: 'pinboards',
|
|
79
82
|
[Page.Data]: 'data/tables',
|
|
80
83
|
[Page.Home]: 'home',
|
|
81
84
|
};
|
|
@@ -167,4 +170,42 @@ describe('App embed tests', () => {
|
|
|
167
170
|
);
|
|
168
171
|
});
|
|
169
172
|
});
|
|
173
|
+
|
|
174
|
+
describe('Naviage to Page API', () => {
|
|
175
|
+
const path = 'pinboard/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
|
|
176
|
+
beforeEach(() => {
|
|
177
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
178
|
+
() => 'http://tshost',
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('when app is AppEmbed after navigateToPage function call, new path should be set to iframe', async () => {
|
|
183
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
184
|
+
frameParams: {
|
|
185
|
+
width: '100%',
|
|
186
|
+
height: '100%',
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
await appEmbed.render();
|
|
190
|
+
appEmbed.navigateToPage(path);
|
|
191
|
+
expect(getIFrameSrc()).toBe(
|
|
192
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}#/${path}`,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('navigateToPage function use before render', async () => {
|
|
197
|
+
spyOn(console, 'log');
|
|
198
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
199
|
+
frameParams: {
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
appEmbed.navigateToPage(path);
|
|
205
|
+
await appEmbed.render();
|
|
206
|
+
expect(console.log).toHaveBeenCalledWith(
|
|
207
|
+
'Please call render before invoking this method',
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
170
211
|
});
|
package/src/embed/app.ts
CHANGED
|
@@ -31,7 +31,11 @@ export enum Page {
|
|
|
31
31
|
*/
|
|
32
32
|
Answers = 'answers',
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Liveboards listing page
|
|
35
|
+
*/
|
|
36
|
+
Liveboards = 'liveboards',
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
35
39
|
*/
|
|
36
40
|
Pinboards = 'pinboards',
|
|
37
41
|
/**
|
|
@@ -68,7 +72,7 @@ export interface AppViewConfig extends ViewConfig {
|
|
|
68
72
|
pageId?: Page;
|
|
69
73
|
/**
|
|
70
74
|
* This puts a filter tag on the application. All metadata lists in the application, such as
|
|
71
|
-
*
|
|
75
|
+
* Liveboards and answers, would be filtered by this tag.
|
|
72
76
|
*/
|
|
73
77
|
tag?: string;
|
|
74
78
|
/**
|
|
@@ -91,7 +95,7 @@ export class AppEmbed extends V1Embed {
|
|
|
91
95
|
|
|
92
96
|
/**
|
|
93
97
|
* Constructs a map of parameters to be passed on to the
|
|
94
|
-
* embedded
|
|
98
|
+
* embedded Liveboard or visualization.
|
|
95
99
|
*/
|
|
96
100
|
private getEmbedParams() {
|
|
97
101
|
const params = this.getBaseQueryParams();
|
|
@@ -139,6 +143,8 @@ export class AppEmbed extends V1Embed {
|
|
|
139
143
|
return 'answer';
|
|
140
144
|
case Page.Answers:
|
|
141
145
|
return 'answers';
|
|
146
|
+
case Page.Liveboards:
|
|
147
|
+
return 'pinboards';
|
|
142
148
|
case Page.Pinboards:
|
|
143
149
|
return 'pinboards';
|
|
144
150
|
case Page.Data:
|
|
@@ -167,6 +173,25 @@ export class AppEmbed extends V1Embed {
|
|
|
167
173
|
return path;
|
|
168
174
|
}
|
|
169
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
178
|
+
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
179
|
+
* @param path The string, set to iframe src and navigate to new page
|
|
180
|
+
* eg: appEmbed.navigateToPage('pinboards')
|
|
181
|
+
*/
|
|
182
|
+
public navigateToPage(path: string): void {
|
|
183
|
+
if (this.iFrame) {
|
|
184
|
+
const iframeSrc = this.iFrame.src;
|
|
185
|
+
const embedPath = '#/embed';
|
|
186
|
+
const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
|
|
187
|
+
this.iFrame.src = `${
|
|
188
|
+
iframeSrc.split(currentPath)[0]
|
|
189
|
+
}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
190
|
+
} else {
|
|
191
|
+
console.log('Please call render before invoking this method');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
170
195
|
/**
|
|
171
196
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
172
197
|
* @param renderOptions An object containing the page ID
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
EmbedEvent,
|
|
5
5
|
SearchEmbed,
|
|
6
6
|
PinboardEmbed,
|
|
7
|
+
LiveboardEmbed,
|
|
7
8
|
HostEvent,
|
|
8
9
|
} from '../index';
|
|
9
10
|
import {
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
getRootEl2,
|
|
16
17
|
postMessageToParent,
|
|
17
18
|
} from '../test/test-utils';
|
|
18
|
-
import {
|
|
19
|
+
import { LiveboardViewConfig } from './liveboard';
|
|
19
20
|
|
|
20
21
|
const thoughtSpotHost = 'tshost';
|
|
21
22
|
const defaultViewConfig = {
|
|
@@ -119,8 +120,14 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
119
120
|
const embedTwo = new PinboardEmbed(getRootEl2(), {
|
|
120
121
|
...defaultViewConfig,
|
|
121
122
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
122
|
-
} as
|
|
123
|
+
} as LiveboardViewConfig);
|
|
124
|
+
const spyThree = jest.fn();
|
|
125
|
+
const embedThree = new LiveboardEmbed(getRootEl2(), {
|
|
126
|
+
...defaultViewConfig,
|
|
127
|
+
liveboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
128
|
+
} as LiveboardViewConfig);
|
|
123
129
|
embedTwo.on(EmbedEvent.CustomAction, spyTwo).render();
|
|
130
|
+
embedThree.on(EmbedEvent.CustomAction, spyThree).render();
|
|
124
131
|
|
|
125
132
|
await executeAfterWait(() => {
|
|
126
133
|
const iframeOne = getIFrameEl();
|
|
@@ -133,15 +140,34 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
133
140
|
await executeAfterWait(() => {
|
|
134
141
|
expect(spyOne).toHaveBeenCalled();
|
|
135
142
|
expect(spyTwo).not.toHaveBeenCalled();
|
|
143
|
+
expect(spyThree).not.toHaveBeenCalled();
|
|
136
144
|
}, EVENT_WAIT_TIME);
|
|
137
145
|
});
|
|
138
146
|
|
|
139
147
|
test('send getIframeCenter Event without eventPort', async () => {
|
|
148
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
149
|
+
...defaultViewConfig,
|
|
150
|
+
fullHeight: true,
|
|
151
|
+
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
152
|
+
} as LiveboardViewConfig);
|
|
153
|
+
liveboardEmbed.render();
|
|
154
|
+
const spy1 = jest.spyOn(global.console, 'log');
|
|
155
|
+
|
|
156
|
+
await executeAfterWait(() => {
|
|
157
|
+
const iframe = getIFrameEl();
|
|
158
|
+
postMessageToParent(iframe.contentWindow, {
|
|
159
|
+
type: EmbedEvent.EmbedIframeCenter,
|
|
160
|
+
data: PAYLOAD,
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
expect(spy1).toHaveBeenCalledWith('Event Port is not defined');
|
|
164
|
+
});
|
|
165
|
+
test('send getIframeCenter Event without eventPort - pinboard', async () => {
|
|
140
166
|
const pinboardEmbed = new PinboardEmbed(getRootEl(), {
|
|
141
167
|
...defaultViewConfig,
|
|
142
168
|
fullHeight: true,
|
|
143
169
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
144
|
-
} as
|
|
170
|
+
} as LiveboardViewConfig);
|
|
145
171
|
pinboardEmbed.render();
|
|
146
172
|
const spy1 = jest.spyOn(global.console, 'log');
|
|
147
173
|
|
|
@@ -155,12 +181,12 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
155
181
|
expect(spy1).toHaveBeenCalledWith('Event Port is not defined');
|
|
156
182
|
});
|
|
157
183
|
|
|
158
|
-
test('send getIframeCenter Event with eventPort', async () => {
|
|
184
|
+
test('send getIframeCenter Event with eventPort - pinboard', async () => {
|
|
159
185
|
const pinboardEmbed = new PinboardEmbed(getRootEl(), {
|
|
160
186
|
...defaultViewConfig,
|
|
161
187
|
fullHeight: true,
|
|
162
188
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
163
|
-
} as
|
|
189
|
+
} as LiveboardViewConfig);
|
|
164
190
|
pinboardEmbed.render();
|
|
165
191
|
const mockPort: any = {
|
|
166
192
|
postMessage: jest.fn(),
|
|
@@ -188,4 +214,37 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
188
214
|
};
|
|
189
215
|
expect(mockPort.postMessage).toHaveBeenCalledWith(heightObj);
|
|
190
216
|
});
|
|
217
|
+
test('send getIframeCenter Event with eventPort', async () => {
|
|
218
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
219
|
+
...defaultViewConfig,
|
|
220
|
+
fullHeight: true,
|
|
221
|
+
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
222
|
+
} as LiveboardViewConfig);
|
|
223
|
+
liveboardEmbed.render();
|
|
224
|
+
const mockPort: any = {
|
|
225
|
+
postMessage: jest.fn(),
|
|
226
|
+
};
|
|
227
|
+
await executeAfterWait(() => {
|
|
228
|
+
const iframe = getIFrameEl();
|
|
229
|
+
postMessageToParent(
|
|
230
|
+
iframe.contentWindow,
|
|
231
|
+
{
|
|
232
|
+
type: EmbedEvent.EmbedIframeCenter,
|
|
233
|
+
data: PAYLOAD,
|
|
234
|
+
},
|
|
235
|
+
mockPort,
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
const heightObj = {
|
|
239
|
+
data: {
|
|
240
|
+
iframeCenter: 0,
|
|
241
|
+
iframeHeight: 0,
|
|
242
|
+
iframeScrolled: 0,
|
|
243
|
+
iframeVisibleViewPort: 0,
|
|
244
|
+
viewPortHeight: 768,
|
|
245
|
+
},
|
|
246
|
+
type: EmbedEvent.EmbedIframeCenter,
|
|
247
|
+
};
|
|
248
|
+
expect(mockPort.postMessage).toHaveBeenCalledWith(heightObj);
|
|
249
|
+
});
|
|
191
250
|
});
|