@thoughtspot/visual-embed-sdk 1.21.0-alpha.9 → 1.21.0-react.1

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 (201) hide show
  1. package/cjs/package.json +11 -8
  2. package/cjs/src/auth.d.ts +2 -0
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +2 -0
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/embed/app.d.ts +28 -1
  7. package/cjs/src/embed/app.d.ts.map +1 -1
  8. package/cjs/src/embed/app.js +32 -1
  9. package/cjs/src/embed/app.js.map +1 -1
  10. package/cjs/src/embed/app.spec.js +67 -0
  11. package/cjs/src/embed/app.spec.js.map +1 -1
  12. package/cjs/src/embed/base.d.ts +16 -0
  13. package/cjs/src/embed/base.d.ts.map +1 -1
  14. package/cjs/src/embed/base.js +85 -1
  15. package/cjs/src/embed/base.js.map +1 -1
  16. package/cjs/src/embed/base.spec.js +127 -0
  17. package/cjs/src/embed/base.spec.js.map +1 -1
  18. package/cjs/src/embed/liveboard.spec.js +19 -0
  19. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  20. package/cjs/src/embed/pinboard.spec.js +19 -0
  21. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  22. package/cjs/src/embed/search.d.ts.map +1 -1
  23. package/cjs/src/embed/search.js +2 -2
  24. package/cjs/src/embed/search.js.map +1 -1
  25. package/cjs/src/embed/search.spec.js +24 -0
  26. package/cjs/src/embed/search.spec.js.map +1 -1
  27. package/cjs/src/embed/searchEmbed-basic-auth.spec.js +1 -1
  28. package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
  29. package/cjs/src/embed/ts-embed.d.ts +3 -3
  30. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  31. package/cjs/src/embed/ts-embed.js +28 -9
  32. package/cjs/src/embed/ts-embed.js.map +1 -1
  33. package/cjs/src/embed/ts-embed.spec.js +82 -6
  34. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  35. package/cjs/src/index.d.ts +3 -3
  36. package/cjs/src/index.d.ts.map +1 -1
  37. package/cjs/src/index.js +4 -1
  38. package/cjs/src/index.js.map +1 -1
  39. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  40. package/cjs/src/mixpanel-service.js +11 -6
  41. package/cjs/src/mixpanel-service.js.map +1 -1
  42. package/cjs/src/react/all-types-export.d.ts +3 -0
  43. package/cjs/src/react/all-types-export.d.ts.map +1 -0
  44. package/cjs/src/react/all-types-export.js +29 -0
  45. package/cjs/src/react/all-types-export.js.map +1 -0
  46. package/cjs/src/react/all-types-export.spec.d.ts +2 -0
  47. package/cjs/src/react/all-types-export.spec.d.ts.map +1 -0
  48. package/cjs/src/react/all-types-export.spec.js +13 -0
  49. package/cjs/src/react/all-types-export.spec.js.map +1 -0
  50. package/cjs/src/react/index.d.ts +63 -6
  51. package/cjs/src/react/index.d.ts.map +1 -1
  52. package/cjs/src/react/index.js +65 -2
  53. package/cjs/src/react/index.js.map +1 -1
  54. package/cjs/src/react/index.spec.js +12 -2
  55. package/cjs/src/react/index.spec.js.map +1 -1
  56. package/cjs/src/test/test-utils.d.ts.map +1 -1
  57. package/cjs/src/test/test-utils.js +2 -2
  58. package/cjs/src/test/test-utils.js.map +1 -1
  59. package/cjs/src/types.d.ts +158 -19
  60. package/cjs/src/types.d.ts.map +1 -1
  61. package/cjs/src/types.js +112 -16
  62. package/cjs/src/types.js.map +1 -1
  63. package/cjs/src/utils/processTrigger.d.ts +6 -0
  64. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  65. package/cjs/src/utils/processTrigger.js +10 -8
  66. package/cjs/src/utils/processTrigger.js.map +1 -1
  67. package/cjs/src/utils/processTrigger.spec.js +5 -2
  68. package/cjs/src/utils/processTrigger.spec.js.map +1 -1
  69. package/cjs/src/utils.d.ts +1 -0
  70. package/cjs/src/utils.d.ts.map +1 -1
  71. package/cjs/src/utils.js +3 -1
  72. package/cjs/src/utils.js.map +1 -1
  73. package/dist/src/auth.d.ts +2 -0
  74. package/dist/src/auth.d.ts.map +1 -1
  75. package/dist/src/embed/app.d.ts +28 -1
  76. package/dist/src/embed/app.d.ts.map +1 -1
  77. package/dist/src/embed/base.d.ts +16 -0
  78. package/dist/src/embed/base.d.ts.map +1 -1
  79. package/dist/src/embed/search.d.ts.map +1 -1
  80. package/dist/src/embed/ts-embed.d.ts +3 -3
  81. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  82. package/dist/src/index.d.ts +3 -3
  83. package/dist/src/index.d.ts.map +1 -1
  84. package/dist/src/mixpanel-service.d.ts.map +1 -1
  85. package/dist/src/react/all-types-export.d.ts +3 -0
  86. package/dist/src/react/all-types-export.d.ts.map +1 -0
  87. package/dist/src/react/all-types-export.spec.d.ts +2 -0
  88. package/dist/src/react/all-types-export.spec.d.ts.map +1 -0
  89. package/dist/src/react/index.d.ts +63 -6
  90. package/dist/src/react/index.d.ts.map +1 -1
  91. package/dist/src/test/test-utils.d.ts.map +1 -1
  92. package/dist/src/types.d.ts +158 -19
  93. package/dist/src/types.d.ts.map +1 -1
  94. package/dist/src/utils/processTrigger.d.ts +6 -0
  95. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  96. package/dist/src/utils.d.ts +1 -0
  97. package/dist/src/utils.d.ts.map +1 -1
  98. package/dist/tsembed-react.es.js +28044 -0
  99. package/dist/tsembed-react.js +27986 -0
  100. package/dist/tsembed.es.js +279 -43
  101. package/dist/tsembed.js +280 -46
  102. package/dist/visual-embed-sdk-react-full.d.ts +3112 -0
  103. package/dist/visual-embed-sdk-react.d.ts +2781 -0
  104. package/dist/visual-embed-sdk.d.ts +3005 -0
  105. package/lib/package.json +11 -8
  106. package/lib/src/auth.d.ts +2 -0
  107. package/lib/src/auth.d.ts.map +1 -1
  108. package/lib/src/auth.js +2 -0
  109. package/lib/src/auth.js.map +1 -1
  110. package/lib/src/embed/app.d.ts +28 -1
  111. package/lib/src/embed/app.d.ts.map +1 -1
  112. package/lib/src/embed/app.js +33 -2
  113. package/lib/src/embed/app.js.map +1 -1
  114. package/lib/src/embed/app.spec.js +68 -1
  115. package/lib/src/embed/app.spec.js.map +1 -1
  116. package/lib/src/embed/base.d.ts +16 -0
  117. package/lib/src/embed/base.d.ts.map +1 -1
  118. package/lib/src/embed/base.js +83 -1
  119. package/lib/src/embed/base.js.map +1 -1
  120. package/lib/src/embed/base.spec.js +127 -0
  121. package/lib/src/embed/base.spec.js.map +1 -1
  122. package/lib/src/embed/liveboard.spec.js +19 -0
  123. package/lib/src/embed/liveboard.spec.js.map +1 -1
  124. package/lib/src/embed/pinboard.spec.js +19 -0
  125. package/lib/src/embed/pinboard.spec.js.map +1 -1
  126. package/lib/src/embed/search.d.ts.map +1 -1
  127. package/lib/src/embed/search.js +2 -2
  128. package/lib/src/embed/search.js.map +1 -1
  129. package/lib/src/embed/search.spec.js +24 -0
  130. package/lib/src/embed/search.spec.js.map +1 -1
  131. package/lib/src/embed/searchEmbed-basic-auth.spec.js +1 -1
  132. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
  133. package/lib/src/embed/ts-embed.d.ts +3 -3
  134. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  135. package/lib/src/embed/ts-embed.js +30 -11
  136. package/lib/src/embed/ts-embed.js.map +1 -1
  137. package/lib/src/embed/ts-embed.spec.js +83 -7
  138. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  139. package/lib/src/index.d.ts +3 -3
  140. package/lib/src/index.d.ts.map +1 -1
  141. package/lib/src/index.js +4 -4
  142. package/lib/src/index.js.map +1 -1
  143. package/lib/src/mixpanel-service.d.ts.map +1 -1
  144. package/lib/src/mixpanel-service.js +11 -6
  145. package/lib/src/mixpanel-service.js.map +1 -1
  146. package/lib/src/react/all-types-export.d.ts +3 -0
  147. package/lib/src/react/all-types-export.d.ts.map +1 -0
  148. package/lib/src/react/all-types-export.js +5 -0
  149. package/lib/src/react/all-types-export.js.map +1 -0
  150. package/lib/src/react/all-types-export.spec.d.ts +2 -0
  151. package/lib/src/react/all-types-export.spec.d.ts.map +1 -0
  152. package/lib/src/react/all-types-export.spec.js +10 -0
  153. package/lib/src/react/all-types-export.spec.js.map +1 -0
  154. package/lib/src/react/index.d.ts +63 -6
  155. package/lib/src/react/index.d.ts.map +1 -1
  156. package/lib/src/react/index.js +59 -1
  157. package/lib/src/react/index.js.map +1 -1
  158. package/lib/src/react/index.spec.js +12 -2
  159. package/lib/src/react/index.spec.js.map +1 -1
  160. package/lib/src/test/test-utils.d.ts.map +1 -1
  161. package/lib/src/test/test-utils.js +2 -2
  162. package/lib/src/test/test-utils.js.map +1 -1
  163. package/lib/src/types.d.ts +158 -19
  164. package/lib/src/types.d.ts.map +1 -1
  165. package/lib/src/types.js +112 -16
  166. package/lib/src/types.js.map +1 -1
  167. package/lib/src/utils/processTrigger.d.ts +6 -0
  168. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  169. package/lib/src/utils/processTrigger.js +7 -6
  170. package/lib/src/utils/processTrigger.js.map +1 -1
  171. package/lib/src/utils/processTrigger.spec.js +5 -2
  172. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  173. package/lib/src/utils.d.ts +1 -0
  174. package/lib/src/utils.d.ts.map +1 -1
  175. package/lib/src/utils.js +1 -0
  176. package/lib/src/utils.js.map +1 -1
  177. package/package.json +11 -8
  178. package/src/auth.ts +2 -0
  179. package/src/embed/app.spec.ts +84 -1
  180. package/src/embed/app.ts +59 -2
  181. package/src/embed/base.spec.ts +144 -0
  182. package/src/embed/base.ts +107 -0
  183. package/src/embed/liveboard.spec.ts +23 -0
  184. package/src/embed/pinboard.spec.ts +23 -0
  185. package/src/embed/search.spec.ts +28 -0
  186. package/src/embed/search.ts +2 -1
  187. package/src/embed/searchEmbed-basic-auth.spec.ts +1 -1
  188. package/src/embed/ts-embed.spec.ts +92 -19
  189. package/src/embed/ts-embed.ts +29 -11
  190. package/src/index.ts +5 -1
  191. package/src/mixpanel-service.ts +10 -6
  192. package/src/react/all-types-export.spec.ts +11 -0
  193. package/src/react/all-types-export.ts +43 -0
  194. package/src/react/index.spec.tsx +18 -2
  195. package/src/react/index.tsx +72 -6
  196. package/src/test/test-utils.ts +2 -2
  197. package/src/types.ts +158 -17
  198. package/src/utils/processTrigger.spec.ts +5 -2
  199. package/src/utils/processTrigger.ts +7 -6
  200. package/src/utils.ts +2 -0
  201. package/lib/src/visual-embed-sdk.d.ts +0 -2861
@@ -156,6 +156,7 @@ export class SearchEmbed extends TsEmbed {
156
156
  runtimeFilters,
157
157
  dataSource,
158
158
  dataSources,
159
+ excludeRuntimeFiltersfromURL,
159
160
  } = this.viewConfig;
160
161
  const queryParams = this.getBaseQueryParams();
161
162
 
@@ -198,7 +199,7 @@ export class SearchEmbed extends TsEmbed {
198
199
  query = `?${queryParamsString}`;
199
200
  }
200
201
  const filterQuery = getFilterQuery(runtimeFilters || []);
201
- if (filterQuery) {
202
+ if (filterQuery && !excludeRuntimeFiltersfromURL) {
202
203
  query += `&${filterQuery}`;
203
204
  }
204
205
  return query;
@@ -24,7 +24,7 @@ describe('Search embed tests when authType is Basic', () => {
24
24
  * @param version
25
25
  */
26
26
  function setupVersion(version: string) {
27
- jest.spyOn(window, 'addEventListener').mockImplementationOnce((event, handler, options) => {
27
+ jest.spyOn(window, 'addEventListener').mockImplementation((event, handler, options) => {
28
28
  handler({
29
29
  data: {
30
30
  type: 'xyz',
@@ -9,7 +9,7 @@ import {
9
9
  AppEmbed,
10
10
  LiveboardEmbed,
11
11
  } from '../index';
12
- import { Action } from '../types';
12
+ import { Action, RuntimeFilter, RuntimeFilterOp } from '../types';
13
13
  import {
14
14
  executeAfterWait,
15
15
  getDocumentBody,
@@ -99,7 +99,7 @@ describe('Unit test case for ts embed', () => {
99
99
  });
100
100
  expect(mockPort.postMessage).toHaveBeenCalledWith({
101
101
  type: EmbedEvent.APP_INIT,
102
- data: { customisations, authToken: '' },
102
+ data: { customisations, authToken: '', runtimeFilterParams: null },
103
103
  });
104
104
  });
105
105
 
@@ -122,13 +122,52 @@ describe('Unit test case for ts embed', () => {
122
122
  });
123
123
  expect(mockPort.postMessage).toHaveBeenCalledWith({
124
124
  type: EmbedEvent.APP_INIT,
125
- data: { customisations: customisationsView, authToken: '' },
125
+ data: {
126
+ customisations: customisationsView,
127
+ authToken: '',
128
+ runtimeFilterParams: null,
129
+ },
126
130
  });
127
131
  expect(getIFrameSrc()).toContain(
128
132
  `customCssUrl=${customisationsView.style.customCSSUrl}`,
129
133
  );
130
134
  });
131
135
 
136
+ test('Runtime filters from view Config should be part of app_init payload', async () => {
137
+ const mockEmbedEventPayload = {
138
+ type: EmbedEvent.APP_INIT,
139
+ data: {},
140
+ };
141
+ const mockRuntimeFilters: RuntimeFilter[] = [
142
+ {
143
+ columnName: 'color',
144
+ operator: RuntimeFilterOp.EQ,
145
+ values: ['blue'],
146
+ },
147
+ ];
148
+
149
+ const searchEmbed = new SearchEmbed(getRootEl(), {
150
+ ...defaultViewConfig,
151
+ runtimeFilters: mockRuntimeFilters,
152
+ });
153
+ searchEmbed.render();
154
+ const mockPort: any = {
155
+ postMessage: jest.fn(),
156
+ };
157
+ await executeAfterWait(() => {
158
+ const iframe = getIFrameEl();
159
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
160
+ });
161
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
162
+ type: EmbedEvent.APP_INIT,
163
+ data: {
164
+ customisations,
165
+ authToken: '',
166
+ runtimeFilterParams: 'col1=color&op1=EQ&val1=blue',
167
+ },
168
+ });
169
+ });
170
+
132
171
  test('when Embed event status have start status', (done) => {
133
172
  const mockEmbedEventPayload = {
134
173
  type: EmbedEvent.Save,
@@ -231,19 +270,13 @@ describe('Unit test case for ts embed', () => {
231
270
 
232
271
  await executeAfterWait(() => {
233
272
  const iframe = getIFrameEl();
234
- postMessageToParent(
235
- iframe.contentWindow,
236
- mockEmbedEventPayload,
237
- );
273
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
238
274
  });
239
275
 
240
276
  searchEmbed.off(EmbedEvent.Save, mockFn);
241
277
  await executeAfterWait(() => {
242
278
  const iframe = getIFrameEl();
243
- postMessageToParent(
244
- iframe.contentWindow,
245
- mockEmbedEventPayload,
246
- );
279
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
247
280
  });
248
281
  await executeAfterWait(() => {
249
282
  expect(mockFn).toHaveBeenCalledTimes(1);
@@ -280,7 +313,11 @@ describe('Unit test case for ts embed', () => {
280
313
  await executeAfterWait(() => {
281
314
  expect(mockPort.postMessage).toHaveBeenCalledWith({
282
315
  type: EmbedEvent.APP_INIT,
283
- data: { customisations, authToken: 'test_auth_token1' },
316
+ data: {
317
+ customisations,
318
+ authToken: 'test_auth_token1',
319
+ runtimeFilterParams: null,
320
+ },
284
321
  });
285
322
  });
286
323
  });
@@ -673,7 +710,7 @@ describe('Unit test case for ts embed', () => {
673
710
  },
674
711
  });
675
712
  tsEmbed.render();
676
- waitFor(() => !!getIFrameEl()).then(() => {
713
+ await waitFor(() => !!getIFrameEl()).then(() => {
677
714
  expect(getIFrameSrc()).toContain('?base64UrlEncodedFlags');
678
715
  });
679
716
  });
@@ -685,7 +722,7 @@ describe('Unit test case for ts embed', () => {
685
722
  },
686
723
  });
687
724
  appEmbed.render();
688
- waitFor(() => !!getIFrameEl()).then(() => {
725
+ await waitFor(() => !!getIFrameEl()).then(() => {
689
726
  expect(getIFrameSrc()).toContain('?base64UrlEncodedFlags');
690
727
  });
691
728
  });
@@ -724,7 +761,7 @@ describe('Unit test case for ts embed', () => {
724
761
  expectUrlMatchesWithParams(
725
762
  getIFrameSrc(),
726
763
  `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
727
- + `&foo=bar&baz=1&bool=true${defaultParamsPost}#/home`,
764
+ + `&foo=bar&baz=1&bool=true${defaultParamsPost}#/home`,
728
765
  );
729
766
  });
730
767
 
@@ -740,7 +777,7 @@ describe('Unit test case for ts embed', () => {
740
777
  expectUrlMatchesWithParams(
741
778
  getIFrameSrc(),
742
779
  `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
743
- + `&showAlerts=true${defaultParamsPost}#/home`,
780
+ + `&showAlerts=true${defaultParamsPost}#/home`,
744
781
  );
745
782
  });
746
783
  it('Sets the locale param', async () => {
@@ -755,7 +792,7 @@ describe('Unit test case for ts embed', () => {
755
792
  expectUrlMatchesWithParams(
756
793
  getIFrameSrc(),
757
794
  `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
758
- + `&locale=ja-JP${defaultParamsPost}#/home`,
795
+ + `&locale=ja-JP${defaultParamsPost}#/home`,
759
796
  );
760
797
  });
761
798
  it('Sets the iconSprite url', async () => {
@@ -772,7 +809,7 @@ describe('Unit test case for ts embed', () => {
772
809
  expectUrlMatchesWithParams(
773
810
  getIFrameSrc(),
774
811
  `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
775
- + `&iconSprite=iconSprite.com${defaultParamsPost}#/home`,
812
+ + `&iconSprite=iconSprite.com${defaultParamsPost}#/home`,
776
813
  );
777
814
  });
778
815
 
@@ -814,7 +851,7 @@ describe('Unit test case for ts embed', () => {
814
851
  },
815
852
  });
816
853
  appEmbed.render();
817
- waitFor(() => !!getIFrameEl()).then(() => {
854
+ await waitFor(() => !!getIFrameEl()).then(() => {
818
855
  expect(getIFrameSrc()).toContain('authType=EmbeddedSSO');
819
856
  expect(getIFrameSrc()).toContain('forceSAMLAutoRedirect=true');
820
857
  done();
@@ -903,4 +940,40 @@ describe('Unit test case for ts embed', () => {
903
940
  expect(tsEmbed.getThoughtSpotPostUrlParams()).toBe(postHashParams);
904
941
  });
905
942
  });
943
+ describe('Block full app access while naviagting from embed app', () => {
944
+ it('should contain blockNonEmbedFullAppAccess as false in query params', async () => {
945
+ init({
946
+ thoughtSpotHost: 'tshost',
947
+ authType: AuthType.None,
948
+ blockNonEmbedFullAppAccess: false,
949
+ });
950
+ const appEmbed = new AppEmbed(getRootEl(), {
951
+ frameParams: {
952
+ width: '100%',
953
+ height: '100%',
954
+ },
955
+ });
956
+ appEmbed.render();
957
+ await waitFor(() => !!getIFrameEl()).then(() => {
958
+ expect(getIFrameSrc()).toContain('blockNonEmbedFullAppAccess=false');
959
+ });
960
+ });
961
+
962
+ it('should contain blockNonEmbedFullAppAccess as true in query params', async () => {
963
+ init({
964
+ thoughtSpotHost: 'tshost',
965
+ authType: AuthType.None,
966
+ });
967
+ const appEmbed = new AppEmbed(getRootEl(), {
968
+ frameParams: {
969
+ width: '100%',
970
+ height: '100%',
971
+ },
972
+ });
973
+ appEmbed.render();
974
+ await waitFor(() => !!getIFrameEl()).then(() => {
975
+ expect(getIFrameSrc()).toContain('blockNonEmbedFullAppAccess=true');
976
+ });
977
+ });
978
+ });
906
979
  });
@@ -14,6 +14,7 @@ import {
14
14
  embedEventStatus,
15
15
  setAttributes,
16
16
  getCustomisations,
17
+ getRuntimeFilters,
17
18
  getDOMNode,
18
19
  getFilterQuery,
19
20
  getQueryParamString,
@@ -145,6 +146,9 @@ export class TsEmbed {
145
146
  this.el = getDOMNode(domSelector);
146
147
  // TODO: handle error
147
148
  this.embedConfig = getEmbedConfig();
149
+ if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
150
+ this.embedConfig.authTriggerContainer = domSelector;
151
+ }
148
152
  this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
149
153
  this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
150
154
  this.eventHandlerMap = new Map();
@@ -236,6 +240,16 @@ export class TsEmbed {
236
240
  );
237
241
  }
238
242
  });
243
+ window.addEventListener('online', (e) => {
244
+ this.trigger(HostEvent.Reload);
245
+ });
246
+ window.addEventListener('offline', (e) => {
247
+ const offlineWarning = 'Network not Detected. Embed is offline. Please reconnect and refresh';
248
+ this.executeCallbacks(EmbedEvent.Error, {
249
+ offlineWarning,
250
+ });
251
+ console.warn(offlineWarning);
252
+ });
239
253
  }
240
254
 
241
255
  /**
@@ -255,6 +269,8 @@ export class TsEmbed {
255
269
  data: {
256
270
  customisations: getCustomisations(this.embedConfig, this.viewConfig),
257
271
  authToken,
272
+ runtimeFilterParams: getRuntimeFilters(this.viewConfig.runtimeFilters),
273
+ hostConfig: this.embedConfig.hostConfig,
258
274
  },
259
275
  });
260
276
  };
@@ -325,6 +341,8 @@ export class TsEmbed {
325
341
  queryParams[Param.ViewPortWidth] = window.innerWidth;
326
342
  queryParams[Param.Version] = version;
327
343
  queryParams[Param.AuthType] = this.embedConfig.authType;
344
+ queryParams[Param.blockNonEmbedFullAppAccess] = this.embedConfig.blockNonEmbedFullAppAccess
345
+ ?? true;
328
346
  if (this.embedConfig.disableLoginRedirect === true || this.embedConfig.autoLogin === true) {
329
347
  queryParams[Param.DisableLoginRedirect] = true;
330
348
  }
@@ -571,8 +589,8 @@ export class TsEmbed {
571
589
  *
572
590
  * @param height The height in pixels
573
591
  */
574
- protected setIFrameHeight(height: number): void {
575
- this.iFrame.style.height = `${height}px`;
592
+ protected setIFrameHeight(height: number | string): void {
593
+ this.iFrame.style.height = getCssDimension(height);
576
594
  }
577
595
 
578
596
  /**
@@ -709,10 +727,7 @@ export class TsEmbed {
709
727
  * tsEmbed.off(EmbedEvent.Error, errorHandler);
710
728
  * ```
711
729
  */
712
- public off(
713
- messageType: EmbedEvent,
714
- callback: MessageCallback,
715
- ): typeof TsEmbed.prototype {
730
+ public off(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype {
716
731
  const callbacks = this.eventHandlerMap.get(messageType) || [];
717
732
  const index = callbacks.findIndex((cb) => cb.callback === callback);
718
733
  if (index > -1) {
@@ -822,7 +837,7 @@ export class TsEmbed {
822
837
  * This means without the path but with the flags already applied.
823
838
  * This is useful for prerendering the component in the background.
824
839
  *
825
- * @version SDK: 1.21.0 | ThoughtSpot: * / Search: 9.3.0.cl
840
+ * @version SDK: 1.22.0
826
841
  * @returns
827
842
  */
828
843
  public async prerenderGeneric(): Promise<any> {
@@ -847,7 +862,7 @@ export class V1Embed extends TsEmbed {
847
862
  }
848
863
 
849
864
  /**
850
- * Render the ap p in an iframe and set up event handlers
865
+ * Render the app in an iframe and set up event handlers
851
866
  *
852
867
  * @param iframeSrc
853
868
  */
@@ -856,10 +871,13 @@ export class V1Embed extends TsEmbed {
856
871
  }
857
872
 
858
873
  protected getRootIframeSrc(): string {
859
- const runtimeFilters = this.viewConfig.runtimeFilters;
860
- const filterQuery = getFilterQuery(runtimeFilters || []);
861
874
  const queryParams = this.getEmbedParams();
862
- const queryString = [filterQuery, queryParams].filter(Boolean).join('&');
875
+ let queryString = queryParams;
876
+ if (!this.viewConfig.excludeRuntimeFiltersfromURL) {
877
+ const runtimeFilters = this.viewConfig.runtimeFilters;
878
+ const filterQuery = getFilterQuery(runtimeFilters || []);
879
+ queryString = [filterQuery, queryParams].filter(Boolean).join('&');
880
+ }
863
881
  return this.getV1EmbedBasePath(queryString);
864
882
  }
865
883
 
package/src/index.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { AppEmbed, Page, AppViewConfig } from './embed/app';
11
11
  import {
12
- init, prefetch, logout, getEmbedConfig,
12
+ init, prefetch, logout, getEmbedConfig, executeTML, exportTML,
13
13
  } from './embed/base';
14
14
  import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/liveboard';
15
15
  import { SearchEmbed, SearchViewConfig } from './embed/search';
@@ -35,12 +35,15 @@ import {
35
35
  CustomisationsInterface,
36
36
  CustomStyles,
37
37
  customCssInterface,
38
+ ContextMenuTriggerOptions,
38
39
  } from './types';
39
40
 
40
41
  export {
41
42
  init,
42
43
  logout,
43
44
  prefetch,
45
+ executeTML,
46
+ exportTML,
44
47
  getEmbedConfig as getInitConfig,
45
48
  getSessionInfo,
46
49
  SearchEmbed,
@@ -61,6 +64,7 @@ export {
61
64
  HostEvent,
62
65
  DataSourceVisualMode,
63
66
  Action,
67
+ ContextMenuTriggerOptions,
64
68
  EmbedConfig,
65
69
  SearchViewConfig,
66
70
  SearchBarViewConfig,
@@ -56,13 +56,17 @@ export function initMixpanel(sessionInfo: any): void {
56
56
  // userGUID
57
57
  const isPublicCluster = !!sessionInfo.isPublicUser;
58
58
  const token = sessionInfo.mixpanelToken;
59
- if (token) {
60
- mixpanel.init(token);
61
- if (!isPublicCluster) {
62
- mixpanel.identify(sessionInfo.userGUID);
59
+ try {
60
+ if (token) {
61
+ mixpanel.init(token);
62
+ if (!isPublicCluster) {
63
+ mixpanel.identify(sessionInfo.userGUID);
64
+ }
65
+ isMixpanelInitialized = true;
66
+ emptyQueue();
63
67
  }
64
- isMixpanelInitialized = true;
65
- emptyQueue();
68
+ } catch (e) {
69
+ console.error('Error initializing mixpanel', e);
66
70
  }
67
71
  }
68
72
 
@@ -0,0 +1,11 @@
1
+ import * as Exports from './all-types-export';
2
+
3
+ describe('Exports', () => {
4
+ it('should have exports', () => {
5
+ expect(typeof Exports).toBe('object');
6
+ });
7
+
8
+ it('should not have undefined exports', () => {
9
+ Object.keys(Exports).forEach((exportKey) => expect(Boolean(Exports[exportKey])).toBe(true));
10
+ });
11
+ });
@@ -0,0 +1,43 @@
1
+ export {
2
+ SearchEmbed,
3
+ LiveboardEmbed,
4
+ SearchBarEmbed,
5
+ AppEmbed,
6
+ useEmbedRef,
7
+ } from './index';
8
+
9
+ export {
10
+ init,
11
+ logout,
12
+ prefetch,
13
+ getInitConfig,
14
+ getSessionInfo,
15
+ PinboardEmbed,
16
+ AuthFailureType,
17
+ AuthStatus,
18
+ AuthEvent,
19
+ AuthEventEmitter,
20
+ // types
21
+ Page,
22
+ AuthType,
23
+ RuntimeFilter,
24
+ RuntimeFilterOp,
25
+ EmbedEvent,
26
+ HostEvent,
27
+ DataSourceVisualMode,
28
+ Action,
29
+ EmbedConfig,
30
+ SearchViewConfig,
31
+ SearchBarViewConfig,
32
+ LiveboardViewConfig,
33
+ AppViewConfig,
34
+ PrefetchFeatures,
35
+ FrameParams,
36
+ DOMSelector,
37
+ MessageOptions,
38
+ MessageCallback,
39
+ MessagePayload,
40
+ CustomisationsInterface,
41
+ CustomStyles,
42
+ customCssInterface,
43
+ } from '../index';
@@ -17,6 +17,7 @@ import {
17
17
  import {
18
18
  SearchEmbed, AppEmbed, LiveboardEmbed, useEmbedRef, SearchBarEmbed,
19
19
  } from './index';
20
+ import * as allExports from './index';
20
21
  import { AuthType, init } from '../index';
21
22
 
22
23
  import { version } from '../../package.json';
@@ -46,7 +47,7 @@ describe('React Components', () => {
46
47
  ),
47
48
  ).toBe(true);
48
49
  expect(getIFrameSrc(container)).toBe(
49
- `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
50
+ `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]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
50
51
  );
51
52
  });
52
53
 
@@ -219,8 +220,23 @@ describe('React Components', () => {
219
220
  ),
220
221
  ).toBe(true);
221
222
  expect(getIFrameSrc(container)).toBe(
222
- `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22]&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
223
+ `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
223
224
  );
224
225
  });
225
226
  });
226
227
  });
228
+
229
+ describe('allExports', () => {
230
+ it('should have exports', () => {
231
+ expect(typeof allExports).toBe('object');
232
+ });
233
+
234
+ it('should not have undefined exports', () => {
235
+ Object.keys(allExports).forEach(
236
+ (exportKey) => expect(
237
+ Boolean(allExports[exportKey]),
238
+ )
239
+ .toBe(true),
240
+ );
241
+ });
242
+ });
@@ -69,12 +69,39 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
69
69
 
70
70
  interface SearchProps extends EmbedProps, SearchViewConfig {}
71
71
 
72
+ /**
73
+ * React component for Search Embed.
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * function Search() {
78
+ * return <SearchEmbed
79
+ * dataSource="dataSourceId"
80
+ * searchOptions={{ searchTokenString: "[revenue]" }}
81
+ * />
82
+ * }
83
+ * ```
84
+ */
72
85
  export const SearchEmbed = componentFactory<typeof _SearchEmbed, SearchProps, SearchViewConfig>(
73
86
  _SearchEmbed,
74
87
  );
75
88
 
76
89
  interface AppProps extends EmbedProps, AppViewConfig {}
77
90
 
91
+ /**
92
+ * React component for Full app Embed.
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * function Search() {
97
+ * return <AppEmbed
98
+ * showPrimaryNavbar={false}
99
+ * pageId={Page.Liveboards}
100
+ * onError={(error) => console.error(error)}
101
+ * />
102
+ * }
103
+ * ```
104
+ */
78
105
  export const AppEmbed = componentFactory<typeof _AppEmbed, AppProps, AppViewConfig>(_AppEmbed);
79
106
 
80
107
  interface LiveboardProps extends EmbedProps, LiveboardViewConfig {}
@@ -100,18 +127,57 @@ export const LiveboardEmbed = componentFactory<
100
127
  LiveboardViewConfig
101
128
  >(_LiveboardEmbed);
102
129
 
103
- export const PinboardEmbed = componentFactory<
104
- typeof _LiveboardEmbed,
105
- LiveboardProps,
106
- LiveboardViewConfig
107
- >(_LiveboardEmbed);
130
+ export const PinboardEmbed = LiveboardEmbed;
108
131
 
109
132
  interface SearchBarEmbedProps extends EmbedProps, SearchBarViewConfig {}
110
133
 
134
+ /**
135
+ * React component for Search bar embed.
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * function SearchBar() {
140
+ * return <SearchBarEmbed
141
+ * dataSource="dataSourceId"
142
+ * searchOptions={{ searchTokenString: "[revenue]" }}
143
+ * />
144
+ * }
145
+ * ```
146
+ */
111
147
  export const SearchBarEmbed = componentFactory<
112
148
  typeof _SearchBarEmbed,
113
149
  SearchBarEmbedProps,
114
150
  SearchBarViewConfig
115
151
  >(_SearchBarEmbed);
116
152
 
117
- export const useEmbedRef = (): React.MutableRefObject<TsEmbed> => React.useRef<TsEmbed>(null);
153
+ /**
154
+ * Get a reference to the embed component to trigger events on the component.
155
+ *
156
+ * @example
157
+ * ```
158
+ * function Component() {
159
+ * const ref = useEmbedRef();
160
+ * useEffect(() => {
161
+ * ref.current.trigger(
162
+ * EmbedEvent.UpdateRuntimeFilter,
163
+ * [{ columnName: 'name', operator: 'EQ', values: ['value']}]);
164
+ * }, [])
165
+ * return <LiveboardEmbed ref={ref} liveboardId={<id>} />
166
+ * }
167
+ * ```
168
+ * @returns {React.MutableRefObject<TsEmbed>} ref
169
+ */
170
+ export const useEmbedRef = (): React.MutableRefObject<_AppEmbed | _LiveboardEmbed | _SearchEmbed | _SearchBarEmbed> => React.useRef<_AppEmbed | _LiveboardEmbed | _SearchEmbed | _SearchBarEmbed>(null);
171
+
172
+ export {
173
+ LiveboardViewConfig,
174
+ SearchViewConfig,
175
+ AppViewConfig,
176
+ Page,
177
+ RuntimeFilter,
178
+ RuntimeFilterOp,
179
+ EmbedEvent,
180
+ HostEvent,
181
+ Action,
182
+ FrameParams,
183
+ } from '../index';
@@ -8,9 +8,9 @@ global.fetch = jest.fn(() => Promise.resolve({
8
8
  json: () => ({ mixpanelAccessToken: '' }),
9
9
  }));
10
10
 
11
- export const defaultParamsWithoutHiddenActions = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=${AuthType.None}`;
11
+ export const defaultParamsWithoutHiddenActions = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=${AuthType.None}&blockNonEmbedFullAppAccess=true`;
12
12
  export const defaultParams = `&${defaultParamsWithoutHiddenActions}&hideAction=[%22${Action.ReportError}%22]`;
13
- export const defaultParamsForPinboardEmbed = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22]`;
13
+ export const defaultParamsForPinboardEmbed = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]`;
14
14
  export const getDocumentBody = () => '<div id="embed"></div><div id="embed-2"></div>';
15
15
 
16
16
  type DOMElement = HTMLElement | Document;