@thoughtspot/visual-embed-sdk 1.10.0-alpha.3 → 1.10.1
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 +22 -3
- package/dist/src/auth.d.ts +18 -5
- package/dist/src/embed/app.d.ts +4 -2
- package/dist/src/embed/base.d.ts +21 -5
- 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 -1
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/tsembed.es.js +560 -43
- package/dist/tsembed.js +558 -42
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +18 -5
- package/lib/src/auth.js +48 -9
- 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/app.d.ts +4 -2
- package/lib/src/embed/app.js +17 -7
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +36 -2
- package/lib/src/embed/app.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/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 -1
- package/lib/src/types.js +23 -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/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/visual-embed-sdk.d.ts +123 -11
- package/package.json +2 -1
- package/src/auth.spec.ts +90 -11
- package/src/auth.ts +63 -13
- package/src/embed/app.spec.ts +49 -1
- package/src/embed/app.ts +18 -6
- 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 +29 -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/dist/tsembed.js
CHANGED
|
@@ -296,6 +296,16 @@
|
|
|
296
296
|
* The ThoughtSpot auth session has expired.
|
|
297
297
|
*/
|
|
298
298
|
EmbedEvent["AuthExpire"] = "ThoughtspotAuthExpired";
|
|
299
|
+
/**
|
|
300
|
+
* ThoughtSpot failed to validate the auth session.
|
|
301
|
+
* @hidden
|
|
302
|
+
*/
|
|
303
|
+
EmbedEvent["AuthFailure"] = "ThoughtspotAuthFailure";
|
|
304
|
+
/**
|
|
305
|
+
* ThoughtSpot failed to validate the auth session.
|
|
306
|
+
* @hidden
|
|
307
|
+
*/
|
|
308
|
+
EmbedEvent["AuthLogout"] = "ThoughtspotAuthLogout";
|
|
299
309
|
/**
|
|
300
310
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
301
311
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -347,6 +357,12 @@
|
|
|
347
357
|
* @version 1.9.1 or later
|
|
348
358
|
*/
|
|
349
359
|
EmbedEvent["LiveboardRendered"] = "PinboardRendered";
|
|
360
|
+
/**
|
|
361
|
+
* This can be used to register an event listener which
|
|
362
|
+
* is triggered on all events.
|
|
363
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
364
|
+
*/
|
|
365
|
+
EmbedEvent["ALL"] = "*";
|
|
350
366
|
/**
|
|
351
367
|
* Emitted when answer is saved in the app
|
|
352
368
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -483,6 +499,13 @@
|
|
|
483
499
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
484
500
|
*/
|
|
485
501
|
HostEvent["UpdateRuntimeFilters"] = "UpdateRuntimeFilters";
|
|
502
|
+
/**
|
|
503
|
+
* Navigate to a specific page in App embed without any reload.
|
|
504
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
505
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
506
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
507
|
+
*/
|
|
508
|
+
HostEvent["Navigate"] = "Navigate";
|
|
486
509
|
})(exports.HostEvent || (exports.HostEvent = {}));
|
|
487
510
|
(function (DataSourceVisualMode) {
|
|
488
511
|
/**
|
|
@@ -8642,9 +8665,361 @@
|
|
|
8642
8665
|
}
|
|
8643
8666
|
}
|
|
8644
8667
|
|
|
8668
|
+
function createCommonjsModule(fn) {
|
|
8669
|
+
var module = { exports: {} };
|
|
8670
|
+
return fn(module, module.exports), module.exports;
|
|
8671
|
+
}
|
|
8672
|
+
|
|
8673
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
8674
|
+
|
|
8675
|
+
var has = Object.prototype.hasOwnProperty
|
|
8676
|
+
, prefix = '~';
|
|
8677
|
+
|
|
8678
|
+
/**
|
|
8679
|
+
* Constructor to create a storage for our `EE` objects.
|
|
8680
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
8681
|
+
*
|
|
8682
|
+
* @constructor
|
|
8683
|
+
* @private
|
|
8684
|
+
*/
|
|
8685
|
+
function Events() {}
|
|
8686
|
+
|
|
8687
|
+
//
|
|
8688
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
8689
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
8690
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
8691
|
+
// character to make sure that the built-in object properties are not
|
|
8692
|
+
// overridden or used as an attack vector.
|
|
8693
|
+
//
|
|
8694
|
+
if (Object.create) {
|
|
8695
|
+
Events.prototype = Object.create(null);
|
|
8696
|
+
|
|
8697
|
+
//
|
|
8698
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
8699
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
8700
|
+
//
|
|
8701
|
+
if (!new Events().__proto__) prefix = false;
|
|
8702
|
+
}
|
|
8703
|
+
|
|
8704
|
+
/**
|
|
8705
|
+
* Representation of a single event listener.
|
|
8706
|
+
*
|
|
8707
|
+
* @param {Function} fn The listener function.
|
|
8708
|
+
* @param {*} context The context to invoke the listener with.
|
|
8709
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
8710
|
+
* @constructor
|
|
8711
|
+
* @private
|
|
8712
|
+
*/
|
|
8713
|
+
function EE(fn, context, once) {
|
|
8714
|
+
this.fn = fn;
|
|
8715
|
+
this.context = context;
|
|
8716
|
+
this.once = once || false;
|
|
8717
|
+
}
|
|
8718
|
+
|
|
8719
|
+
/**
|
|
8720
|
+
* Add a listener for a given event.
|
|
8721
|
+
*
|
|
8722
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8723
|
+
* @param {(String|Symbol)} event The event name.
|
|
8724
|
+
* @param {Function} fn The listener function.
|
|
8725
|
+
* @param {*} context The context to invoke the listener with.
|
|
8726
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
8727
|
+
* @returns {EventEmitter}
|
|
8728
|
+
* @private
|
|
8729
|
+
*/
|
|
8730
|
+
function addListener(emitter, event, fn, context, once) {
|
|
8731
|
+
if (typeof fn !== 'function') {
|
|
8732
|
+
throw new TypeError('The listener must be a function');
|
|
8733
|
+
}
|
|
8734
|
+
|
|
8735
|
+
var listener = new EE(fn, context || emitter, once)
|
|
8736
|
+
, evt = prefix ? prefix + event : event;
|
|
8737
|
+
|
|
8738
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
8739
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
8740
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
8741
|
+
|
|
8742
|
+
return emitter;
|
|
8743
|
+
}
|
|
8744
|
+
|
|
8745
|
+
/**
|
|
8746
|
+
* Clear event by name.
|
|
8747
|
+
*
|
|
8748
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
8749
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
8750
|
+
* @private
|
|
8751
|
+
*/
|
|
8752
|
+
function clearEvent(emitter, evt) {
|
|
8753
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
8754
|
+
else delete emitter._events[evt];
|
|
8755
|
+
}
|
|
8756
|
+
|
|
8757
|
+
/**
|
|
8758
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
8759
|
+
* `EventEmitter` interface.
|
|
8760
|
+
*
|
|
8761
|
+
* @constructor
|
|
8762
|
+
* @public
|
|
8763
|
+
*/
|
|
8764
|
+
function EventEmitter() {
|
|
8765
|
+
this._events = new Events();
|
|
8766
|
+
this._eventsCount = 0;
|
|
8767
|
+
}
|
|
8768
|
+
|
|
8769
|
+
/**
|
|
8770
|
+
* Return an array listing the events for which the emitter has registered
|
|
8771
|
+
* listeners.
|
|
8772
|
+
*
|
|
8773
|
+
* @returns {Array}
|
|
8774
|
+
* @public
|
|
8775
|
+
*/
|
|
8776
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
8777
|
+
var names = []
|
|
8778
|
+
, events
|
|
8779
|
+
, name;
|
|
8780
|
+
|
|
8781
|
+
if (this._eventsCount === 0) return names;
|
|
8782
|
+
|
|
8783
|
+
for (name in (events = this._events)) {
|
|
8784
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
8785
|
+
}
|
|
8786
|
+
|
|
8787
|
+
if (Object.getOwnPropertySymbols) {
|
|
8788
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
8789
|
+
}
|
|
8790
|
+
|
|
8791
|
+
return names;
|
|
8792
|
+
};
|
|
8793
|
+
|
|
8794
|
+
/**
|
|
8795
|
+
* Return the listeners registered for a given event.
|
|
8796
|
+
*
|
|
8797
|
+
* @param {(String|Symbol)} event The event name.
|
|
8798
|
+
* @returns {Array} The registered listeners.
|
|
8799
|
+
* @public
|
|
8800
|
+
*/
|
|
8801
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
8802
|
+
var evt = prefix ? prefix + event : event
|
|
8803
|
+
, handlers = this._events[evt];
|
|
8804
|
+
|
|
8805
|
+
if (!handlers) return [];
|
|
8806
|
+
if (handlers.fn) return [handlers.fn];
|
|
8807
|
+
|
|
8808
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
8809
|
+
ee[i] = handlers[i].fn;
|
|
8810
|
+
}
|
|
8811
|
+
|
|
8812
|
+
return ee;
|
|
8813
|
+
};
|
|
8814
|
+
|
|
8815
|
+
/**
|
|
8816
|
+
* Return the number of listeners listening to a given event.
|
|
8817
|
+
*
|
|
8818
|
+
* @param {(String|Symbol)} event The event name.
|
|
8819
|
+
* @returns {Number} The number of listeners.
|
|
8820
|
+
* @public
|
|
8821
|
+
*/
|
|
8822
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
8823
|
+
var evt = prefix ? prefix + event : event
|
|
8824
|
+
, listeners = this._events[evt];
|
|
8825
|
+
|
|
8826
|
+
if (!listeners) return 0;
|
|
8827
|
+
if (listeners.fn) return 1;
|
|
8828
|
+
return listeners.length;
|
|
8829
|
+
};
|
|
8830
|
+
|
|
8831
|
+
/**
|
|
8832
|
+
* Calls each of the listeners registered for a given event.
|
|
8833
|
+
*
|
|
8834
|
+
* @param {(String|Symbol)} event The event name.
|
|
8835
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
8836
|
+
* @public
|
|
8837
|
+
*/
|
|
8838
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
8839
|
+
var evt = prefix ? prefix + event : event;
|
|
8840
|
+
|
|
8841
|
+
if (!this._events[evt]) return false;
|
|
8842
|
+
|
|
8843
|
+
var listeners = this._events[evt]
|
|
8844
|
+
, len = arguments.length
|
|
8845
|
+
, args
|
|
8846
|
+
, i;
|
|
8847
|
+
|
|
8848
|
+
if (listeners.fn) {
|
|
8849
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
8850
|
+
|
|
8851
|
+
switch (len) {
|
|
8852
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
8853
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
8854
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
8855
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
8856
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
8857
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
8858
|
+
}
|
|
8859
|
+
|
|
8860
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
8861
|
+
args[i - 1] = arguments[i];
|
|
8862
|
+
}
|
|
8863
|
+
|
|
8864
|
+
listeners.fn.apply(listeners.context, args);
|
|
8865
|
+
} else {
|
|
8866
|
+
var length = listeners.length
|
|
8867
|
+
, j;
|
|
8868
|
+
|
|
8869
|
+
for (i = 0; i < length; i++) {
|
|
8870
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
8871
|
+
|
|
8872
|
+
switch (len) {
|
|
8873
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
8874
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
8875
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
8876
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
8877
|
+
default:
|
|
8878
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
8879
|
+
args[j - 1] = arguments[j];
|
|
8880
|
+
}
|
|
8881
|
+
|
|
8882
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
8883
|
+
}
|
|
8884
|
+
}
|
|
8885
|
+
}
|
|
8886
|
+
|
|
8887
|
+
return true;
|
|
8888
|
+
};
|
|
8889
|
+
|
|
8890
|
+
/**
|
|
8891
|
+
* Add a listener for a given event.
|
|
8892
|
+
*
|
|
8893
|
+
* @param {(String|Symbol)} event The event name.
|
|
8894
|
+
* @param {Function} fn The listener function.
|
|
8895
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8896
|
+
* @returns {EventEmitter} `this`.
|
|
8897
|
+
* @public
|
|
8898
|
+
*/
|
|
8899
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
8900
|
+
return addListener(this, event, fn, context, false);
|
|
8901
|
+
};
|
|
8902
|
+
|
|
8903
|
+
/**
|
|
8904
|
+
* Add a one-time listener for a given event.
|
|
8905
|
+
*
|
|
8906
|
+
* @param {(String|Symbol)} event The event name.
|
|
8907
|
+
* @param {Function} fn The listener function.
|
|
8908
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
8909
|
+
* @returns {EventEmitter} `this`.
|
|
8910
|
+
* @public
|
|
8911
|
+
*/
|
|
8912
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
8913
|
+
return addListener(this, event, fn, context, true);
|
|
8914
|
+
};
|
|
8915
|
+
|
|
8916
|
+
/**
|
|
8917
|
+
* Remove the listeners of a given event.
|
|
8918
|
+
*
|
|
8919
|
+
* @param {(String|Symbol)} event The event name.
|
|
8920
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
8921
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
8922
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
8923
|
+
* @returns {EventEmitter} `this`.
|
|
8924
|
+
* @public
|
|
8925
|
+
*/
|
|
8926
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
8927
|
+
var evt = prefix ? prefix + event : event;
|
|
8928
|
+
|
|
8929
|
+
if (!this._events[evt]) return this;
|
|
8930
|
+
if (!fn) {
|
|
8931
|
+
clearEvent(this, evt);
|
|
8932
|
+
return this;
|
|
8933
|
+
}
|
|
8934
|
+
|
|
8935
|
+
var listeners = this._events[evt];
|
|
8936
|
+
|
|
8937
|
+
if (listeners.fn) {
|
|
8938
|
+
if (
|
|
8939
|
+
listeners.fn === fn &&
|
|
8940
|
+
(!once || listeners.once) &&
|
|
8941
|
+
(!context || listeners.context === context)
|
|
8942
|
+
) {
|
|
8943
|
+
clearEvent(this, evt);
|
|
8944
|
+
}
|
|
8945
|
+
} else {
|
|
8946
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
8947
|
+
if (
|
|
8948
|
+
listeners[i].fn !== fn ||
|
|
8949
|
+
(once && !listeners[i].once) ||
|
|
8950
|
+
(context && listeners[i].context !== context)
|
|
8951
|
+
) {
|
|
8952
|
+
events.push(listeners[i]);
|
|
8953
|
+
}
|
|
8954
|
+
}
|
|
8955
|
+
|
|
8956
|
+
//
|
|
8957
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
8958
|
+
//
|
|
8959
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
8960
|
+
else clearEvent(this, evt);
|
|
8961
|
+
}
|
|
8962
|
+
|
|
8963
|
+
return this;
|
|
8964
|
+
};
|
|
8965
|
+
|
|
8966
|
+
/**
|
|
8967
|
+
* Remove all listeners, or those of the specified event.
|
|
8968
|
+
*
|
|
8969
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
8970
|
+
* @returns {EventEmitter} `this`.
|
|
8971
|
+
* @public
|
|
8972
|
+
*/
|
|
8973
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
8974
|
+
var evt;
|
|
8975
|
+
|
|
8976
|
+
if (event) {
|
|
8977
|
+
evt = prefix ? prefix + event : event;
|
|
8978
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
8979
|
+
} else {
|
|
8980
|
+
this._events = new Events();
|
|
8981
|
+
this._eventsCount = 0;
|
|
8982
|
+
}
|
|
8983
|
+
|
|
8984
|
+
return this;
|
|
8985
|
+
};
|
|
8986
|
+
|
|
8987
|
+
//
|
|
8988
|
+
// Alias methods names because people roll like that.
|
|
8989
|
+
//
|
|
8990
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
8991
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
8992
|
+
|
|
8993
|
+
//
|
|
8994
|
+
// Expose the prefix.
|
|
8995
|
+
//
|
|
8996
|
+
EventEmitter.prefixed = prefix;
|
|
8997
|
+
|
|
8998
|
+
//
|
|
8999
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
9000
|
+
//
|
|
9001
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
9002
|
+
|
|
9003
|
+
//
|
|
9004
|
+
// Expose the module.
|
|
9005
|
+
//
|
|
9006
|
+
{
|
|
9007
|
+
module.exports = EventEmitter;
|
|
9008
|
+
}
|
|
9009
|
+
});
|
|
9010
|
+
|
|
8645
9011
|
// eslint-disable-next-line import/no-cycle
|
|
9012
|
+
function failureLoggedFetch(url, options = {}) {
|
|
9013
|
+
return fetch(url, options).then(async (r) => {
|
|
9014
|
+
var _a;
|
|
9015
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
9016
|
+
console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
9017
|
+
}
|
|
9018
|
+
return r;
|
|
9019
|
+
});
|
|
9020
|
+
}
|
|
8646
9021
|
function fetchSessionInfoService(authVerificationUrl) {
|
|
8647
|
-
return
|
|
9022
|
+
return failureLoggedFetch(authVerificationUrl, {
|
|
8648
9023
|
credentials: 'include',
|
|
8649
9024
|
});
|
|
8650
9025
|
}
|
|
@@ -8652,12 +9027,14 @@
|
|
|
8652
9027
|
return fetch(authEndpoint);
|
|
8653
9028
|
}
|
|
8654
9029
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
8655
|
-
return
|
|
9030
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
8656
9031
|
credentials: 'include',
|
|
9032
|
+
// We do not want to follow the redirect, as it starts giving a CORS error
|
|
9033
|
+
redirect: 'manual',
|
|
8657
9034
|
});
|
|
8658
9035
|
}
|
|
8659
9036
|
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
8660
|
-
return
|
|
9037
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
8661
9038
|
method: 'POST',
|
|
8662
9039
|
headers: {
|
|
8663
9040
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -8666,6 +9043,13 @@
|
|
|
8666
9043
|
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
8667
9044
|
credentials: 'include',
|
|
8668
9045
|
});
|
|
9046
|
+
}
|
|
9047
|
+
async function fetchLogoutService(thoughtSpotHost) {
|
|
9048
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
9049
|
+
credentials: 'include',
|
|
9050
|
+
mode: 'no-cors',
|
|
9051
|
+
method: 'POST',
|
|
9052
|
+
});
|
|
8669
9053
|
}
|
|
8670
9054
|
|
|
8671
9055
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -8683,7 +9067,19 @@
|
|
|
8683
9067
|
OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
8684
9068
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
8685
9069
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
9070
|
+
LOGOUT: '/callosum/v1/session/logout',
|
|
8686
9071
|
};
|
|
9072
|
+
(function (AuthFailureType) {
|
|
9073
|
+
AuthFailureType["SDK"] = "SDK";
|
|
9074
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
9075
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
9076
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
9077
|
+
})(exports.AuthFailureType || (exports.AuthFailureType = {}));
|
|
9078
|
+
(function (AuthStatus) {
|
|
9079
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
9080
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
9081
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
9082
|
+
})(exports.AuthStatus || (exports.AuthStatus = {}));
|
|
8687
9083
|
/**
|
|
8688
9084
|
* Check if we are logged into the ThoughtSpot cluster
|
|
8689
9085
|
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
@@ -8703,6 +9099,17 @@
|
|
|
8703
9099
|
sessionInfo = sessionDetails;
|
|
8704
9100
|
initMixpanel(sessionInfo);
|
|
8705
9101
|
}
|
|
9102
|
+
const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.' +
|
|
9103
|
+
'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
9104
|
+
let prevAuthToken = null;
|
|
9105
|
+
function alertForDuplicateToken(authtoken) {
|
|
9106
|
+
if (prevAuthToken === authtoken) {
|
|
9107
|
+
// eslint-disable-next-line no-alert
|
|
9108
|
+
alert(DUPLICATE_TOKEN_ERR);
|
|
9109
|
+
throw new Error(DUPLICATE_TOKEN_ERR);
|
|
9110
|
+
}
|
|
9111
|
+
prevAuthToken = authtoken;
|
|
9112
|
+
}
|
|
8706
9113
|
/**
|
|
8707
9114
|
* Check if we are stuck at the SSO redirect URL
|
|
8708
9115
|
*/
|
|
@@ -8728,20 +9135,22 @@
|
|
|
8728
9135
|
if (!authEndpoint && !getAuthToken) {
|
|
8729
9136
|
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
8730
9137
|
}
|
|
8731
|
-
|
|
8732
|
-
if (!
|
|
9138
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
9139
|
+
if (!loggedInStatus) {
|
|
8733
9140
|
let authToken = null;
|
|
8734
9141
|
if (getAuthToken) {
|
|
8735
9142
|
authToken = await getAuthToken();
|
|
9143
|
+
alertForDuplicateToken(authToken);
|
|
8736
9144
|
}
|
|
8737
9145
|
else {
|
|
8738
9146
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
8739
9147
|
authToken = await response.text();
|
|
8740
9148
|
}
|
|
8741
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
8742
|
-
|
|
9149
|
+
const resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
9150
|
+
// token login issues a 302 when successful
|
|
9151
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
8743
9152
|
}
|
|
8744
|
-
loggedInStatus
|
|
9153
|
+
return loggedInStatus;
|
|
8745
9154
|
};
|
|
8746
9155
|
/**
|
|
8747
9156
|
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
@@ -8756,9 +9165,12 @@
|
|
|
8756
9165
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
8757
9166
|
if (!loggedIn) {
|
|
8758
9167
|
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
8759
|
-
loggedInStatus = response.
|
|
9168
|
+
loggedInStatus = response.ok;
|
|
8760
9169
|
}
|
|
8761
|
-
|
|
9170
|
+
else {
|
|
9171
|
+
loggedInStatus = true;
|
|
9172
|
+
}
|
|
9173
|
+
return loggedInStatus;
|
|
8762
9174
|
};
|
|
8763
9175
|
async function samlPopupFlow(ssoURL) {
|
|
8764
9176
|
document.body.insertAdjacentHTML('beforeend', '<div id="ts-saml-auth"></div>');
|
|
@@ -8808,6 +9220,7 @@
|
|
|
8808
9220
|
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
8809
9221
|
if (embedConfig.noRedirect) {
|
|
8810
9222
|
await samlPopupFlow(ssoURL);
|
|
9223
|
+
loggedInStatus = true;
|
|
8811
9224
|
return;
|
|
8812
9225
|
}
|
|
8813
9226
|
window.location.href = ssoURL;
|
|
@@ -8822,6 +9235,7 @@
|
|
|
8822
9235
|
// bring back the page to the same URL
|
|
8823
9236
|
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8824
9237
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
9238
|
+
return loggedInStatus;
|
|
8825
9239
|
};
|
|
8826
9240
|
const doOIDCAuth = async (embedConfig) => {
|
|
8827
9241
|
const { thoughtSpotHost } = embedConfig;
|
|
@@ -8833,6 +9247,13 @@
|
|
|
8833
9247
|
// bring back the page to the same URL
|
|
8834
9248
|
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
8835
9249
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
9250
|
+
return loggedInStatus;
|
|
9251
|
+
};
|
|
9252
|
+
const logout = async (embedConfig) => {
|
|
9253
|
+
const { thoughtSpotHost } = embedConfig;
|
|
9254
|
+
const response = await fetchLogoutService(thoughtSpotHost);
|
|
9255
|
+
loggedInStatus = false;
|
|
9256
|
+
return loggedInStatus;
|
|
8836
9257
|
};
|
|
8837
9258
|
/**
|
|
8838
9259
|
* Perform authentication on the ThoughtSpot cluster
|
|
@@ -8850,26 +9271,55 @@
|
|
|
8850
9271
|
case exports.AuthType.Basic:
|
|
8851
9272
|
return doBasicAuth(embedConfig);
|
|
8852
9273
|
default:
|
|
8853
|
-
return Promise.resolve();
|
|
9274
|
+
return Promise.resolve(true);
|
|
8854
9275
|
}
|
|
8855
9276
|
};
|
|
8856
9277
|
|
|
8857
9278
|
/* eslint-disable import/no-mutable-exports */
|
|
8858
9279
|
let config = {};
|
|
9280
|
+
const CONFIG_DEFAULTS = {
|
|
9281
|
+
loginFailedMessage: 'Not logged in',
|
|
9282
|
+
authType: exports.AuthType.None,
|
|
9283
|
+
};
|
|
8859
9284
|
let authPromise;
|
|
9285
|
+
const getEmbedConfig = () => config;
|
|
9286
|
+
const getAuthPromise = () => authPromise;
|
|
9287
|
+
let authEE;
|
|
9288
|
+
function notifyAuthSuccess() {
|
|
9289
|
+
if (!authEE) {
|
|
9290
|
+
console.error('SDK not initialized');
|
|
9291
|
+
return;
|
|
9292
|
+
}
|
|
9293
|
+
authEE.emit(exports.AuthStatus.SUCCESS);
|
|
9294
|
+
}
|
|
9295
|
+
function notifyAuthFailure(failureType) {
|
|
9296
|
+
if (!authEE) {
|
|
9297
|
+
console.error('SDK not initialized');
|
|
9298
|
+
return;
|
|
9299
|
+
}
|
|
9300
|
+
authEE.emit(exports.AuthStatus.FAILURE, failureType);
|
|
9301
|
+
}
|
|
9302
|
+
function notifyLogout() {
|
|
9303
|
+
if (!authEE) {
|
|
9304
|
+
console.error('SDK not initialized');
|
|
9305
|
+
return;
|
|
9306
|
+
}
|
|
9307
|
+
authEE.emit(exports.AuthStatus.LOGOUT);
|
|
9308
|
+
}
|
|
8860
9309
|
/**
|
|
8861
9310
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
8862
9311
|
*/
|
|
8863
9312
|
const handleAuth = () => {
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
9313
|
+
authPromise = authenticate(config);
|
|
9314
|
+
authPromise.then((isLoggedIn) => {
|
|
9315
|
+
if (!isLoggedIn) {
|
|
9316
|
+
notifyAuthFailure(exports.AuthFailureType.SDK);
|
|
9317
|
+
}
|
|
9318
|
+
}, () => {
|
|
9319
|
+
notifyAuthFailure(exports.AuthFailureType.SDK);
|
|
9320
|
+
});
|
|
8869
9321
|
return authPromise;
|
|
8870
9322
|
};
|
|
8871
|
-
const getEmbedConfig = () => config;
|
|
8872
|
-
const getAuthPromise = () => authPromise;
|
|
8873
9323
|
/**
|
|
8874
9324
|
* 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.
|
|
8875
9325
|
* @param url The URL provided for prefetch
|
|
@@ -8898,7 +9348,12 @@
|
|
|
8898
9348
|
* @returns authPromise Promise which resolves when authentication is complete.
|
|
8899
9349
|
*/
|
|
8900
9350
|
const init = (embedConfig) => {
|
|
8901
|
-
config =
|
|
9351
|
+
config = {
|
|
9352
|
+
...CONFIG_DEFAULTS,
|
|
9353
|
+
...embedConfig,
|
|
9354
|
+
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
9355
|
+
};
|
|
9356
|
+
authEE = new eventemitter3();
|
|
8902
9357
|
handleAuth();
|
|
8903
9358
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
8904
9359
|
authType: config.authType,
|
|
@@ -8907,7 +9362,19 @@
|
|
|
8907
9362
|
if (config.callPrefetch) {
|
|
8908
9363
|
prefetch(config.thoughtSpotHost);
|
|
8909
9364
|
}
|
|
8910
|
-
return
|
|
9365
|
+
return authEE;
|
|
9366
|
+
};
|
|
9367
|
+
function disableAutoLogin() {
|
|
9368
|
+
config.autoLogin = false;
|
|
9369
|
+
}
|
|
9370
|
+
const logout$1 = (doNotDisableAutoLogin = false) => {
|
|
9371
|
+
if (!doNotDisableAutoLogin) {
|
|
9372
|
+
disableAutoLogin();
|
|
9373
|
+
}
|
|
9374
|
+
return logout(config).then((isLoggedIn) => {
|
|
9375
|
+
notifyLogout();
|
|
9376
|
+
return isLoggedIn;
|
|
9377
|
+
});
|
|
8911
9378
|
};
|
|
8912
9379
|
let renderQueue = Promise.resolve();
|
|
8913
9380
|
/**
|
|
@@ -8993,6 +9460,7 @@
|
|
|
8993
9460
|
var _a, _b;
|
|
8994
9461
|
// Store user session details sent by app.
|
|
8995
9462
|
initSession(e.data);
|
|
9463
|
+
notifyAuthSuccess();
|
|
8996
9464
|
// Expose only allowed details (eg: userGUID) back to SDK users.
|
|
8997
9465
|
return {
|
|
8998
9466
|
...e,
|
|
@@ -9006,9 +9474,36 @@
|
|
|
9006
9474
|
if (autoLogin) {
|
|
9007
9475
|
handleAuth();
|
|
9008
9476
|
}
|
|
9477
|
+
notifyAuthFailure(exports.AuthFailureType.EXPIRY);
|
|
9478
|
+
return e;
|
|
9479
|
+
}
|
|
9480
|
+
function processNoCookieAccess(e, containerEl) {
|
|
9481
|
+
const { loginFailedMessage, suppressNoCookieAccessAlert, } = getEmbedConfig();
|
|
9482
|
+
if (!suppressNoCookieAccessAlert) {
|
|
9483
|
+
// eslint-disable-next-line no-alert
|
|
9484
|
+
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.');
|
|
9485
|
+
}
|
|
9486
|
+
// eslint-disable-next-line no-param-reassign
|
|
9487
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9488
|
+
notifyAuthFailure(exports.AuthFailureType.NO_COOKIE_ACCESS);
|
|
9489
|
+
return e;
|
|
9490
|
+
}
|
|
9491
|
+
function processAuthFailure(e, containerEl) {
|
|
9492
|
+
const { loginFailedMessage } = getEmbedConfig();
|
|
9493
|
+
// eslint-disable-next-line no-param-reassign
|
|
9494
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9495
|
+
notifyAuthFailure(exports.AuthFailureType.OTHER);
|
|
9009
9496
|
return e;
|
|
9010
9497
|
}
|
|
9011
|
-
function
|
|
9498
|
+
function processAuthLogout(e, containerEl) {
|
|
9499
|
+
const { loginFailedMessage } = getEmbedConfig();
|
|
9500
|
+
// eslint-disable-next-line no-param-reassign
|
|
9501
|
+
containerEl.innerHTML = loginFailedMessage;
|
|
9502
|
+
disableAutoLogin();
|
|
9503
|
+
notifyLogout();
|
|
9504
|
+
return e;
|
|
9505
|
+
}
|
|
9506
|
+
function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
9012
9507
|
switch (type) {
|
|
9013
9508
|
case exports.EmbedEvent.CustomAction:
|
|
9014
9509
|
return processCustomAction(e, thoughtSpotHost);
|
|
@@ -9016,6 +9511,12 @@
|
|
|
9016
9511
|
return processAuthInit(e);
|
|
9017
9512
|
case exports.EmbedEvent.AuthExpire:
|
|
9018
9513
|
return processAuthExpire(e);
|
|
9514
|
+
case exports.EmbedEvent.NoCookieAccess:
|
|
9515
|
+
return processNoCookieAccess(e, containerEl);
|
|
9516
|
+
case exports.EmbedEvent.AuthFailure:
|
|
9517
|
+
return processAuthFailure(e, containerEl);
|
|
9518
|
+
case exports.EmbedEvent.AuthLogout:
|
|
9519
|
+
return processAuthLogout(e, containerEl);
|
|
9019
9520
|
}
|
|
9020
9521
|
return e;
|
|
9021
9522
|
}
|
|
@@ -9044,7 +9545,7 @@
|
|
|
9044
9545
|
}
|
|
9045
9546
|
}
|
|
9046
9547
|
|
|
9047
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.10.
|
|
9548
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.10.1";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$1={".":"./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$1,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};
|
|
9048
9549
|
|
|
9049
9550
|
/**
|
|
9050
9551
|
* Copyright (c) 2022
|
|
@@ -9091,12 +9592,6 @@
|
|
|
9091
9592
|
this.isError = false;
|
|
9092
9593
|
this.viewConfig = viewConfig;
|
|
9093
9594
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
9094
|
-
if (!this.embedConfig.suppressNoCookieAccessAlert) {
|
|
9095
|
-
this.on(exports.EmbedEvent.NoCookieAccess, () => {
|
|
9096
|
-
// eslint-disable-next-line no-alert
|
|
9097
|
-
alert('Third party cookie access is blocked on this browser, please allow third party cookies for ThoughtSpot to work properly');
|
|
9098
|
-
});
|
|
9099
|
-
}
|
|
9100
9595
|
}
|
|
9101
9596
|
/**
|
|
9102
9597
|
* Gets a reference to the root DOM node where
|
|
@@ -9151,9 +9646,10 @@
|
|
|
9151
9646
|
* will be removed for ts7.oct.cl
|
|
9152
9647
|
* @hidden
|
|
9153
9648
|
*/
|
|
9154
|
-
formatEventData(event) {
|
|
9649
|
+
formatEventData(event, eventType) {
|
|
9155
9650
|
const eventData = {
|
|
9156
9651
|
...event.data,
|
|
9652
|
+
type: eventType,
|
|
9157
9653
|
};
|
|
9158
9654
|
if (!eventData.data) {
|
|
9159
9655
|
eventData.data = event.data.payload;
|
|
@@ -9170,9 +9666,9 @@
|
|
|
9170
9666
|
window.addEventListener('message', (event) => {
|
|
9171
9667
|
const eventType = this.getEventType(event);
|
|
9172
9668
|
const eventPort = this.getEventPort(event);
|
|
9173
|
-
const eventData = this.formatEventData(event);
|
|
9669
|
+
const eventData = this.formatEventData(event, eventType);
|
|
9174
9670
|
if (event.source === this.iFrame.contentWindow) {
|
|
9175
|
-
this.executeCallbacks(eventType,
|
|
9671
|
+
this.executeCallbacks(eventType, processEventData(eventType, eventData, this.thoughtSpotHost, this.el), eventPort);
|
|
9176
9672
|
}
|
|
9177
9673
|
});
|
|
9178
9674
|
}
|
|
@@ -9288,9 +9784,14 @@
|
|
|
9288
9784
|
data: {
|
|
9289
9785
|
timestamp: initTimestamp,
|
|
9290
9786
|
},
|
|
9787
|
+
type: exports.EmbedEvent.Init,
|
|
9291
9788
|
});
|
|
9292
9789
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9293
|
-
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
9790
|
+
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
|
|
9791
|
+
if (!isLoggedIn) {
|
|
9792
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9793
|
+
return;
|
|
9794
|
+
}
|
|
9294
9795
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
9295
9796
|
this.iFrame =
|
|
9296
9797
|
this.iFrame || document.createElement('iframe');
|
|
@@ -9306,7 +9807,7 @@
|
|
|
9306
9807
|
this.iFrame.mozallowfullscreen = true;
|
|
9307
9808
|
const { height: frameHeight, width: frameWidth, ...restParams } = frameOptions;
|
|
9308
9809
|
const width = getCssDimension(frameWidth || DEFAULT_EMBED_WIDTH);
|
|
9309
|
-
const height = getCssDimension(
|
|
9810
|
+
const height = getCssDimension(frameHeight || DEFAULT_EMBED_HEIGHT);
|
|
9310
9811
|
setAttributes(this.iFrame, restParams);
|
|
9311
9812
|
this.iFrame.style.width = `${width}`;
|
|
9312
9813
|
this.iFrame.style.height = `${height}`;
|
|
@@ -9319,6 +9820,7 @@
|
|
|
9319
9820
|
data: {
|
|
9320
9821
|
timestamp: loadTimestamp,
|
|
9321
9822
|
},
|
|
9823
|
+
type: exports.EmbedEvent.Load,
|
|
9322
9824
|
});
|
|
9323
9825
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_IFRAME_LOAD_PERFORMANCE, {
|
|
9324
9826
|
timeTookToLoad: loadTimestamp - initTimestamp,
|
|
@@ -9339,6 +9841,7 @@
|
|
|
9339
9841
|
}).catch((error) => {
|
|
9340
9842
|
nextInQueue();
|
|
9341
9843
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
|
|
9844
|
+
this.el.innerHTML = this.embedConfig.loginFailedMessage;
|
|
9342
9845
|
this.handleError(error);
|
|
9343
9846
|
});
|
|
9344
9847
|
});
|
|
@@ -9358,6 +9861,8 @@
|
|
|
9358
9861
|
*/
|
|
9359
9862
|
executeCallbacks(eventType, data, eventPort) {
|
|
9360
9863
|
const callbacks = this.eventHandlerMap.get(eventType) || [];
|
|
9864
|
+
const allHandlers = this.eventHandlerMap.get(exports.EmbedEvent.ALL) || [];
|
|
9865
|
+
callbacks.push(...allHandlers);
|
|
9361
9866
|
const dataStatus = (data === null || data === void 0 ? void 0 : data.status) || embedEventStatus.END;
|
|
9362
9867
|
callbacks.forEach((callbackObj) => {
|
|
9363
9868
|
if ((callbackObj.options.start &&
|
|
@@ -9524,9 +10029,9 @@
|
|
|
9524
10029
|
this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
|
|
9525
10030
|
}
|
|
9526
10031
|
// @override
|
|
9527
|
-
on(messageType, callback) {
|
|
10032
|
+
on(messageType, callback, options = { start: false }) {
|
|
9528
10033
|
const eventType = this.getCompatibleEventType(messageType);
|
|
9529
|
-
return super.on(eventType, callback);
|
|
10034
|
+
return super.on(eventType, callback, options);
|
|
9530
10035
|
}
|
|
9531
10036
|
}
|
|
9532
10037
|
|
|
@@ -9652,19 +10157,29 @@
|
|
|
9652
10157
|
/**
|
|
9653
10158
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
9654
10159
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
9655
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
10160
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
9656
10161
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
10162
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
10163
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
9657
10164
|
*/
|
|
9658
|
-
navigateToPage(path) {
|
|
9659
|
-
if (this.iFrame) {
|
|
10165
|
+
navigateToPage(path, noReload = false) {
|
|
10166
|
+
if (!this.iFrame) {
|
|
10167
|
+
console.log('Please call render before invoking this method');
|
|
10168
|
+
return;
|
|
10169
|
+
}
|
|
10170
|
+
if (noReload) {
|
|
10171
|
+
this.trigger(exports.HostEvent.Navigate, path);
|
|
10172
|
+
}
|
|
10173
|
+
else {
|
|
10174
|
+
if (typeof path !== 'string') {
|
|
10175
|
+
console.warn('Path can only by a string when triggered without noReload');
|
|
10176
|
+
return;
|
|
10177
|
+
}
|
|
9660
10178
|
const iframeSrc = this.iFrame.src;
|
|
9661
10179
|
const embedPath = '#/embed';
|
|
9662
10180
|
const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
|
|
9663
10181
|
this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
9664
10182
|
}
|
|
9665
|
-
else {
|
|
9666
|
-
console.log('Please call render before invoking this method');
|
|
9667
|
-
}
|
|
9668
10183
|
}
|
|
9669
10184
|
/**
|
|
9670
10185
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
@@ -9845,7 +10360,7 @@
|
|
|
9845
10360
|
*/
|
|
9846
10361
|
getIFrameSrc(answerId, dataSources) {
|
|
9847
10362
|
var _a;
|
|
9848
|
-
const { hideResults, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
10363
|
+
const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, } = this.viewConfig;
|
|
9849
10364
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
9850
10365
|
const queryParams = this.getBaseQueryParams();
|
|
9851
10366
|
queryParams[Param.HideActions] = [
|
|
@@ -9898,6 +10413,7 @@
|
|
|
9898
10413
|
exports.PinboardEmbed = PinboardEmbed;
|
|
9899
10414
|
exports.SearchEmbed = SearchEmbed;
|
|
9900
10415
|
exports.init = init;
|
|
10416
|
+
exports.logout = logout$1;
|
|
9901
10417
|
exports.prefetch = prefetch;
|
|
9902
10418
|
|
|
9903
10419
|
Object.defineProperty(exports, '__esModule', { value: true });
|