@thoughtspot/visual-embed-sdk 1.5.0 → 1.6.0-alpha.3
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/search.d.ts +0 -4
- 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 +22 -20
- package/dist/tsembed.es.js +83 -71
- package/dist/tsembed.js +82 -69
- package/lib/package.json +1 -2
- 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/liveboard.js +115 -0
- 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/search.d.ts +0 -4
- 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 +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 +22 -20
- package/lib/src/types.js +19 -18
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/fetchAnswers.d.ts +3 -0
- package/lib/src/utils/fetchAnswers.js +49 -0
- package/lib/src/utils/fetchAnswers.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +78 -62
- package/package.json +1 -2
- 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/search.ts +0 -5
- 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 +22 -20
package/lib/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,qCAAqC;AACrC,MAAM,CAAN,IAAY,QAoBX;AApBD,WAAY,QAAQ;IAChB;;OAEG;IACH,yBAAa,CAAA;IACb;;OAEG;IACH,4BAAgB,CAAA;IAChB;;OAEG;IACH,qCAAyB,CAAA;IACzB;;;;;OAKG;IACH,2BAAe,CAAA;AACnB,CAAC,EApBW,QAAQ,KAAR,QAAQ,QAoBnB;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,qCAAqC;AACrC,MAAM,CAAN,IAAY,QAoBX;AApBD,WAAY,QAAQ;IAChB;;OAEG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B,2DAAiD,CAAA;IACjD,qBAAW,CAAA;IACX,uCAA6B,CAAA;IAC7B,uCAA6B,CAAA;IAC7B,6BAAmB,CAAA;IACnB,oDAA0C,CAAA;IAC1C,oDAA0C,CAAA;IAC1C,iEAAuD,CAAA;IACvD,8CAAoC,CAAA;IACpC,wDAA8C,CAAA;IAC9C,mDAAyC,CAAA;IACzC,6BAAmB,CAAA;IACnB,yCAA+B,CAAA;IAC/B,qDAA2C,CAAA;AAC/C,CAAC,EAhEW,MAAM,KAAN,MAAM,QAgEjB;AAQD,qCAAqC;AACrC,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,sDAAqC,CAAA;IACrC,sEAAqD,CAAA;AACzD,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OperationType } from '../types';
|
|
2
|
+
function FetchAnswers(session, query, operation, thoughtSpotHost) {
|
|
3
|
+
let variable;
|
|
4
|
+
const fetchQuery = async (variables) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operation}`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
10
|
+
'x-requested-by': 'ThoughtSpot',
|
|
11
|
+
accept: '*/*',
|
|
12
|
+
'accept-language': 'en-us',
|
|
13
|
+
},
|
|
14
|
+
body: JSON.stringify({
|
|
15
|
+
operationName: operation,
|
|
16
|
+
query,
|
|
17
|
+
variables,
|
|
18
|
+
}),
|
|
19
|
+
credentials: 'include'
|
|
20
|
+
});
|
|
21
|
+
const result = await response.json();
|
|
22
|
+
return result.data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getAnswer = (offset, batchSize) => {
|
|
29
|
+
if (operation === OperationType.GetChartWithData) {
|
|
30
|
+
variable = { batchSize, offset };
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
variable = {
|
|
34
|
+
dataPaginationParams: {
|
|
35
|
+
isClientPaginated: true,
|
|
36
|
+
offset,
|
|
37
|
+
size: batchSize,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return fetchQuery({
|
|
42
|
+
session,
|
|
43
|
+
...variable,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return getAnswer;
|
|
47
|
+
}
|
|
48
|
+
export default FetchAnswers;
|
|
49
|
+
//# sourceMappingURL=fetchAnswers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAnswers.js","sourceRoot":"","sources":["../../../src/utils/fetchAnswers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D,SAAS,YAAY,CACjB,OAAyB,EACzB,KAAa,EACb,SAAiB,EACjB,eAAuB;IAEvB,IAAI,QAAa,CAAC;IAElB,MAAM,UAAU,GAAG,KAAK,EAAE,SAAc,EAAE,EAAE;QACxC,IAAI;YACA,MAAM,QAAQ,GAAG,MAAM,KAAK,CACxB,GAAG,eAAe,cAAc,SAAS,EAAE,EAC3C;gBACI,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACL,cAAc,EAAE,gCAAgC;oBAChD,gBAAgB,EAAE,aAAa;oBAC/B,MAAM,EAAE,KAAK;oBACb,iBAAiB,EAAE,OAAO;iBAC7B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACjB,aAAa,EAAE,SAAS;oBACxB,KAAK;oBACL,SAAS;iBACZ,CAAC;gBACF,WAAW,EAAE,SAAS;aACzB,CACA,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAE,EAAE;QACpD,IAAI,SAAS,KAAK,aAAa,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;SACpC;aAAM;YACH,QAAQ,GAAG;gBACP,oBAAoB,EAAE;oBAClB,iBAAiB,EAAE,IAAI;oBACvB,MAAM;oBACN,IAAI,EAAE,SAAS;iBAClB;aACJ,CAAC;SACL;QACD,OAAO,UAAU,CAAC;YACd,OAAO;YACP,GAAG,QAAQ;SACd,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -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
|
|
|
@@ -248,10 +275,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
248
275
|
* using raw answer data.
|
|
249
276
|
*/
|
|
250
277
|
hideResults?: boolean;
|
|
251
|
-
/**
|
|
252
|
-
* If set to true, expands all the data sources panel.
|
|
253
|
-
*/
|
|
254
|
-
expandAllDataSource?: boolean;
|
|
255
278
|
/**
|
|
256
279
|
* If set to true, the Search Assist feature is enabled.
|
|
257
280
|
*/
|
|
@@ -405,12 +428,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
405
428
|
* When there are multiple embeds, queue the render of embed to start
|
|
406
429
|
* after the previous embed's render is complete. This helps in the load performance
|
|
407
430
|
* by decreasing the load on the browser.
|
|
431
|
+
* * _Version 1.5.0 or later _
|
|
408
432
|
* @default false
|
|
409
433
|
*/
|
|
410
434
|
queueMultiRenders?: boolean;
|
|
411
435
|
/**
|
|
412
436
|
* Dynamic CSS Url to be injected in the loaded application.
|
|
413
|
-
*
|
|
437
|
+
* * _Version 1.6.0 or later _
|
|
414
438
|
* @default ''
|
|
415
439
|
*/
|
|
416
440
|
customCssUrl?: string;
|
|
@@ -486,7 +510,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
486
510
|
IN = "IN"
|
|
487
511
|
}
|
|
488
512
|
/**
|
|
489
|
-
* A filter that can be applied to ThoughtSpot answers,
|
|
513
|
+
* A filter that can be applied to ThoughtSpot answers, Liveboards, or
|
|
490
514
|
* visualizations at runtime.
|
|
491
515
|
*/
|
|
492
516
|
export interface RuntimeFilter {
|
|
@@ -524,12 +548,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
524
548
|
*/
|
|
525
549
|
Load = "load",
|
|
526
550
|
/**
|
|
527
|
-
* Data pertaining to answer or
|
|
528
|
-
* @return data - The answer or
|
|
551
|
+
* Data pertaining to answer or Liveboard is received
|
|
552
|
+
* @return data - The answer or Liveboard data
|
|
529
553
|
*/
|
|
530
554
|
Data = "data",
|
|
531
555
|
/**
|
|
532
|
-
* Search/answer/
|
|
556
|
+
* Search/answer/Liveboard filters have been applied/updated
|
|
533
557
|
* @hidden
|
|
534
558
|
*/
|
|
535
559
|
FiltersChanged = "filtersChanged",
|
|
@@ -552,13 +576,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
552
576
|
/**
|
|
553
577
|
* A custom action has been triggered
|
|
554
578
|
* @return actionId - The id of the custom action
|
|
555
|
-
* @return data - The answer or
|
|
579
|
+
* @return data - The answer or Liveboard data
|
|
556
580
|
*/
|
|
557
581
|
CustomAction = "customAction",
|
|
558
582
|
/**
|
|
559
583
|
* A double click has been triggered on table/chart
|
|
560
584
|
* @return ContextMenuInputPoints - data point that is double clicked
|
|
561
|
-
* *
|
|
585
|
+
* * _Version 1.5.0 or later _
|
|
562
586
|
*/
|
|
563
587
|
VizPointDoubleClick = "vizPointDoubleClick",
|
|
564
588
|
/**
|
|
@@ -576,8 +600,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
576
600
|
*/
|
|
577
601
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
578
602
|
/**
|
|
579
|
-
* The height of the embedded
|
|
580
|
-
* @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
|
|
581
605
|
* @hidden
|
|
582
606
|
*/
|
|
583
607
|
EmbedHeight = "EMBED_HEIGHT",
|
|
@@ -589,7 +613,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
589
613
|
EmbedIframeCenter = "EmbedIframeCenter",
|
|
590
614
|
/**
|
|
591
615
|
* Detects the route change.
|
|
592
|
-
* @hidden
|
|
593
616
|
*/
|
|
594
617
|
RouteChange = "ROUTE_CHANGE",
|
|
595
618
|
/**
|
|
@@ -612,12 +635,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
612
635
|
SAMLComplete = "samlComplete",
|
|
613
636
|
/**
|
|
614
637
|
* Emitted when any modal is opened in the app
|
|
615
|
-
* *
|
|
638
|
+
* * _Version 1.6.0 or later _
|
|
616
639
|
*/
|
|
617
640
|
DialogOpen = "dialog-open",
|
|
618
641
|
/**
|
|
619
642
|
* Emitted when any modal is closed in the app
|
|
620
|
-
* *
|
|
643
|
+
* * _Version 1.6.0 or later _
|
|
621
644
|
*/
|
|
622
645
|
DialogClose = "dialog-close"
|
|
623
646
|
}
|
|
@@ -638,7 +661,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
638
661
|
* eg. { selectedPoints: []}
|
|
639
662
|
* @param columnGuid - a string guid of the column to drill by. This is optional,
|
|
640
663
|
* if not provided it will auto drill by the configured column. \
|
|
641
|
-
* *
|
|
664
|
+
* * _Version 1.5.0 or later _
|
|
642
665
|
*/
|
|
643
666
|
DrillDown = "triggerDrillDown",
|
|
644
667
|
/**
|
|
@@ -652,10 +675,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
652
675
|
*/
|
|
653
676
|
Reload = "reload",
|
|
654
677
|
/**
|
|
655
|
-
* Set the visible
|
|
656
|
-
* @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
|
|
657
680
|
* will be hidden.
|
|
658
|
-
*
|
|
681
|
+
* * _Version 1.6.0 or later _
|
|
659
682
|
*/
|
|
660
683
|
SetVisibleVizs = "SetPinboardVisibleVizs"
|
|
661
684
|
}
|
|
@@ -684,11 +707,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
684
707
|
export enum Param {
|
|
685
708
|
DataSources = "dataSources",
|
|
686
709
|
DataSourceMode = "dataSourceMode",
|
|
687
|
-
ExpandAllDataSource = "expandAllDataSource",
|
|
688
710
|
DisableActions = "disableAction",
|
|
689
711
|
DisableActionReason = "disableHint",
|
|
690
712
|
ForceTable = "forceTable",
|
|
691
|
-
|
|
713
|
+
preventLiveboardFilterRemoval = "preventPinboardFilterRemoval",
|
|
692
714
|
SearchQuery = "searchQuery",
|
|
693
715
|
HideActions = "hideAction",
|
|
694
716
|
HideObjects = "hideObjects",
|
|
@@ -710,7 +732,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
710
732
|
}
|
|
711
733
|
/**
|
|
712
734
|
* The list of actions that can be performed on visual ThoughtSpot
|
|
713
|
-
* entities, such as answers and
|
|
735
|
+
* entities, such as answers and Liveboards.
|
|
714
736
|
*/
|
|
715
737
|
export enum Action {
|
|
716
738
|
Save = "save",
|
|
@@ -720,7 +742,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
720
742
|
MakeACopy = "makeACopy",
|
|
721
743
|
EditACopy = "editACopy",
|
|
722
744
|
CopyLink = "embedDocument",
|
|
723
|
-
PinboardSnapshot = "pinboardSnapshot",
|
|
724
745
|
ResetLayout = "resetLayout",
|
|
725
746
|
Schedule = "schedule",
|
|
726
747
|
SchedulesList = "schedule-list",
|
|
@@ -753,7 +774,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
753
774
|
Describe = "describe",
|
|
754
775
|
Relate = "relate",
|
|
755
776
|
CustomizeHeadlines = "customizeHeadlines",
|
|
777
|
+
/**
|
|
778
|
+
* @hidden
|
|
779
|
+
*/
|
|
756
780
|
PinboardInfo = "pinboardInfo",
|
|
781
|
+
LiveboardInfo = "pinboardInfo",
|
|
757
782
|
SendAnswerFeedback = "sendFeedback",
|
|
758
783
|
/**
|
|
759
784
|
* @deprecated Will be removed in next version
|
|
@@ -858,7 +883,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
858
883
|
visibleActions?: Action[];
|
|
859
884
|
/**
|
|
860
885
|
* The list of runtime filters to apply to a search answer,
|
|
861
|
-
* visualization, or
|
|
886
|
+
* visualization, or Liveboard.
|
|
862
887
|
*/
|
|
863
888
|
runtimeFilters?: RuntimeFilter[];
|
|
864
889
|
}
|
|
@@ -897,7 +922,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
897
922
|
protected getBaseQueryParams(): {};
|
|
898
923
|
/**
|
|
899
924
|
* Constructs the base URL string to load v1 of the ThoughtSpot app.
|
|
900
|
-
* This is used for embedding
|
|
925
|
+
* This is used for embedding Liveboards, visualizations, and full application.
|
|
901
926
|
* @param queryString The query string to append to the URL.
|
|
902
927
|
* @param isAppEmbed A Boolean parameter to specify if you are embedding
|
|
903
928
|
* the full application.
|
|
@@ -956,15 +981,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
956
981
|
* @param callback A callback function
|
|
957
982
|
*/
|
|
958
983
|
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
959
|
-
/**
|
|
960
|
-
* Navigates users to the specified application page.
|
|
961
|
-
* Use this method to navigate users from the embedded
|
|
962
|
-
* ThoughtSpot context to a specific page in your app.
|
|
963
|
-
* @param path The page path string.
|
|
964
|
-
* For example, to navigate users to a pinboard page,
|
|
965
|
-
* define the method as navigateToPage('pinboard/<pinboardId>').
|
|
966
|
-
*/
|
|
967
|
-
navigateToPage(path: string): void;
|
|
968
984
|
/**
|
|
969
985
|
* Triggers an event to the embedded app
|
|
970
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.6.0-alpha.3",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -65,7 +65,6 @@
|
|
|
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",
|
|
69
68
|
"command-line-args": "^5.1.1",
|
|
70
69
|
"coveralls": "^3.1.0",
|
|
71
70
|
"dts-bundle": "0.7.3",
|
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
|