@thoughtspot/visual-embed-sdk 1.33.4 → 1.33.5

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.
Files changed (98) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/config.d.ts.map +1 -1
  3. package/cjs/src/config.js.map +1 -1
  4. package/cjs/src/embed/app.d.ts.map +1 -1
  5. package/cjs/src/embed/app.js +0 -1
  6. package/cjs/src/embed/app.js.map +1 -1
  7. package/cjs/src/embed/base.d.ts +4 -1
  8. package/cjs/src/embed/base.d.ts.map +1 -1
  9. package/cjs/src/embed/base.js +14 -6
  10. package/cjs/src/embed/base.js.map +1 -1
  11. package/cjs/src/embed/base.spec.js +45 -3
  12. package/cjs/src/embed/base.spec.js.map +1 -1
  13. package/cjs/src/embed/bodyless-conversation.d.ts +17 -0
  14. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  15. package/cjs/src/embed/bodyless-conversation.js +13 -0
  16. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  17. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  18. package/cjs/src/embed/liveboard.js +0 -1
  19. package/cjs/src/embed/liveboard.js.map +1 -1
  20. package/cjs/src/embed/sage.d.ts.map +1 -1
  21. package/cjs/src/embed/sage.js +0 -1
  22. package/cjs/src/embed/sage.js.map +1 -1
  23. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  24. package/cjs/src/embed/ts-embed.js +13 -2
  25. package/cjs/src/embed/ts-embed.js.map +1 -1
  26. package/cjs/src/embed/ts-embed.spec.js +40 -0
  27. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  28. package/cjs/src/react/index.spec.js +2 -2
  29. package/cjs/src/react/index.spec.js.map +1 -1
  30. package/cjs/src/types.d.ts +43 -5
  31. package/cjs/src/types.d.ts.map +1 -1
  32. package/cjs/src/types.js +5 -3
  33. package/cjs/src/types.js.map +1 -1
  34. package/dist/{index-Cl8Rsh6W.js → index-CAHz286m.js} +1 -1
  35. package/dist/src/config.d.ts.map +1 -1
  36. package/dist/src/embed/app.d.ts.map +1 -1
  37. package/dist/src/embed/base.d.ts +4 -1
  38. package/dist/src/embed/base.d.ts.map +1 -1
  39. package/dist/src/embed/bodyless-conversation.d.ts +17 -0
  40. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  41. package/dist/src/embed/liveboard.d.ts.map +1 -1
  42. package/dist/src/embed/sage.d.ts.map +1 -1
  43. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  44. package/dist/src/types.d.ts +43 -5
  45. package/dist/src/types.d.ts.map +1 -1
  46. package/dist/tsembed-react.es.js +142 -65
  47. package/dist/tsembed-react.js +141 -64
  48. package/dist/tsembed.es.js +164 -67
  49. package/dist/tsembed.js +163 -66
  50. package/dist/visual-embed-sdk-react-full.d.ts +64 -6
  51. package/dist/visual-embed-sdk-react.d.ts +64 -6
  52. package/dist/visual-embed-sdk.d.ts +64 -6
  53. package/lib/package.json +1 -1
  54. package/lib/src/config.d.ts.map +1 -1
  55. package/lib/src/config.js.map +1 -1
  56. package/lib/src/embed/app.d.ts.map +1 -1
  57. package/lib/src/embed/app.js +0 -1
  58. package/lib/src/embed/app.js.map +1 -1
  59. package/lib/src/embed/base.d.ts +4 -1
  60. package/lib/src/embed/base.d.ts.map +1 -1
  61. package/lib/src/embed/base.js +15 -7
  62. package/lib/src/embed/base.js.map +1 -1
  63. package/lib/src/embed/base.spec.js +45 -3
  64. package/lib/src/embed/base.spec.js.map +1 -1
  65. package/lib/src/embed/bodyless-conversation.d.ts +17 -0
  66. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  67. package/lib/src/embed/bodyless-conversation.js +13 -0
  68. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  69. package/lib/src/embed/liveboard.d.ts.map +1 -1
  70. package/lib/src/embed/liveboard.js +0 -1
  71. package/lib/src/embed/liveboard.js.map +1 -1
  72. package/lib/src/embed/sage.d.ts.map +1 -1
  73. package/lib/src/embed/sage.js +0 -1
  74. package/lib/src/embed/sage.js.map +1 -1
  75. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  76. package/lib/src/embed/ts-embed.js +13 -2
  77. package/lib/src/embed/ts-embed.js.map +1 -1
  78. package/lib/src/embed/ts-embed.spec.js +41 -1
  79. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  80. package/lib/src/react/index.spec.js +2 -2
  81. package/lib/src/react/index.spec.js.map +1 -1
  82. package/lib/src/types.d.ts +43 -5
  83. package/lib/src/types.d.ts.map +1 -1
  84. package/lib/src/types.js +5 -3
  85. package/lib/src/types.js.map +1 -1
  86. package/lib/src/visual-embed-sdk.d.ts +64 -6
  87. package/package.json +1 -1
  88. package/src/config.ts +0 -1
  89. package/src/embed/app.ts +0 -1
  90. package/src/embed/base.spec.ts +48 -3
  91. package/src/embed/base.ts +21 -7
  92. package/src/embed/bodyless-conversation.ts +17 -0
  93. package/src/embed/liveboard.ts +0 -1
  94. package/src/embed/sage.ts +0 -1
  95. package/src/embed/ts-embed.spec.ts +47 -0
  96. package/src/embed/ts-embed.ts +16 -2
  97. package/src/react/index.spec.tsx +2 -2
  98. package/src/types.ts +40 -4
@@ -542,10 +542,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
542
542
  * to your app.
543
543
  * @param url The URL provided for prefetch
544
544
  * @param prefetchFeatures Specify features which needs to be prefetched.
545
+ * @param additionalFlags This can be used to add any URL flag.
545
546
  * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
546
547
  * @group Global methods
547
548
  */
548
- export const prefetch: (url?: string, prefetchFeatures?: PrefetchFeatures[]) => void;
549
+ export const prefetch: (url?: string, prefetchFeatures?: PrefetchFeatures[], additionalFlags?: {
550
+ [key: string]: string | number | boolean;
551
+ }) => void;
549
552
  /**
550
553
  * Initializes the Visual Embed SDK globally and perform
551
554
  * authentication if applicable. This function needs to be called before any ThoughtSpot
@@ -1381,6 +1384,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search-bar' {
1381
1384
 
1382
1385
  declare module '@thoughtspot/visual-embed-sdk/embed/bodyless-conversation' {
1383
1386
  import { ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
1387
+ /**
1388
+ * Configuration for bodyless conversation options.
1389
+ * @group Embed components
1390
+ */
1384
1391
  export interface BodylessConversationViewConfig extends ViewConfig {
1385
1392
  /**
1386
1393
  * The ID of the worksheet to use for the conversation.
@@ -1390,6 +1397,19 @@ declare module '@thoughtspot/visual-embed-sdk/embed/bodyless-conversation' {
1390
1397
  /**
1391
1398
  * Create a conversation embed, which can be integrated inside
1392
1399
  * chatbots or other conversational interfaces.
1400
+ * @example
1401
+ * ```js
1402
+ * import { BodylessConversation } from '@thoughtspot/visual-embed-sdk';
1403
+ *
1404
+ * const conversation = new BodylessConversation({
1405
+ * worksheetId: 'worksheetId',
1406
+ * });
1407
+ *
1408
+ * const { container, error } = await conversation.sendMessage('show me sales by region');
1409
+ *
1410
+ * // append the container to the DOM
1411
+ * document.body.appendChild(container); // or to any other element
1412
+ * ```
1393
1413
  * @group Embed components
1394
1414
  * @version SDK: 1.33.1 | ThoughtSpot: 10.5.0.cl
1395
1415
  */
@@ -2250,6 +2270,28 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
2250
2270
  * @version SDK 1.32.3 | Thoughtspot: *
2251
2271
  */
2252
2272
  disableLoginFailurePage?: boolean;
2273
+ /**
2274
+ * This is an object (key/val) of override flags which will be applied
2275
+ * to the internal embedded object. This can be used to add any
2276
+ * URL flag.
2277
+ * Warning: This option is for advanced use only and is used internally
2278
+ * to control embed behavior in non-regular ways. We do not publish the
2279
+ * list of supported keys and values associated with each.
2280
+ * @example
2281
+ * ```js
2282
+ * const embed = new LiveboardEmbed('#embed', {
2283
+ * ... // other liveboard view config
2284
+ * additionalFlags: {
2285
+ * flag1: 'value1',
2286
+ * flag2: 'value2'
2287
+ * }
2288
+ * });
2289
+ * ```
2290
+ * @version SDK: 1.33.5 | ThoughtSpot: *
2291
+ */
2292
+ additionalFlags?: {
2293
+ [key: string]: string | number | boolean;
2294
+ };
2253
2295
  }
2254
2296
  export interface LayoutConfig {
2255
2297
  }
@@ -2437,6 +2479,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
2437
2479
  * This is an object (key/val) of override flags which will be applied
2438
2480
  * to the internal embedded object. This can be used to add any
2439
2481
  * URL flag.
2482
+ * If the same flags are passed in init, they will be overriden by the values here.
2440
2483
  * Warning: This option is for advanced use only and is used internally
2441
2484
  * to control embed behavior in non-regular ways. We do not publish the
2442
2485
  * list of supported keys and values associated with each.
@@ -2724,6 +2767,19 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
2724
2767
  * ```
2725
2768
  */
2726
2769
  enableCustomColumnGroups?: boolean;
2770
+ /**
2771
+ * View content for another org directly without having to use the org switcher
2772
+ * This flag is honoured if orgPerUrl feature is enabled for the ThoughtSpot cluster
2773
+ * @example
2774
+ * ```js
2775
+ * const embed = new LiveboardEmbed('#embed', {
2776
+ * ... // other options
2777
+ * overrideOrgId: 142536
2778
+ * });
2779
+ * ```
2780
+ * @version SDK: 1.35.0 | ThoughtSpot: 10.5.0.cl
2781
+ */
2782
+ overrideOrgId?: number;
2727
2783
  }
2728
2784
  /**
2729
2785
  * MessagePayload: Embed event payload: message type, data and status (start/end)
@@ -2769,7 +2825,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
2769
2825
  };
2770
2826
  export type GenericCallbackFn = (...args: any[]) => any;
2771
2827
  export type QueryParams = {
2772
- [key: string]: string;
2828
+ [key: string]: string | boolean | number;
2773
2829
  };
2774
2830
  /**
2775
2831
  * A map of the supported runtime filter operations
@@ -4604,12 +4660,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
4604
4660
  * see link:https://developers.thoughtspot.com/docs/runtime-filters#rtOperator[Developer Documentation].
4605
4661
  *
4606
4662
  * `values` - An array of one or several values. The value definition on the
4607
- * data type you choose to filter on. For a complete list of supported data types, see
4608
- * link:https://developers.thoughtspot.com/docs/runtime-filters#_supported_data_types[Supported data types].
4663
+ * data type you choose to filter on. For a complete list of supported data types,
4664
+ * see
4665
+ * link:https://developers.thoughtspot.com/docs/runtime-filters#_supported_data_types[Supported
4666
+ * data types].
4609
4667
  *
4610
4668
  * `type` - To update filters for date time, specify the date format type.
4611
4669
  * For more information and examples, see link:https://developers.thoughtspot.com/docs/embed-liveboard#_date_filters[Date filters].
4612
- *
4613
4670
  * @example
4614
4671
  * ```js
4615
4672
  *
@@ -4895,7 +4952,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
4895
4952
  ShowLiveboardReverifyBanner = "showLiveboardReverifyBanner",
4896
4953
  LiveboardHeaderV2 = "isLiveboardHeaderV2Enabled",
4897
4954
  SpotterEnabled = "isSpotterExperienceEnabled",
4898
- IsUnifiedSearchExperienceEnabled = "isUnifiedSearchExperienceEnabled"
4955
+ IsUnifiedSearchExperienceEnabled = "isUnifiedSearchExperienceEnabled",
4956
+ OverrideOrgId = "orgId"
4899
4957
  }
4900
4958
  /**
4901
4959
  * ThoughtSpot application pages include actions and menu commands
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.33.4",
3
+ "version": "1.33.5",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
package/src/config.ts CHANGED
@@ -42,7 +42,6 @@ export const getThoughtSpotHost = (config: EmbedConfig): string => {
42
42
  }
43
43
  // const urlParams = urlParts[7];
44
44
  // const hash = urlParts[8];
45
-
46
45
  return `${protocol}//${host}${path}`;
47
46
  };
48
47
 
package/src/embed/app.ts CHANGED
@@ -505,7 +505,6 @@ export class AppEmbed extends V1Embed {
505
505
  } = this.viewConfig;
506
506
 
507
507
  let params = {};
508
- params[Param.EmbedApp] = true;
509
508
  params[Param.PrimaryNavHidden] = !showPrimaryNavbar;
510
509
  params[Param.HideProfleAndHelp] = !!disableProfileAndHelp;
511
510
  params[Param.HideApplicationSwitcher] = !!hideApplicationSwitcher;
@@ -249,7 +249,7 @@ describe('Base TS Embed', () => {
249
249
  });
250
250
 
251
251
  test('Should add the prefetch iframe when prefetch is called. Should remove it once init is called.', async () => {
252
- const url = 'https://10.87.90.95/';
252
+ const url = 'https://10.87.90.95/?embedApp=true';
253
253
  index.init({
254
254
  thoughtSpotHost: url,
255
255
  authType: index.AuthType.None,
@@ -266,8 +266,8 @@ describe('Base TS Embed', () => {
266
266
 
267
267
  test('Should add the prefetch iframe when prefetch is called with multiple options', async () => {
268
268
  const url = 'https://10.87.90.95/';
269
- const searchUrl = `${url}v2/#/embed/answer`;
270
- const liveboardUrl = url;
269
+ const searchUrl = `${url}v2/?embedApp=true#/embed/answer`;
270
+ const liveboardUrl = `${url}?embedApp=true`;
271
271
  index.prefetch(url, [
272
272
  index.PrefetchFeatures.SearchEmbed,
273
273
  index.PrefetchFeatures.LiveboardEmbed,
@@ -281,6 +281,51 @@ describe('Base TS Embed', () => {
281
281
  expect(secondIframe.src).toBe(liveboardUrl);
282
282
  });
283
283
 
284
+ test('Should add the prefetch iframe with additionalFlags', async () => {
285
+ const url = 'https://10.87.90.95/';
286
+ const searchUrl = `${url}v2/?embedApp=true&flag2=bool&flag3=block&flag1=true#/embed/answer`;
287
+ const liveboardUrl = `${url}?embedApp=true&flag2=bool&flag3=block&flag1=true`;
288
+ base.init({
289
+ thoughtSpotHost: url,
290
+ authType: index.AuthType.None,
291
+ additionalFlags: {
292
+ flag2: 'bar',
293
+ flag3: 'block',
294
+ },
295
+ });
296
+ index.prefetch(url, [
297
+ index.PrefetchFeatures.SearchEmbed,
298
+ index.PrefetchFeatures.LiveboardEmbed,
299
+ ],
300
+ { flag1: true, flag2: 'bool' });
301
+ expect(getAllIframeEl().length).toBe(2);
302
+ const prefetchIframe = document.querySelectorAll<HTMLIFrameElement>('.prefetchIframe');
303
+ expect(prefetchIframe.length).toBe(2);
304
+ const firstIframe = <HTMLIFrameElement>prefetchIframe[0];
305
+ expect(firstIframe.src).toBe(searchUrl);
306
+ const secondIframe = <HTMLIFrameElement>prefetchIframe[1];
307
+ expect(secondIframe.src).toBe(liveboardUrl);
308
+ });
309
+
310
+ test('Should add the prefetch iframe with additionalFlags for prefetch from init', async () => {
311
+ const url = 'https://10.87.90.95/';
312
+ const prefetchUrl = `${url}?embedApp=true&flag2=bar&flag3=block`;
313
+ base.init({
314
+ thoughtSpotHost: url,
315
+ authType: index.AuthType.None,
316
+ additionalFlags: {
317
+ flag2: 'bar',
318
+ flag3: 'block',
319
+ },
320
+ callPrefetch: true,
321
+ });
322
+ expect(getAllIframeEl().length).toBe(1);
323
+ const prefetchIframe = document.querySelectorAll<HTMLIFrameElement>('.prefetchIframe');
324
+ expect(prefetchIframe.length).toBe(1);
325
+ const firstIframe = <HTMLIFrameElement>prefetchIframe[0];
326
+ expect(firstIframe.src).toBe(prefetchUrl);
327
+ });
328
+
284
329
  test('Should not generate a prefetch iframe when url is empty string', async () => {
285
330
  const url = '';
286
331
  index.prefetch(url);
package/src/embed/base.ts CHANGED
@@ -15,7 +15,7 @@ import { tokenizedFetch } from '../tokenizedFetch';
15
15
  import { EndPoints } from '../utils/authService/authService';
16
16
  import { getThoughtSpotHost } from '../config';
17
17
  import {
18
- AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
18
+ AuthType, EmbedConfig, LogLevel, Param, PrefetchFeatures,
19
19
  } from '../types';
20
20
  import {
21
21
  authenticate,
@@ -33,6 +33,7 @@ import {
33
33
  } from '../auth';
34
34
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
35
35
  import { getEmbedConfig, setEmbedConfig } from './embedConfig';
36
+ import { getQueryParamString } from '../utils';
36
37
 
37
38
  const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
38
39
  loginFailedMessage: 'Not logged in',
@@ -88,10 +89,10 @@ export const handleAuth = (): Promise<boolean> => {
88
89
  };
89
90
 
90
91
  const hostUrlToFeatureUrl = {
91
- [PrefetchFeatures.SearchEmbed]: (url: string) => `${url}v2/#/embed/answer`,
92
- [PrefetchFeatures.LiveboardEmbed]: (url: string) => url,
93
- [PrefetchFeatures.FullApp]: (url: string) => url,
94
- [PrefetchFeatures.VizEmbed]: (url: string) => url,
92
+ [PrefetchFeatures.SearchEmbed]: (url: string, flags: string) => `${url}v2/?${flags}#/embed/answer`,
93
+ [PrefetchFeatures.LiveboardEmbed]: (url: string, flags: string) => `${url}?${flags}`,
94
+ [PrefetchFeatures.FullApp]: (url: string, flags: string) => `${url}?${flags}`,
95
+ [PrefetchFeatures.VizEmbed]: (url: string, flags: string) => `${url}?${flags}`,
95
96
  };
96
97
 
97
98
  /**
@@ -100,20 +101,33 @@ const hostUrlToFeatureUrl = {
100
101
  * to your app.
101
102
  * @param url The URL provided for prefetch
102
103
  * @param prefetchFeatures Specify features which needs to be prefetched.
104
+ * @param additionalFlags This can be used to add any URL flag.
103
105
  * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
104
106
  * @group Global methods
105
107
  */
106
- export const prefetch = (url?: string, prefetchFeatures?: PrefetchFeatures[]): void => {
108
+ export const prefetch = (
109
+ url?: string,
110
+ prefetchFeatures?: PrefetchFeatures[],
111
+ additionalFlags?: { [key: string]: string | number | boolean },
112
+ ): void => {
107
113
  if (url === '') {
108
114
  // eslint-disable-next-line no-console
109
115
  logger.warn('The prefetch method does not have a valid URL');
110
116
  } else {
111
117
  const features = prefetchFeatures || [PrefetchFeatures.FullApp];
112
118
  let hostUrl = url || getEmbedConfig().thoughtSpotHost;
119
+ const prefetchFlags = {
120
+ [Param.EmbedApp]: true,
121
+ ...getEmbedConfig()?.additionalFlags,
122
+ ...additionalFlags,
123
+ };
113
124
  hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
114
125
  Array.from(
115
126
  new Set(features
116
- .map((feature) => hostUrlToFeatureUrl[feature](hostUrl))),
127
+ .map((feature) => hostUrlToFeatureUrl[feature](
128
+ hostUrl,
129
+ getQueryParamString(prefetchFlags),
130
+ ))),
117
131
  )
118
132
  .forEach(
119
133
  (prefetchUrl, index) => {
@@ -4,6 +4,10 @@ import { Conversation as ConversationService } from '../utils/graphql/nlsService
4
4
  import { getEmbedConfig } from './embedConfig';
5
5
  import { getQueryParamString } from '../utils';
6
6
 
7
+ /**
8
+ * Configuration for bodyless conversation options.
9
+ * @group Embed components
10
+ */
7
11
  export interface BodylessConversationViewConfig extends ViewConfig {
8
12
  /**
9
13
  * The ID of the worksheet to use for the conversation.
@@ -60,6 +64,19 @@ class ConversationMessage extends TsEmbed {
60
64
  /**
61
65
  * Create a conversation embed, which can be integrated inside
62
66
  * chatbots or other conversational interfaces.
67
+ * @example
68
+ * ```js
69
+ * import { BodylessConversation } from '@thoughtspot/visual-embed-sdk';
70
+ *
71
+ * const conversation = new BodylessConversation({
72
+ * worksheetId: 'worksheetId',
73
+ * });
74
+ *
75
+ * const { container, error } = await conversation.sendMessage('show me sales by region');
76
+ *
77
+ * // append the container to the DOM
78
+ * document.body.appendChild(container); // or to any other element
79
+ * ```
63
80
  * @group Embed components
64
81
  * @version SDK: 1.33.1 | ThoughtSpot: 10.5.0.cl
65
82
  */
@@ -363,7 +363,6 @@ export class LiveboardEmbed extends V1Embed {
363
363
  */
364
364
  protected getEmbedParams() {
365
365
  let params = {};
366
- params[Param.EmbedApp] = true;
367
366
  params = this.getBaseQueryParams(params);
368
367
  const {
369
368
  enableVizTransformations,
package/src/embed/sage.ts CHANGED
@@ -158,7 +158,6 @@ export class SageEmbed extends V1Embed {
158
158
  } = this.viewConfig;
159
159
 
160
160
  const params = this.getBaseQueryParams();
161
- params[Param.EmbedApp] = true;
162
161
  params[Param.IsSageEmbed] = true;
163
162
  params[Param.DisableWorksheetChange] = !!disableWorksheetChange;
164
163
  params[Param.HideWorksheetSelector] = !!hideWorksheetSelector;
@@ -13,6 +13,7 @@ import {
13
13
  import {
14
14
  Action, HomeLeftNavItem, RuntimeFilter, RuntimeFilterOp, HomepageModule, HostEvent,
15
15
  RuntimeParameter,
16
+ Param,
16
17
  } from '../types';
17
18
  import {
18
19
  executeAfterWait,
@@ -24,10 +25,12 @@ import {
24
25
  defaultParamsForPinboardEmbed,
25
26
  waitFor,
26
27
  expectUrlMatchesWithParams,
28
+ expectUrlToHaveParamsWithValues,
27
29
  mockMessageChannel,
28
30
  createRootEleForEmbed,
29
31
  } from '../test/test-utils';
30
32
  import * as config from '../config';
33
+ import * as embedConfig from './embedConfig';
31
34
  import * as tsEmbedInstance from './ts-embed';
32
35
  import * as mixpanelInstance from '../mixpanel-service';
33
36
  import * as authInstance from '../auth';
@@ -1274,6 +1277,36 @@ describe('Unit test case for ts embed', () => {
1274
1277
  );
1275
1278
  });
1276
1279
 
1280
+ it('should set the additional flags correctly on the iframe src from init and view config', async () => {
1281
+ init({
1282
+ thoughtSpotHost: 'http://tshost',
1283
+ authType: AuthType.None,
1284
+ additionalFlags: {
1285
+ foo: 'bar1',
1286
+ foo2: 'bar2',
1287
+ foo3: false,
1288
+ },
1289
+ });
1290
+ const appEmbed = new AppEmbed(getRootEl(), {
1291
+ frameParams: {
1292
+ width: '100%',
1293
+ height: '100%',
1294
+ },
1295
+ additionalFlags: {
1296
+ foo: 'bar',
1297
+ baz: 1,
1298
+ bool: true,
1299
+ },
1300
+ });
1301
+ await appEmbed.render();
1302
+ console.log('val ', getIFrameSrc());
1303
+ expectUrlMatchesWithParams(
1304
+ getIFrameSrc(),
1305
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
1306
+ + `&foo=bar&foo2=bar2&foo3=false&baz=1&bool=true${defaultParamsPost}#/home`,
1307
+ );
1308
+ });
1309
+
1277
1310
  it('Sets the showAlerts param', async () => {
1278
1311
  const appEmbed = new AppEmbed(getRootEl(), {
1279
1312
  frameParams: {
@@ -1407,6 +1440,20 @@ describe('Unit test case for ts embed', () => {
1407
1440
  `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&numberFormatLocale=en-US&dateFormatLocale=en-IN&currencyFormat=USD${defaultParamsPost}#/home`,
1408
1441
  );
1409
1442
  });
1443
+ it('Sets the overrideOrgId param', async () => {
1444
+ const overrideOrgId = 142536;
1445
+ const appEmbed = new AppEmbed(getRootEl(), {
1446
+ frameParams: {
1447
+ width: '100%',
1448
+ height: '100%',
1449
+ },
1450
+ overrideOrgId,
1451
+ });
1452
+ await appEmbed.render();
1453
+ expectUrlToHaveParamsWithValues(getIFrameSrc(), {
1454
+ orgId: overrideOrgId,
1455
+ });
1456
+ });
1410
1457
  });
1411
1458
 
1412
1459
  describe('When destroyed', () => {
@@ -7,6 +7,8 @@
7
7
  */
8
8
 
9
9
  import isEqual from 'lodash/isEqual';
10
+ import isEmpty from 'lodash/isEmpty';
11
+ import isObject from 'lodash/isObject';
10
12
  import { logger } from '../utils/logger';
11
13
  import { getAuthenticationToken } from '../authToken';
12
14
  import { AnswerService } from '../utils/graphql/answerService/answerService';
@@ -398,6 +400,7 @@ export class TsEmbed {
398
400
  if (hostAppUrl.includes('localhost') || hostAppUrl.includes('127.0.0.1')) {
399
401
  hostAppUrl = 'local-host';
400
402
  }
403
+ queryParams[Param.EmbedApp] = true;
401
404
  queryParams[Param.HostAppUrl] = encodeURIComponent(hostAppUrl);
402
405
  queryParams[Param.ViewPortHeight] = window.innerHeight;
403
406
  queryParams[Param.ViewPortWidth] = window.innerWidth;
@@ -435,15 +438,23 @@ export class TsEmbed {
435
438
  hiddenTabs,
436
439
  visibleTabs,
437
440
  showAlerts,
438
- additionalFlags,
441
+ additionalFlags: additionalFlagsFromView,
439
442
  locale,
440
443
  customizations,
441
444
  contextMenuTrigger,
442
445
  linkOverride,
443
446
  insertInToSlide,
444
447
  disableRedirectionLinksInNewTab,
448
+ overrideOrgId,
445
449
  } = this.viewConfig;
446
450
 
451
+ const { additionalFlags: additionalFlagsFromInit } = this.embedConfig;
452
+
453
+ const additionalFlags = {
454
+ ...additionalFlagsFromInit,
455
+ ...additionalFlagsFromView,
456
+ };
457
+
447
458
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
448
459
  this.handleError('You cannot have both hidden actions and visible actions');
449
460
  return queryParams;
@@ -503,11 +514,14 @@ export class TsEmbed {
503
514
  if (disableRedirectionLinksInNewTab) {
504
515
  queryParams[Param.DisableRedirectionLinksInNewTab] = disableRedirectionLinksInNewTab;
505
516
  }
517
+ if (overrideOrgId !== undefined) {
518
+ queryParams[Param.OverrideOrgId] = overrideOrgId;
519
+ }
506
520
 
507
521
  queryParams[Param.OverrideNativeConsole] = true;
508
522
  queryParams[Param.ClientLogLevel] = this.embedConfig.logLevel;
509
523
 
510
- if (additionalFlags && additionalFlags.constructor.name === 'Object') {
524
+ if (isObject(additionalFlags) && !isEmpty(additionalFlags)) {
511
525
  Object.assign(queryParams, additionalFlags);
512
526
  }
513
527
 
@@ -56,7 +56,7 @@ describe('React Components', () => {
56
56
  ),
57
57
  ).toBe(true);
58
58
  expect(getIFrameSrc(container)).toBe(
59
- `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=false&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true&collapseSearchBarInitially=true&enableCustomColumnGroups=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_ALL#/embed/answer`,
59
+ `http://${thoughtSpotHost}/?embedApp=true&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=false&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true&collapseSearchBarInitially=true&enableCustomColumnGroups=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_ALL#/embed/answer`,
60
60
  );
61
61
  });
62
62
 
@@ -230,7 +230,7 @@ describe('React Components', () => {
230
230
  ),
231
231
  ).toBe(true);
232
232
  expect(getIFrameSrc(container)).toBe(
233
- `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
233
+ `http://${thoughtSpotHost}/?embedApp=true&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
234
234
  );
235
235
  });
236
236
  });
package/src/types.ts CHANGED
@@ -588,6 +588,26 @@ export interface EmbedConfig {
588
588
  * @version SDK 1.32.3 | Thoughtspot: *
589
589
  */
590
590
  disableLoginFailurePage?: boolean;
591
+ /**
592
+ * This is an object (key/val) of override flags which will be applied
593
+ * to the internal embedded object. This can be used to add any
594
+ * URL flag.
595
+ * Warning: This option is for advanced use only and is used internally
596
+ * to control embed behavior in non-regular ways. We do not publish the
597
+ * list of supported keys and values associated with each.
598
+ * @example
599
+ * ```js
600
+ * const embed = new LiveboardEmbed('#embed', {
601
+ * ... // other liveboard view config
602
+ * additionalFlags: {
603
+ * flag1: 'value1',
604
+ * flag2: 'value2'
605
+ * }
606
+ * });
607
+ * ```
608
+ * @version SDK: 1.33.5 | ThoughtSpot: *
609
+ */
610
+ additionalFlags?: { [key: string]: string | number | boolean };
591
611
  }
592
612
 
593
613
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -779,6 +799,7 @@ export interface ViewConfig {
779
799
  * This is an object (key/val) of override flags which will be applied
780
800
  * to the internal embedded object. This can be used to add any
781
801
  * URL flag.
802
+ * If the same flags are passed in init, they will be overriden by the values here.
782
803
  * Warning: This option is for advanced use only and is used internally
783
804
  * to control embed behavior in non-regular ways. We do not publish the
784
805
  * list of supported keys and values associated with each.
@@ -1066,6 +1087,19 @@ export interface ViewConfig {
1066
1087
  * ```
1067
1088
  */
1068
1089
  enableCustomColumnGroups?: boolean;
1090
+ /**
1091
+ * View content for another org directly without having to use the org switcher
1092
+ * This flag is honoured if orgPerUrl feature is enabled for the ThoughtSpot cluster
1093
+ * @example
1094
+ * ```js
1095
+ * const embed = new LiveboardEmbed('#embed', {
1096
+ * ... // other options
1097
+ * overrideOrgId: 142536
1098
+ * });
1099
+ * ```
1100
+ * @version SDK: 1.35.0 | ThoughtSpot: 10.5.0.cl
1101
+ */
1102
+ overrideOrgId?: number;
1069
1103
  }
1070
1104
 
1071
1105
  /**
@@ -1121,7 +1155,7 @@ export type MessageCallbackObj = {
1121
1155
  export type GenericCallbackFn = (...args: any[]) => any;
1122
1156
 
1123
1157
  export type QueryParams = {
1124
- [key: string]: string;
1158
+ [key: string]: string | boolean | number;
1125
1159
  };
1126
1160
 
1127
1161
  /**
@@ -2965,12 +2999,13 @@ export enum HostEvent {
2965
2999
  * see link:https://developers.thoughtspot.com/docs/runtime-filters#rtOperator[Developer Documentation].
2966
3000
  *
2967
3001
  * `values` - An array of one or several values. The value definition on the
2968
- * data type you choose to filter on. For a complete list of supported data types, see
2969
- * link:https://developers.thoughtspot.com/docs/runtime-filters#_supported_data_types[Supported data types].
3002
+ * data type you choose to filter on. For a complete list of supported data types,
3003
+ * see
3004
+ * link:https://developers.thoughtspot.com/docs/runtime-filters#_supported_data_types[Supported
3005
+ * data types].
2970
3006
  *
2971
3007
  * `type` - To update filters for date time, specify the date format type.
2972
3008
  * For more information and examples, see link:https://developers.thoughtspot.com/docs/embed-liveboard#_date_filters[Date filters].
2973
- *
2974
3009
  * @example
2975
3010
  * ```js
2976
3011
  *
@@ -3262,6 +3297,7 @@ export enum Param {
3262
3297
  LiveboardHeaderV2 = 'isLiveboardHeaderV2Enabled',
3263
3298
  SpotterEnabled = 'isSpotterExperienceEnabled',
3264
3299
  IsUnifiedSearchExperienceEnabled = 'isUnifiedSearchExperienceEnabled',
3300
+ OverrideOrgId = 'orgId',
3265
3301
  }
3266
3302
 
3267
3303
  /**