@thoughtspot/visual-embed-sdk 1.10.0-alpha.4 → 1.10.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.
- package/CHANGELOG.md +2 -2
- package/README.md +1 -1
- package/dist/src/auth.d.ts +18 -5
- package/dist/src/embed/base.d.ts +21 -5
- package/dist/src/embed/pinboard.d.ts +6 -0
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/types.d.ts +29 -0
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +543 -39
- package/dist/tsembed.js +541 -38
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +18 -5
- package/lib/src/auth.js +51 -12
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +69 -11
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +21 -5
- package/lib/src/embed/base.js +64 -10
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +49 -3
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +30 -1
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +6 -0
- package/lib/src/embed/pinboard.js +4 -1
- package/lib/src/embed/pinboard.js.map +1 -1
- package/lib/src/embed/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.js +18 -14
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +16 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- package/lib/src/index.js +3 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +29 -0
- package/lib/src/types.js +16 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +21 -3
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +21 -5
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- package/lib/src/utils/processData.d.ts +1 -1
- package/lib/src/utils/processData.js +37 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +106 -4
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +1 -0
- package/lib/src/utils.js +4 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +14 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +119 -8
- package/package.json +2 -1
- package/src/auth.spec.ts +90 -11
- package/src/auth.ts +74 -16
- package/src/embed/base.spec.ts +56 -4
- package/src/embed/base.ts +83 -16
- package/src/embed/embed.spec.ts +1 -1
- package/src/embed/events.spec.ts +32 -0
- package/src/embed/search.ts +5 -0
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +24 -15
- package/src/index.ts +5 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +31 -0
- package/src/utils/authService.spec.ts +31 -5
- package/src/utils/authService.ts +27 -3
- package/src/utils/processData.spec.ts +139 -4
- package/src/utils/processData.ts +54 -4
- package/src/utils.spec.ts +26 -0
- package/src/utils.ts +5 -0
- package/lib/src/utils/fetchAnswers.d.ts +0 -3
- package/lib/src/utils/fetchAnswers.js +0 -49
- package/lib/src/utils/fetchAnswers.js.map +0 -1
package/dist/tsembed.es.js
CHANGED
|
@@ -96,6 +96,10 @@ const appendToUrlHash = (url, stringToAppend) => {
|
|
|
96
96
|
}
|
|
97
97
|
return outputUrl;
|
|
98
98
|
};
|
|
99
|
+
function getRedirectUrl(url, stringToAppend, path = '') {
|
|
100
|
+
const targetUrl = path ? new URL(path, window.location.origin).href : url;
|
|
101
|
+
return appendToUrlHash(targetUrl, stringToAppend);
|
|
102
|
+
}
|
|
99
103
|
const getEncodedQueryParamsString = (queryString) => {
|
|
100
104
|
if (!queryString) {
|
|
101
105
|
return queryString;
|
|
@@ -306,6 +310,16 @@ var EmbedEvent;
|
|
|
306
310
|
* The ThoughtSpot auth session has expired.
|
|
307
311
|
*/
|
|
308
312
|
EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
|
|
313
|
+
/**
|
|
314
|
+
* ThoughtSpot failed to validate the auth session.
|
|
315
|
+
* @hidden
|
|
316
|
+
*/
|
|
317
|
+
EmbedEvent["AuthFailure"] = "ThoughtspotAuthFailure";
|
|
318
|
+
/**
|
|
319
|
+
* ThoughtSpot failed to validate the auth session.
|
|
320
|
+
* @hidden
|
|
321
|
+
*/
|
|
322
|
+
EmbedEvent["AuthLogout"] = "ThoughtspotAuthLogout";
|
|
309
323
|
/**
|
|
310
324
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
311
325
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -357,6 +371,12 @@ var EmbedEvent;
|
|
|
357
371
|
* @version 1.9.1 or later
|
|
358
372
|
*/
|
|
359
373
|
EmbedEvent["LiveboardRendered"] = "PinboardRendered";
|
|
374
|
+
/**
|
|
375
|
+
* This can be used to register an event listener which
|
|
376
|
+
* is triggered on all events.
|
|
377
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
378
|
+
*/
|
|
379
|
+
EmbedEvent["ALL"] = "*";
|
|
360
380
|
/**
|
|
361
381
|
* Emitted when answer is saved in the app
|
|
362
382
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -8680,9 +8700,361 @@ function initMixpanel(sessionInfo) {
|
|
|
8680
8700
|
}
|
|
8681
8701
|
}
|
|
8682
8702
|
|
|
8703
|
+
function createCommonjsModule(fn) {
|
|
8704
|
+
var module = { exports: {} };
|
|
8705
|
+
return fn(module, module.exports), module.exports;
|
|
8706
|
+
}
|
|
8707
|
+
|
|
8708
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
8709
|
+
|
|
8710
|
+
var has = Object.prototype.hasOwnProperty
|
|
8711
|
+
, prefix = '~';
|
|
8712
|
+
|
|
8713
|
+
/**
|
|
8714
|
+
* Constructor to create a storage for our `EE` objects.
|
|
8715
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
8716
|
+
*
|
|
8717
|
+
* @constructor
|
|
8718
|
+
* @private
|
|
8719
|
+
*/
|
|
8720
|
+
function Events() {}
|
|
8721
|
+
|
|
8722
|
+
//
|
|
8723
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
8724
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
8725
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
8726
|
+
// character to make sure that the built-in object properties are not
|
|
8727
|
+
// overridden or used as an attack vector.
|
|
8728
|
+
//
|
|
8729
|
+
if (Object.create) {
|
|
8730
|
+
Events.prototype = Object.create(null);
|
|
8731
|
+
|
|
8732
|
+
//
|
|
8733
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
8734
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
8735
|
+
//
|
|
8736
|
+
if (!new Events().__proto__) prefix = false;
|
|
8737
|
+
}
|
|
8738
|
+
|
|
8739
|
+
/**
|
|
8740
|
+
* Representation of a single event listener.
|
|
8741
|
+
*
|
|
8742
|
+
* @param {Function} fn The listener function.
|
|
8743
|
+
* @param {*} context The context to invoke the listener with.
|
|
8744
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
8745
|
+
* @constructor
|
|
8746
|
+
* @private
|
|
8747
|
+
*/
|
|
8748
|
+
function EE(fn, context, once) {
|
|
8749
|
+
this.fn = fn;
|
|
8750
|
+
this.context = context;
|
|
8751
|
+
this.once = once || false;
|
|
8752
|
+
}
|
|
8753
|
+
|
|
8754
|
+
/**
|
|
8755
|
+
* Add a listener for a given event.
|
|
8756
|
+
*
|
|
8757
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8758
|
+
* @param {(String|Symbol)} event The event name.
|
|
8759
|
+
* @param {Function} fn The listener function.
|
|
8760
|
+
* @param {*} context The context to invoke the listener with.
|
|
8761
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
8762
|
+
* @returns {EventEmitter}
|
|
8763
|
+
* @private
|
|
8764
|
+
*/
|
|
8765
|
+
function addListener(emitter, event, fn, context, once) {
|
|
8766
|
+
if (typeof fn !== 'function') {
|
|
8767
|
+
throw new TypeError('The listener must be a function');
|
|
8768
|
+
}
|
|
8769
|
+
|
|
8770
|
+
var listener = new EE(fn, context || emitter, once)
|
|
8771
|
+
, evt = prefix ? prefix + event : event;
|
|
8772
|
+
|
|
8773
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
8774
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
8775
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
8776
|
+
|
|
8777
|
+
return emitter;
|
|
8778
|
+
}
|
|
8779
|
+
|
|
8780
|
+
/**
|
|
8781
|
+
* Clear event by name.
|
|
8782
|
+
*
|
|
8783
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8784
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
8785
|
+
* @private
|
|
8786
|
+
*/
|
|
8787
|
+
function clearEvent(emitter, evt) {
|
|
8788
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
8789
|
+
else delete emitter._events[evt];
|
|
8790
|
+
}
|
|
8791
|
+
|
|
8792
|
+
/**
|
|
8793
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
8794
|
+
* `EventEmitter` interface.
|
|
8795
|
+
*
|
|
8796
|
+
* @constructor
|
|
8797
|
+
* @public
|
|
8798
|
+
*/
|
|
8799
|
+
function EventEmitter() {
|
|
8800
|
+
this._events = new Events();
|
|
8801
|
+
this._eventsCount = 0;
|
|
8802
|
+
}
|
|
8803
|
+
|
|
8804
|
+
/**
|
|
8805
|
+
* Return an array listing the events for which the emitter has registered
|
|
8806
|
+
* listeners.
|
|
8807
|
+
*
|
|
8808
|
+
* @returns {Array}
|
|
8809
|
+
* @public
|
|
8810
|
+
*/
|
|
8811
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
8812
|
+
var names = []
|
|
8813
|
+
, events
|
|
8814
|
+
, name;
|
|
8815
|
+
|
|
8816
|
+
if (this._eventsCount === 0) return names;
|
|
8817
|
+
|
|
8818
|
+
for (name in (events = this._events)) {
|
|
8819
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
8820
|
+
}
|
|
8821
|
+
|
|
8822
|
+
if (Object.getOwnPropertySymbols) {
|
|
8823
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
8824
|
+
}
|
|
8825
|
+
|
|
8826
|
+
return names;
|
|
8827
|
+
};
|
|
8828
|
+
|
|
8829
|
+
/**
|
|
8830
|
+
* Return the listeners registered for a given event.
|
|
8831
|
+
*
|
|
8832
|
+
* @param {(String|Symbol)} event The event name.
|
|
8833
|
+
* @returns {Array} The registered listeners.
|
|
8834
|
+
* @public
|
|
8835
|
+
*/
|
|
8836
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
8837
|
+
var evt = prefix ? prefix + event : event
|
|
8838
|
+
, handlers = this._events[evt];
|
|
8839
|
+
|
|
8840
|
+
if (!handlers) return [];
|
|
8841
|
+
if (handlers.fn) return [handlers.fn];
|
|
8842
|
+
|
|
8843
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
8844
|
+
ee[i] = handlers[i].fn;
|
|
8845
|
+
}
|
|
8846
|
+
|
|
8847
|
+
return ee;
|
|
8848
|
+
};
|
|
8849
|
+
|
|
8850
|
+
/**
|
|
8851
|
+
* Return the number of listeners listening to a given event.
|
|
8852
|
+
*
|
|
8853
|
+
* @param {(String|Symbol)} event The event name.
|
|
8854
|
+
* @returns {Number} The number of listeners.
|
|
8855
|
+
* @public
|
|
8856
|
+
*/
|
|
8857
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
8858
|
+
var evt = prefix ? prefix + event : event
|
|
8859
|
+
, listeners = this._events[evt];
|
|
8860
|
+
|
|
8861
|
+
if (!listeners) return 0;
|
|
8862
|
+
if (listeners.fn) return 1;
|
|
8863
|
+
return listeners.length;
|
|
8864
|
+
};
|
|
8865
|
+
|
|
8866
|
+
/**
|
|
8867
|
+
* Calls each of the listeners registered for a given event.
|
|
8868
|
+
*
|
|
8869
|
+
* @param {(String|Symbol)} event The event name.
|
|
8870
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
8871
|
+
* @public
|
|
8872
|
+
*/
|
|
8873
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
8874
|
+
var evt = prefix ? prefix + event : event;
|
|
8875
|
+
|
|
8876
|
+
if (!this._events[evt]) return false;
|
|
8877
|
+
|
|
8878
|
+
var listeners = this._events[evt]
|
|
8879
|
+
, len = arguments.length
|
|
8880
|
+
, args
|
|
8881
|
+
, i;
|
|
8882
|
+
|
|
8883
|
+
if (listeners.fn) {
|
|
8884
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
8885
|
+
|
|
8886
|
+
switch (len) {
|
|
8887
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
8888
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
8889
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
8890
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
8891
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
8892
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
8893
|
+
}
|
|
8894
|
+
|
|
8895
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
8896
|
+
args[i - 1] = arguments[i];
|
|
8897
|
+
}
|
|
8898
|
+
|
|
8899
|
+
listeners.fn.apply(listeners.context, args);
|
|
8900
|
+
} else {
|
|
8901
|
+
var length = listeners.length
|
|
8902
|
+
, j;
|
|
8903
|
+
|
|
8904
|
+
for (i = 0; i < length; i++) {
|
|
8905
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
8906
|
+
|
|
8907
|
+
switch (len) {
|
|
8908
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
8909
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
8910
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
8911
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
8912
|
+
default:
|
|
8913
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
8914
|
+
args[j - 1] = arguments[j];
|
|
8915
|
+
}
|
|
8916
|
+
|
|
8917
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
8918
|
+
}
|
|
8919
|
+
}
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8922
|
+
return true;
|
|
8923
|
+
};
|
|
8924
|
+
|
|
8925
|
+
/**
|
|
8926
|
+
* Add a listener for a given event.
|
|
8927
|
+
*
|
|
8928
|
+
* @param {(String|Symbol)} event The event name.
|
|
8929
|
+
* @param {Function} fn The listener function.
|
|
8930
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8931
|
+
* @returns {EventEmitter} `this`.
|
|
8932
|
+
* @public
|
|
8933
|
+
*/
|
|
8934
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
8935
|
+
return addListener(this, event, fn, context, false);
|
|
8936
|
+
};
|
|
8937
|
+
|
|
8938
|
+
/**
|
|
8939
|
+
* Add a one-time listener for a given event.
|
|
8940
|
+
*
|
|
8941
|
+
* @param {(String|Symbol)} event The event name.
|
|
8942
|
+
* @param {Function} fn The listener function.
|
|
8943
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8944
|
+
* @returns {EventEmitter} `this`.
|
|
8945
|
+
* @public
|
|
8946
|
+
*/
|
|
8947
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
8948
|
+
return addListener(this, event, fn, context, true);
|
|
8949
|
+
};
|
|
8950
|
+
|
|
8951
|
+
/**
|
|
8952
|
+
* Remove the listeners of a given event.
|
|
8953
|
+
*
|
|
8954
|
+
* @param {(String|Symbol)} event The event name.
|
|
8955
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
8956
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
8957
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
8958
|
+
* @returns {EventEmitter} `this`.
|
|
8959
|
+
* @public
|
|
8960
|
+
*/
|
|
8961
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
8962
|
+
var evt = prefix ? prefix + event : event;
|
|
8963
|
+
|
|
8964
|
+
if (!this._events[evt]) return this;
|
|
8965
|
+
if (!fn) {
|
|
8966
|
+
clearEvent(this, evt);
|
|
8967
|
+
return this;
|
|
8968
|
+
}
|
|
8969
|
+
|
|
8970
|
+
var listeners = this._events[evt];
|
|
8971
|
+
|
|
8972
|
+
if (listeners.fn) {
|
|
8973
|
+
if (
|
|
8974
|
+
listeners.fn === fn &&
|
|
8975
|
+
(!once || listeners.once) &&
|
|
8976
|
+
(!context || listeners.context === context)
|
|
8977
|
+
) {
|
|
8978
|
+
clearEvent(this, evt);
|
|
8979
|
+
}
|
|
8980
|
+
} else {
|
|
8981
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
8982
|
+
if (
|
|
8983
|
+
listeners[i].fn !== fn ||
|
|
8984
|
+
(once && !listeners[i].once) ||
|
|
8985
|
+
(context && listeners[i].context !== context)
|
|
8986
|
+
) {
|
|
8987
|
+
events.push(listeners[i]);
|
|
8988
|
+
}
|
|
8989
|
+
}
|
|
8990
|
+
|
|
8991
|
+
//
|
|
8992
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
8993
|
+
//
|
|
8994
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
8995
|
+
else clearEvent(this, evt);
|
|
8996
|
+
}
|
|
8997
|
+
|
|
8998
|
+
return this;
|
|
8999
|
+
};
|
|
9000
|
+
|
|
9001
|
+
/**
|
|
9002
|
+
* Remove all listeners, or those of the specified event.
|
|
9003
|
+
*
|
|
9004
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
9005
|
+
* @returns {EventEmitter} `this`.
|
|
9006
|
+
* @public
|
|
9007
|
+
*/
|
|
9008
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
9009
|
+
var evt;
|
|
9010
|
+
|
|
9011
|
+
if (event) {
|
|
9012
|
+
evt = prefix ? prefix + event : event;
|
|
9013
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
9014
|
+
} else {
|
|
9015
|
+
this._events = new Events();
|
|
9016
|
+
this._eventsCount = 0;
|
|
9017
|
+
}
|
|
9018
|
+
|
|
9019
|
+
return this;
|
|
9020
|
+
};
|
|
9021
|
+
|
|
9022
|
+
//
|
|
9023
|
+
// Alias methods names because people roll like that.
|
|
9024
|
+
//
|
|
9025
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
9026
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
9027
|
+
|
|
9028
|
+
//
|
|
9029
|
+
// Expose the prefix.
|
|
9030
|
+
//
|
|
9031
|
+
EventEmitter.prefixed = prefix;
|
|
9032
|
+
|
|
9033
|
+
//
|
|
9034
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
9035
|
+
//
|
|
9036
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
9037
|
+
|
|
9038
|
+
//
|
|
9039
|
+
// Expose the module.
|
|
9040
|
+
//
|
|
9041
|
+
{
|
|
9042
|
+
module.exports = EventEmitter;
|
|
9043
|
+
}
|
|
9044
|
+
});
|
|
9045
|
+
|
|
8683
9046
|
// eslint-disable-next-line import/no-cycle
|
|
9047
|
+
function failureLoggedFetch(url, options = {}) {
|
|
9048
|
+
return fetch(url, options).then(async (r) => {
|
|
9049
|
+
var _a;
|
|
9050
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
9051
|
+
console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
9052
|
+
}
|
|
9053
|
+
return r;
|
|
9054
|
+
});
|
|
9055
|
+
}
|
|
8684
9056
|
function fetchSessionInfoService(authVerificationUrl) {
|
|
8685
|
-
return
|
|
9057
|
+
return failureLoggedFetch(authVerificationUrl, {
|
|
8686
9058
|
credentials: 'include',
|
|
8687
9059
|
});
|
|
8688
9060
|
}
|
|
@@ -8690,12 +9062,14 @@ async function fetchAuthTokenService(authEndpoint) {
|
|
|
8690
9062
|
return fetch(authEndpoint);
|
|
8691
9063
|
}
|
|
8692
9064
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
8693
|
-
return
|
|
9065
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
8694
9066
|
credentials: 'include',
|
|
9067
|
+
// We do not want to follow the redirect, as it starts giving a CORS error
|
|
9068
|
+
redirect: 'manual',
|
|
8695
9069
|
});
|
|
8696
9070
|
}
|
|
8697
9071
|
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
8698
|
-
return
|
|
9072
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
8699
9073
|
method: 'POST',
|
|
8700
9074
|
headers: {
|
|
8701
9075
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -8704,6 +9078,13 @@ async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
|
8704
9078
|
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
8705
9079
|
credentials: 'include',
|
|
8706
9080
|
});
|
|
9081
|
+
}
|
|
9082
|
+
async function fetchLogoutService(thoughtSpotHost) {
|
|
9083
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
9084
|
+
credentials: 'include',
|
|
9085
|
+
mode: 'no-cors',
|
|
9086
|
+
method: 'POST',
|
|
9087
|
+
});
|
|
8707
9088
|
}
|
|
8708
9089
|
|
|
8709
9090
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -8721,7 +9102,21 @@ const EndPoints = {
|
|
|
8721
9102
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
8722
9103
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
8723
9104
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
9105
|
+
LOGOUT: '/callosum/v1/session/logout',
|
|
8724
9106
|
};
|
|
9107
|
+
var AuthFailureType;
|
|
9108
|
+
(function (AuthFailureType) {
|
|
9109
|
+
AuthFailureType["SDK"] = "SDK";
|
|
9110
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
9111
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
9112
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
9113
|
+
})(AuthFailureType || (AuthFailureType = {}));
|
|
9114
|
+
var AuthStatus;
|
|
9115
|
+
(function (AuthStatus) {
|
|
9116
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
9117
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
9118
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
9119
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
8725
9120
|
/**
|
|
8726
9121
|
* Check if we are logged into the ThoughtSpot cluster
|
|
8727
9122
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
@@ -8741,6 +9136,17 @@ function initSession(sessionDetails) {
|
|
|
8741
9136
|
sessionInfo = sessionDetails;
|
|
8742
9137
|
initMixpanel(sessionInfo);
|
|
8743
9138
|
}
|
|
9139
|
+
const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
|
|
9140
|
+
'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
9141
|
+
let prevAuthToken = null;
|
|
9142
|
+
function alertForDuplicateToken(authtoken) {
|
|
9143
|
+
if (prevAuthToken === authtoken) {
|
|
9144
|
+
// eslint-disable-next-line no-alert
|
|
9145
|
+
alert(DUPLICATE_TOKEN_ERR);
|
|
9146
|
+
throw new Error(DUPLICATE_TOKEN_ERR);
|
|
9147
|
+
}
|
|
9148
|
+
prevAuthToken = authtoken;
|
|
9149
|
+
}
|
|
8744
9150
|
/**
|
|
8745
9151
|
* Check if we are stuck at the SSO redirect URL
|
|
8746
9152
|
*/
|
|
@@ -8766,20 +9172,22 @@ const doTokenAuth = async (embedConfig) => {
|
|
|
8766
9172
|
if (!authEndpoint && !getAuthToken) {
|
|
8767
9173
|
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
8768
9174
|
}
|
|
8769
|
-
|
|
8770
|
-
if (!
|
|
9175
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
9176
|
+
if (!loggedInStatus) {
|
|
8771
9177
|
let authToken = null;
|
|
8772
9178
|
if (getAuthToken) {
|
|
8773
9179
|
authToken = await getAuthToken();
|
|
9180
|
+
alertForDuplicateToken(authToken);
|
|
8774
9181
|
}
|
|
8775
9182
|
else {
|
|
8776
9183
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
8777
9184
|
authToken = await response.text();
|
|
8778
9185
|
}
|
|
8779
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8780
|
-
|
|
9186
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
9187
|
+
// token login issues a 302 when successful
|
|
9188
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
8781
9189
|
}
|
|
8782
|
-
loggedInStatus
|
|
9190
|
+
return loggedInStatus;
|
|
8783
9191
|
};
|
|
8784
9192
|
/**
|
|
8785
9193
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -8794,9 +9202,12 @@ const doBasicAuth = async (embedConfig) => {
|
|
|
8794
9202
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
8795
9203
|
if (!loggedIn) {
|
|
8796
9204
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
8797
|
-
loggedInStatus = response.
|
|
9205
|
+
loggedInStatus = response.ok;
|
|
8798
9206
|
}
|
|
8799
|
-
|
|
9207
|
+
else {
|
|
9208
|
+
loggedInStatus = true;
|
|
9209
|
+
}
|
|
9210
|
+
return loggedInStatus;
|
|
8800
9211
|
};
|
|
8801
9212
|
async function samlPopupFlow(ssoURL) {
|
|
8802
9213
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -8846,6 +9257,7 @@ const doSSOAuth = async (embedConfig, ssoEndPoint) => {
|
|
|
8846
9257
|
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
8847
9258
|
if (embedConfig.noRedirect) {
|
|
8848
9259
|
await samlPopupFlow(ssoURL);
|
|
9260
|
+
loggedInStatus = true;
|
|
8849
9261
|
return;
|
|
8850
9262
|
}
|
|
8851
9263
|
window.location.href = ssoURL;
|
|
@@ -8856,10 +9268,11 @@ const doSamlAuth = async (embedConfig) => {
|
|
|
8856
9268
|
// again and the same JS will execute again.
|
|
8857
9269
|
const ssoRedirectUrl = embedConfig.noRedirect
|
|
8858
9270
|
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
8859
|
-
:
|
|
9271
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
8860
9272
|
// bring back the page to the same URL
|
|
8861
9273
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8862
9274
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
9275
|
+
return loggedInStatus;
|
|
8863
9276
|
};
|
|
8864
9277
|
const doOIDCAuth = async (embedConfig) => {
|
|
8865
9278
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -8867,10 +9280,17 @@ const doOIDCAuth = async (embedConfig) => {
|
|
|
8867
9280
|
// again and the same JS will execute again.
|
|
8868
9281
|
const ssoRedirectUrl = embedConfig.noRedirect
|
|
8869
9282
|
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
8870
|
-
:
|
|
9283
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
8871
9284
|
// bring back the page to the same URL
|
|
8872
9285
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8873
9286
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
9287
|
+
return loggedInStatus;
|
|
9288
|
+
};
|
|
9289
|
+
const logout = async (embedConfig) => {
|
|
9290
|
+
const { thoughtSpotHost } = embedConfig;
|
|
9291
|
+
const response = await fetchLogoutService(thoughtSpotHost);
|
|
9292
|
+
loggedInStatus = false;
|
|
9293
|
+
return loggedInStatus;
|
|
8874
9294
|
};
|
|
8875
9295
|
/**
|
|
8876
9296
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -8888,26 +9308,55 @@ const authenticate = async (embedConfig) => {
|
|
|
8888
9308
|
case AuthType.Basic:
|
|
8889
9309
|
return doBasicAuth(embedConfig);
|
|
8890
9310
|
default:
|
|
8891
|
-
return Promise.resolve();
|
|
9311
|
+
return Promise.resolve(true);
|
|
8892
9312
|
}
|
|
8893
9313
|
};
|
|
8894
9314
|
|
|
8895
9315
|
/* eslint-disable import/no-mutable-exports */
|
|
8896
9316
|
let config = {};
|
|
9317
|
+
const CONFIG_DEFAULTS = {
|
|
9318
|
+
loginFailedMessage: 'Not logged in',
|
|
9319
|
+
authType: AuthType.None,
|
|
9320
|
+
};
|
|
8897
9321
|
let authPromise;
|
|
9322
|
+
const getEmbedConfig = () => config;
|
|
9323
|
+
const getAuthPromise = () => authPromise;
|
|
9324
|
+
let authEE;
|
|
9325
|
+
function notifyAuthSuccess() {
|
|
9326
|
+
if (!authEE) {
|
|
9327
|
+
console.error('SDK not initialized');
|
|
9328
|
+
return;
|
|
9329
|
+
}
|
|
9330
|
+
authEE.emit(AuthStatus.SUCCESS);
|
|
9331
|
+
}
|
|
9332
|
+
function notifyAuthFailure(failureType) {
|
|
9333
|
+
if (!authEE) {
|
|
9334
|
+
console.error('SDK not initialized');
|
|
9335
|
+
return;
|
|
9336
|
+
}
|
|
9337
|
+
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
9338
|
+
}
|
|
9339
|
+
function notifyLogout() {
|
|
9340
|
+
if (!authEE) {
|
|
9341
|
+
console.error('SDK not initialized');
|
|
9342
|
+
return;
|
|
9343
|
+
}
|
|
9344
|
+
authEE.emit(AuthStatus.LOGOUT);
|
|
9345
|
+
}
|
|
8898
9346
|
/**
|
|
8899
9347
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
8900
9348
|
*/
|
|
8901
9349
|
const handleAuth = () => {
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
9350
|
+
authPromise = authenticate(config);
|
|
9351
|
+
authPromise.then((isLoggedIn) => {
|
|
9352
|
+
if (!isLoggedIn) {
|
|
9353
|
+
notifyAuthFailure(AuthFailureType.SDK);
|
|
9354
|
+
}
|
|
9355
|
+
}, () => {
|
|
9356
|
+
notifyAuthFailure(AuthFailureType.SDK);
|
|
9357
|
+
});
|
|
8907
9358
|
return authPromise;
|
|
8908
9359
|
};
|
|
8909
|
-
const getEmbedConfig = () => config;
|
|
8910
|
-
const getAuthPromise = () => authPromise;
|
|
8911
9360
|
/**
|
|
8912
9361
|
* Prefetches static resources from the specified URL. Web browsers can then cache the prefetched resources and serve them from the user's local disk to provide faster access to your app.
|
|
8913
9362
|
* @param url The URL provided for prefetch
|
|
@@ -8936,7 +9385,12 @@ const prefetch = (url) => {
|
|
|
8936
9385
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
8937
9386
|
*/
|
|
8938
9387
|
const init = (embedConfig) => {
|
|
8939
|
-
config =
|
|
9388
|
+
config = {
|
|
9389
|
+
...CONFIG_DEFAULTS,
|
|
9390
|
+
...embedConfig,
|
|
9391
|
+
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
9392
|
+
};
|
|
9393
|
+
authEE = new eventemitter3();
|
|
8940
9394
|
handleAuth();
|
|
8941
9395
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
8942
9396
|
authType: config.authType,
|
|
@@ -8945,7 +9399,19 @@ const init = (embedConfig) => {
|
|
|
8945
9399
|
if (config.callPrefetch) {
|
|
8946
9400
|
prefetch(config.thoughtSpotHost);
|
|
8947
9401
|
}
|
|
8948
|
-
return
|
|
9402
|
+
return authEE;
|
|
9403
|
+
};
|
|
9404
|
+
function disableAutoLogin() {
|
|
9405
|
+
config.autoLogin = false;
|
|
9406
|
+
}
|
|
9407
|
+
const logout$1 = (doNotDisableAutoLogin = false) => {
|
|
9408
|
+
if (!doNotDisableAutoLogin) {
|
|
9409
|
+
disableAutoLogin();
|
|
9410
|
+
}
|
|
9411
|
+
return logout(config).then((isLoggedIn) => {
|
|
9412
|
+
notifyLogout();
|
|
9413
|
+
return isLoggedIn;
|
|
9414
|
+
});
|
|
8949
9415
|
};
|
|
8950
9416
|
let renderQueue = Promise.resolve();
|
|
8951
9417
|
/**
|
|
@@ -9031,6 +9497,7 @@ function processAuthInit(e) {
|
|
|
9031
9497
|
var _a, _b;
|
|
9032
9498
|
// Store user session details sent by app.
|
|
9033
9499
|
initSession(e.data);
|
|
9500
|
+
notifyAuthSuccess();
|
|
9034
9501
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
9035
9502
|
return {
|
|
9036
9503
|
...e,
|
|
@@ -9044,9 +9511,36 @@ function processAuthExpire(e) {
|
|
|
9044
9511
|
if (autoLogin) {
|
|
9045
9512
|
handleAuth();
|
|
9046
9513
|
}
|
|
9514
|
+
notifyAuthFailure(AuthFailureType.EXPIRY);
|
|
9047
9515
|
return e;
|
|
9048
9516
|
}
|
|
9049
|
-
function
|
|
9517
|
+
function processNoCookieAccess(e, containerEl) {
|
|
9518
|
+
const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
|
|
9519
|
+
if (!suppressNoCookieAccessAlert) {
|
|
9520
|
+
// eslint-disable-next-line no-alert
|
|
9521
|
+
alert('Third party cookie access is blocked on this browser, please allow third party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.');
|
|
9522
|
+
}
|
|
9523
|
+
// eslint-disable-next-line no-param-reassign
|
|
9524
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9525
|
+
notifyAuthFailure(AuthFailureType.NO_COOKIE_ACCESS);
|
|
9526
|
+
return e;
|
|
9527
|
+
}
|
|
9528
|
+
function processAuthFailure(e, containerEl) {
|
|
9529
|
+
const { loginFailedMessage } = getEmbedConfig();
|
|
9530
|
+
// eslint-disable-next-line no-param-reassign
|
|
9531
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9532
|
+
notifyAuthFailure(AuthFailureType.OTHER);
|
|
9533
|
+
return e;
|
|
9534
|
+
}
|
|
9535
|
+
function processAuthLogout(e, containerEl) {
|
|
9536
|
+
const { loginFailedMessage } = getEmbedConfig();
|
|
9537
|
+
// eslint-disable-next-line no-param-reassign
|
|
9538
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9539
|
+
disableAutoLogin();
|
|
9540
|
+
notifyLogout();
|
|
9541
|
+
return e;
|
|
9542
|
+
}
|
|
9543
|
+
function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
9050
9544
|
switch (type) {
|
|
9051
9545
|
case EmbedEvent.CustomAction:
|
|
9052
9546
|
return processCustomAction(e, thoughtSpotHost);
|
|
@@ -9054,6 +9548,12 @@ function getProcessData(type, e, thoughtSpotHost) {
|
|
|
9054
9548
|
return processAuthInit(e);
|
|
9055
9549
|
case EmbedEvent.AuthExpire:
|
|
9056
9550
|
return processAuthExpire(e);
|
|
9551
|
+
case EmbedEvent.NoCookieAccess:
|
|
9552
|
+
return processNoCookieAccess(e, containerEl);
|
|
9553
|
+
case EmbedEvent.AuthFailure:
|
|
9554
|
+
return processAuthFailure(e, containerEl);
|
|
9555
|
+
case EmbedEvent.AuthLogout:
|
|
9556
|
+
return processAuthLogout(e, containerEl);
|
|
9057
9557
|
}
|
|
9058
9558
|
return e;
|
|
9059
9559
|
}
|
|
@@ -9082,7 +9582,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
9082
9582
|
}
|
|
9083
9583
|
}
|
|
9084
9584
|
|
|
9085
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.10.
|
|
9585
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.10.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","mixpanel-browser":"^2.41.0"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
|
|
9086
9586
|
|
|
9087
9587
|
/**
|
|
9088
9588
|
* Copyright (c) 2022
|
|
@@ -9129,12 +9629,6 @@ class TsEmbed {
|
|
|
9129
9629
|
this.isError = false;
|
|
9130
9630
|
this.viewConfig = viewConfig;
|
|
9131
9631
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
9132
|
-
if (!this.embedConfig.suppressNoCookieAccessAlert) {
|
|
9133
|
-
this.on(EmbedEvent.NoCookieAccess, () => {
|
|
9134
|
-
// eslint-disable-next-line no-alert
|
|
9135
|
-
alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
|
|
9136
|
-
});
|
|
9137
|
-
}
|
|
9138
9632
|
}
|
|
9139
9633
|
/**
|
|
9140
9634
|
* Gets a reference to the root DOM node where
|
|
@@ -9189,9 +9683,10 @@ class TsEmbed {
|
|
|
9189
9683
|
* will be removed for ts7.oct.cl
|
|
9190
9684
|
* @hidden
|
|
9191
9685
|
*/
|
|
9192
|
-
formatEventData(event) {
|
|
9686
|
+
formatEventData(event, eventType) {
|
|
9193
9687
|
const eventData = {
|
|
9194
9688
|
...event.data,
|
|
9689
|
+
type: eventType,
|
|
9195
9690
|
};
|
|
9196
9691
|
if (!eventData.data) {
|
|
9197
9692
|
eventData.data = event.data.payload;
|
|
@@ -9208,9 +9703,9 @@ class TsEmbed {
|
|
|
9208
9703
|
window.addEventListener('message', (event) => {
|
|
9209
9704
|
const eventType = this.getEventType(event);
|
|
9210
9705
|
const eventPort = this.getEventPort(event);
|
|
9211
|
-
const eventData = this.formatEventData(event);
|
|
9706
|
+
const eventData = this.formatEventData(event, eventType);
|
|
9212
9707
|
if (event.source === this.iFrame.contentWindow) {
|
|
9213
|
-
this.executeCallbacks(eventType,
|
|
9708
|
+
this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
|
|
9214
9709
|
}
|
|
9215
9710
|
});
|
|
9216
9711
|
}
|
|
@@ -9326,9 +9821,14 @@ class TsEmbed {
|
|
|
9326
9821
|
data: {
|
|
9327
9822
|
timestamp: initTimestamp,
|
|
9328
9823
|
},
|
|
9824
|
+
type: EmbedEvent.Init,
|
|
9329
9825
|
});
|
|
9330
9826
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9331
|
-
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
9827
|
+
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9828
|
+
if (!isLoggedIn) {
|
|
9829
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9830
|
+
return;
|
|
9831
|
+
}
|
|
9332
9832
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
9333
9833
|
this.iFrame =
|
|
9334
9834
|
this.iFrame || document.createElement('iframe');
|
|
@@ -9344,7 +9844,7 @@ class TsEmbed {
|
|
|
9344
9844
|
this.iFrame.mozallowfullscreen = true;
|
|
9345
9845
|
const { height: frameHeight, width: frameWidth, ...restParams } = frameOptions;
|
|
9346
9846
|
const width = getCssDimension(frameWidth || DEFAULT_EMBED_WIDTH);
|
|
9347
|
-
const height = getCssDimension(
|
|
9847
|
+
const height = getCssDimension(frameHeight || DEFAULT_EMBED_HEIGHT);
|
|
9348
9848
|
setAttributes(this.iFrame, restParams);
|
|
9349
9849
|
this.iFrame.style.width = `${width}`;
|
|
9350
9850
|
this.iFrame.style.height = `${height}`;
|
|
@@ -9357,6 +9857,7 @@ class TsEmbed {
|
|
|
9357
9857
|
data: {
|
|
9358
9858
|
timestamp: loadTimestamp,
|
|
9359
9859
|
},
|
|
9860
|
+
type: EmbedEvent.Load,
|
|
9360
9861
|
});
|
|
9361
9862
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_IFRAME_LOAD_PERFORMANCE, {
|
|
9362
9863
|
timeTookToLoad: loadTimestamp - initTimestamp,
|
|
@@ -9377,6 +9878,7 @@ class TsEmbed {
|
|
|
9377
9878
|
}).catch((error) => {
|
|
9378
9879
|
nextInQueue();
|
|
9379
9880
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
|
|
9881
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9380
9882
|
this.handleError(error);
|
|
9381
9883
|
});
|
|
9382
9884
|
});
|
|
@@ -9396,6 +9898,8 @@ class TsEmbed {
|
|
|
9396
9898
|
*/
|
|
9397
9899
|
executeCallbacks(eventType, data, eventPort) {
|
|
9398
9900
|
const callbacks = this.eventHandlerMap.get(eventType) || [];
|
|
9901
|
+
const allHandlers = this.eventHandlerMap.get(EmbedEvent.ALL) || [];
|
|
9902
|
+
callbacks.push(...allHandlers);
|
|
9399
9903
|
const dataStatus = (data === null || data === void 0 ? void 0 : data.status) || embedEventStatus.END;
|
|
9400
9904
|
callbacks.forEach((callbackObj) => {
|
|
9401
9905
|
if ((callbackObj.options.start &&
|
|
@@ -9562,9 +10066,9 @@ class V1Embed extends TsEmbed {
|
|
|
9562
10066
|
this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
|
|
9563
10067
|
}
|
|
9564
10068
|
// @override
|
|
9565
|
-
on(messageType, callback) {
|
|
10069
|
+
on(messageType, callback, options = { start: false }) {
|
|
9566
10070
|
const eventType = this.getCompatibleEventType(messageType);
|
|
9567
|
-
return super.on(eventType, callback);
|
|
10071
|
+
return super.on(eventType, callback, options);
|
|
9568
10072
|
}
|
|
9569
10073
|
}
|
|
9570
10074
|
|
|
@@ -9898,7 +10402,7 @@ class SearchEmbed extends TsEmbed {
|
|
|
9898
10402
|
*/
|
|
9899
10403
|
getIFrameSrc(answerId, dataSources) {
|
|
9900
10404
|
var _a;
|
|
9901
|
-
const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
10405
|
+
const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
9902
10406
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
9903
10407
|
const queryParams = this.getBaseQueryParams();
|
|
9904
10408
|
queryParams[Param.HideActions] = [
|
|
@@ -9946,4 +10450,4 @@ class SearchEmbed extends TsEmbed {
|
|
|
9946
10450
|
}
|
|
9947
10451
|
}
|
|
9948
10452
|
|
|
9949
|
-
export { Action, AppEmbed, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, prefetch };
|
|
10453
|
+
export { Action, AppEmbed, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, RuntimeFilterOp, SearchEmbed, init, logout$1 as logout, prefetch };
|