@thoughtspot/visual-embed-sdk 1.5.1 → 1.6.0

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 (62) 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/ts-embed.d.ts +2 -11
  6. package/dist/src/errors.d.ts +1 -1
  7. package/dist/src/index.d.ts +2 -2
  8. package/dist/src/react/index.d.ts +4 -3
  9. package/dist/src/types.d.ts +24 -22
  10. package/dist/tsembed.es.js +83 -74
  11. package/dist/tsembed.js +82 -72
  12. package/lib/package.json +4 -1
  13. package/lib/src/embed/app.d.ts +14 -3
  14. package/lib/src/embed/app.js +25 -2
  15. package/lib/src/embed/app.js.map +1 -1
  16. package/lib/src/embed/app.spec.js +32 -0
  17. package/lib/src/embed/app.spec.js.map +1 -1
  18. package/lib/src/embed/events.spec.js +55 -2
  19. package/lib/src/embed/events.spec.js.map +1 -1
  20. package/lib/src/embed/liveboard.d.ts +101 -0
  21. package/lib/src/embed/{pinboard.js → liveboard.js} +34 -29
  22. package/lib/src/embed/liveboard.js.map +1 -0
  23. package/lib/src/embed/liveboard.spec.d.ts +1 -0
  24. package/lib/src/embed/liveboard.spec.js +159 -0
  25. package/lib/src/embed/liveboard.spec.js.map +1 -0
  26. package/lib/src/embed/pinboard.spec.js +1 -1
  27. package/lib/src/embed/pinboard.spec.js.map +1 -1
  28. package/lib/src/embed/ts-embed.d.ts +2 -11
  29. package/lib/src/embed/ts-embed.js +2 -22
  30. package/lib/src/embed/ts-embed.js.map +1 -1
  31. package/lib/src/embed/ts-embed.spec.js +63 -6
  32. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  33. package/lib/src/errors.d.ts +1 -1
  34. package/lib/src/errors.js +1 -1
  35. package/lib/src/errors.js.map +1 -1
  36. package/lib/src/index.d.ts +2 -2
  37. package/lib/src/index.js +2 -2
  38. package/lib/src/index.js.map +1 -1
  39. package/lib/src/react/index.d.ts +4 -3
  40. package/lib/src/react/index.js +3 -2
  41. package/lib/src/react/index.js.map +1 -1
  42. package/lib/src/types.d.ts +24 -22
  43. package/lib/src/types.js +20 -19
  44. package/lib/src/types.js.map +1 -1
  45. package/lib/src/visual-embed-sdk.d.ts +79 -65
  46. package/package.json +4 -1
  47. package/src/embed/app.spec.ts +41 -0
  48. package/src/embed/app.ts +28 -3
  49. package/src/embed/events.spec.ts +64 -5
  50. package/src/embed/liveboard.spec.ts +199 -0
  51. package/src/embed/{pinboard.ts → liveboard.ts} +59 -51
  52. package/src/embed/pinboard.spec.ts +11 -11
  53. package/src/embed/ts-embed.spec.ts +81 -8
  54. package/src/embed/ts-embed.ts +3 -24
  55. package/src/errors.ts +2 -2
  56. package/src/index.ts +7 -2
  57. package/src/react/index.tsx +14 -8
  58. package/src/types.ts +23 -21
  59. package/dist/src/embed/pinboard.d.ts +0 -91
  60. package/dist/src/v1/api.d.ts +0 -19
  61. package/lib/src/embed/pinboard.d.ts +0 -91
  62. package/lib/src/embed/pinboard.js.map +0 -1
@@ -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
  /**
@@ -307,7 +306,7 @@ var EmbedEvent;
307
306
  * Emitted when the embed does not have cookie access. This
308
307
  * happens on Safari where third-party cookies are blocked by default.
309
308
  *
310
- * @version 1.1.0
309
+ * @version 1.1.0 or later
311
310
  */
312
311
  EmbedEvent["NoCookieAccess"] = "noCookieAccess";
313
312
  /**
@@ -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.5.0_
365
+ * @version 1.6.0 or later
367
366
  */
368
367
  HostEvent["SetVisibleVizs"] = "SetPinboardVisibleVizs";
369
368
  })(HostEvent || (HostEvent = {}));
@@ -400,7 +399,7 @@ var Param;
400
399
  Param["DisableActions"] = "disableAction";
401
400
  Param["DisableActionReason"] = "disableHint";
402
401
  Param["ForceTable"] = "forceTable";
403
- Param["preventPinboardFilterRemoval"] = "preventPinboardFilterRemoval";
402
+ Param["preventLiveboardFilterRemoval"] = "preventPinboardFilterRemoval";
404
403
  Param["SearchQuery"] = "searchQuery";
405
404
  Param["HideActions"] = "hideAction";
406
405
  Param["HideObjects"] = "hideObjects";
@@ -419,11 +418,10 @@ var Param;
419
418
  Param["ViewPortWidth"] = "viewPortWidth";
420
419
  Param["VisibleActions"] = "visibleAction";
421
420
  Param["CustomCSSUrl"] = "customCssUrl";
422
- Param["PinboardVisibleVizs"] = "pinboardVisibleVizs";
423
421
  })(Param || (Param = {}));
424
422
  /**
425
423
  * The list of actions that can be performed on visual ThoughtSpot
426
- * entities, such as answers and pinboards.
424
+ * entities, such as answers and Liveboards.
427
425
  */
428
426
  // eslint-disable-next-line no-shadow
429
427
  var Action;
@@ -435,7 +433,6 @@ var Action;
435
433
  Action["MakeACopy"] = "makeACopy";
436
434
  Action["EditACopy"] = "editACopy";
437
435
  Action["CopyLink"] = "embedDocument";
438
- Action["PinboardSnapshot"] = "pinboardSnapshot";
439
436
  Action["ResetLayout"] = "resetLayout";
440
437
  Action["Schedule"] = "schedule";
441
438
  Action["SchedulesList"] = "schedule-list";
@@ -468,7 +465,11 @@ var Action;
468
465
  Action["Describe"] = "describe";
469
466
  Action["Relate"] = "relate";
470
467
  Action["CustomizeHeadlines"] = "customizeHeadlines";
468
+ /**
469
+ * @hidden
470
+ */
471
471
  Action["PinboardInfo"] = "pinboardInfo";
472
+ Action["LiveboardInfo"] = "pinboardInfo";
472
473
  Action["SendAnswerFeedback"] = "sendFeedback";
473
474
  /**
474
475
  * @deprecated Will be removed in next version
@@ -498,7 +499,7 @@ var OperationType;
498
499
 
499
500
  const ERROR_MESSAGE = {
500
501
  INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
501
- PINBOARD_VIZ_ID_VALIDATION: 'Please provide either pinboardId or both pinboardId and vizId',
502
+ LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
502
503
  };
503
504
 
504
505
  /**
@@ -8839,7 +8840,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
8839
8840
  }
8840
8841
  }
8841
8842
 
8842
- var version="1.5.1";
8843
+ var version="1.6.0";
8843
8844
 
8844
8845
  /**
8845
8846
  * Copyright (c) 2021
@@ -9005,7 +9006,7 @@ class TsEmbed {
9005
9006
  queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
9006
9007
  }
9007
9008
  const { disabledActions, disabledActionReason, hiddenActions, visibleActions, } = this.viewConfig;
9008
- if ((visibleActions === null || visibleActions === void 0 ? void 0 : visibleActions.length) && (hiddenActions === null || hiddenActions === void 0 ? void 0 : hiddenActions.length)) {
9009
+ if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
9009
9010
  this.handleError('You cannot have both hidden actions and visible actions');
9010
9011
  return queryParams;
9011
9012
  }
@@ -9025,7 +9026,7 @@ class TsEmbed {
9025
9026
  }
9026
9027
  /**
9027
9028
  * Constructs the base URL string to load v1 of the ThoughtSpot app.
9028
- * This is used for embedding pinboards, visualizations, and full application.
9029
+ * This is used for embedding Liveboards, visualizations, and full application.
9029
9030
  * @param queryString The query string to append to the URL.
9030
9031
  * @param isAppEmbed A Boolean parameter to specify if you are embedding
9031
9032
  * the full application.
@@ -9203,26 +9204,6 @@ class TsEmbed {
9203
9204
  this.eventHandlerMap.set(messageType, callbacks);
9204
9205
  return this;
9205
9206
  }
9206
- /**
9207
- * Navigates users to the specified application page.
9208
- * Use this method to navigate users from the embedded
9209
- * ThoughtSpot context to a specific page in your app.
9210
- * @param path The page path string.
9211
- * For example, to navigate users to a pinboard page,
9212
- * define the method as navigateToPage('pinboard/<pinboardId>').
9213
- */
9214
- navigateToPage(path) {
9215
- var _a;
9216
- const iframeSrc = (_a = this.iFrame) === null || _a === void 0 ? void 0 : _a.src;
9217
- if (iframeSrc) {
9218
- const embedPath = '#/embed';
9219
- const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
9220
- this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
9221
- }
9222
- else {
9223
- console.log('Please call render before invoking this method');
9224
- }
9225
- }
9226
9207
  /**
9227
9208
  * Triggers an event on specific Port registered against
9228
9209
  * for the EmbedEvent
@@ -9320,7 +9301,11 @@ var Page;
9320
9301
  */
9321
9302
  Page["Answers"] = "answers";
9322
9303
  /**
9323
- * Pinboards listing page
9304
+ * Liveboards listing page
9305
+ */
9306
+ Page["Liveboards"] = "liveboards";
9307
+ /**
9308
+ * @hidden
9324
9309
  */
9325
9310
  Page["Pinboards"] = "pinboards";
9326
9311
  /**
@@ -9339,7 +9324,7 @@ class AppEmbed extends V1Embed {
9339
9324
  }
9340
9325
  /**
9341
9326
  * Constructs a map of parameters to be passed on to the
9342
- * embedded pinboard or visualization.
9327
+ * embedded Liveboard or visualization.
9343
9328
  */
9344
9329
  getEmbedParams() {
9345
9330
  const params = this.getBaseQueryParams();
@@ -9376,6 +9361,8 @@ class AppEmbed extends V1Embed {
9376
9361
  return 'answer';
9377
9362
  case Page.Answers:
9378
9363
  return 'answers';
9364
+ case Page.Liveboards:
9365
+ return 'pinboards';
9379
9366
  case Page.Pinboards:
9380
9367
  return 'pinboards';
9381
9368
  case Page.Data:
@@ -9400,6 +9387,23 @@ class AppEmbed extends V1Embed {
9400
9387
  }
9401
9388
  return path;
9402
9389
  }
9390
+ /**
9391
+ * Navigate to particular page for app embed. eg:answers/pinboards/home
9392
+ * This is used for embedding answers, pinboards, visualizations and full application only.
9393
+ * @param path The string, set to iframe src and navigate to new page
9394
+ * eg: appEmbed.navigateToPage('pinboards')
9395
+ */
9396
+ navigateToPage(path) {
9397
+ if (this.iFrame) {
9398
+ const iframeSrc = this.iFrame.src;
9399
+ const embedPath = '#/embed';
9400
+ const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
9401
+ this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
9402
+ }
9403
+ else {
9404
+ console.log('Please call render before invoking this method');
9405
+ }
9406
+ }
9403
9407
  /**
9404
9408
  * Renders the embedded application pages in the ThoughtSpot app.
9405
9409
  * @param renderOptions An object containing the page ID
@@ -9418,18 +9422,18 @@ class AppEmbed extends V1Embed {
9418
9422
  /**
9419
9423
  * Copyright (c) 2021
9420
9424
  *
9421
- * Embed a ThoughtSpot pinboard or visualization
9425
+ * Embed a ThoughtSpot Liveboard or visualization
9422
9426
  * https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
9423
9427
  * https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
9424
9428
  *
9425
- * @summary Pinboard & visualization embed
9429
+ * @summary Liveboard & visualization embed
9426
9430
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9427
9431
  */
9428
9432
  /**
9429
- * Embed a ThoughtSpot pinboard or visualization
9430
- * @Category Pinboards and Charts
9433
+ * Embed a ThoughtSpot Liveboard or visualization
9434
+ * @Category Liveboards and Charts
9431
9435
  */
9432
- class PinboardEmbed extends V1Embed {
9436
+ class LiveboardEmbed extends V1Embed {
9433
9437
  // eslint-disable-next-line no-useless-constructor
9434
9438
  constructor(domSelector, viewConfig) {
9435
9439
  super(domSelector, viewConfig);
@@ -9446,20 +9450,21 @@ class PinboardEmbed extends V1Embed {
9446
9450
  const obj = this.getIframeCenter();
9447
9451
  responder({ type: EmbedEvent.EmbedIframeCenter, data: obj });
9448
9452
  };
9449
- this.handleRouteChangeFullHeightPinboard = (data) => {
9450
- if (data.data.canvasState !== 'EMBED' &&
9451
- data.data.canvasState !== 'pinboard') {
9453
+ this.setIframeHeightForNonEmbedLiveboard = (data) => {
9454
+ if (!data.data.currentPath.startsWith('/embed/viz/')) {
9452
9455
  this.setIFrameHeight(this.defaultHeight);
9453
9456
  }
9454
9457
  };
9455
9458
  }
9456
9459
  /**
9457
9460
  * Construct a map of params to be passed on to the
9458
- * embedded pinboard or visualization.
9461
+ * embedded Liveboard or visualization.
9459
9462
  */
9460
9463
  getEmbedParams() {
9461
9464
  const params = this.getBaseQueryParams();
9462
- const { enableVizTransformations, fullHeight, preventPinboardFilterRemoval, defaultHeight, pinboardVisibleVizs, } = this.viewConfig;
9465
+ const { enableVizTransformations, fullHeight, defaultHeight, } = this.viewConfig;
9466
+ const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval ||
9467
+ this.viewConfig.preventPinboardFilterRemoval;
9463
9468
  if (fullHeight === true) {
9464
9469
  params[Param.fullHeight] = true;
9465
9470
  }
@@ -9469,56 +9474,60 @@ class PinboardEmbed extends V1Embed {
9469
9474
  if (enableVizTransformations !== undefined) {
9470
9475
  params[Param.EnableVizTransformations] = enableVizTransformations.toString();
9471
9476
  }
9472
- if (preventPinboardFilterRemoval) {
9473
- params[Param.preventPinboardFilterRemoval] = true;
9474
- }
9475
- if (pinboardVisibleVizs) {
9476
- params[Param.PinboardVisibleVizs] = pinboardVisibleVizs;
9477
+ if (preventLiveboardFilterRemoval) {
9478
+ params[Param.preventLiveboardFilterRemoval] = true;
9477
9479
  }
9478
9480
  params[Param.livedBoardEmbed] = true;
9479
9481
  const queryParams = getQueryParamString(params, true);
9480
9482
  return queryParams;
9481
9483
  }
9482
9484
  /**
9483
- * Construct the URL of the embedded ThoughtSpot pinboard or visualization
9485
+ * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
9484
9486
  * to be loaded within the iframe.
9485
- * @param pinboardId The GUID of the pinboard.
9486
- * @param vizId The optional GUID of a visualization within the pinboard.
9487
+ * @param liveboardId The GUID of the Liveboard.
9488
+ * @param vizId The optional GUID of a visualization within the Liveboard.
9487
9489
  * @param runtimeFilters A list of runtime filters to be applied to
9488
- * the pinboard or visualization on load.
9490
+ * the Liveboard or visualization on load.
9489
9491
  */
9490
- getIFrameSrc(pinboardId, vizId, runtimeFilters) {
9492
+ getIFrameSrc(liveboardId, vizId, runtimeFilters) {
9491
9493
  const filterQuery = getFilterQuery(runtimeFilters || []);
9492
9494
  const queryParams = this.getEmbedParams();
9493
9495
  const queryString = [filterQuery, queryParams]
9494
9496
  .filter(Boolean)
9495
9497
  .join('&');
9496
- let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${pinboardId}`;
9498
+ let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${liveboardId}`;
9497
9499
  if (vizId) {
9498
9500
  url = `${url}/${vizId}`;
9499
9501
  }
9500
9502
  return url;
9501
9503
  }
9502
9504
  /**
9503
- * Render an embedded ThoughtSpot pinboard or visualization
9504
- * @param renderOptions An object specifying the pinboard ID,
9505
+ * Render an embedded ThoughtSpot Liveboard or visualization
9506
+ * @param renderOptions An object specifying the Liveboard ID,
9505
9507
  * visualization ID and the runtime filters.
9506
9508
  */
9507
9509
  render() {
9508
- const { pinboardId, vizId, runtimeFilters } = this.viewConfig;
9509
- if (!pinboardId && !vizId) {
9510
- this.handleError(ERROR_MESSAGE.PINBOARD_VIZ_ID_VALIDATION);
9510
+ var _a;
9511
+ const { vizId, runtimeFilters } = this.viewConfig;
9512
+ const liveboardId = (_a = this.viewConfig.liveboardId) !== null && _a !== void 0 ? _a : this.viewConfig.pinboardId;
9513
+ if (!liveboardId) {
9514
+ this.handleError(ERROR_MESSAGE.LIVEBOARD_VIZ_ID_VALIDATION);
9511
9515
  }
9512
9516
  if (this.viewConfig.fullHeight === true) {
9513
- this.on(EmbedEvent.RouteChange, this.handleRouteChangeFullHeightPinboard);
9517
+ this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
9514
9518
  this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
9515
9519
  this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
9516
9520
  }
9517
9521
  super.render();
9518
- const src = this.getIFrameSrc(pinboardId, vizId, runtimeFilters);
9522
+ const src = this.getIFrameSrc(liveboardId, vizId, runtimeFilters);
9519
9523
  this.renderV1Embed(src);
9520
9524
  return this;
9521
9525
  }
9526
+ }
9527
+ /**
9528
+ * @hidden
9529
+ */
9530
+ class PinboardEmbed extends LiveboardEmbed {
9522
9531
  }
9523
9532
 
9524
9533
  /**
@@ -9602,4 +9611,4 @@ class SearchEmbed extends TsEmbed {
9602
9611
  }
9603
9612
  }
9604
9613
 
9605
- export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
9614
+ export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };