@thoughtspot/visual-embed-sdk 1.10.0-alpha.1 → 1.10.0-alpha.2

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 (46) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/src/embed/app.d.ts +8 -0
  3. package/dist/src/embed/liveboard.d.ts +8 -0
  4. package/dist/src/embed/ts-embed.d.ts +16 -1
  5. package/dist/src/types.d.ts +56 -5
  6. package/dist/src/utils.d.ts +3 -0
  7. package/dist/tsembed.es.js +105 -12
  8. package/dist/tsembed.js +105 -12
  9. package/lib/package.json +1 -1
  10. package/lib/src/embed/app.d.ts +8 -0
  11. package/lib/src/embed/app.js +5 -2
  12. package/lib/src/embed/app.js.map +1 -1
  13. package/lib/src/embed/app.spec.js +11 -10
  14. package/lib/src/embed/app.spec.js.map +1 -1
  15. package/lib/src/embed/liveboard.d.ts +8 -0
  16. package/lib/src/embed/liveboard.js +4 -1
  17. package/lib/src/embed/liveboard.js.map +1 -1
  18. package/lib/src/embed/liveboard.spec.js +1 -1
  19. package/lib/src/embed/liveboard.spec.js.map +1 -1
  20. package/lib/src/embed/pinboard.spec.js +1 -1
  21. package/lib/src/embed/pinboard.spec.js.map +1 -1
  22. package/lib/src/embed/search.js +2 -1
  23. package/lib/src/embed/search.js.map +1 -1
  24. package/lib/src/embed/ts-embed.d.ts +16 -1
  25. package/lib/src/embed/ts-embed.js +34 -4
  26. package/lib/src/embed/ts-embed.js.map +1 -1
  27. package/lib/src/embed/ts-embed.spec.js +52 -7
  28. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  29. package/lib/src/types.d.ts +56 -5
  30. package/lib/src/types.js +55 -4
  31. package/lib/src/types.js.map +1 -1
  32. package/lib/src/utils.d.ts +3 -0
  33. package/lib/src/utils.js +5 -0
  34. package/lib/src/utils.js.map +1 -1
  35. package/lib/src/visual-embed-sdk.d.ts +88 -6
  36. package/package.json +1 -1
  37. package/src/embed/app.spec.ts +11 -10
  38. package/src/embed/app.ts +14 -2
  39. package/src/embed/liveboard.spec.ts +1 -1
  40. package/src/embed/liveboard.ts +13 -0
  41. package/src/embed/pinboard.spec.ts +1 -1
  42. package/src/embed/search.ts +4 -1
  43. package/src/embed/ts-embed.spec.ts +75 -7
  44. package/src/embed/ts-embed.ts +49 -3
  45. package/src/types.ts +55 -4
  46. package/src/utils.ts +9 -0
@@ -11,6 +11,7 @@ import {
11
11
  getEncodedQueryParamsString,
12
12
  getCssDimension,
13
13
  getOffsetTop,
14
+ setAttributes,
14
15
  } from '../utils';
15
16
  import {
16
17
  getThoughtSpotHost,
@@ -37,6 +38,11 @@ import { getAuthPromise, getEmbedConfig, renderInQueue } from './base';
37
38
 
38
39
  const { version } = pkgInfo;
39
40
 
41
+ /**
42
+ * Global prefix for all Thoughtspot postHash Params.
43
+ */
44
+ export const THOUGHTSPOT_PARAM_PREFIX = 'ts-';
45
+
40
46
  /**
41
47
  * The event id map from v2 event names to v1 event id
42
48
  * v1 events are the classic embed events implemented in Blink v1
@@ -62,6 +68,11 @@ export interface FrameParams {
62
68
  * The height of the iFrame (unit is pixels if numeric).
63
69
  */
64
70
  height?: number | string;
71
+ /**
72
+ * This parameters will be passed on the iframe
73
+ * as is.
74
+ */
75
+ [key: string]: string | number | boolean;
65
76
  }
66
77
 
67
78
  /**
@@ -403,7 +414,7 @@ export class TsEmbed {
403
414
  * @param url
404
415
  * @param frameOptions
405
416
  */
406
- protected renderIFrame(url: string, frameOptions: FrameParams): void {
417
+ protected renderIFrame(url: string, frameOptions: FrameParams = {}): void {
407
418
  if (this.isError) {
408
419
  return;
409
420
  }
@@ -445,12 +456,19 @@ export class TsEmbed {
445
456
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
446
457
  // @ts-ignore
447
458
  this.iFrame.mozallowfullscreen = true;
459
+ const {
460
+ height: frameHeight,
461
+ width: frameWidth,
462
+ ...restParams
463
+ } = frameOptions;
448
464
  const width = getCssDimension(
449
- frameOptions?.width || DEFAULT_EMBED_WIDTH,
465
+ frameWidth || DEFAULT_EMBED_WIDTH,
450
466
  );
451
467
  const height = getCssDimension(
452
- frameOptions?.height || DEFAULT_EMBED_HEIGHT,
468
+ frameWidth || DEFAULT_EMBED_HEIGHT,
453
469
  );
470
+ setAttributes(this.iFrame, restParams);
471
+
454
472
  this.iFrame.style.width = `${width}`;
455
473
  this.iFrame.style.height = `${height}`;
456
474
  this.iFrame.style.border = '0';
@@ -653,6 +671,34 @@ export class TsEmbed {
653
671
 
654
672
  return this;
655
673
  }
674
+
675
+ /**
676
+ * Get the Post Url Params for THOUGHTSPOT from the current
677
+ * host app URL.
678
+ * THOUGHTSPOT URL params starts with a prefix "ts-"
679
+ */
680
+ public getThoughtSpotPostUrlParams(): string {
681
+ const urlHash = window.location.hash;
682
+ const queryParams = window.location.search;
683
+ const postHashParams = urlHash.split('?');
684
+ const postURLParams = postHashParams[postHashParams.length - 1];
685
+ const queryParamsObj = new URLSearchParams(queryParams);
686
+ const postURLParamsObj = new URLSearchParams(postURLParams);
687
+ const params = new URLSearchParams();
688
+
689
+ const addKeyValuePairCb = (value: string, key: string): void => {
690
+ if (key.startsWith(THOUGHTSPOT_PARAM_PREFIX)) {
691
+ params.append(key, value);
692
+ }
693
+ };
694
+ queryParamsObj.forEach(addKeyValuePairCb);
695
+ postURLParamsObj.forEach(addKeyValuePairCb);
696
+
697
+ let tsParams = params.toString();
698
+ tsParams = tsParams ? `?${tsParams}` : '';
699
+
700
+ return tsParams;
701
+ }
656
702
  }
657
703
 
658
704
  /**
package/src/types.ts CHANGED
@@ -484,6 +484,7 @@ export enum Param {
484
484
  CustomCSSUrl = 'customCssUrl',
485
485
  DisableLoginRedirect = 'disableLoginRedirect',
486
486
  visibleVizs = 'pinboardVisibleVizs',
487
+ LiveboardV2Enabled = 'isPinboardV2Enabled',
487
488
  }
488
489
 
489
490
  /**
@@ -493,30 +494,57 @@ export enum Param {
493
494
  // eslint-disable-next-line no-shadow
494
495
  export enum Action {
495
496
  Save = 'save',
497
+ /**
498
+ * @hidden
499
+ */
496
500
  Update = 'update',
501
+ /**
502
+ * @hidden
503
+ */
497
504
  SaveUntitled = 'saveUntitled',
498
505
  SaveAsView = 'saveAsView',
499
506
  MakeACopy = 'makeACopy',
500
507
  EditACopy = 'editACopy',
501
508
  CopyLink = 'embedDocument',
509
+ /**
510
+ * @hidden
511
+ */
502
512
  ResetLayout = 'resetLayout',
503
513
  Schedule = 'subscription',
504
514
  SchedulesList = 'schedule-list',
505
515
  Share = 'share',
506
516
  AddFilter = 'addFilter',
507
517
  ConfigureFilter = 'configureFilter',
518
+ /**
519
+ * @hidden
520
+ */
508
521
  AddFormula = 'addFormula',
522
+ /**
523
+ * @hidden
524
+ */
509
525
  SearchOnTop = 'searchOnTop',
510
526
  SpotIQAnalyze = 'spotIQAnalyze',
527
+ /**
528
+ * @hidden
529
+ */
511
530
  ExplainInsight = 'explainInsight',
531
+ /**
532
+ * @hidden
533
+ */
512
534
  SpotIQFollow = 'spotIQFollow',
513
535
  ShareViz = 'shareViz',
536
+ /**
537
+ * @hidden
538
+ */
514
539
  ReplaySearch = 'replaySearch',
515
540
  ShowUnderlyingData = 'showUnderlyingData',
516
541
  Download = 'download',
517
542
  DownloadAsPdf = 'downloadAsPdf',
518
543
  DownloadAsCsv = 'downloadAsCSV',
519
544
  DownloadAsXlsx = 'downloadAsXLSX',
545
+ /**
546
+ * @hidden
547
+ */
520
548
  DownloadTrace = 'downloadTrace',
521
549
  ExportTML = 'exportTSL',
522
550
  ImportTML = 'importTSL',
@@ -527,18 +555,39 @@ export enum Action {
527
555
  Edit = 'edit',
528
556
  EditTitle = 'editTitle',
529
557
  Remove = 'delete',
558
+ /**
559
+ * @hidden
560
+ */
530
561
  Ungroup = 'ungroup',
562
+ /**
563
+ * @hidden
564
+ */
531
565
  Describe = 'describe',
566
+ /**
567
+ * @hidden
568
+ */
532
569
  Relate = 'relate',
570
+ /**
571
+ * @hidden
572
+ */
533
573
  CustomizeHeadlines = 'customizeHeadlines',
534
574
  /**
535
575
  * @hidden
536
576
  */
537
577
  PinboardInfo = 'pinboardInfo',
538
578
  LiveboardInfo = 'pinboardInfo',
579
+ /**
580
+ * @hidden
581
+ */
539
582
  SendAnswerFeedback = 'sendFeedback',
583
+ /**
584
+ * @hidden
585
+ */
540
586
  DownloadEmbraceQueries = 'downloadEmbraceQueries',
541
587
  Pin = 'pin',
588
+ /**
589
+ * @hidden
590
+ */
542
591
  AnalysisInfo = 'analysisInfo',
543
592
  Subscription = 'subscription',
544
593
  Explore = 'explore',
@@ -546,16 +595,18 @@ export enum Action {
546
595
  DrillExclude = 'context-menu-item-exclude',
547
596
  CopyToClipboard = 'context-menu-item-copy-to-clipboard',
548
597
  CopyAndEdit = 'context-menu-item-copy-and-edit',
598
+ /**
599
+ * @hidden
600
+ */
549
601
  DrillEdit = 'context-menu-item-edit',
550
602
  EditMeasure = 'context-menu-item-edit-measure',
551
603
  Separator = 'context-menu-item-separator',
604
+ /**
605
+ * @hidden
606
+ */
552
607
  DrillDown = 'DRILL',
553
608
  RequestAccess = 'requestAccess',
554
609
  QueryDetailsButtons = 'queryDetailsButtons',
555
- /**
556
- * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
557
- */
558
- Monitor = 'createMonitor',
559
610
  /**
560
611
  * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
561
612
  */
package/src/utils.ts CHANGED
@@ -135,3 +135,12 @@ export const getOffsetTop = (element: any) => {
135
135
  const rect = element.getBoundingClientRect();
136
136
  return rect.top + window.scrollY;
137
137
  };
138
+
139
+ export const setAttributes = (
140
+ element: HTMLElement,
141
+ attributes: { [key: string]: string | number | boolean },
142
+ ): void => {
143
+ Object.keys(attributes).forEach((key) => {
144
+ element.setAttribute(key, attributes[key].toString());
145
+ });
146
+ };