@thoughtspot/visual-embed-sdk 1.6.0-alpha.1 → 1.7.0-alpha.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 +23 -20
- package/dist/tsembed.es.js +83 -70
- package/dist/tsembed.js +82 -68
- 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 -26
- 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 +23 -20
- package/lib/src/types.js +20 -18
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +79 -58
- 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} +60 -42
- 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 -20
- package/dist/src/embed/pinboard.d.ts +0 -85
- package/lib/src/embed/pinboard.d.ts +0 -85
- 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,32 +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)
|
|
202
|
+
*/
|
|
203
|
+
preventLiveboardFilterRemoval?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* To support backward compatibilty
|
|
206
|
+
* @hidden
|
|
185
207
|
*/
|
|
186
208
|
preventPinboardFilterRemoval?: boolean;
|
|
187
209
|
}
|
|
188
210
|
/**
|
|
189
|
-
* Embed a ThoughtSpot
|
|
190
|
-
* @Category
|
|
211
|
+
* Embed a ThoughtSpot Liveboard or visualization
|
|
212
|
+
* @Category Liveboards and Charts
|
|
191
213
|
*/
|
|
192
|
-
export class
|
|
193
|
-
protected viewConfig:
|
|
194
|
-
constructor(domSelector: DOMSelector, viewConfig:
|
|
214
|
+
export class LiveboardEmbed extends V1Embed {
|
|
215
|
+
protected viewConfig: LiveboardViewConfig;
|
|
216
|
+
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig);
|
|
195
217
|
/**
|
|
196
|
-
* Render an embedded ThoughtSpot
|
|
197
|
-
* @param renderOptions An object specifying the
|
|
218
|
+
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
219
|
+
* @param renderOptions An object specifying the Liveboard ID,
|
|
198
220
|
* visualization ID and the runtime filters.
|
|
199
221
|
*/
|
|
200
|
-
render():
|
|
222
|
+
render(): LiveboardEmbed;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
export class PinboardEmbed extends LiveboardEmbed {
|
|
201
228
|
}
|
|
202
229
|
}
|
|
203
230
|
|
|
@@ -401,12 +428,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
401
428
|
* When there are multiple embeds, queue the render of embed to start
|
|
402
429
|
* after the previous embed's render is complete. This helps in the load performance
|
|
403
430
|
* by decreasing the load on the browser.
|
|
431
|
+
* @version 1.5.0 or later
|
|
404
432
|
* @default false
|
|
405
433
|
*/
|
|
406
434
|
queueMultiRenders?: boolean;
|
|
407
435
|
/**
|
|
408
436
|
* Dynamic CSS Url to be injected in the loaded application.
|
|
409
|
-
*
|
|
437
|
+
* @version 1.6.0 or later
|
|
410
438
|
* @default ''
|
|
411
439
|
*/
|
|
412
440
|
customCssUrl?: string;
|
|
@@ -482,7 +510,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
482
510
|
IN = "IN"
|
|
483
511
|
}
|
|
484
512
|
/**
|
|
485
|
-
* A filter that can be applied to ThoughtSpot answers,
|
|
513
|
+
* A filter that can be applied to ThoughtSpot answers, Liveboards, or
|
|
486
514
|
* visualizations at runtime.
|
|
487
515
|
*/
|
|
488
516
|
export interface RuntimeFilter {
|
|
@@ -520,12 +548,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
520
548
|
*/
|
|
521
549
|
Load = "load",
|
|
522
550
|
/**
|
|
523
|
-
* Data pertaining to answer or
|
|
524
|
-
* @return data - The answer or
|
|
551
|
+
* Data pertaining to answer or Liveboard is received
|
|
552
|
+
* @return data - The answer or Liveboard data
|
|
525
553
|
*/
|
|
526
554
|
Data = "data",
|
|
527
555
|
/**
|
|
528
|
-
* Search/answer/
|
|
556
|
+
* Search/answer/Liveboard filters have been applied/updated
|
|
529
557
|
* @hidden
|
|
530
558
|
*/
|
|
531
559
|
FiltersChanged = "filtersChanged",
|
|
@@ -548,13 +576,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
548
576
|
/**
|
|
549
577
|
* A custom action has been triggered
|
|
550
578
|
* @return actionId - The id of the custom action
|
|
551
|
-
* @return data - The answer or
|
|
579
|
+
* @return data - The answer or Liveboard data
|
|
552
580
|
*/
|
|
553
581
|
CustomAction = "customAction",
|
|
554
582
|
/**
|
|
555
583
|
* A double click has been triggered on table/chart
|
|
556
584
|
* @return ContextMenuInputPoints - data point that is double clicked
|
|
557
|
-
*
|
|
585
|
+
* @version 1.5.0 or later
|
|
558
586
|
*/
|
|
559
587
|
VizPointDoubleClick = "vizPointDoubleClick",
|
|
560
588
|
/**
|
|
@@ -572,8 +600,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
572
600
|
*/
|
|
573
601
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
574
602
|
/**
|
|
575
|
-
* The height of the embedded
|
|
576
|
-
* @return data - The height of the embedded
|
|
603
|
+
* The height of the embedded Liveboard or visualization has been computed.
|
|
604
|
+
* @return data - The height of the embedded Liveboard or visualization
|
|
577
605
|
* @hidden
|
|
578
606
|
*/
|
|
579
607
|
EmbedHeight = "EMBED_HEIGHT",
|
|
@@ -585,7 +613,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
585
613
|
EmbedIframeCenter = "EmbedIframeCenter",
|
|
586
614
|
/**
|
|
587
615
|
* Detects the route change.
|
|
588
|
-
* @hidden
|
|
589
616
|
*/
|
|
590
617
|
RouteChange = "ROUTE_CHANGE",
|
|
591
618
|
/**
|
|
@@ -597,7 +624,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
597
624
|
* Emitted when the embed does not have cookie access. This
|
|
598
625
|
* happens on Safari where third-party cookies are blocked by default.
|
|
599
626
|
*
|
|
600
|
-
* @version 1.1.0
|
|
627
|
+
* @version 1.1.0 or later
|
|
601
628
|
*/
|
|
602
629
|
NoCookieAccess = "noCookieAccess",
|
|
603
630
|
/**
|
|
@@ -608,12 +635,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
608
635
|
SAMLComplete = "samlComplete",
|
|
609
636
|
/**
|
|
610
637
|
* Emitted when any modal is opened in the app
|
|
611
|
-
*
|
|
638
|
+
* @version 1.6.0 or later
|
|
612
639
|
*/
|
|
613
640
|
DialogOpen = "dialog-open",
|
|
614
641
|
/**
|
|
615
642
|
* Emitted when any modal is closed in the app
|
|
616
|
-
*
|
|
643
|
+
* @version 1.6.0 or later
|
|
617
644
|
*/
|
|
618
645
|
DialogClose = "dialog-close"
|
|
619
646
|
}
|
|
@@ -634,7 +661,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
634
661
|
* eg. { selectedPoints: []}
|
|
635
662
|
* @param columnGuid - a string guid of the column to drill by. This is optional,
|
|
636
663
|
* if not provided it will auto drill by the configured column. \
|
|
637
|
-
*
|
|
664
|
+
* @version 1.5.0 or later
|
|
638
665
|
*/
|
|
639
666
|
DrillDown = "triggerDrillDown",
|
|
640
667
|
/**
|
|
@@ -648,10 +675,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
648
675
|
*/
|
|
649
676
|
Reload = "reload",
|
|
650
677
|
/**
|
|
651
|
-
* Set the visible
|
|
652
|
-
* @param - an array of ids of
|
|
678
|
+
* Set the visible visualizations on a Liveboard.
|
|
679
|
+
* @param - an array of ids of visualizations to show, the ids not passed
|
|
653
680
|
* will be hidden.
|
|
654
|
-
*
|
|
681
|
+
* @version 1.6.0 or later
|
|
655
682
|
*/
|
|
656
683
|
SetVisibleVizs = "SetPinboardVisibleVizs"
|
|
657
684
|
}
|
|
@@ -683,7 +710,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
683
710
|
DisableActions = "disableAction",
|
|
684
711
|
DisableActionReason = "disableHint",
|
|
685
712
|
ForceTable = "forceTable",
|
|
686
|
-
|
|
713
|
+
preventLiveboardFilterRemoval = "preventPinboardFilterRemoval",
|
|
687
714
|
SearchQuery = "searchQuery",
|
|
688
715
|
HideActions = "hideAction",
|
|
689
716
|
HideObjects = "hideObjects",
|
|
@@ -705,7 +732,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
705
732
|
}
|
|
706
733
|
/**
|
|
707
734
|
* The list of actions that can be performed on visual ThoughtSpot
|
|
708
|
-
* entities, such as answers and
|
|
735
|
+
* entities, such as answers and Liveboards.
|
|
709
736
|
*/
|
|
710
737
|
export enum Action {
|
|
711
738
|
Save = "save",
|
|
@@ -715,7 +742,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
715
742
|
MakeACopy = "makeACopy",
|
|
716
743
|
EditACopy = "editACopy",
|
|
717
744
|
CopyLink = "embedDocument",
|
|
718
|
-
PinboardSnapshot = "pinboardSnapshot",
|
|
719
745
|
ResetLayout = "resetLayout",
|
|
720
746
|
Schedule = "schedule",
|
|
721
747
|
SchedulesList = "schedule-list",
|
|
@@ -748,7 +774,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
748
774
|
Describe = "describe",
|
|
749
775
|
Relate = "relate",
|
|
750
776
|
CustomizeHeadlines = "customizeHeadlines",
|
|
777
|
+
/**
|
|
778
|
+
* @hidden
|
|
779
|
+
*/
|
|
751
780
|
PinboardInfo = "pinboardInfo",
|
|
781
|
+
LiveboardInfo = "pinboardInfo",
|
|
752
782
|
SendAnswerFeedback = "sendFeedback",
|
|
753
783
|
/**
|
|
754
784
|
* @deprecated Will be removed in next version
|
|
@@ -853,7 +883,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
853
883
|
visibleActions?: Action[];
|
|
854
884
|
/**
|
|
855
885
|
* The list of runtime filters to apply to a search answer,
|
|
856
|
-
* visualization, or
|
|
886
|
+
* visualization, or Liveboard.
|
|
857
887
|
*/
|
|
858
888
|
runtimeFilters?: RuntimeFilter[];
|
|
859
889
|
}
|
|
@@ -892,7 +922,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
892
922
|
protected getBaseQueryParams(): {};
|
|
893
923
|
/**
|
|
894
924
|
* Constructs the base URL string to load v1 of the ThoughtSpot app.
|
|
895
|
-
* This is used for embedding
|
|
925
|
+
* This is used for embedding Liveboards, visualizations, and full application.
|
|
896
926
|
* @param queryString The query string to append to the URL.
|
|
897
927
|
* @param isAppEmbed A Boolean parameter to specify if you are embedding
|
|
898
928
|
* the full application.
|
|
@@ -951,15 +981,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
951
981
|
* @param callback A callback function
|
|
952
982
|
*/
|
|
953
983
|
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
954
|
-
/**
|
|
955
|
-
* Navigates users to the specified application page.
|
|
956
|
-
* Use this method to navigate users from the embedded
|
|
957
|
-
* ThoughtSpot context to a specific page in your app.
|
|
958
|
-
* @param path The page path string.
|
|
959
|
-
* For example, to navigate users to a pinboard page,
|
|
960
|
-
* define the method as navigateToPage('pinboard/<pinboardId>').
|
|
961
|
-
*/
|
|
962
|
-
navigateToPage(path: string): void;
|
|
963
984
|
/**
|
|
964
985
|
* Triggers an event to the embedded app
|
|
965
986
|
* @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.7.0-alpha.0",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -126,6 +126,9 @@
|
|
|
126
126
|
"type": "git",
|
|
127
127
|
"url": "git+https://github.com/thoughtspot/visual-embed-sdk.git"
|
|
128
128
|
},
|
|
129
|
+
"publishConfig": {
|
|
130
|
+
"registry": "https://registry.npmjs.org"
|
|
131
|
+
},
|
|
129
132
|
"keywords": [
|
|
130
133
|
"thoughtspot",
|
|
131
134
|
"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
|
});
|