@thoughtspot/visual-embed-sdk 1.17.2-customcss → 1.18.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.17.2-customcss",
3
+ "version": "1.18.0-alpha.0",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -12,12 +12,16 @@
12
12
  ],
13
13
  "exports": {
14
14
  ".": "./lib/src/index.js",
15
- "./react": "./lib/src/react/index.js"
15
+ "./react": {
16
+ "import": "./lib/src/react/index.js",
17
+ "require": "./cjs/src/react.index.js",
18
+ "types": "./lib/src/react/index.d.ts"
19
+ }
16
20
  },
17
21
  "scripts": {
18
22
  "lint": "eslint 'src/**'",
19
23
  "lint:fix": "eslint 'src/**/*.*' --fix",
20
- "tsc": "tsc -p . --incremental false",
24
+ "tsc": "tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",
21
25
  "start": "gatsby develop",
22
26
  "build:gatsby": "npm run clean:gatsby && gatsby build --prefix-paths",
23
27
  "build:gatsby:noprefix": "npm run clean:gatsby && gatsby build",
@@ -117,7 +121,7 @@
117
121
  "typedoc": "0.21.6",
118
122
  "typedoc-neo-theme": "^1.1.0",
119
123
  "typedoc-plugin-toc-group": "0.0.5",
120
- "typescript": "^4.1.0",
124
+ "typescript": "^4.9.4",
121
125
  "url-search-params-polyfill": "^8.1.0",
122
126
  "util": "^0.12.4"
123
127
  },
package/src/embed/base.ts CHANGED
@@ -171,11 +171,11 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
171
171
  authType: config.authType,
172
172
  host: config.thoughtSpotHost,
173
173
  usedCustomizationSheet:
174
- embedConfig.customisations?.style?.customCSSUrl != null,
174
+ embedConfig.customizations?.style?.customCSSUrl != null,
175
175
  usedCustomizationVariables:
176
- embedConfig.customisations?.style?.customCss?.variables != null,
176
+ embedConfig.customizations?.style?.customCSS?.variables != null,
177
177
  usedCustomizationRules:
178
- embedConfig.customisations?.style?.customCss?.rules_UNSTABLE !=
178
+ embedConfig.customizations?.style?.customCSS?.rules_UNSTABLE !=
179
179
  null,
180
180
  });
181
181
 
@@ -22,7 +22,7 @@ export interface SearchBarViewConfig extends ViewConfig {
22
22
  * Embed ThoughtSpot search bar
23
23
  *
24
24
  * @Category Search Embed
25
- * @version: SDK: 1.17.0 | ThoughtSpot 8.10.0.cl, 9.0.1-sw
25
+ * @version: SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
26
26
  */
27
27
  export class SearchBarEmbed extends TsEmbed {
28
28
  /**
@@ -52,10 +52,6 @@ export interface SearchViewConfig extends ViewConfig {
52
52
  * using raw answer data.
53
53
  */
54
54
  hideResults?: boolean;
55
- /**
56
- * If set to true, expands all the data sources panel.
57
- */
58
- expandAllDataSource?: boolean;
59
55
  /**
60
56
  * If set to true, the Search Assist feature is enabled.
61
57
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
@@ -134,7 +130,6 @@ export class SearchEmbed extends TsEmbed {
134
130
  private getIFrameSrc(answerId: string, dataSources?: string[]) {
135
131
  const {
136
132
  hideResults,
137
- expandAllDataSource,
138
133
  enableSearchAssist,
139
134
  forceTable,
140
135
  searchOptions,
@@ -66,7 +66,7 @@ describe('Unit test case for ts embed', () => {
66
66
  init({
67
67
  thoughtSpotHost: 'tshost',
68
68
  authType: AuthType.None,
69
- customisations,
69
+ customizations: customisations,
70
70
  });
71
71
  });
72
72
 
@@ -148,13 +148,6 @@ export interface ViewConfig {
148
148
  * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
149
149
  */
150
150
  additionalFlags?: { [key: string]: string | number | boolean };
151
- /**
152
- * Dynamic CSS Url to be injected in the loaded application.
153
- * You would also need to set `style-src` in the CSP settings.
154
- * @version SDK: 1.17.2 | ThoughtSpot: 8.4.1-sw, 8.4.0.cl
155
- * @default ''
156
- */
157
- customCssUrl?: string;
158
151
  }
159
152
 
160
153
  /**
@@ -376,6 +369,10 @@ export class TsEmbed {
376
369
  ) {
377
370
  queryParams[Param.DisableLoginRedirect] = true;
378
371
  }
372
+ // TODO remove this
373
+ if (this.embedConfig.customCssUrl) {
374
+ queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
375
+ }
379
376
  if (this.embedConfig.authType === AuthType.EmbeddedSSO) {
380
377
  queryParams[Param.ForceSAMLAutoRedirect] = true;
381
378
  }
@@ -388,7 +385,6 @@ export class TsEmbed {
388
385
  showAlerts,
389
386
  additionalFlags,
390
387
  locale,
391
- customCssUrl,
392
388
  } = this.viewConfig;
393
389
 
394
390
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
@@ -398,16 +394,6 @@ export class TsEmbed {
398
394
  return queryParams;
399
395
  }
400
396
 
401
- // TODO remove this
402
- if (this.embedConfig.customCssUrl) {
403
- queryParams[Param.CustomCSSUrl] = this.embedConfig.customCssUrl;
404
- }
405
-
406
- // If you need to override customCSS URL for a specific embed liveboard
407
- if (customCssUrl) {
408
- queryParams[Param.CustomCSSUrl] = customCssUrl;
409
- }
410
-
411
397
  if (disabledActions?.length) {
412
398
  queryParams[Param.DisableActions] = disabledActions;
413
399
  }
@@ -733,7 +719,7 @@ export class TsEmbed {
733
719
  * @param messageType The event type
734
720
  * @param data The payload to send with the message
735
721
  */
736
- public trigger(messageType: HostEvent, data: any): Promise<any> {
722
+ public trigger(messageType: HostEvent, data: any = {}): Promise<any> {
737
723
  uploadMixpanelEvent(
738
724
  `${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`,
739
725
  );
package/src/types.ts CHANGED
@@ -87,11 +87,11 @@ interface customCssInterface {
87
87
  }
88
88
  interface CustomStyles {
89
89
  customCSSUrl?: string;
90
- customCss?: customCssInterface;
90
+ customCSS?: customCssInterface;
91
91
  }
92
92
  export interface CustomisationsInterface {
93
- style: CustomStyles;
94
- content: {
93
+ style?: CustomStyles;
94
+ content?: {
95
95
  [key: string]: string;
96
96
  };
97
97
  }
@@ -239,13 +239,12 @@ export interface EmbedConfig {
239
239
  * @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl, 8.4.1-sw*
240
240
  */
241
241
  suppressSearchEmbedBetaWarning?: boolean;
242
-
243
242
  /**
244
243
  * Custom style params for embed Config.
245
244
  *
246
245
  * @version SDK: 1.17.0 | ThoughtSpot: 8.9.0.cl
247
246
  */
248
- customisations?: CustomisationsInterface;
247
+ customizations?: CustomisationsInterface;
249
248
  /**
250
249
  * For noRedirect SSO Auth, we need a button which the user
251
250
  * click to trigger the flow. This is the containing element
@@ -778,7 +777,10 @@ export enum HostEvent {
778
777
  * Triggers the Pin action on an embedded object
779
778
  * @param - incase of Liveboard embed, takes in an object with vizId as a key
780
779
  * can be left empty for search and visualization embeds
781
- * @example liveboardEmbed.trigger(HostEvent.Pin, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
780
+ * @example
781
+ * liveboardEmbed.trigger(HostEvent.Pin, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
782
+ * vizEmbed.trigger(HostEvent.Pin)
783
+ * searchEmbed.trigger(HostEvent.Pin)
782
784
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
783
785
  */
784
786
  Pin = 'pin',
@@ -825,8 +827,11 @@ export enum HostEvent {
825
827
  */
826
828
  DownloadAsPdf = 'downloadAsPdf',
827
829
  /**
828
- * Triggers the Make a copy action on a Liveboard
829
- * @example liveboardEmbed.trigger(HostEvent.MakeACopy)
830
+ * Triggers the Make a copy action on a Liveboard, search or visualization
831
+ * @example
832
+ * liveboardEmbed.trigger(HostEvent.MakeACopy, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
833
+ * vizEmbed.trigger(HostEvent.MakeACopy)
834
+ * searchEmbed.trigger(HostEvent.MakeACopy)
830
835
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
831
836
  */
832
837
  MakeACopy = 'makeACopy',
@@ -890,15 +895,74 @@ export enum HostEvent {
890
895
  /**
891
896
  * Get TML for the current search.
892
897
  * @example searchEmbed.trigger(HostEvent.GetTML)
893
- * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
898
+ * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl
894
899
  */
895
900
  GetTML = 'getTML',
901
+ /**
902
+ * Triggers the ShowUnderlyingData action on visualization or search
903
+ * @param - an object with vizId as a key
904
+ * @example
905
+ * liveboardEmbed.trigger(HostEvent.ShowUnderlyingData, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
906
+ * vizEmbed.trigger(HostEvent.ShowUnderlyingData)
907
+ * searchEmbed.trigger(HostEvent.ShowUnderlyingData)
908
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
909
+ */
910
+ ShowUnderlyingData = 'showUnderlyingData',
911
+ /**
912
+ * Triggers the Delete action on visualization or search
913
+ * @param - incase of Liveboard embed, takes in an object with vizId as a key
914
+ * can be left empty for search and visualization embeds
915
+ * @example
916
+ * liveboardEmbed.trigger(HostEvent.Delete, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
917
+ * vizEmbed.trigger(HostEvent.Delete)
918
+ * searchEmbed.trigger(HostEvent.Delete)
919
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
920
+ */
921
+ Delete = 'delete',
922
+ /**
923
+ * Triggers the SpotIQAnalyze action on visualization or search
924
+ * @param - incase of Liveboard embed, takes in an object with vizId as a key
925
+ * can be left empty for search and visualization embeds
926
+ * @example
927
+ * liveboardEmbed.trigger(HostEvent.SpotIQAnalyze, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
928
+ * vizEmbed.trigger(HostEvent.SpotIQAnalyze)
929
+ * searchEmbed.trigger(HostEvent.SpotIQAnalyze)
930
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
931
+ */
932
+ SpotIQAnalyze = 'spotIQAnalyze',
933
+ /**
934
+ * Triggers the Download action on visualization or search when Displaymode is Chart
935
+ * @example
936
+ * liveboardEmbed.trigger(HostEvent.Download, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
937
+ * vizEmbed.trigger(HostEvent.Download)
938
+ * searchEmbed.trigger(HostEvent.Download)
939
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
940
+ */
941
+ Download = 'download',
942
+ /**
943
+ * Triggers the downloadAsCSV action on visualization or search when Displaymode is Table
944
+ * @example
945
+ * liveboardEmbed.trigger(HostEvent.DownloadAsCsv, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
946
+ * vizEmbed.trigger(HostEvent.DownloadAsCsv)
947
+ * searchEmbed.trigger(HostEvent.DownloadAsCsv)
948
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
949
+ */
950
+ DownloadAsCsv = 'downloadAsCSV',
951
+ /**
952
+ * Triggers the downloadAsXLSX action on visualization or search when Displaymode is Table
953
+ * @example
954
+ * liveboardEmbed.trigger(HostEvent.DownloadAsXlsx, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
955
+ * vizEmbed.trigger(HostEvent.DownloadAsXlsx)
956
+ * searchEmbed.trigger(HostEvent.DownloadAsXlsx)
957
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
958
+ */
959
+ DownloadAsXlsx = 'downloadAsXLSX',
896
960
  /**
897
961
  * Triggers the Share action on a liveboard or answer
898
962
  * @example
899
963
  * liveboardEmbed.trigger(HostEvent.Share)
900
964
  * searchEmbed.trigger(HostEvent.Share)
901
- * @version SDK: 1.19.0 | Thoughtspot: 9.0.0.cl, 9.0.1-sw
965
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
902
966
  */
903
967
  Share = 'share',
904
968
  /**
@@ -906,9 +970,36 @@ export enum HostEvent {
906
970
  * @example
907
971
  * liveboardEmbed.trigger(HostEvent.Save)
908
972
  * searchEmbed.trigger(HostEvent.Save)
909
- * @version SDK: 1.19.0 | Thoughtspot: 9.0.0.cl, 9.0.1-sw
973
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
910
974
  */
911
975
  Save = 'save',
976
+ /**
977
+ * Triggers the SyncToSheets action on visualization
978
+ * @param - an object with vizId as a key
979
+ * @example
980
+ * liveboardEmbed.trigger(HostEvent.SyncToSheets, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
981
+ * vizEmbed.trigger(HostEvent.SyncToSheets)
982
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
983
+ */
984
+ SyncToSheets = 'sync-to-sheets',
985
+ /**
986
+ * Triggers the SyncToOtherApps action on visualization
987
+ * @param - an object with vizId as a key
988
+ * @example
989
+ * liveboardEmbed.trigger(HostEvent.SyncToOtherApps, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
990
+ * vizEmbed.trigger(HostEvent.SyncToOtherApps)
991
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
992
+ */
993
+ SyncToOtherApps = 'sync-to-other-apps',
994
+ /**
995
+ * Triggers the ManagePipelines action on visualization
996
+ * @param - an object with vizId as a key
997
+ * @example
998
+ * liveboardEmbed.trigger(HostEvent.ManagePipelines, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
999
+ * vizEmbed.trigger(HostEvent.ManagePipelines)
1000
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
1001
+ */
1002
+ ManagePipelines = 'manage-pipeline',
912
1003
  }
913
1004
 
914
1005
  /**
package/src/utils.ts CHANGED
@@ -181,12 +181,14 @@ export const getCustomisations = (
181
181
  embedConfig: EmbedConfig,
182
182
  ): CustomisationsInterface => {
183
183
  const { customCssUrl } = embedConfig;
184
- let { customisations } = embedConfig;
185
- customisations = customisations || ({} as CustomisationsInterface);
186
- customisations.style = customisations.style || {};
187
- customisations.style.customCSSUrl =
188
- customisations.style.customCSSUrl || customCssUrl;
189
- return customisations;
184
+ let customizations =
185
+ embedConfig.customizations ||
186
+ ((embedConfig as any).customisations as CustomisationsInterface);
187
+ customizations = customizations || ({} as CustomisationsInterface);
188
+ customizations.style = customizations.style || {};
189
+ customizations.style.customCSSUrl =
190
+ customizations.style.customCSSUrl || customCssUrl;
191
+ return customizations;
190
192
  };
191
193
 
192
194
  /**