@thoughtspot/visual-embed-sdk 1.35.5-hostEvent.6 → 1.35.5-hostEvent.8

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 (105) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/embed/app.d.ts +1 -1
  3. package/cjs/src/embed/base.d.ts +1 -1
  4. package/cjs/src/embed/base.js +1 -1
  5. package/cjs/src/embed/hostEventClient/contracts.d.ts +26 -30
  6. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  7. package/cjs/src/embed/hostEventClient/contracts.js +10 -10
  8. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  9. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  10. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  11. package/cjs/src/embed/hostEventClient/host-event-client.js +62 -28
  12. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  13. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +43 -39
  14. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  15. package/cjs/src/embed/liveboard.d.ts +8 -7
  16. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  17. package/cjs/src/embed/liveboard.js +2 -2
  18. package/cjs/src/embed/liveboard.js.map +1 -1
  19. package/cjs/src/embed/liveboard.spec.js +4 -2
  20. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  21. package/cjs/src/embed/ts-embed.d.ts +14 -9
  22. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  23. package/cjs/src/embed/ts-embed.js +23 -15
  24. package/cjs/src/embed/ts-embed.js.map +1 -1
  25. package/cjs/src/embed/ts-embed.spec.js +4 -4
  26. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  27. package/cjs/src/index.d.ts +2 -2
  28. package/cjs/src/index.js +2 -2
  29. package/cjs/src/react/all-types-export.d.ts +1 -1
  30. package/cjs/src/react/all-types-export.js +2 -2
  31. package/cjs/src/types.d.ts +26 -21
  32. package/cjs/src/types.d.ts.map +1 -1
  33. package/cjs/src/types.js +20 -19
  34. package/cjs/src/types.js.map +1 -1
  35. package/dist/index-DaLHJaLd.js +7370 -0
  36. package/dist/index-nWevLycs.js +7370 -0
  37. package/dist/src/embed/app.d.ts +1 -1
  38. package/dist/src/embed/base.d.ts +1 -1
  39. package/dist/src/embed/hostEventClient/contracts.d.ts +26 -30
  40. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  41. package/dist/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  42. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  43. package/dist/src/embed/liveboard.d.ts +8 -7
  44. package/dist/src/embed/liveboard.d.ts.map +1 -1
  45. package/dist/src/embed/ts-embed.d.ts +14 -9
  46. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  47. package/dist/src/index.d.ts +2 -2
  48. package/dist/src/react/all-types-export.d.ts +1 -1
  49. package/dist/src/types.d.ts +26 -21
  50. package/dist/src/types.d.ts.map +1 -1
  51. package/dist/tsembed-react.es.js +118 -76
  52. package/dist/tsembed-react.js +117 -75
  53. package/dist/tsembed.es.js +120 -78
  54. package/dist/tsembed.js +118 -76
  55. package/dist/visual-embed-sdk-react-full.d.ts +96 -75
  56. package/dist/visual-embed-sdk-react.d.ts +96 -75
  57. package/dist/visual-embed-sdk.d.ts +96 -75
  58. package/lib/package.json +1 -1
  59. package/lib/src/embed/app.d.ts +1 -1
  60. package/lib/src/embed/base.d.ts +1 -1
  61. package/lib/src/embed/base.js +1 -1
  62. package/lib/src/embed/hostEventClient/contracts.d.ts +26 -30
  63. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  64. package/lib/src/embed/hostEventClient/contracts.js +9 -9
  65. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  66. package/lib/src/embed/hostEventClient/host-event-client.d.ts +21 -7
  67. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  68. package/lib/src/embed/hostEventClient/host-event-client.js +64 -30
  69. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  70. package/lib/src/embed/hostEventClient/host-event-client.spec.js +43 -40
  71. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  72. package/lib/src/embed/liveboard.d.ts +8 -7
  73. package/lib/src/embed/liveboard.d.ts.map +1 -1
  74. package/lib/src/embed/liveboard.js +2 -2
  75. package/lib/src/embed/liveboard.js.map +1 -1
  76. package/lib/src/embed/liveboard.spec.js +4 -2
  77. package/lib/src/embed/liveboard.spec.js.map +1 -1
  78. package/lib/src/embed/ts-embed.d.ts +14 -9
  79. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  80. package/lib/src/embed/ts-embed.js +23 -15
  81. package/lib/src/embed/ts-embed.js.map +1 -1
  82. package/lib/src/embed/ts-embed.spec.js +5 -5
  83. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  84. package/lib/src/index.d.ts +2 -2
  85. package/lib/src/index.js +2 -2
  86. package/lib/src/react/all-types-export.d.ts +1 -1
  87. package/lib/src/react/all-types-export.js +1 -1
  88. package/lib/src/types.d.ts +26 -21
  89. package/lib/src/types.d.ts.map +1 -1
  90. package/lib/src/types.js +20 -19
  91. package/lib/src/types.js.map +1 -1
  92. package/lib/src/visual-embed-sdk.d.ts +99 -78
  93. package/package.json +1 -1
  94. package/src/embed/app.ts +1 -1
  95. package/src/embed/base.ts +1 -1
  96. package/src/embed/hostEventClient/contracts.ts +43 -32
  97. package/src/embed/hostEventClient/host-event-client.spec.ts +58 -54
  98. package/src/embed/hostEventClient/host-event-client.ts +105 -48
  99. package/src/embed/liveboard.spec.ts +4 -2
  100. package/src/embed/liveboard.ts +8 -7
  101. package/src/embed/ts-embed.spec.ts +6 -6
  102. package/src/embed/ts-embed.ts +39 -28
  103. package/src/index.ts +2 -2
  104. package/src/react/all-types-export.ts +1 -1
  105. package/src/types.ts +26 -21
@@ -12,9 +12,11 @@ import isObject from 'lodash/isObject';
12
12
  import {
13
13
  HostEventRequest,
14
14
  HostEventResponse,
15
- UiPassthroughArrayResponse,
16
- UiPassthroughEvent,
17
- UiPassthroughRequest,
15
+ TriggerPayload,
16
+ TriggerResponse,
17
+ UIPassthroughArrayResponse,
18
+ UIPassthroughEvent,
19
+ UIPassthroughRequest,
18
20
  } from './hostEventClient/contracts';
19
21
  import { logger } from '../utils/logger';
20
22
  import { getAuthenticationToken } from '../authToken';
@@ -85,7 +87,7 @@ const TS_EMBED_ID = '_thoughtspot-embed';
85
87
  * We cannot rename v1 event types to maintain backward compatibility
86
88
  * @internal
87
89
  */
88
- const V1EventMap = {};
90
+ const V1EventMap: Record<string, any> = {};
89
91
 
90
92
  /**
91
93
  * Base class for embedding v2 experience
@@ -119,6 +121,15 @@ export class TsEmbed {
119
121
  */
120
122
  protected iFrame: HTMLIFrameElement;
121
123
 
124
+ /**
125
+ * Setter for the iframe element
126
+ * @param {HTMLIFrameElement} iFrame HTMLIFrameElement
127
+ */
128
+ protected setIframeElement(iFrame: HTMLIFrameElement): void {
129
+ this.iFrame = iFrame;
130
+ this.hostEventClient.setIframeElement(iFrame);
131
+ }
132
+
122
133
  protected viewConfig: ViewConfig;
123
134
 
124
135
  protected embedConfig: EmbedConfig;
@@ -190,7 +201,7 @@ export class TsEmbed {
190
201
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
191
202
  ...viewConfig,
192
203
  });
193
- this.hostEventClient = new HostEventClient(this.embedConfig.thoughtSpotHost);
204
+ this.hostEventClient = new HostEventClient(this.iFrame);
194
205
  }
195
206
 
196
207
  /**
@@ -252,7 +263,7 @@ export class TsEmbed {
252
263
  return eventData;
253
264
  }
254
265
 
255
- private subscribedListeners = {};
266
+ private subscribedListeners: Record<string, any> = {};
256
267
 
257
268
  /**
258
269
  * Adds a global event listener to window for "message" events.
@@ -620,7 +631,7 @@ export class TsEmbed {
620
631
  this.insertIntoDOM(child);
621
632
  }
622
633
  if (this.insertedDomEl instanceof Node) {
623
- this.insertedDomEl[this.embedNodeKey] = this;
634
+ (this.insertedDomEl as any)[this.embedNodeKey] = this;
624
635
  }
625
636
  }
626
637
 
@@ -658,7 +669,7 @@ export class TsEmbed {
658
669
  return;
659
670
  }
660
671
 
661
- this.iFrame = this.iFrame || this.createIframeEl(url);
672
+ this.setIframeElement(this.iFrame || this.createIframeEl(url));
662
673
  this.iFrame.addEventListener('load', () => {
663
674
  nextInQueue();
664
675
  const loadTimestamp = Date.now();
@@ -728,7 +739,7 @@ export class TsEmbed {
728
739
  if (this.preRenderWrapper && this.preRenderChild) {
729
740
  this.isPreRendered = true;
730
741
  if (this.preRenderChild instanceof HTMLIFrameElement) {
731
- this.iFrame = this.preRenderChild;
742
+ this.setIframeElement(this.preRenderChild);
732
743
  }
733
744
  this.insertedDomEl = this.preRenderWrapper;
734
745
  this.isRendered = true;
@@ -777,7 +788,7 @@ export class TsEmbed {
777
788
  this.preRenderWrapper = preRenderWrapper;
778
789
 
779
790
  if (preRenderChild instanceof HTMLIFrameElement) {
780
- this.iFrame = preRenderChild;
791
+ this.setIframeElement(preRenderChild);
781
792
  }
782
793
  this.insertedDomEl = preRenderWrapper;
783
794
 
@@ -994,14 +1005,14 @@ export class TsEmbed {
994
1005
 
995
1006
  /**
996
1007
  * Triggers an event to the embedded app
997
- * @param messageType The event type
998
- * @param data The payload to send with the message
1008
+ * @param {HostEvent} messageType The event type
1009
+ * @param {any} data The payload to send with the message
999
1010
  * @returns A promise that resolves with the response from the embedded app
1000
1011
  */
1001
- public trigger<HostEventT extends HostEvent>(
1012
+ public async trigger<HostEventT extends HostEvent, PayloadT>(
1002
1013
  messageType: HostEventT,
1003
- data?: HostEventRequest<HostEventT>,
1004
- ): Promise<HostEventResponse<HostEventT>> {
1014
+ data?: TriggerPayload<PayloadT, HostEventT>,
1015
+ ): Promise<TriggerResponse<PayloadT, HostEventT>> {
1005
1016
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
1006
1017
 
1007
1018
  if (!this.isRendered) {
@@ -1014,22 +1025,22 @@ export class TsEmbed {
1014
1025
  return null;
1015
1026
  }
1016
1027
 
1017
- return this.hostEventClient.executeHostEvent(this.iFrame, messageType, data);
1028
+ return this.hostEventClient.triggerHostEvent(messageType, data);
1018
1029
  }
1019
1030
 
1020
1031
  /**
1021
1032
  * Triggers an event to the embedded app, skipping the UI flow.
1022
- * @param {UiPassthroughEvent} apiName - The name of the API to be triggered.
1023
- * @param {UiPassthroughRequest} parameters - The parameters to be passed to the API.
1024
- * @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
1033
+ * @param {UIPassthroughEvent} apiName - The name of the API to be triggered.
1034
+ * @param {UIPassthroughRequest} parameters - The parameters to be passed to the API.
1035
+ * @returns {Promise<UIPassthroughRequest>} - A promise that resolves with the response
1025
1036
  * from the embedded app.
1026
1037
  */
1027
- // eslint-disable-next-line arrow-body-style
1028
- public triggerUiPassThrough<UiPassthroughEventT extends UiPassthroughEvent>(
1029
- apiName: UiPassthroughEventT,
1030
- parameters: UiPassthroughRequest<UiPassthroughEventT>,
1031
- ): UiPassthroughArrayResponse<UiPassthroughEventT> {
1032
- return this.hostEventClient.executeUiPassthroughApi(this.iFrame, apiName, parameters);
1038
+ public async triggerUIPassThrough<UIPassthroughEventT extends UIPassthroughEvent>(
1039
+ apiName: UIPassthroughEventT,
1040
+ parameters: UIPassthroughRequest<UIPassthroughEventT>,
1041
+ ): Promise<UIPassthroughArrayResponse<UIPassthroughEventT>> {
1042
+ const response = this.hostEventClient.triggerUIPassthroughApi(apiName, parameters);
1043
+ return response;
1033
1044
  }
1034
1045
 
1035
1046
  /**
@@ -1135,14 +1146,14 @@ export class TsEmbed {
1135
1146
 
1136
1147
  private validatePreRenderViewConfig = (viewConfig: ViewConfig) => {
1137
1148
  const preRenderAllowedKeys = ['preRenderId', 'vizId', 'liveboardId'];
1138
- const preRenderedObject = this.insertedDomEl?.[this.embedNodeKey] as TsEmbed;
1149
+ const preRenderedObject = (this.insertedDomEl as any)?.[this.embedNodeKey] as TsEmbed;
1139
1150
  if (!preRenderedObject) return;
1140
1151
  if (viewConfig.preRenderId) {
1141
1152
  const allOtherKeys = Object.keys(viewConfig).filter(
1142
1153
  (key) => !preRenderAllowedKeys.includes(key) && !key.startsWith('on'),
1143
1154
  );
1144
1155
 
1145
- allOtherKeys.forEach((key) => {
1156
+ allOtherKeys.forEach((key: keyof ViewConfig) => {
1146
1157
  if (
1147
1158
  !isUndefined(viewConfig[key])
1148
1159
  && !isEqual(viewConfig[key], preRenderedObject.viewConfig[key])
@@ -1271,7 +1282,7 @@ export class TsEmbed {
1271
1282
  /**
1272
1283
  * Returns the answerService which can be used to make arbitrary graphql calls on top
1273
1284
  * session.
1274
- * @param vizId [Optional] to get for a specific viz in case of a liveboard.
1285
+ * @param vizId [Optional] to get for a specific viz in case of a Liveboard.
1275
1286
  * @version SDK: 1.25.0 / ThoughtSpot 9.10.0
1276
1287
  */
1277
1288
  public async getAnswerService(vizId?: string): Promise<AnswerService> {
package/src/index.ts CHANGED
@@ -61,7 +61,7 @@ import { uploadMixpanelEvent, MIXPANEL_EVENT } from './mixpanel-service';
61
61
  import { tokenizedFetch } from './tokenizedFetch';
62
62
  import { getAnswerFromQuery } from './utils/graphql/nlsService/nls-answer-service';
63
63
  import { createLiveboardWithAnswers } from './utils/liveboardService/liveboardService';
64
- import { UiPassthroughEvent } from './embed/hostEventClient/contracts';
64
+ import { UIPassthroughEvent } from './embed/hostEventClient/contracts';
65
65
 
66
66
  export {
67
67
  init,
@@ -128,7 +128,7 @@ export {
128
128
  HomePageSearchBarMode,
129
129
  VizPoint,
130
130
  CustomActionPayload,
131
- UiPassthroughEvent,
131
+ UIPassthroughEvent,
132
132
  };
133
133
 
134
134
  export { resetCachedAuthToken } from './authToken';
@@ -51,5 +51,5 @@ export {
51
51
  CustomCssVariables,
52
52
  RuntimeParameter,
53
53
  resetCachedAuthToken,
54
- UiPassthroughEvent,
54
+ UIPassthroughEvent,
55
55
  } from '../index';
package/src/types.ts CHANGED
@@ -1088,8 +1088,12 @@ export interface ViewConfig {
1088
1088
  */
1089
1089
  enableCustomColumnGroups?: boolean;
1090
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
1091
+ * Overrides an Org context for embedding application users.
1092
+ * This parameter allows a user authenticated to one Org to view the
1093
+ * objects from another Org.
1094
+ * The `overrideOrgId` setting is honoured only if the
1095
+ * Per Org URL feature is enabled on your ThoughtSpot instance.
1096
+ *
1093
1097
  * @example
1094
1098
  * ```js
1095
1099
  * const embed = new LiveboardEmbed('#embed', {
@@ -2365,7 +2369,7 @@ export enum HostEvent {
2365
2369
  * @param - autoDrillDown - Optional. If true, the drill down will be
2366
2370
  * done automatically on the most popular column.
2367
2371
  * @param - vizId [TS >= 9.8.0] - Optional. The GUID of the visualization to drill
2368
- * in case of a liveboard.
2372
+ * in case of a Liveboard.
2369
2373
  * @example
2370
2374
  * ```js
2371
2375
  * searchEmbed.on(EmbedEvent.VizPointDoubleClick, (payload) => {
@@ -2452,26 +2456,26 @@ export enum HostEvent {
2452
2456
  */
2453
2457
  SetActiveTab = 'SetActiveTab',
2454
2458
  /**
2455
- * Update runtime filters applied on a Saved Answer or Liveboard. The
2456
- * runtime filters passed here are appended to the existing runtime
2457
- * filters.
2459
+ * Updates the runtime filters applied on a Liveboard. The filter
2460
+ * attributes passed with this event are appended to the existing runtime
2461
+ * filters applied on a Liveboard.
2462
+ *
2458
2463
  * Pass an array of runtime filters with the following attributes:
2459
2464
  *
2460
- * `columnName`
2461
- * _String_. The name of the column to filter on.
2465
+ * `columnName` - _String_. The name of the column to filter on.
2462
2466
  *
2463
- * `operator`
2464
- * Runtime filter operator to apply. For information,
2467
+ * `operator` - Runtime filter operator to apply. For more information,
2465
2468
  * see link:https://developers.thoughtspot.com/docs/?pageid=runtime-filters#rtOperator[Developer Documentation].
2466
2469
  *
2467
- * `values`
2468
- * List of operands. Some operators such as EQ, LE allow a single value, whereas
2469
- * operators such as BW and IN accept multiple operands.
2470
+ * `values` - List of operands. Some operators such as EQ and LE allow a
2471
+ * single value, whereas BW and IN accept multiple values.
2472
+ *
2473
+ * **Note**: `HostEvent.UpdateRuntimeFilters` is supported in `LiveboardEmbed`
2474
+ * and `AppEmbed` only. In full application embedding, this event updates
2475
+ * the runtime filters applied on the Liveboard and saved Answer objects.
2470
2476
  *
2471
- * **Note**: `HostEvent.UpdateRuntimeFilters` is not supported in
2472
- * Search embedding (SearchEmbed) and Natural Language Search
2473
- * embedding (SageEmbed).
2474
2477
  * @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
2478
+ *
2475
2479
  * @example
2476
2480
  * ```js
2477
2481
  * liveboardEmbed.trigger(HostEvent.UpdateRuntimeFilters, [
@@ -3170,7 +3174,7 @@ export enum HostEvent {
3170
3174
  */
3171
3175
  ResetLiveboardPersonalisedView = 'ResetLiveboardPersonalisedView',
3172
3176
  /**
3173
- * Triggers Update RuntimeParameters for answers and liveboard
3177
+ * Triggers an event to Update Parameter values for Answers and Liveboard
3174
3178
  * @example
3175
3179
  * ```js
3176
3180
  * liveboardEmbed.trigger(HostEvent.UpdateParameters, [{
@@ -3192,7 +3196,7 @@ export enum HostEvent {
3192
3196
  */
3193
3197
  GetParameters = 'GetParameters',
3194
3198
  /**
3195
- * Triggers update of persoanlised view for a liveboard
3199
+ * Triggers an event to update a persoanlised view of a Liveboard
3196
3200
  * ```js
3197
3201
  * liveboardEmbed.trigger(HostEvent.UpdatePersonalisedView, {viewId: '1234'})
3198
3202
  * ```
@@ -3208,7 +3212,7 @@ export enum HostEvent {
3208
3212
  * EmbedApi
3209
3213
  * @hidden
3210
3214
  */
3211
- UiPassthrough = 'UiPassthrough',
3215
+ UIPassthrough = 'UiPassthrough',
3212
3216
  }
3213
3217
 
3214
3218
  /**
@@ -4189,7 +4193,7 @@ export enum Action {
4189
4193
  */
4190
4194
  ModifySageAnswer = 'modifySageAnswer',
4191
4195
  /**
4192
- * The **Move to Tab** menu action on visualizations in liveboard edit mode.
4196
+ * The **Move to Tab** menu action on visualizations in Liveboard edit mode.
4193
4197
  * Allows moving a visualization to a different tab.
4194
4198
  * @example
4195
4199
  * ```js
@@ -4244,7 +4248,8 @@ export enum Action {
4244
4248
  TML = 'tml',
4245
4249
 
4246
4250
  /**
4247
- * Action Id for CreateLiveboard for liveboard list page & Pin Modal
4251
+ * Action ID for the create Liveboard option on the Liveboard list page
4252
+ * and Pin modal
4248
4253
  * @example
4249
4254
  * ```js
4250
4255
  * hiddenAction: [Action.CreateLiveboard]