@thoughtspot/visual-embed-sdk 1.6.0-alpha.2 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/auth.d.ts +2 -4
- package/dist/src/embed/app.d.ts +9 -2
- package/dist/src/embed/liveboard.d.ts +19 -19
- package/dist/src/embed/liveboard.spec.d.ts +1 -0
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +2 -11
- package/dist/src/types.d.ts +24 -24
- package/dist/tsembed.es.js +82 -68
- package/dist/tsembed.js +81 -67
- package/lib/package.json +5 -1
- package/lib/src/auth.d.ts +2 -4
- package/lib/src/auth.js +25 -7
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts +9 -2
- package/lib/src/embed/app.js +18 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +31 -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 +19 -19
- package/lib/src/embed/liveboard.js +12 -13
- package/lib/src/embed/liveboard.js.map +1 -1
- 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/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +2 -11
- package/lib/src/embed/ts-embed.js +4 -23
- 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/types.d.ts +24 -24
- package/lib/src/types.js +21 -22
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +51 -49
- package/package.json +5 -1
- package/src/auth.ts +35 -7
- package/src/embed/app.spec.ts +40 -0
- package/src/embed/app.ts +21 -2
- package/src/embed/events.spec.ts +60 -1
- package/src/embed/liveboard.spec.ts +199 -0
- package/src/embed/liveboard.ts +21 -24
- package/src/embed/search.ts +5 -0
- package/src/embed/ts-embed.spec.ts +78 -5
- package/src/embed/ts-embed.ts +6 -25
- package/src/types.ts +24 -24
- package/dist/src/embed/pinboard.d.ts +0 -85
- package/lib/src/embed/pinboard.d.ts +0 -85
- package/lib/src/embed/pinboard.js +0 -107
- package/lib/src/embed/pinboard.js.map +0 -1
- package/lib/src/utils/fetchAnswers.d.ts +0 -3
- package/lib/src/utils/fetchAnswers.js +0 -49
- package/lib/src/utils/fetchAnswers.js.map +0 -1
|
@@ -88,7 +88,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
88
88
|
pageId?: Page;
|
|
89
89
|
/**
|
|
90
90
|
* This puts a filter tag on the application. All metadata lists in the application, such as
|
|
91
|
-
*
|
|
91
|
+
* Liveboards and answers, would be filtered by this tag.
|
|
92
92
|
*/
|
|
93
93
|
tag?: string;
|
|
94
94
|
/**
|
|
@@ -103,6 +103,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
103
103
|
export class AppEmbed extends V1Embed {
|
|
104
104
|
protected viewConfig: AppViewConfig;
|
|
105
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;
|
|
106
113
|
/**
|
|
107
114
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
108
115
|
* @param renderOptions An object containing the page ID
|
|
@@ -144,7 +151,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
144
151
|
/**
|
|
145
152
|
* Copyright (c) 2021
|
|
146
153
|
*
|
|
147
|
-
* Embed a ThoughtSpot
|
|
154
|
+
* Embed a ThoughtSpot Liveboard or visualization
|
|
148
155
|
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
149
156
|
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
|
|
150
157
|
*
|
|
@@ -154,21 +161,21 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
154
161
|
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
|
|
155
162
|
import { V1Embed, ViewConfig } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
156
163
|
/**
|
|
157
|
-
* The configuration for the embedded
|
|
164
|
+
* The configuration for the embedded Liveboard or visualization page view.
|
|
158
165
|
* @Category Liveboards and Charts
|
|
159
166
|
*/
|
|
160
167
|
export interface LiveboardViewConfig extends ViewConfig {
|
|
161
168
|
/**
|
|
162
169
|
* If set to true, the embedded object container dynamically resizes
|
|
163
|
-
* according to the height of the
|
|
170
|
+
* according to the height of the Liveboard.
|
|
164
171
|
*/
|
|
165
172
|
fullHeight?: boolean;
|
|
166
173
|
/**
|
|
167
|
-
* This is the minimum height(in pixels) for a full height
|
|
168
|
-
* Setting this height helps resolves issues with empty
|
|
169
|
-
* 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_
|
|
170
178
|
* @default 500
|
|
171
|
-
* * _since 1.5.0_
|
|
172
179
|
*/
|
|
173
180
|
defaultHeight?: number;
|
|
174
181
|
/**
|
|
@@ -176,7 +183,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
176
183
|
*/
|
|
177
184
|
enableVizTransformations?: boolean;
|
|
178
185
|
/**
|
|
179
|
-
* The
|
|
186
|
+
* The Liveboard to display in the embedded view.
|
|
180
187
|
* Use either of liveboardId or pinboardId to reference the Liveboard to embed.
|
|
181
188
|
*/
|
|
182
189
|
liveboardId?: string;
|
|
@@ -186,12 +193,12 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
186
193
|
*/
|
|
187
194
|
pinboardId?: string;
|
|
188
195
|
/**
|
|
189
|
-
* The visualization within the
|
|
196
|
+
* The visualization within the Liveboard to display.
|
|
190
197
|
*/
|
|
191
198
|
vizId?: string;
|
|
192
199
|
/**
|
|
193
200
|
* If set to true, all filter chips from a
|
|
194
|
-
*
|
|
201
|
+
* Liveboard page will be read-only (no X buttons)
|
|
195
202
|
*/
|
|
196
203
|
preventLiveboardFilterRemoval?: boolean;
|
|
197
204
|
/**
|
|
@@ -201,15 +208,15 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
201
208
|
preventPinboardFilterRemoval?: boolean;
|
|
202
209
|
}
|
|
203
210
|
/**
|
|
204
|
-
* Embed a ThoughtSpot
|
|
211
|
+
* Embed a ThoughtSpot Liveboard or visualization
|
|
205
212
|
* @Category Liveboards and Charts
|
|
206
213
|
*/
|
|
207
214
|
export class LiveboardEmbed extends V1Embed {
|
|
208
215
|
protected viewConfig: LiveboardViewConfig;
|
|
209
216
|
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig);
|
|
210
217
|
/**
|
|
211
|
-
* Render an embedded ThoughtSpot
|
|
212
|
-
* @param renderOptions An object specifying the
|
|
218
|
+
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
219
|
+
* @param renderOptions An object specifying the Liveboard ID,
|
|
213
220
|
* visualization ID and the runtime filters.
|
|
214
221
|
*/
|
|
215
222
|
render(): LiveboardEmbed;
|
|
@@ -268,6 +275,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
268
275
|
* using raw answer data.
|
|
269
276
|
*/
|
|
270
277
|
hideResults?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* If set to true, expands all the data sources panel.
|
|
280
|
+
*/
|
|
281
|
+
expandAllDataSource?: boolean;
|
|
271
282
|
/**
|
|
272
283
|
* If set to true, the Search Assist feature is enabled.
|
|
273
284
|
*/
|
|
@@ -328,6 +339,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
328
339
|
* SSO using SAML
|
|
329
340
|
*/
|
|
330
341
|
SSO = "SSO_SAML",
|
|
342
|
+
/**
|
|
343
|
+
* SSO using IODC
|
|
344
|
+
*/
|
|
345
|
+
IODC = "SSO_IODC",
|
|
331
346
|
/**
|
|
332
347
|
* Trusted authentication server
|
|
333
348
|
*/
|
|
@@ -421,12 +436,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
421
436
|
* When there are multiple embeds, queue the render of embed to start
|
|
422
437
|
* after the previous embed's render is complete. This helps in the load performance
|
|
423
438
|
* by decreasing the load on the browser.
|
|
439
|
+
* @version 1.5.0 or later
|
|
424
440
|
* @default false
|
|
425
441
|
*/
|
|
426
442
|
queueMultiRenders?: boolean;
|
|
427
443
|
/**
|
|
428
444
|
* Dynamic CSS Url to be injected in the loaded application.
|
|
429
|
-
*
|
|
445
|
+
* @version 1.6.0 or later
|
|
430
446
|
* @default ''
|
|
431
447
|
*/
|
|
432
448
|
customCssUrl?: string;
|
|
@@ -502,7 +518,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
502
518
|
IN = "IN"
|
|
503
519
|
}
|
|
504
520
|
/**
|
|
505
|
-
* A filter that can be applied to ThoughtSpot answers,
|
|
521
|
+
* A filter that can be applied to ThoughtSpot answers, Liveboards, or
|
|
506
522
|
* visualizations at runtime.
|
|
507
523
|
*/
|
|
508
524
|
export interface RuntimeFilter {
|
|
@@ -540,12 +556,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
540
556
|
*/
|
|
541
557
|
Load = "load",
|
|
542
558
|
/**
|
|
543
|
-
* Data pertaining to answer or
|
|
544
|
-
* @return data - The answer or
|
|
559
|
+
* Data pertaining to answer or Liveboard is received
|
|
560
|
+
* @return data - The answer or Liveboard data
|
|
545
561
|
*/
|
|
546
562
|
Data = "data",
|
|
547
563
|
/**
|
|
548
|
-
* Search/answer/
|
|
564
|
+
* Search/answer/Liveboard filters have been applied/updated
|
|
549
565
|
* @hidden
|
|
550
566
|
*/
|
|
551
567
|
FiltersChanged = "filtersChanged",
|
|
@@ -568,13 +584,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
568
584
|
/**
|
|
569
585
|
* A custom action has been triggered
|
|
570
586
|
* @return actionId - The id of the custom action
|
|
571
|
-
* @return data - The answer or
|
|
587
|
+
* @return data - The answer or Liveboard data
|
|
572
588
|
*/
|
|
573
589
|
CustomAction = "customAction",
|
|
574
590
|
/**
|
|
575
591
|
* A double click has been triggered on table/chart
|
|
576
592
|
* @return ContextMenuInputPoints - data point that is double clicked
|
|
577
|
-
*
|
|
593
|
+
* @version 1.5.0 or later
|
|
578
594
|
*/
|
|
579
595
|
VizPointDoubleClick = "vizPointDoubleClick",
|
|
580
596
|
/**
|
|
@@ -592,8 +608,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
592
608
|
*/
|
|
593
609
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
594
610
|
/**
|
|
595
|
-
* The height of the embedded
|
|
596
|
-
* @return data - The height of the embedded
|
|
611
|
+
* The height of the embedded Liveboard or visualization has been computed.
|
|
612
|
+
* @return data - The height of the embedded Liveboard or visualization
|
|
597
613
|
* @hidden
|
|
598
614
|
*/
|
|
599
615
|
EmbedHeight = "EMBED_HEIGHT",
|
|
@@ -605,7 +621,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
605
621
|
EmbedIframeCenter = "EmbedIframeCenter",
|
|
606
622
|
/**
|
|
607
623
|
* Detects the route change.
|
|
608
|
-
* @hidden
|
|
609
624
|
*/
|
|
610
625
|
RouteChange = "ROUTE_CHANGE",
|
|
611
626
|
/**
|
|
@@ -617,7 +632,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
617
632
|
* Emitted when the embed does not have cookie access. This
|
|
618
633
|
* happens on Safari where third-party cookies are blocked by default.
|
|
619
634
|
*
|
|
620
|
-
* @version 1.1.0
|
|
635
|
+
* @version 1.1.0 or later
|
|
621
636
|
*/
|
|
622
637
|
NoCookieAccess = "noCookieAccess",
|
|
623
638
|
/**
|
|
@@ -628,12 +643,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
628
643
|
SAMLComplete = "samlComplete",
|
|
629
644
|
/**
|
|
630
645
|
* Emitted when any modal is opened in the app
|
|
631
|
-
*
|
|
646
|
+
* @version 1.6.0 or later
|
|
632
647
|
*/
|
|
633
648
|
DialogOpen = "dialog-open",
|
|
634
649
|
/**
|
|
635
650
|
* Emitted when any modal is closed in the app
|
|
636
|
-
*
|
|
651
|
+
* @version 1.6.0 or later
|
|
637
652
|
*/
|
|
638
653
|
DialogClose = "dialog-close"
|
|
639
654
|
}
|
|
@@ -654,7 +669,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
654
669
|
* eg. { selectedPoints: []}
|
|
655
670
|
* @param columnGuid - a string guid of the column to drill by. This is optional,
|
|
656
671
|
* if not provided it will auto drill by the configured column. \
|
|
657
|
-
*
|
|
672
|
+
* @version 1.5.0 or later
|
|
658
673
|
*/
|
|
659
674
|
DrillDown = "triggerDrillDown",
|
|
660
675
|
/**
|
|
@@ -668,10 +683,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
668
683
|
*/
|
|
669
684
|
Reload = "reload",
|
|
670
685
|
/**
|
|
671
|
-
* Set the visible
|
|
672
|
-
* @param - an array of ids of
|
|
686
|
+
* Set the visible visualizations on a Liveboard.
|
|
687
|
+
* @param - an array of ids of visualizations to show, the ids not passed
|
|
673
688
|
* will be hidden.
|
|
674
|
-
*
|
|
689
|
+
* @version 1.6.0 or later
|
|
675
690
|
*/
|
|
676
691
|
SetVisibleVizs = "SetPinboardVisibleVizs"
|
|
677
692
|
}
|
|
@@ -700,6 +715,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
700
715
|
export enum Param {
|
|
701
716
|
DataSources = "dataSources",
|
|
702
717
|
DataSourceMode = "dataSourceMode",
|
|
718
|
+
ExpandAllDataSource = "expandAllDataSource",
|
|
703
719
|
DisableActions = "disableAction",
|
|
704
720
|
DisableActionReason = "disableHint",
|
|
705
721
|
ForceTable = "forceTable",
|
|
@@ -725,7 +741,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
725
741
|
}
|
|
726
742
|
/**
|
|
727
743
|
* The list of actions that can be performed on visual ThoughtSpot
|
|
728
|
-
* entities, such as answers and
|
|
744
|
+
* entities, such as answers and Liveboards.
|
|
729
745
|
*/
|
|
730
746
|
export enum Action {
|
|
731
747
|
Save = "save",
|
|
@@ -735,11 +751,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
735
751
|
MakeACopy = "makeACopy",
|
|
736
752
|
EditACopy = "editACopy",
|
|
737
753
|
CopyLink = "embedDocument",
|
|
738
|
-
/**
|
|
739
|
-
* @hidden
|
|
740
|
-
*/
|
|
741
|
-
PinboardSnapshot = "pinboardSnapshot",
|
|
742
|
-
LiveboardSnapshot = "liveboardSnapshot",
|
|
743
754
|
ResetLayout = "resetLayout",
|
|
744
755
|
Schedule = "schedule",
|
|
745
756
|
SchedulesList = "schedule-list",
|
|
@@ -776,7 +787,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
776
787
|
* @hidden
|
|
777
788
|
*/
|
|
778
789
|
PinboardInfo = "pinboardInfo",
|
|
779
|
-
LiveboardInfo = "
|
|
790
|
+
LiveboardInfo = "pinboardInfo",
|
|
780
791
|
SendAnswerFeedback = "sendFeedback",
|
|
781
792
|
/**
|
|
782
793
|
* @deprecated Will be removed in next version
|
|
@@ -881,7 +892,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
881
892
|
visibleActions?: Action[];
|
|
882
893
|
/**
|
|
883
894
|
* The list of runtime filters to apply to a search answer,
|
|
884
|
-
* visualization, or
|
|
895
|
+
* visualization, or Liveboard.
|
|
885
896
|
*/
|
|
886
897
|
runtimeFilters?: RuntimeFilter[];
|
|
887
898
|
}
|
|
@@ -920,7 +931,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
920
931
|
protected getBaseQueryParams(): {};
|
|
921
932
|
/**
|
|
922
933
|
* Constructs the base URL string to load v1 of the ThoughtSpot app.
|
|
923
|
-
* This is used for embedding
|
|
934
|
+
* This is used for embedding Liveboards, visualizations, and full application.
|
|
924
935
|
* @param queryString The query string to append to the URL.
|
|
925
936
|
* @param isAppEmbed A Boolean parameter to specify if you are embedding
|
|
926
937
|
* the full application.
|
|
@@ -979,15 +990,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
979
990
|
* @param callback A callback function
|
|
980
991
|
*/
|
|
981
992
|
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
982
|
-
/**
|
|
983
|
-
* Navigates users to the specified application page.
|
|
984
|
-
* Use this method to navigate users from the embedded
|
|
985
|
-
* ThoughtSpot context to a specific page in your app.
|
|
986
|
-
* @param path The page path string.
|
|
987
|
-
* For example, to navigate users to a liveboard page,
|
|
988
|
-
* define the method as navigateToPage('liveboard/<liveboardId>').
|
|
989
|
-
*/
|
|
990
|
-
navigateToPage(path: string): void;
|
|
991
993
|
/**
|
|
992
994
|
* Triggers an event to the embedded app
|
|
993
995
|
* @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.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"asciidoctor": "^2.2.1",
|
|
66
66
|
"babel-jest": "^26.6.3",
|
|
67
67
|
"babel-preset-gatsby": "^1.10.0",
|
|
68
|
+
"classnames": "^2.3.1",
|
|
68
69
|
"command-line-args": "^5.1.1",
|
|
69
70
|
"coveralls": "^3.1.0",
|
|
70
71
|
"dts-bundle": "0.7.3",
|
|
@@ -126,6 +127,9 @@
|
|
|
126
127
|
"type": "git",
|
|
127
128
|
"url": "git+https://github.com/thoughtspot/visual-embed-sdk.git"
|
|
128
129
|
},
|
|
130
|
+
"publishConfig": {
|
|
131
|
+
"registry": "https://registry.npmjs.org"
|
|
132
|
+
},
|
|
129
133
|
"keywords": [
|
|
130
134
|
"thoughtspot",
|
|
131
135
|
"everywhere",
|
package/src/auth.ts
CHANGED
|
@@ -25,6 +25,8 @@ export const EndPoints = {
|
|
|
25
25
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
26
26
|
SSO_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
27
27
|
`/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
28
|
+
IODC_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
29
|
+
`/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
28
30
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
29
31
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
30
32
|
};
|
|
@@ -171,7 +173,10 @@ async function samlPopupFlow(ssoURL: string) {
|
|
|
171
173
|
* Perform SAML authentication
|
|
172
174
|
* @param embedConfig The embed configuration
|
|
173
175
|
*/
|
|
174
|
-
|
|
176
|
+
const doSSOAuth = async (
|
|
177
|
+
embedConfig: EmbedConfig,
|
|
178
|
+
ssoEndPoint: string,
|
|
179
|
+
): Promise<void> => {
|
|
175
180
|
const { thoughtSpotHost } = embedConfig;
|
|
176
181
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
177
182
|
if (loggedIn) {
|
|
@@ -190,6 +195,17 @@ export const doSamlAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
190
195
|
return;
|
|
191
196
|
}
|
|
192
197
|
|
|
198
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
199
|
+
if (embedConfig.noRedirect) {
|
|
200
|
+
await samlPopupFlow(ssoURL);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
window.location.href = ssoURL;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
208
|
+
const { thoughtSpotHost } = embedConfig;
|
|
193
209
|
// redirect for SSO, when the SSO authentication is done, this page will be loaded
|
|
194
210
|
// again and the same JS will execute again.
|
|
195
211
|
const ssoRedirectUrl = embedConfig.noRedirect
|
|
@@ -201,13 +217,23 @@ export const doSamlAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
201
217
|
encodeURIComponent(ssoRedirectUrl),
|
|
202
218
|
)}`;
|
|
203
219
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
await samlPopupFlow(ssoURL);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
220
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
221
|
+
};
|
|
209
222
|
|
|
210
|
-
|
|
223
|
+
export const doIODCAuth = async (embedConfig: EmbedConfig) => {
|
|
224
|
+
const { thoughtSpotHost } = embedConfig;
|
|
225
|
+
// redirect for SSO, when the SSO authentication is done, this page will be loaded
|
|
226
|
+
// again and the same JS will execute again.
|
|
227
|
+
const ssoRedirectUrl = embedConfig.noRedirect
|
|
228
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
229
|
+
: appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
|
|
230
|
+
|
|
231
|
+
// bring back the page to the same URL
|
|
232
|
+
const ssoEndPoint = `${EndPoints.IODC_LOGIN_TEMPLATE(
|
|
233
|
+
encodeURIComponent(ssoRedirectUrl),
|
|
234
|
+
)}`;
|
|
235
|
+
|
|
236
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
211
237
|
};
|
|
212
238
|
|
|
213
239
|
/**
|
|
@@ -219,6 +245,8 @@ export const authenticate = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
219
245
|
switch (authType) {
|
|
220
246
|
case AuthType.SSO:
|
|
221
247
|
return doSamlAuth(embedConfig);
|
|
248
|
+
case AuthType.IODC:
|
|
249
|
+
return doIODCAuth(embedConfig);
|
|
222
250
|
case AuthType.AuthServer:
|
|
223
251
|
return doTokenAuth(embedConfig);
|
|
224
252
|
case AuthType.Basic:
|
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({
|
|
@@ -168,4 +170,42 @@ describe('App embed tests', () => {
|
|
|
168
170
|
);
|
|
169
171
|
});
|
|
170
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
|
+
});
|
|
171
211
|
});
|
package/src/embed/app.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface AppViewConfig extends ViewConfig {
|
|
|
72
72
|
pageId?: Page;
|
|
73
73
|
/**
|
|
74
74
|
* This puts a filter tag on the application. All metadata lists in the application, such as
|
|
75
|
-
*
|
|
75
|
+
* Liveboards and answers, would be filtered by this tag.
|
|
76
76
|
*/
|
|
77
77
|
tag?: string;
|
|
78
78
|
/**
|
|
@@ -95,7 +95,7 @@ export class AppEmbed extends V1Embed {
|
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Constructs a map of parameters to be passed on to the
|
|
98
|
-
* embedded
|
|
98
|
+
* embedded Liveboard or visualization.
|
|
99
99
|
*/
|
|
100
100
|
private getEmbedParams() {
|
|
101
101
|
const params = this.getBaseQueryParams();
|
|
@@ -173,6 +173,25 @@ export class AppEmbed extends V1Embed {
|
|
|
173
173
|
return path;
|
|
174
174
|
}
|
|
175
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
|
+
|
|
176
195
|
/**
|
|
177
196
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
178
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 {
|
|
@@ -120,7 +121,13 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
120
121
|
...defaultViewConfig,
|
|
121
122
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
122
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,10 +140,29 @@ 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,
|
|
@@ -155,7 +181,7 @@ 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,
|
|
@@ -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
|
});
|