@thoughtspot/visual-embed-sdk 1.10.0-alpha.2 → 1.10.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 (44) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +22 -3
  3. package/dist/src/embed/app.d.ts +9 -3
  4. package/dist/src/embed/search.d.ts +4 -0
  5. package/dist/src/embed/ts-embed.d.ts +18 -4
  6. package/dist/src/types.d.ts +139 -3
  7. package/dist/src/utils.d.ts +4 -0
  8. package/dist/tsembed.es.js +179 -21
  9. package/dist/tsembed.js +179 -21
  10. package/lib/package.json +2 -2
  11. package/lib/src/embed/app.d.ts +9 -3
  12. package/lib/src/embed/app.js +23 -7
  13. package/lib/src/embed/app.js.map +1 -1
  14. package/lib/src/embed/app.spec.js +36 -2
  15. package/lib/src/embed/app.spec.js.map +1 -1
  16. package/lib/src/embed/base.spec.js +13 -1
  17. package/lib/src/embed/base.spec.js.map +1 -1
  18. package/lib/src/embed/events.spec.js +30 -1
  19. package/lib/src/embed/events.spec.js.map +1 -1
  20. package/lib/src/embed/search.d.ts +4 -0
  21. package/lib/src/embed/search.js +1 -1
  22. package/lib/src/embed/search.js.map +1 -1
  23. package/lib/src/embed/ts-embed.d.ts +18 -4
  24. package/lib/src/embed/ts-embed.js +36 -14
  25. package/lib/src/embed/ts-embed.js.map +1 -1
  26. package/lib/src/embed/ts-embed.spec.js +123 -14
  27. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  28. package/lib/src/types.d.ts +139 -3
  29. package/lib/src/types.js +116 -0
  30. package/lib/src/types.js.map +1 -1
  31. package/lib/src/utils.d.ts +4 -0
  32. package/lib/src/utils.js +4 -0
  33. package/lib/src/utils.js.map +1 -1
  34. package/lib/src/visual-embed-sdk.d.ts +170 -10
  35. package/package.json +2 -2
  36. package/src/embed/app.spec.ts +49 -1
  37. package/src/embed/app.ts +24 -6
  38. package/src/embed/base.spec.ts +14 -0
  39. package/src/embed/events.spec.ts +32 -0
  40. package/src/embed/search.ts +5 -0
  41. package/src/embed/ts-embed.spec.ts +166 -14
  42. package/src/embed/ts-embed.ts +56 -16
  43. package/src/types.ts +148 -1
  44. package/src/utils.ts +5 -0
package/src/types.ts CHANGED
@@ -155,11 +155,42 @@ export interface EmbedConfig {
155
155
  customCssUrl?: string;
156
156
  }
157
157
 
158
- export type MessagePayload = { type: string; data: any };
158
+ /**
159
+ * MessagePayload: Embed event payload: message type, data and status (start/end)
160
+ */
161
+ export type MessagePayload = {
162
+ /* type: message type eg: 'save' */
163
+ type: string;
164
+ /* data: message payload data eg: { answerId: '123' } */
165
+ data: any;
166
+ /* status: message payload status - start or end */
167
+ status?: string;
168
+ };
169
+ /**
170
+ * MessageOptions: By Providing options, getting specific event start / end based on option
171
+ */
172
+ export type MessageOptions = {
173
+ /* A boolean value indicating that start status events of this type will be dispatched */
174
+ start?: boolean;
175
+ };
176
+ /**
177
+ * MessageCallback: Embed event message callback
178
+ */
159
179
  export type MessageCallback = (
180
+ /* payload: Message payload contain type, data and status */
160
181
  payload: MessagePayload,
182
+ /* responder: Messsage callback function triggered when embed event initiated */
161
183
  responder?: (data: any) => void,
162
184
  ) => void;
185
+ /**
186
+ * MessageCallbackObj: contains message options & callback function
187
+ */
188
+ export type MessageCallbackObj = {
189
+ /* options: It contains start, A boolean value indicating that start status events of this type will be dispatched */
190
+ /* callback: Embed event message callback */
191
+ options: MessageOptions;
192
+ callback: MessageCallback;
193
+ };
163
194
 
164
195
  export type GenericCallbackFn = (...args: any[]) => any;
165
196
 
@@ -314,6 +345,12 @@ export enum EmbedEvent {
314
345
  * @version 1.5.0 or later
315
346
  */
316
347
  VizPointDoubleClick = 'vizPointDoubleClick',
348
+ /**
349
+ * A click has been triggered on table/chart
350
+ * @return ContextMenuInputPoints - data point that is clicked
351
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
352
+ */
353
+ VizPointClick = 'vizPointClick',
317
354
  /**
318
355
  * An error has occurred.
319
356
  * @return error - An error object or message
@@ -379,6 +416,107 @@ export enum EmbedEvent {
379
416
  * @version 1.9.1 or later
380
417
  */
381
418
  LiveboardRendered = 'PinboardRendered',
419
+ /**
420
+ * This can be used to register an event listener which
421
+ * is triggered on all events.
422
+ * @version SDK: 1.10.0 | ThoughtSpot: any
423
+ */
424
+ ALL = '*',
425
+ /**
426
+ * Emitted when answer is saved in the app
427
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
428
+ */
429
+ Save = 'save',
430
+ /**
431
+ * Emitted when the download action is triggered on an answer
432
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
433
+ */
434
+ Download = 'download',
435
+ /**
436
+ * Emitted when the Download as PDF action is triggered on an answer
437
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
438
+ */
439
+ DownloadAsPdf = 'downloadAsPdf',
440
+ /**
441
+ * Emitted when the Download as CSV action is triggered on an answer
442
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
443
+ */
444
+ DownloadAsCsv = 'downloadAsCsv',
445
+ /**
446
+ * Emitted when the Download as XLSX action is triggered on an answer
447
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
448
+ */
449
+ DownloadAsXlsx = 'downloadAsXlsx',
450
+ /**
451
+ * Emitted when an answer is deleted in the app
452
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
453
+ */
454
+ AnswerDelete = 'answerDelete',
455
+ /**
456
+ * Emitted when an answer is pinned to a Liveboard
457
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
458
+ */
459
+ Pin = 'pin',
460
+ /**
461
+ * Emitted when SpotIQ analysis is triggered
462
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
463
+ */
464
+ SpotIQAnalyze = 'spotIQAnalyze',
465
+ /**
466
+ * Emitted when a user shares an object with another user or group
467
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
468
+ */
469
+ Share = 'share',
470
+ /**
471
+ * Emitted when a user clicks the Include action to include a specific value or data on a chart or table
472
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
473
+ */
474
+ DrillInclude = 'context-menu-item-include',
475
+ /**
476
+ * Emitted when a user clicks the Exclude action to exclude a specific value or data on a chart or table
477
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
478
+ */
479
+ DrillExclude = 'context-menu-item-exclude',
480
+ /**
481
+ * Emitted when copied column value on the app
482
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
483
+ */
484
+ CopyToClipboard = 'context-menu-item-copy-to-clipboard',
485
+ /**
486
+ * Emitted when a user clicks the Update TML action
487
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
488
+ */
489
+ UpdateTML = 'updateTSL',
490
+ /**
491
+ * Emitted when a user clicks the Edit TML action
492
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
493
+ */
494
+ EditTML = 'editTSL',
495
+ /**
496
+ * Emitted when ExportTML trigger in answer on the app
497
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
498
+ */
499
+ ExportTML = 'exportTSL',
500
+ /**
501
+ * Emitted when an answer is saved as a view
502
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
503
+ */
504
+ SaveAsView = 'saveAsView',
505
+ /**
506
+ * Emitted when copy of existing answer on the app
507
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
508
+ */
509
+ CopyAEdit = 'copyAEdit',
510
+ /**
511
+ * Emitted when a user clicks Show underlying data on an answe
512
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
513
+ */
514
+ ShowUnderlyingData = 'showUnderlyingData',
515
+ /**
516
+ * Emitted when an answer is switched to a chart or table view
517
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
518
+ */
519
+ AnswerChartSwitcher = 'answerChartSwitcher',
382
520
  }
383
521
 
384
522
  /**
@@ -429,6 +567,13 @@ export enum HostEvent {
429
567
  * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
430
568
  */
431
569
  UpdateRuntimeFilters = 'UpdateRuntimeFilters',
570
+ /**
571
+ * Navigate to a specific page in App embed without any reload.
572
+ * This is the same as calling `appEmbed.navigateToPage(path, true)`
573
+ * @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
574
+ * @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
575
+ */
576
+ Navigate = 'Navigate',
432
577
  }
433
578
 
434
579
  /**
@@ -485,6 +630,8 @@ export enum Param {
485
630
  DisableLoginRedirect = 'disableLoginRedirect',
486
631
  visibleVizs = 'pinboardVisibleVizs',
487
632
  LiveboardV2Enabled = 'isPinboardV2Enabled',
633
+ ShowAlerts = 'showAlerts',
634
+ Locale = 'locale',
488
635
  }
489
636
 
490
637
  /**
package/src/utils.ts CHANGED
@@ -136,6 +136,11 @@ export const getOffsetTop = (element: any) => {
136
136
  return rect.top + window.scrollY;
137
137
  };
138
138
 
139
+ export const embedEventStatus = {
140
+ START: 'start',
141
+ END: 'end',
142
+ };
143
+
139
144
  export const setAttributes = (
140
145
  element: HTMLElement,
141
146
  attributes: { [key: string]: string | number | boolean },