@thoughtspot/visual-embed-sdk 1.6.0-alpha.1 → 1.7.0-alpha.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 (61) 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 +23 -20
  10. package/dist/tsembed.es.js +83 -70
  11. package/dist/tsembed.js +82 -68
  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 -26
  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 +23 -20
  43. package/lib/src/types.js +20 -18
  44. package/lib/src/types.js.map +1 -1
  45. package/lib/src/visual-embed-sdk.d.ts +79 -58
  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} +60 -42
  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 -20
  59. package/dist/src/embed/pinboard.d.ts +0 -85
  60. package/lib/src/embed/pinboard.d.ts +0 -85
  61. 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.6.0_
365
+ * @version 1.6.0 or later
367
366
  */
368
367
  HostEvent["SetVisibleVizs"] = "SetPinboardVisibleVizs";
369
368
  })(HostEvent || (HostEvent = {}));
@@ -399,7 +398,7 @@ var Param;
399
398
  Param["DisableActions"] = "disableAction";
400
399
  Param["DisableActionReason"] = "disableHint";
401
400
  Param["ForceTable"] = "forceTable";
402
- Param["preventPinboardFilterRemoval"] = "preventPinboardFilterRemoval";
401
+ Param["preventLiveboardFilterRemoval"] = "preventPinboardFilterRemoval";
403
402
  Param["SearchQuery"] = "searchQuery";
404
403
  Param["HideActions"] = "hideAction";
405
404
  Param["HideObjects"] = "hideObjects";
@@ -421,7 +420,7 @@ var Param;
421
420
  })(Param || (Param = {}));
422
421
  /**
423
422
  * The list of actions that can be performed on visual ThoughtSpot
424
- * entities, such as answers and pinboards.
423
+ * entities, such as answers and Liveboards.
425
424
  */
426
425
  // eslint-disable-next-line no-shadow
427
426
  var Action;
@@ -433,7 +432,6 @@ var Action;
433
432
  Action["MakeACopy"] = "makeACopy";
434
433
  Action["EditACopy"] = "editACopy";
435
434
  Action["CopyLink"] = "embedDocument";
436
- Action["PinboardSnapshot"] = "pinboardSnapshot";
437
435
  Action["ResetLayout"] = "resetLayout";
438
436
  Action["Schedule"] = "schedule";
439
437
  Action["SchedulesList"] = "schedule-list";
@@ -466,7 +464,11 @@ var Action;
466
464
  Action["Describe"] = "describe";
467
465
  Action["Relate"] = "relate";
468
466
  Action["CustomizeHeadlines"] = "customizeHeadlines";
467
+ /**
468
+ * @hidden
469
+ */
469
470
  Action["PinboardInfo"] = "pinboardInfo";
471
+ Action["LiveboardInfo"] = "pinboardInfo";
470
472
  Action["SendAnswerFeedback"] = "sendFeedback";
471
473
  /**
472
474
  * @deprecated Will be removed in next version
@@ -496,7 +498,7 @@ var OperationType;
496
498
 
497
499
  const ERROR_MESSAGE = {
498
500
  INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
499
- PINBOARD_VIZ_ID_VALIDATION: 'Please provide either pinboardId or both pinboardId and vizId',
501
+ LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
500
502
  };
501
503
 
502
504
  /**
@@ -8837,7 +8839,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
8837
8839
  }
8838
8840
  }
8839
8841
 
8840
- var version="1.6.0-alpha.1";
8842
+ var version="1.7.0-alpha.0";
8841
8843
 
8842
8844
  /**
8843
8845
  * Copyright (c) 2021
@@ -9003,7 +9005,7 @@ class TsEmbed {
9003
9005
  queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
9004
9006
  }
9005
9007
  const { disabledActions, disabledActionReason, hiddenActions, visibleActions, } = this.viewConfig;
9006
- 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)) {
9007
9009
  this.handleError('You cannot have both hidden actions and visible actions');
9008
9010
  return queryParams;
9009
9011
  }
@@ -9023,7 +9025,7 @@ class TsEmbed {
9023
9025
  }
9024
9026
  /**
9025
9027
  * Constructs the base URL string to load v1 of the ThoughtSpot app.
9026
- * This is used for embedding pinboards, visualizations, and full application.
9028
+ * This is used for embedding Liveboards, visualizations, and full application.
9027
9029
  * @param queryString The query string to append to the URL.
9028
9030
  * @param isAppEmbed A Boolean parameter to specify if you are embedding
9029
9031
  * the full application.
@@ -9201,26 +9203,6 @@ class TsEmbed {
9201
9203
  this.eventHandlerMap.set(messageType, callbacks);
9202
9204
  return this;
9203
9205
  }
9204
- /**
9205
- * Navigates users to the specified application page.
9206
- * Use this method to navigate users from the embedded
9207
- * ThoughtSpot context to a specific page in your app.
9208
- * @param path The page path string.
9209
- * For example, to navigate users to a pinboard page,
9210
- * define the method as navigateToPage('pinboard/<pinboardId>').
9211
- */
9212
- navigateToPage(path) {
9213
- var _a;
9214
- const iframeSrc = (_a = this.iFrame) === null || _a === void 0 ? void 0 : _a.src;
9215
- if (iframeSrc) {
9216
- const embedPath = '#/embed';
9217
- const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
9218
- this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
9219
- }
9220
- else {
9221
- console.log('Please call render before invoking this method');
9222
- }
9223
- }
9224
9206
  /**
9225
9207
  * Triggers an event on specific Port registered against
9226
9208
  * for the EmbedEvent
@@ -9318,7 +9300,11 @@ var Page;
9318
9300
  */
9319
9301
  Page["Answers"] = "answers";
9320
9302
  /**
9321
- * Pinboards listing page
9303
+ * Liveboards listing page
9304
+ */
9305
+ Page["Liveboards"] = "liveboards";
9306
+ /**
9307
+ * @hidden
9322
9308
  */
9323
9309
  Page["Pinboards"] = "pinboards";
9324
9310
  /**
@@ -9337,7 +9323,7 @@ class AppEmbed extends V1Embed {
9337
9323
  }
9338
9324
  /**
9339
9325
  * Constructs a map of parameters to be passed on to the
9340
- * embedded pinboard or visualization.
9326
+ * embedded Liveboard or visualization.
9341
9327
  */
9342
9328
  getEmbedParams() {
9343
9329
  const params = this.getBaseQueryParams();
@@ -9374,6 +9360,8 @@ class AppEmbed extends V1Embed {
9374
9360
  return 'answer';
9375
9361
  case Page.Answers:
9376
9362
  return 'answers';
9363
+ case Page.Liveboards:
9364
+ return 'pinboards';
9377
9365
  case Page.Pinboards:
9378
9366
  return 'pinboards';
9379
9367
  case Page.Data:
@@ -9398,6 +9386,23 @@ class AppEmbed extends V1Embed {
9398
9386
  }
9399
9387
  return path;
9400
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
+ }
9401
9406
  /**
9402
9407
  * Renders the embedded application pages in the ThoughtSpot app.
9403
9408
  * @param renderOptions An object containing the page ID
@@ -9416,18 +9421,18 @@ class AppEmbed extends V1Embed {
9416
9421
  /**
9417
9422
  * Copyright (c) 2021
9418
9423
  *
9419
- * Embed a ThoughtSpot pinboard or visualization
9424
+ * Embed a ThoughtSpot Liveboard or visualization
9420
9425
  * https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
9421
9426
  * https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
9422
9427
  *
9423
- * @summary Pinboard & visualization embed
9428
+ * @summary Liveboard & visualization embed
9424
9429
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9425
9430
  */
9426
9431
  /**
9427
- * Embed a ThoughtSpot pinboard or visualization
9428
- * @Category Pinboards and Charts
9432
+ * Embed a ThoughtSpot Liveboard or visualization
9433
+ * @Category Liveboards and Charts
9429
9434
  */
9430
- class PinboardEmbed extends V1Embed {
9435
+ class LiveboardEmbed extends V1Embed {
9431
9436
  // eslint-disable-next-line no-useless-constructor
9432
9437
  constructor(domSelector, viewConfig) {
9433
9438
  super(domSelector, viewConfig);
@@ -9444,20 +9449,21 @@ class PinboardEmbed extends V1Embed {
9444
9449
  const obj = this.getIframeCenter();
9445
9450
  responder({ type: EmbedEvent.EmbedIframeCenter, data: obj });
9446
9451
  };
9447
- this.handleRouteChangeFullHeightPinboard = (data) => {
9448
- if (data.data.canvasState !== 'EMBED' &&
9449
- data.data.canvasState !== 'pinboard') {
9452
+ this.setIframeHeightForNonEmbedLiveboard = (data) => {
9453
+ if (!data.data.currentPath.startsWith('/embed/viz/')) {
9450
9454
  this.setIFrameHeight(this.defaultHeight);
9451
9455
  }
9452
9456
  };
9453
9457
  }
9454
9458
  /**
9455
9459
  * Construct a map of params to be passed on to the
9456
- * embedded pinboard or visualization.
9460
+ * embedded Liveboard or visualization.
9457
9461
  */
9458
9462
  getEmbedParams() {
9459
9463
  const params = this.getBaseQueryParams();
9460
- const { enableVizTransformations, fullHeight, preventPinboardFilterRemoval, defaultHeight, } = this.viewConfig;
9464
+ const { enableVizTransformations, fullHeight, defaultHeight, } = this.viewConfig;
9465
+ const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval ||
9466
+ this.viewConfig.preventPinboardFilterRemoval;
9461
9467
  if (fullHeight === true) {
9462
9468
  params[Param.fullHeight] = true;
9463
9469
  }
@@ -9467,53 +9473,60 @@ class PinboardEmbed extends V1Embed {
9467
9473
  if (enableVizTransformations !== undefined) {
9468
9474
  params[Param.EnableVizTransformations] = enableVizTransformations.toString();
9469
9475
  }
9470
- if (preventPinboardFilterRemoval) {
9471
- params[Param.preventPinboardFilterRemoval] = true;
9476
+ if (preventLiveboardFilterRemoval) {
9477
+ params[Param.preventLiveboardFilterRemoval] = true;
9472
9478
  }
9473
9479
  params[Param.livedBoardEmbed] = true;
9474
9480
  const queryParams = getQueryParamString(params, true);
9475
9481
  return queryParams;
9476
9482
  }
9477
9483
  /**
9478
- * Construct the URL of the embedded ThoughtSpot pinboard or visualization
9484
+ * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
9479
9485
  * to be loaded within the iframe.
9480
- * @param pinboardId The GUID of the pinboard.
9481
- * @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.
9482
9488
  * @param runtimeFilters A list of runtime filters to be applied to
9483
- * the pinboard or visualization on load.
9489
+ * the Liveboard or visualization on load.
9484
9490
  */
9485
- getIFrameSrc(pinboardId, vizId, runtimeFilters) {
9491
+ getIFrameSrc(liveboardId, vizId, runtimeFilters) {
9486
9492
  const filterQuery = getFilterQuery(runtimeFilters || []);
9487
9493
  const queryParams = this.getEmbedParams();
9488
9494
  const queryString = [filterQuery, queryParams]
9489
9495
  .filter(Boolean)
9490
9496
  .join('&');
9491
- let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${pinboardId}`;
9497
+ let url = `${this.getV1EmbedBasePath(queryString, true, false, false)}/viz/${liveboardId}`;
9492
9498
  if (vizId) {
9493
9499
  url = `${url}/${vizId}`;
9494
9500
  }
9495
9501
  return url;
9496
9502
  }
9497
9503
  /**
9498
- * Render an embedded ThoughtSpot pinboard or visualization
9499
- * @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,
9500
9506
  * visualization ID and the runtime filters.
9501
9507
  */
9502
9508
  render() {
9503
- const { pinboardId, vizId, runtimeFilters } = this.viewConfig;
9504
- if (!pinboardId && !vizId) {
9505
- 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);
9506
9514
  }
9507
9515
  if (this.viewConfig.fullHeight === true) {
9508
- this.on(EmbedEvent.RouteChange, this.handleRouteChangeFullHeightPinboard);
9516
+ this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
9509
9517
  this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
9510
9518
  this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
9511
9519
  }
9512
9520
  super.render();
9513
- const src = this.getIFrameSrc(pinboardId, vizId, runtimeFilters);
9521
+ const src = this.getIFrameSrc(liveboardId, vizId, runtimeFilters);
9514
9522
  this.renderV1Embed(src);
9515
9523
  return this;
9516
9524
  }
9525
+ }
9526
+ /**
9527
+ * @hidden
9528
+ */
9529
+ class PinboardEmbed extends LiveboardEmbed {
9517
9530
  }
9518
9531
 
9519
9532
  /**
@@ -9597,4 +9610,4 @@ class SearchEmbed extends TsEmbed {
9597
9610
  }
9598
9611
  }
9599
9612
 
9600
- 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 };