@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.
Files changed (66) hide show
  1. package/README.md +8 -8
  2. package/dist/src/embed/app.d.ts +14 -3
  3. package/dist/src/embed/liveboard.d.ts +101 -0
  4. package/dist/src/embed/liveboard.spec.d.ts +1 -0
  5. package/dist/src/embed/search.d.ts +0 -4
  6. package/dist/src/embed/ts-embed.d.ts +2 -11
  7. package/dist/src/errors.d.ts +1 -1
  8. package/dist/src/index.d.ts +2 -2
  9. package/dist/src/react/index.d.ts +4 -3
  10. package/dist/src/types.d.ts +22 -20
  11. package/dist/tsembed.es.js +83 -71
  12. package/dist/tsembed.js +82 -69
  13. package/lib/package.json +1 -2
  14. package/lib/src/embed/app.d.ts +14 -3
  15. package/lib/src/embed/app.js +25 -2
  16. package/lib/src/embed/app.js.map +1 -1
  17. package/lib/src/embed/app.spec.js +32 -0
  18. package/lib/src/embed/app.spec.js.map +1 -1
  19. package/lib/src/embed/events.spec.js +55 -2
  20. package/lib/src/embed/events.spec.js.map +1 -1
  21. package/lib/src/embed/liveboard.d.ts +101 -0
  22. package/lib/src/embed/liveboard.js +115 -0
  23. package/lib/src/embed/liveboard.js.map +1 -0
  24. package/lib/src/embed/liveboard.spec.d.ts +1 -0
  25. package/lib/src/embed/liveboard.spec.js +159 -0
  26. package/lib/src/embed/liveboard.spec.js.map +1 -0
  27. package/lib/src/embed/pinboard.spec.js +1 -1
  28. package/lib/src/embed/pinboard.spec.js.map +1 -1
  29. package/lib/src/embed/search.d.ts +0 -4
  30. package/lib/src/embed/search.js +1 -1
  31. package/lib/src/embed/search.js.map +1 -1
  32. package/lib/src/embed/ts-embed.d.ts +2 -11
  33. package/lib/src/embed/ts-embed.js +2 -22
  34. package/lib/src/embed/ts-embed.js.map +1 -1
  35. package/lib/src/embed/ts-embed.spec.js +63 -6
  36. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  37. package/lib/src/errors.d.ts +1 -1
  38. package/lib/src/errors.js +1 -1
  39. package/lib/src/errors.js.map +1 -1
  40. package/lib/src/index.d.ts +2 -2
  41. package/lib/src/index.js +2 -2
  42. package/lib/src/index.js.map +1 -1
  43. package/lib/src/react/index.d.ts +4 -3
  44. package/lib/src/react/index.js +3 -2
  45. package/lib/src/react/index.js.map +1 -1
  46. package/lib/src/types.d.ts +22 -20
  47. package/lib/src/types.js +19 -18
  48. package/lib/src/types.js.map +1 -1
  49. package/lib/src/utils/fetchAnswers.d.ts +3 -0
  50. package/lib/src/utils/fetchAnswers.js +49 -0
  51. package/lib/src/utils/fetchAnswers.js.map +1 -0
  52. package/lib/src/visual-embed-sdk.d.ts +78 -62
  53. package/package.json +1 -2
  54. package/src/embed/app.spec.ts +41 -0
  55. package/src/embed/app.ts +28 -3
  56. package/src/embed/events.spec.ts +64 -5
  57. package/src/embed/liveboard.spec.ts +199 -0
  58. package/src/embed/{pinboard.ts → liveboard.ts} +60 -42
  59. package/src/embed/pinboard.spec.ts +11 -11
  60. package/src/embed/search.ts +0 -5
  61. package/src/embed/ts-embed.spec.ts +81 -8
  62. package/src/embed/ts-embed.ts +3 -24
  63. package/src/errors.ts +2 -2
  64. package/src/index.ts +7 -2
  65. package/src/react/index.tsx +14 -8
  66. package/src/types.ts +22 -20
@@ -230,12 +230,12 @@ var EmbedEvent;
230
230
  */
231
231
  EmbedEvent["Load"] = "load";
232
232
  /**
233
- * Data pertaining to answer or pinboard is received
234
- * @return data - The answer or pinboard data
233
+ * Data pertaining to answer or Liveboard is received
234
+ * @return data - The answer or Liveboard data
235
235
  */
236
236
  EmbedEvent["Data"] = "data";
237
237
  /**
238
- * Search/answer/pinboard filters have been applied/updated
238
+ * Search/answer/Liveboard filters have been applied/updated
239
239
  * @hidden
240
240
  */
241
241
  EmbedEvent["FiltersChanged"] = "filtersChanged";
@@ -258,13 +258,13 @@ var EmbedEvent;
258
258
  /**
259
259
  * A custom action has been triggered
260
260
  * @return actionId - The id of the custom action
261
- * @return data - The answer or pinboard data
261
+ * @return data - The answer or Liveboard data
262
262
  */
263
263
  EmbedEvent["CustomAction"] = "customAction";
264
264
  /**
265
265
  * A double click has been triggered on table/chart
266
266
  * @return ContextMenuInputPoints - data point that is double clicked
267
- * * _since: 1.5.0_
267
+ * * _Version 1.5.0 or later _
268
268
  */
269
269
  EmbedEvent["VizPointDoubleClick"] = "vizPointDoubleClick";
270
270
  /**
@@ -282,8 +282,8 @@ var EmbedEvent;
282
282
  */
283
283
  EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
284
284
  /**
285
- * The height of the embedded pinboard or visualization has been computed.
286
- * @return data - The height of the embedded pinboard or visualization
285
+ * The height of the embedded Liveboard or visualization has been computed.
286
+ * @return data - The height of the embedded Liveboard or visualization
287
287
  * @hidden
288
288
  */
289
289
  EmbedEvent["EmbedHeight"] = "EMBED_HEIGHT";
@@ -295,7 +295,6 @@ var EmbedEvent;
295
295
  EmbedEvent["EmbedIframeCenter"] = "EmbedIframeCenter";
296
296
  /**
297
297
  * Detects the route change.
298
- * @hidden
299
298
  */
300
299
  EmbedEvent["RouteChange"] = "ROUTE_CHANGE";
301
300
  /**
@@ -318,12 +317,12 @@ var EmbedEvent;
318
317
  EmbedEvent["SAMLComplete"] = "samlComplete";
319
318
  /**
320
319
  * Emitted when any modal is opened in the app
321
- * * _since: 1.6.0_
320
+ * * _Version 1.6.0 or later _
322
321
  */
323
322
  EmbedEvent["DialogOpen"] = "dialog-open";
324
323
  /**
325
324
  * Emitted when any modal is closed in the app
326
- * * _since: 1.6.0_
325
+ * * _Version 1.6.0 or later _
327
326
  */
328
327
  EmbedEvent["DialogClose"] = "dialog-close";
329
328
  })(EmbedEvent || (EmbedEvent = {}));
@@ -346,7 +345,7 @@ var HostEvent;
346
345
  * eg. { selectedPoints: []}
347
346
  * @param columnGuid - a string guid of the column to drill by. This is optional,
348
347
  * if not provided it will auto drill by the configured column. \
349
- * * _since: 1.5.0_
348
+ * * _Version 1.5.0 or later _
350
349
  */
351
350
  HostEvent["DrillDown"] = "triggerDrillDown";
352
351
  /**
@@ -360,10 +359,10 @@ var HostEvent;
360
359
  */
361
360
  HostEvent["Reload"] = "reload";
362
361
  /**
363
- * Set the visible Vizs on a pinboard/liveboard.
364
- * @param - an array of ids of vizs to show, the ids not passed
362
+ * Set the visible visualizations on a Liveboard.
363
+ * @param - an array of ids of visualizations to show, the ids not passed
365
364
  * will be hidden.
366
- * _since: 1.6.0_
365
+ * * _Version 1.6.0 or later _
367
366
  */
368
367
  HostEvent["SetVisibleVizs"] = "SetPinboardVisibleVizs";
369
368
  })(HostEvent || (HostEvent = {}));
@@ -396,11 +395,10 @@ var Param;
396
395
  (function (Param) {
397
396
  Param["DataSources"] = "dataSources";
398
397
  Param["DataSourceMode"] = "dataSourceMode";
399
- Param["ExpandAllDataSource"] = "expandAllDataSource";
400
398
  Param["DisableActions"] = "disableAction";
401
399
  Param["DisableActionReason"] = "disableHint";
402
400
  Param["ForceTable"] = "forceTable";
403
- Param["preventPinboardFilterRemoval"] = "preventPinboardFilterRemoval";
401
+ Param["preventLiveboardFilterRemoval"] = "preventPinboardFilterRemoval";
404
402
  Param["SearchQuery"] = "searchQuery";
405
403
  Param["HideActions"] = "hideAction";
406
404
  Param["HideObjects"] = "hideObjects";
@@ -422,7 +420,7 @@ var Param;
422
420
  })(Param || (Param = {}));
423
421
  /**
424
422
  * The list of actions that can be performed on visual ThoughtSpot
425
- * entities, such as answers and pinboards.
423
+ * entities, such as answers and Liveboards.
426
424
  */
427
425
  // eslint-disable-next-line no-shadow
428
426
  var Action;
@@ -434,7 +432,6 @@ var Action;
434
432
  Action["MakeACopy"] = "makeACopy";
435
433
  Action["EditACopy"] = "editACopy";
436
434
  Action["CopyLink"] = "embedDocument";
437
- Action["PinboardSnapshot"] = "pinboardSnapshot";
438
435
  Action["ResetLayout"] = "resetLayout";
439
436
  Action["Schedule"] = "schedule";
440
437
  Action["SchedulesList"] = "schedule-list";
@@ -467,7 +464,11 @@ var Action;
467
464
  Action["Describe"] = "describe";
468
465
  Action["Relate"] = "relate";
469
466
  Action["CustomizeHeadlines"] = "customizeHeadlines";
467
+ /**
468
+ * @hidden
469
+ */
470
470
  Action["PinboardInfo"] = "pinboardInfo";
471
+ Action["LiveboardInfo"] = "pinboardInfo";
471
472
  Action["SendAnswerFeedback"] = "sendFeedback";
472
473
  /**
473
474
  * @deprecated Will be removed in next version
@@ -497,7 +498,7 @@ var OperationType;
497
498
 
498
499
  const ERROR_MESSAGE = {
499
500
  INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
500
- PINBOARD_VIZ_ID_VALIDATION: 'Please provide either pinboardId or both pinboardId and vizId',
501
+ LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
501
502
  };
502
503
 
503
504
  /**
@@ -8838,7 +8839,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
8838
8839
  }
8839
8840
  }
8840
8841
 
8841
- var version="1.5.0";
8842
+ var version="1.6.0-alpha.3";
8842
8843
 
8843
8844
  /**
8844
8845
  * Copyright (c) 2021
@@ -9004,7 +9005,7 @@ class TsEmbed {
9004
9005
  queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
9005
9006
  }
9006
9007
  const { disabledActions, disabledActionReason, hiddenActions, visibleActions, } = this.viewConfig;
9007
- if ((visibleActions === null || visibleActions === void 0 ? void 0 : visibleActions.length) && (hiddenActions === null || hiddenActions === void 0 ? void 0 : hiddenActions.length)) {
9008
+ if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
9008
9009
  this.handleError('You cannot have both hidden actions and visible actions');
9009
9010
  return queryParams;
9010
9011
  }
@@ -9024,7 +9025,7 @@ class TsEmbed {
9024
9025
  }
9025
9026
  /**
9026
9027
  * Constructs the base URL string to load v1 of the ThoughtSpot app.
9027
- * This is used for embedding pinboards, visualizations, and full application.
9028
+ * This is used for embedding Liveboards, visualizations, and full application.
9028
9029
  * @param queryString The query string to append to the URL.
9029
9030
  * @param isAppEmbed A Boolean parameter to specify if you are embedding
9030
9031
  * the full application.
@@ -9202,26 +9203,6 @@ class TsEmbed {
9202
9203
  this.eventHandlerMap.set(messageType, callbacks);
9203
9204
  return this;
9204
9205
  }
9205
- /**
9206
- * Navigates users to the specified application page.
9207
- * Use this method to navigate users from the embedded
9208
- * ThoughtSpot context to a specific page in your app.
9209
- * @param path The page path string.
9210
- * For example, to navigate users to a pinboard page,
9211
- * define the method as navigateToPage('pinboard/<pinboardId>').
9212
- */
9213
- navigateToPage(path) {
9214
- var _a;
9215
- const iframeSrc = (_a = this.iFrame) === null || _a === void 0 ? void 0 : _a.src;
9216
- if (iframeSrc) {
9217
- const embedPath = '#/embed';
9218
- const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
9219
- this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
9220
- }
9221
- else {
9222
- console.log('Please call render before invoking this method');
9223
- }
9224
- }
9225
9206
  /**
9226
9207
  * Triggers an event on specific Port registered against
9227
9208
  * for the EmbedEvent
@@ -9319,7 +9300,11 @@ var Page;
9319
9300
  */
9320
9301
  Page["Answers"] = "answers";
9321
9302
  /**
9322
- * Pinboards listing page
9303
+ * Liveboards listing page
9304
+ */
9305
+ Page["Liveboards"] = "liveboards";
9306
+ /**
9307
+ * @hidden
9323
9308
  */
9324
9309
  Page["Pinboards"] = "pinboards";
9325
9310
  /**
@@ -9338,7 +9323,7 @@ class AppEmbed extends V1Embed {
9338
9323
  }
9339
9324
  /**
9340
9325
  * Constructs a map of parameters to be passed on to the
9341
- * embedded pinboard or visualization.
9326
+ * embedded Liveboard or visualization.
9342
9327
  */
9343
9328
  getEmbedParams() {
9344
9329
  const params = this.getBaseQueryParams();
@@ -9375,6 +9360,8 @@ class AppEmbed extends V1Embed {
9375
9360
  return 'answer';
9376
9361
  case Page.Answers:
9377
9362
  return 'answers';
9363
+ case Page.Liveboards:
9364
+ return 'pinboards';
9378
9365
  case Page.Pinboards:
9379
9366
  return 'pinboards';
9380
9367
  case Page.Data:
@@ -9399,6 +9386,23 @@ class AppEmbed extends V1Embed {
9399
9386
  }
9400
9387
  return path;
9401
9388
  }
9389
+ /**
9390
+ * Navigate to particular page for app embed. eg:answers/pinboards/home
9391
+ * This is used for embedding answers, pinboards, visualizations and full application only.
9392
+ * @param path The string, set to iframe src and navigate to new page
9393
+ * eg: appEmbed.navigateToPage('pinboards')
9394
+ */
9395
+ navigateToPage(path) {
9396
+ if (this.iFrame) {
9397
+ const iframeSrc = this.iFrame.src;
9398
+ const embedPath = '#/embed';
9399
+ const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
9400
+ this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
9401
+ }
9402
+ else {
9403
+ console.log('Please call render before invoking this method');
9404
+ }
9405
+ }
9402
9406
  /**
9403
9407
  * Renders the embedded application pages in the ThoughtSpot app.
9404
9408
  * @param renderOptions An object containing the page ID
@@ -9417,18 +9421,18 @@ class AppEmbed extends V1Embed {
9417
9421
  /**
9418
9422
  * Copyright (c) 2021
9419
9423
  *
9420
- * Embed a ThoughtSpot pinboard or visualization
9424
+ * Embed a ThoughtSpot Liveboard or visualization
9421
9425
  * https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
9422
9426
  * https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
9423
9427
  *
9424
- * @summary Pinboard & visualization embed
9428
+ * @summary Liveboard & visualization embed
9425
9429
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9426
9430
  */
9427
9431
  /**
9428
- * Embed a ThoughtSpot pinboard or visualization
9429
- * @Category Pinboards and Charts
9432
+ * Embed a ThoughtSpot Liveboard or visualization
9433
+ * @Category Liveboards and Charts
9430
9434
  */
9431
- class PinboardEmbed extends V1Embed {
9435
+ class LiveboardEmbed extends V1Embed {
9432
9436
  // eslint-disable-next-line no-useless-constructor
9433
9437
  constructor(domSelector, viewConfig) {
9434
9438
  super(domSelector, viewConfig);
@@ -9445,20 +9449,21 @@ class PinboardEmbed extends V1Embed {
9445
9449
  const obj = this.getIframeCenter();
9446
9450
  responder({ type: EmbedEvent.EmbedIframeCenter, data: obj });
9447
9451
  };
9448
- this.handleRouteChangeFullHeightPinboard = (data) => {
9449
- if (data.data.canvasState !== 'EMBED' &&
9450
- data.data.canvasState !== 'pinboard') {
9452
+ this.setIframeHeightForNonEmbedLiveboard = (data) => {
9453
+ if (!data.data.currentPath.startsWith('/embed/viz/')) {
9451
9454
  this.setIFrameHeight(this.defaultHeight);
9452
9455
  }
9453
9456
  };
9454
9457
  }
9455
9458
  /**
9456
9459
  * Construct a map of params to be passed on to the
9457
- * embedded pinboard or visualization.
9460
+ * embedded Liveboard or visualization.
9458
9461
  */
9459
9462
  getEmbedParams() {
9460
9463
  const params = this.getBaseQueryParams();
9461
- const { enableVizTransformations, fullHeight, preventPinboardFilterRemoval, defaultHeight, } = this.viewConfig;
9464
+ const { enableVizTransformations, fullHeight, defaultHeight, } = this.viewConfig;
9465
+ const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval ||
9466
+ this.viewConfig.preventPinboardFilterRemoval;
9462
9467
  if (fullHeight === true) {
9463
9468
  params[Param.fullHeight] = true;
9464
9469
  }
@@ -9468,53 +9473,60 @@ class PinboardEmbed extends V1Embed {
9468
9473
  if (enableVizTransformations !== undefined) {
9469
9474
  params[Param.EnableVizTransformations] = enableVizTransformations.toString();
9470
9475
  }
9471
- if (preventPinboardFilterRemoval) {
9472
- params[Param.preventPinboardFilterRemoval] = true;
9476
+ if (preventLiveboardFilterRemoval) {
9477
+ params[Param.preventLiveboardFilterRemoval] = true;
9473
9478
  }
9474
9479
  params[Param.livedBoardEmbed] = true;
9475
9480
  const queryParams = getQueryParamString(params, true);
9476
9481
  return queryParams;
9477
9482
  }
9478
9483
  /**
9479
- * Construct the URL of the embedded ThoughtSpot pinboard or visualization
9484
+ * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
9480
9485
  * to be loaded within the iframe.
9481
- * @param pinboardId The GUID of the pinboard.
9482
- * @param vizId The optional GUID of a visualization within the pinboard.
9486
+ * @param liveboardId The GUID of the Liveboard.
9487
+ * @param vizId The optional GUID of a visualization within the Liveboard.
9483
9488
  * @param runtimeFilters A list of runtime filters to be applied to
9484
- * the pinboard or visualization on load.
9489
+ * the Liveboard or visualization on load.
9485
9490
  */
9486
- getIFrameSrc(pinboardId, vizId, runtimeFilters) {
9491
+ getIFrameSrc(liveboardId, vizId, runtimeFilters) {
9487
9492
  const filterQuery = getFilterQuery(runtimeFilters || []);
9488
9493
  const queryParams = this.getEmbedParams();
9489
9494
  const queryString = [filterQuery, queryParams]
9490
9495
  .filter(Boolean)
9491
9496
  .join('&');
9492
- let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${pinboardId}`;
9497
+ let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${liveboardId}`;
9493
9498
  if (vizId) {
9494
9499
  url = `${url}/${vizId}`;
9495
9500
  }
9496
9501
  return url;
9497
9502
  }
9498
9503
  /**
9499
- * Render an embedded ThoughtSpot pinboard or visualization
9500
- * @param renderOptions An object specifying the pinboard ID,
9504
+ * Render an embedded ThoughtSpot Liveboard or visualization
9505
+ * @param renderOptions An object specifying the Liveboard ID,
9501
9506
  * visualization ID and the runtime filters.
9502
9507
  */
9503
9508
  render() {
9504
- const { pinboardId, vizId, runtimeFilters } = this.viewConfig;
9505
- if (!pinboardId && !vizId) {
9506
- this.handleError(ERROR_MESSAGE.PINBOARD_VIZ_ID_VALIDATION);
9509
+ var _a;
9510
+ const { vizId, runtimeFilters } = this.viewConfig;
9511
+ const liveboardId = (_a = this.viewConfig.liveboardId) !== null && _a !== void 0 ? _a : this.viewConfig.pinboardId;
9512
+ if (!liveboardId) {
9513
+ this.handleError(ERROR_MESSAGE.LIVEBOARD_VIZ_ID_VALIDATION);
9507
9514
  }
9508
9515
  if (this.viewConfig.fullHeight === true) {
9509
- this.on(EmbedEvent.RouteChange, this.handleRouteChangeFullHeightPinboard);
9516
+ this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
9510
9517
  this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
9511
9518
  this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
9512
9519
  }
9513
9520
  super.render();
9514
- const src = this.getIFrameSrc(pinboardId, vizId, runtimeFilters);
9521
+ const src = this.getIFrameSrc(liveboardId, vizId, runtimeFilters);
9515
9522
  this.renderV1Embed(src);
9516
9523
  return this;
9517
9524
  }
9525
+ }
9526
+ /**
9527
+ * @hidden
9528
+ */
9529
+ class PinboardEmbed extends LiveboardEmbed {
9518
9530
  }
9519
9531
 
9520
9532
  /**
@@ -9556,7 +9568,7 @@ class SearchEmbed extends TsEmbed {
9556
9568
  * @param dataSources A list of data source GUIDs
9557
9569
  */
9558
9570
  getIFrameSrc(answerId, dataSources) {
9559
- const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
9571
+ const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
9560
9572
  const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
9561
9573
  const queryParams = this.getBaseQueryParams();
9562
9574
  if (dataSources && dataSources.length) {
@@ -9598,4 +9610,4 @@ class SearchEmbed extends TsEmbed {
9598
9610
  }
9599
9611
  }
9600
9612
 
9601
- export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
9613
+ export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };