@thoughtspot/visual-embed-sdk 1.28.1-alpha.1 → 1.28.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/README.md +1 -1
- package/cjs/package.json +1 -1
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +2 -2
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/authToken.d.ts +5 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +5 -1
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/embed/app.d.ts +6 -12
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +2 -2
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +6 -6
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -1
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +2 -8
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/search.d.ts +5 -11
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -4
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +6 -6
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +18 -9
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/index.spec.js +12 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +14 -21
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +3 -11
- package/cjs/src/types.js.map +1 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +5 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +6 -12
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -8
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +5 -11
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/types.d.ts +14 -21
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1451 -1455
- package/dist/tsembed-react.js +2224 -2228
- package/dist/tsembed.es.js +1834 -1838
- package/dist/tsembed.js +15354 -15358
- package/dist/visual-embed-sdk-react-full.d.ts +30 -51
- package/dist/visual-embed-sdk-react.d.ts +30 -51
- package/dist/visual-embed-sdk.d.ts +30 -51
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +3 -3
- package/lib/src/auth.js.map +1 -1
- package/lib/src/authToken.d.ts +5 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +5 -1
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/embed/app.d.ts +6 -12
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +2 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +5 -5
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +2 -8
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/search.d.ts +5 -11
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +5 -5
- 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.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +9 -9
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +18 -9
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/index.spec.js +12 -0
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +14 -21
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +3 -11
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +1 -1
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +34 -55
- package/package.json +1 -1
- package/src/auth.ts +6 -6
- package/src/authToken.ts +5 -1
- package/src/embed/app.ts +8 -19
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/base.ts +14 -14
- package/src/embed/liveboard.ts +3 -16
- package/src/embed/search.ts +10 -19
- package/src/embed/ts-embed.spec.ts +34 -26
- package/src/embed/ts-embed.ts +39 -43
- package/src/react/all-types-export.ts +1 -0
- package/src/react/index.spec.tsx +29 -0
- package/src/types.ts +15 -22
- package/src/utils/authService/authService.spec.ts +4 -4
package/dist/tsembed.es.js
CHANGED
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if `value` is `undefined`.
|
|
3
|
-
*
|
|
4
|
-
* @static
|
|
5
|
-
* @since 0.1.0
|
|
6
|
-
* @memberOf _
|
|
7
|
-
* @category Lang
|
|
8
|
-
* @param {*} value The value to check.
|
|
9
|
-
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* _.isUndefined(void 0);
|
|
13
|
-
* // => true
|
|
14
|
-
*
|
|
15
|
-
* _.isUndefined(null);
|
|
16
|
-
* // => false
|
|
17
|
-
*/
|
|
18
|
-
function isUndefined(value) {
|
|
19
|
-
return value === undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var isUndefined_1 = isUndefined;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This method returns `undefined`.
|
|
26
|
-
*
|
|
27
|
-
* @static
|
|
28
|
-
* @memberOf _
|
|
29
|
-
* @since 2.3.0
|
|
30
|
-
* @category Util
|
|
31
|
-
* @example
|
|
32
|
-
*
|
|
33
|
-
* _.times(2, _.noop);
|
|
34
|
-
* // => [undefined, undefined]
|
|
35
|
-
*/
|
|
36
|
-
function noop() {
|
|
37
|
-
// No operation performed.
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var noop_1 = noop;
|
|
41
|
-
|
|
42
1
|
/**
|
|
43
2
|
* Copyright (c) 2023
|
|
44
3
|
*
|
|
@@ -184,6 +143,7 @@ var AuthType;
|
|
|
184
143
|
* .then((data) => data.token);
|
|
185
144
|
* }
|
|
186
145
|
* });
|
|
146
|
+
* });
|
|
187
147
|
* ```
|
|
188
148
|
*/
|
|
189
149
|
AuthType["TrustedAuthToken"] = "AuthServer";
|
|
@@ -558,7 +518,8 @@ var EmbedEvent;
|
|
|
558
518
|
*
|
|
559
519
|
* API - API call failure error.
|
|
560
520
|
*
|
|
561
|
-
* FULLSCREEN - Error when presenting a Liveboard or visualization in full screen
|
|
521
|
+
* FULLSCREEN - Error when presenting a Liveboard or visualization in full screen
|
|
522
|
+
* mode.
|
|
562
523
|
*
|
|
563
524
|
* SINGLE_VALUE_FILTER - Error due to multiple values in the single value filter.
|
|
564
525
|
*
|
|
@@ -3108,16 +3069,6 @@ var Action;
|
|
|
3108
3069
|
* @version SDK : 1.27.9 | Thoughtspot: 9.12.5.cl
|
|
3109
3070
|
*/
|
|
3110
3071
|
Action["CopyKpiLink"] = "copyKpiLink";
|
|
3111
|
-
/**
|
|
3112
|
-
* The **Organise Favourites** action on Homepage Favourite Module.
|
|
3113
|
-
*
|
|
3114
|
-
* @example
|
|
3115
|
-
* ```js
|
|
3116
|
-
* disabledActions: [Action.OrganiseFavourites]
|
|
3117
|
-
* ```
|
|
3118
|
-
* @version SDK : 1.32.0 | Thoughtspot: 10.0.0.cl
|
|
3119
|
-
*/
|
|
3120
|
-
Action["OrganiseFavourites"] = "organiseFavourites";
|
|
3121
3072
|
/**
|
|
3122
3073
|
* Action ID for AI Highlights button
|
|
3123
3074
|
*
|
|
@@ -3226,76 +3177,6 @@ var LogLevel;
|
|
|
3226
3177
|
LogLevel["TRACE"] = "TRACE";
|
|
3227
3178
|
})(LogLevel || (LogLevel = {}));
|
|
3228
3179
|
|
|
3229
|
-
const logFunctions = {
|
|
3230
|
-
[LogLevel.SILENT]: noop_1,
|
|
3231
|
-
[LogLevel.ERROR]: console.error,
|
|
3232
|
-
[LogLevel.WARN]: console.warn,
|
|
3233
|
-
[LogLevel.INFO]: console.info,
|
|
3234
|
-
[LogLevel.DEBUG]: console.debug,
|
|
3235
|
-
[LogLevel.TRACE]: console.trace,
|
|
3236
|
-
};
|
|
3237
|
-
let globalLogLevelOverride = LogLevel.TRACE;
|
|
3238
|
-
const setGlobalLogLevelOverride = (logLevel) => {
|
|
3239
|
-
globalLogLevelOverride = logLevel;
|
|
3240
|
-
};
|
|
3241
|
-
const logLevelToNumber = {
|
|
3242
|
-
[LogLevel.SILENT]: 0,
|
|
3243
|
-
[LogLevel.ERROR]: 1,
|
|
3244
|
-
[LogLevel.WARN]: 2,
|
|
3245
|
-
[LogLevel.INFO]: 3,
|
|
3246
|
-
[LogLevel.DEBUG]: 4,
|
|
3247
|
-
[LogLevel.TRACE]: 5,
|
|
3248
|
-
};
|
|
3249
|
-
const compareLogLevels = (logLevel1, logLevel2) => {
|
|
3250
|
-
const logLevel1Index = logLevelToNumber[logLevel1];
|
|
3251
|
-
const logLevel2Index = logLevelToNumber[logLevel2];
|
|
3252
|
-
return logLevel1Index - logLevel2Index;
|
|
3253
|
-
};
|
|
3254
|
-
class Logger {
|
|
3255
|
-
constructor() {
|
|
3256
|
-
this.logLevel = LogLevel.ERROR;
|
|
3257
|
-
this.setLogLevel = (newLogLevel) => {
|
|
3258
|
-
this.logLevel = newLogLevel;
|
|
3259
|
-
};
|
|
3260
|
-
this.getLogLevel = () => this.logLevel;
|
|
3261
|
-
}
|
|
3262
|
-
canLog(logLevel) {
|
|
3263
|
-
if (logLevel === LogLevel.SILENT)
|
|
3264
|
-
return false;
|
|
3265
|
-
if (!isUndefined_1(globalLogLevelOverride)) {
|
|
3266
|
-
return compareLogLevels(globalLogLevelOverride, logLevel) >= 0;
|
|
3267
|
-
}
|
|
3268
|
-
return compareLogLevels(this.logLevel, logLevel) >= 0;
|
|
3269
|
-
}
|
|
3270
|
-
logMessages(args, logLevel) {
|
|
3271
|
-
if (this.canLog(logLevel)) {
|
|
3272
|
-
const logFn = logFunctions[logLevel];
|
|
3273
|
-
if (logFn) {
|
|
3274
|
-
logFn(...args);
|
|
3275
|
-
}
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
log(...args) {
|
|
3279
|
-
this.info(args);
|
|
3280
|
-
}
|
|
3281
|
-
info(...args) {
|
|
3282
|
-
this.logMessages(args, LogLevel.INFO);
|
|
3283
|
-
}
|
|
3284
|
-
debug(...args) {
|
|
3285
|
-
this.logMessages(args, LogLevel.DEBUG);
|
|
3286
|
-
}
|
|
3287
|
-
trace(...args) {
|
|
3288
|
-
this.logMessages(args, LogLevel.TRACE);
|
|
3289
|
-
}
|
|
3290
|
-
error(...args) {
|
|
3291
|
-
this.logMessages(args, LogLevel.ERROR);
|
|
3292
|
-
}
|
|
3293
|
-
warn(...args) {
|
|
3294
|
-
this.logMessages(args, LogLevel.WARN);
|
|
3295
|
-
}
|
|
3296
|
-
}
|
|
3297
|
-
const logger = new Logger();
|
|
3298
|
-
|
|
3299
3180
|
// istanbul ignore next
|
|
3300
3181
|
const isObject = (obj) => {
|
|
3301
3182
|
if (typeof obj === "object" && obj !== null) {
|
|
@@ -3601,7 +3482,118 @@ const removeStyleProperties = (element, styleProperties) => {
|
|
|
3601
3482
|
element.style.removeProperty(styleProperty);
|
|
3602
3483
|
});
|
|
3603
3484
|
};
|
|
3604
|
-
const isUndefined
|
|
3485
|
+
const isUndefined = (value) => value === undefined;
|
|
3486
|
+
|
|
3487
|
+
/**
|
|
3488
|
+
* Checks if `value` is `undefined`.
|
|
3489
|
+
*
|
|
3490
|
+
* @static
|
|
3491
|
+
* @since 0.1.0
|
|
3492
|
+
* @memberOf _
|
|
3493
|
+
* @category Lang
|
|
3494
|
+
* @param {*} value The value to check.
|
|
3495
|
+
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
|
3496
|
+
* @example
|
|
3497
|
+
*
|
|
3498
|
+
* _.isUndefined(void 0);
|
|
3499
|
+
* // => true
|
|
3500
|
+
*
|
|
3501
|
+
* _.isUndefined(null);
|
|
3502
|
+
* // => false
|
|
3503
|
+
*/
|
|
3504
|
+
function isUndefined$1(value) {
|
|
3505
|
+
return value === undefined;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
var isUndefined_1 = isUndefined$1;
|
|
3509
|
+
|
|
3510
|
+
/**
|
|
3511
|
+
* This method returns `undefined`.
|
|
3512
|
+
*
|
|
3513
|
+
* @static
|
|
3514
|
+
* @memberOf _
|
|
3515
|
+
* @since 2.3.0
|
|
3516
|
+
* @category Util
|
|
3517
|
+
* @example
|
|
3518
|
+
*
|
|
3519
|
+
* _.times(2, _.noop);
|
|
3520
|
+
* // => [undefined, undefined]
|
|
3521
|
+
*/
|
|
3522
|
+
function noop() {
|
|
3523
|
+
// No operation performed.
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3526
|
+
var noop_1 = noop;
|
|
3527
|
+
|
|
3528
|
+
const logFunctions = {
|
|
3529
|
+
[LogLevel.SILENT]: noop_1,
|
|
3530
|
+
[LogLevel.ERROR]: console.error,
|
|
3531
|
+
[LogLevel.WARN]: console.warn,
|
|
3532
|
+
[LogLevel.INFO]: console.info,
|
|
3533
|
+
[LogLevel.DEBUG]: console.debug,
|
|
3534
|
+
[LogLevel.TRACE]: console.trace,
|
|
3535
|
+
};
|
|
3536
|
+
let globalLogLevelOverride = LogLevel.TRACE;
|
|
3537
|
+
const setGlobalLogLevelOverride = (logLevel) => {
|
|
3538
|
+
globalLogLevelOverride = logLevel;
|
|
3539
|
+
};
|
|
3540
|
+
const logLevelToNumber = {
|
|
3541
|
+
[LogLevel.SILENT]: 0,
|
|
3542
|
+
[LogLevel.ERROR]: 1,
|
|
3543
|
+
[LogLevel.WARN]: 2,
|
|
3544
|
+
[LogLevel.INFO]: 3,
|
|
3545
|
+
[LogLevel.DEBUG]: 4,
|
|
3546
|
+
[LogLevel.TRACE]: 5,
|
|
3547
|
+
};
|
|
3548
|
+
const compareLogLevels = (logLevel1, logLevel2) => {
|
|
3549
|
+
const logLevel1Index = logLevelToNumber[logLevel1];
|
|
3550
|
+
const logLevel2Index = logLevelToNumber[logLevel2];
|
|
3551
|
+
return logLevel1Index - logLevel2Index;
|
|
3552
|
+
};
|
|
3553
|
+
class Logger {
|
|
3554
|
+
constructor() {
|
|
3555
|
+
this.logLevel = LogLevel.ERROR;
|
|
3556
|
+
this.setLogLevel = (newLogLevel) => {
|
|
3557
|
+
this.logLevel = newLogLevel;
|
|
3558
|
+
};
|
|
3559
|
+
this.getLogLevel = () => this.logLevel;
|
|
3560
|
+
}
|
|
3561
|
+
canLog(logLevel) {
|
|
3562
|
+
if (logLevel === LogLevel.SILENT)
|
|
3563
|
+
return false;
|
|
3564
|
+
if (!isUndefined_1(globalLogLevelOverride)) {
|
|
3565
|
+
return compareLogLevels(globalLogLevelOverride, logLevel) >= 0;
|
|
3566
|
+
}
|
|
3567
|
+
return compareLogLevels(this.logLevel, logLevel) >= 0;
|
|
3568
|
+
}
|
|
3569
|
+
logMessages(args, logLevel) {
|
|
3570
|
+
if (this.canLog(logLevel)) {
|
|
3571
|
+
const logFn = logFunctions[logLevel];
|
|
3572
|
+
if (logFn) {
|
|
3573
|
+
logFn(...args);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
log(...args) {
|
|
3578
|
+
this.info(args);
|
|
3579
|
+
}
|
|
3580
|
+
info(...args) {
|
|
3581
|
+
this.logMessages(args, LogLevel.INFO);
|
|
3582
|
+
}
|
|
3583
|
+
debug(...args) {
|
|
3584
|
+
this.logMessages(args, LogLevel.DEBUG);
|
|
3585
|
+
}
|
|
3586
|
+
trace(...args) {
|
|
3587
|
+
this.logMessages(args, LogLevel.TRACE);
|
|
3588
|
+
}
|
|
3589
|
+
error(...args) {
|
|
3590
|
+
this.logMessages(args, LogLevel.ERROR);
|
|
3591
|
+
}
|
|
3592
|
+
warn(...args) {
|
|
3593
|
+
this.logMessages(args, LogLevel.WARN);
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
const logger = new Logger();
|
|
3605
3597
|
|
|
3606
3598
|
/**
|
|
3607
3599
|
* Removes all key-value entries from the list cache.
|
|
@@ -5808,6 +5800,8 @@ function isEqual(value, other) {
|
|
|
5808
5800
|
|
|
5809
5801
|
var isEqual_1 = isEqual;
|
|
5810
5802
|
|
|
5803
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.28.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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",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-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",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 --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","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",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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","current-git-branch":"^1.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.13.1","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":"6.7.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","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,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"45 kB"}],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};
|
|
5804
|
+
|
|
5811
5805
|
const EndPoints = {
|
|
5812
5806
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
5813
5807
|
SAML_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
@@ -5975,801 +5969,252 @@ const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
|
|
|
5975
5969
|
/**
|
|
5976
5970
|
* Resets the auth token and a new token will be fetched on the next request.
|
|
5977
5971
|
*
|
|
5978
|
-
* @
|
|
5972
|
+
* @example
|
|
5973
|
+
* ```js
|
|
5974
|
+
* resetCachedAuthToken();
|
|
5975
|
+
* ```
|
|
5976
|
+
* @version SDK: 1.28.2 | ThoughtSpot: *
|
|
5979
5977
|
* @group Authentication / Init
|
|
5980
5978
|
*/
|
|
5981
5979
|
const resetCachedAuthToken = () => {
|
|
5982
5980
|
cachedAuthToken = null;
|
|
5983
5981
|
};
|
|
5984
5982
|
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
*
|
|
5989
|
-
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
5990
|
-
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
5991
|
-
* @group Global methods
|
|
5992
|
-
*/
|
|
5993
|
-
const getEmbedConfig = () => config;
|
|
5994
|
-
/**
|
|
5995
|
-
* Sets the configuration embed was initialized with.
|
|
5996
|
-
* And returns the new configuration.
|
|
5997
|
-
*
|
|
5998
|
-
* @param newConfig The configuration to set.
|
|
5999
|
-
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
6000
|
-
* @group Global methods
|
|
6001
|
-
*/
|
|
6002
|
-
const setEmbedConfig = (newConfig) => {
|
|
6003
|
-
config = newConfig;
|
|
6004
|
-
return newConfig;
|
|
5983
|
+
var Config = {
|
|
5984
|
+
DEBUG: false,
|
|
5985
|
+
LIB_VERSION: '2.45.0'
|
|
6005
5986
|
};
|
|
6006
5987
|
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
6025
|
-
}
|
|
6026
|
-
return fetch(req);
|
|
6027
|
-
};
|
|
6028
|
-
|
|
6029
|
-
/**
|
|
6030
|
-
*
|
|
6031
|
-
* @param root0
|
|
6032
|
-
* @param root0.query
|
|
6033
|
-
* @param root0.variables
|
|
6034
|
-
* @param root0.thoughtSpotHost
|
|
6035
|
-
* @param root0.isCompositeQuery
|
|
6036
|
-
*/
|
|
6037
|
-
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
6038
|
-
const operationName = getOperationNameFromQuery(query);
|
|
6039
|
-
try {
|
|
6040
|
-
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
6041
|
-
method: 'POST',
|
|
6042
|
-
headers: {
|
|
6043
|
-
'content-type': 'application/json;charset=UTF-8',
|
|
6044
|
-
'x-requested-by': 'ThoughtSpot',
|
|
6045
|
-
accept: '*/*',
|
|
6046
|
-
'accept-language': 'en-us',
|
|
6047
|
-
},
|
|
6048
|
-
body: JSON.stringify({
|
|
6049
|
-
operationName,
|
|
6050
|
-
query,
|
|
6051
|
-
variables,
|
|
6052
|
-
}),
|
|
6053
|
-
credentials: 'include',
|
|
6054
|
-
});
|
|
6055
|
-
const result = await response.json();
|
|
6056
|
-
const dataValues = Object.values(result.data);
|
|
6057
|
-
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
6058
|
-
}
|
|
6059
|
-
catch (error) {
|
|
6060
|
-
return error;
|
|
6061
|
-
}
|
|
5988
|
+
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
5989
|
+
var window$1;
|
|
5990
|
+
if (typeof(window) === 'undefined') {
|
|
5991
|
+
var loc = {
|
|
5992
|
+
hostname: ''
|
|
5993
|
+
};
|
|
5994
|
+
window$1 = {
|
|
5995
|
+
navigator: { userAgent: '' },
|
|
5996
|
+
document: {
|
|
5997
|
+
location: loc,
|
|
5998
|
+
referrer: ''
|
|
5999
|
+
},
|
|
6000
|
+
screen: { width: 0, height: 0 },
|
|
6001
|
+
location: loc
|
|
6002
|
+
};
|
|
6003
|
+
} else {
|
|
6004
|
+
window$1 = window;
|
|
6062
6005
|
}
|
|
6063
6006
|
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6007
|
+
/*
|
|
6008
|
+
* Saved references to long variable names, so that closure compiler can
|
|
6009
|
+
* minimize file size.
|
|
6010
|
+
*/
|
|
6011
|
+
|
|
6012
|
+
var ArrayProto = Array.prototype;
|
|
6013
|
+
var FuncProto = Function.prototype;
|
|
6014
|
+
var ObjProto = Object.prototype;
|
|
6015
|
+
var slice = ArrayProto.slice;
|
|
6016
|
+
var toString = ObjProto.toString;
|
|
6017
|
+
var hasOwnProperty$9 = ObjProto.hasOwnProperty;
|
|
6018
|
+
var windowConsole = window$1.console;
|
|
6019
|
+
var navigator = window$1.navigator;
|
|
6020
|
+
var document$1 = window$1.document;
|
|
6021
|
+
var windowOpera = window$1.opera;
|
|
6022
|
+
var screen = window$1.screen;
|
|
6023
|
+
var userAgent = navigator.userAgent;
|
|
6024
|
+
var nativeBind = FuncProto.bind;
|
|
6025
|
+
var nativeForEach = ArrayProto.forEach;
|
|
6026
|
+
var nativeIndexOf = ArrayProto.indexOf;
|
|
6027
|
+
var nativeMap = ArrayProto.map;
|
|
6028
|
+
var nativeIsArray = Array.isArray;
|
|
6029
|
+
var breaker = {};
|
|
6030
|
+
var _ = {
|
|
6031
|
+
trim: function(str) {
|
|
6032
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6033
|
+
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6034
|
+
}
|
|
6035
|
+
};
|
|
6036
|
+
|
|
6037
|
+
// Console override
|
|
6038
|
+
var console$1 = {
|
|
6039
|
+
/** @type {function(...*)} */
|
|
6040
|
+
log: function() {
|
|
6041
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6042
|
+
try {
|
|
6043
|
+
windowConsole.log.apply(windowConsole, arguments);
|
|
6044
|
+
} catch (err) {
|
|
6045
|
+
_.each(arguments, function(arg) {
|
|
6046
|
+
windowConsole.log(arg);
|
|
6047
|
+
});
|
|
6094
6048
|
}
|
|
6095
|
-
synonyms
|
|
6096
|
-
cohortAnswerId
|
|
6097
|
-
__typename
|
|
6098
6049
|
}
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6050
|
+
},
|
|
6051
|
+
/** @type {function(...*)} */
|
|
6052
|
+
warn: function() {
|
|
6053
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6054
|
+
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6055
|
+
try {
|
|
6056
|
+
windowConsole.warn.apply(windowConsole, args);
|
|
6057
|
+
} catch (err) {
|
|
6058
|
+
_.each(args, function(arg) {
|
|
6059
|
+
windowConsole.warn(arg);
|
|
6060
|
+
});
|
|
6061
|
+
}
|
|
6103
6062
|
}
|
|
6104
|
-
}
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
}
|
|
6116
|
-
const details = await graphqlQuery({
|
|
6117
|
-
query: getSourceDetailQuery,
|
|
6118
|
-
variables: {
|
|
6119
|
-
ids: [sourceId],
|
|
6120
|
-
},
|
|
6121
|
-
thoughtSpotHost,
|
|
6122
|
-
});
|
|
6123
|
-
const souceDetails = details[0];
|
|
6124
|
-
if (souceDetails) {
|
|
6125
|
-
sourceDetailCache.set(sourceId, souceDetails);
|
|
6126
|
-
}
|
|
6127
|
-
return souceDetails;
|
|
6128
|
-
}
|
|
6129
|
-
|
|
6130
|
-
const bachSessionId = `
|
|
6131
|
-
id {
|
|
6132
|
-
sessionId
|
|
6133
|
-
genNo
|
|
6134
|
-
acSession {
|
|
6135
|
-
sessionId
|
|
6136
|
-
genNo
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
`;
|
|
6140
|
-
const getUnaggregatedAnswerSession = `
|
|
6141
|
-
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
6142
|
-
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
6143
|
-
${bachSessionId}
|
|
6144
|
-
answer {
|
|
6145
|
-
visualizations {
|
|
6146
|
-
... on TableViz {
|
|
6147
|
-
columns {
|
|
6148
|
-
column {
|
|
6149
|
-
id
|
|
6150
|
-
name
|
|
6151
|
-
referencedColumns {
|
|
6152
|
-
guid
|
|
6153
|
-
displayName
|
|
6154
|
-
}
|
|
6155
|
-
}
|
|
6156
|
-
}
|
|
6157
|
-
}
|
|
6063
|
+
},
|
|
6064
|
+
/** @type {function(...*)} */
|
|
6065
|
+
error: function() {
|
|
6066
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6067
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6068
|
+
try {
|
|
6069
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6070
|
+
} catch (err) {
|
|
6071
|
+
_.each(args, function(arg) {
|
|
6072
|
+
windowConsole.error(arg);
|
|
6073
|
+
});
|
|
6158
6074
|
}
|
|
6159
6075
|
}
|
|
6160
|
-
}
|
|
6161
|
-
}
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
}
|
|
6173
|
-
`;
|
|
6174
|
-
const addColumns = `
|
|
6175
|
-
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
6176
|
-
Answer__addColumn(session: $session, columns: $columns) {
|
|
6177
|
-
${bachSessionId}
|
|
6076
|
+
},
|
|
6077
|
+
/** @type {function(...*)} */
|
|
6078
|
+
critical: function() {
|
|
6079
|
+
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6080
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6081
|
+
try {
|
|
6082
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6083
|
+
} catch (err) {
|
|
6084
|
+
_.each(args, function(arg) {
|
|
6085
|
+
windowConsole.error(arg);
|
|
6086
|
+
});
|
|
6087
|
+
}
|
|
6178
6088
|
}
|
|
6179
6089
|
}
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6090
|
+
};
|
|
6091
|
+
|
|
6092
|
+
var log_func_with_prefix = function(func, prefix) {
|
|
6093
|
+
return function() {
|
|
6094
|
+
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6095
|
+
return func.apply(console$1, arguments);
|
|
6096
|
+
};
|
|
6097
|
+
};
|
|
6098
|
+
var console_with_prefix = function(prefix) {
|
|
6099
|
+
return {
|
|
6100
|
+
log: log_func_with_prefix(console$1.log, prefix),
|
|
6101
|
+
error: log_func_with_prefix(console$1.error, prefix),
|
|
6102
|
+
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6103
|
+
};
|
|
6104
|
+
};
|
|
6105
|
+
|
|
6106
|
+
|
|
6107
|
+
// UNDERSCORE
|
|
6108
|
+
// Embed part of the Underscore Library
|
|
6109
|
+
_.bind = function(func, context) {
|
|
6110
|
+
var args, bound;
|
|
6111
|
+
if (nativeBind && func.bind === nativeBind) {
|
|
6112
|
+
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6113
|
+
}
|
|
6114
|
+
if (!_.isFunction(func)) {
|
|
6115
|
+
throw new TypeError();
|
|
6116
|
+
}
|
|
6117
|
+
args = slice.call(arguments, 2);
|
|
6118
|
+
bound = function() {
|
|
6119
|
+
if (!(this instanceof bound)) {
|
|
6120
|
+
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6121
|
+
}
|
|
6122
|
+
var ctor = {};
|
|
6123
|
+
ctor.prototype = func.prototype;
|
|
6124
|
+
var self = new ctor();
|
|
6125
|
+
ctor.prototype = null;
|
|
6126
|
+
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6127
|
+
if (Object(result) === result) {
|
|
6128
|
+
return result;
|
|
6129
|
+
}
|
|
6130
|
+
return self;
|
|
6131
|
+
};
|
|
6132
|
+
return bound;
|
|
6133
|
+
};
|
|
6134
|
+
|
|
6135
|
+
/**
|
|
6136
|
+
* @param {*=} obj
|
|
6137
|
+
* @param {function(...*)=} iterator
|
|
6138
|
+
* @param {Object=} context
|
|
6139
|
+
*/
|
|
6140
|
+
_.each = function(obj, iterator, context) {
|
|
6141
|
+
if (obj === null || obj === undefined) {
|
|
6142
|
+
return;
|
|
6143
|
+
}
|
|
6144
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6145
|
+
obj.forEach(iterator, context);
|
|
6146
|
+
} else if (obj.length === +obj.length) {
|
|
6147
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6148
|
+
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6149
|
+
return;
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6152
|
+
} else {
|
|
6153
|
+
for (var key in obj) {
|
|
6154
|
+
if (hasOwnProperty$9.call(obj, key)) {
|
|
6155
|
+
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6156
|
+
return;
|
|
6201
6157
|
}
|
|
6202
6158
|
}
|
|
6203
6159
|
}
|
|
6204
6160
|
}
|
|
6205
|
-
|
|
6161
|
+
};
|
|
6206
6162
|
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
(
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
}
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
* graphql queries in the context of the answer on which the
|
|
6217
|
-
* custom action was triggered.
|
|
6218
|
-
*
|
|
6219
|
-
* @example
|
|
6220
|
-
* ```js
|
|
6221
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6222
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6223
|
-
* 'col name 1'
|
|
6224
|
-
* ]);
|
|
6225
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6226
|
-
* })
|
|
6227
|
-
* ```
|
|
6228
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6229
|
-
* @group Events
|
|
6230
|
-
*/
|
|
6231
|
-
class AnswerService {
|
|
6232
|
-
/**
|
|
6233
|
-
* Should not need to be called directly.
|
|
6234
|
-
*
|
|
6235
|
-
* @param session
|
|
6236
|
-
* @param answer
|
|
6237
|
-
* @param thoughtSpotHost
|
|
6238
|
-
* @param selectedPoints
|
|
6239
|
-
*/
|
|
6240
|
-
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
6241
|
-
this.session = session;
|
|
6242
|
-
this.answer = answer;
|
|
6243
|
-
this.thoughtSpotHost = thoughtSpotHost;
|
|
6244
|
-
this.selectedPoints = selectedPoints;
|
|
6245
|
-
this.session = removeTypename(session);
|
|
6246
|
-
}
|
|
6247
|
-
/**
|
|
6248
|
-
* Get the details about the source used in the answer.
|
|
6249
|
-
* This can be used to get the list of all columns in the data source for example.
|
|
6250
|
-
*/
|
|
6251
|
-
async getSourceDetail() {
|
|
6252
|
-
const sourceId = this.answer.sources[0].header.guid;
|
|
6253
|
-
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
6254
|
-
}
|
|
6255
|
-
/**
|
|
6256
|
-
* Remove columnIds and return updated answer session.
|
|
6257
|
-
*
|
|
6258
|
-
* @param columnIds
|
|
6259
|
-
* @returns
|
|
6260
|
-
*/
|
|
6261
|
-
async removeColumns(columnIds) {
|
|
6262
|
-
return this.executeQuery(removeColumns, {
|
|
6263
|
-
logicalColumnIds: columnIds,
|
|
6264
|
-
});
|
|
6265
|
-
}
|
|
6266
|
-
/**
|
|
6267
|
-
* Add columnIds and return updated answer session.
|
|
6268
|
-
*
|
|
6269
|
-
* @param columnIds
|
|
6270
|
-
* @returns
|
|
6271
|
-
*/
|
|
6272
|
-
async addColumns(columnIds) {
|
|
6273
|
-
return this.executeQuery(addColumns, {
|
|
6274
|
-
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
6275
|
-
});
|
|
6276
|
-
}
|
|
6277
|
-
/**
|
|
6278
|
-
* Fetch data from the answer.
|
|
6279
|
-
*
|
|
6280
|
-
* @param offset
|
|
6281
|
-
* @param size
|
|
6282
|
-
* @returns
|
|
6283
|
-
*/
|
|
6284
|
-
async fetchData(offset = 0, size = 1000) {
|
|
6285
|
-
const { answer } = await this.executeQuery(getAnswerData, {
|
|
6286
|
-
deadline: 0,
|
|
6287
|
-
dataPaginationParams: {
|
|
6288
|
-
isClientPaginated: true,
|
|
6289
|
-
offset,
|
|
6290
|
-
size,
|
|
6291
|
-
},
|
|
6292
|
-
});
|
|
6293
|
-
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
6294
|
-
return {
|
|
6295
|
-
columns,
|
|
6296
|
-
data,
|
|
6297
|
-
};
|
|
6298
|
-
}
|
|
6299
|
-
/**
|
|
6300
|
-
* Fetch the data for the answer as a CSV blob. This might be
|
|
6301
|
-
* quicker for larger data.
|
|
6302
|
-
*
|
|
6303
|
-
* @param userLocale
|
|
6304
|
-
* @param includeInfo Include the CSV header in the output
|
|
6305
|
-
* @returns Response
|
|
6306
|
-
*/
|
|
6307
|
-
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
6308
|
-
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
6309
|
-
return tokenizedFetch(fetchUrl, {
|
|
6310
|
-
credentials: 'include',
|
|
6311
|
-
});
|
|
6312
|
-
}
|
|
6313
|
-
/**
|
|
6314
|
-
* Just get the internal URL for this answer's data
|
|
6315
|
-
* as a CSV blob.
|
|
6316
|
-
*
|
|
6317
|
-
* @param userLocale
|
|
6318
|
-
* @param includeInfo
|
|
6319
|
-
* @returns
|
|
6320
|
-
*/
|
|
6321
|
-
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
6322
|
-
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
6323
|
-
}
|
|
6324
|
-
/**
|
|
6325
|
-
* Get underlying data given a point and the output column names.
|
|
6326
|
-
* In case of a context menu action, the selectedPoints are
|
|
6327
|
-
* automatically passed.
|
|
6328
|
-
*
|
|
6329
|
-
* @param outputColumnNames
|
|
6330
|
-
* @param selectedPoints
|
|
6331
|
-
* @example
|
|
6332
|
-
* ```js
|
|
6333
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6334
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6335
|
-
* 'col name 1' // The column should exist in the data source.
|
|
6336
|
-
* ]);
|
|
6337
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6338
|
-
* })
|
|
6339
|
-
* ```
|
|
6340
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6341
|
-
*/
|
|
6342
|
-
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
6343
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
6344
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
6345
|
-
}
|
|
6346
|
-
if (!selectedPoints) {
|
|
6347
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
6348
|
-
}
|
|
6349
|
-
const sourceDetail = await this.getSourceDetail();
|
|
6350
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
6351
|
-
const unAggAnswer = await graphqlQuery({
|
|
6352
|
-
query: getUnaggregatedAnswerSession,
|
|
6353
|
-
variables: {
|
|
6354
|
-
session: this.session,
|
|
6355
|
-
columns: selectedPoints,
|
|
6356
|
-
},
|
|
6357
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6358
|
-
});
|
|
6359
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
6360
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
6361
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
6362
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
6363
|
-
if (columnsToAdd.length) {
|
|
6364
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
6365
|
-
}
|
|
6366
|
-
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
6367
|
-
if (columnsToRemove.length) {
|
|
6368
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
6369
|
-
}
|
|
6370
|
-
return unaggAnswerSession;
|
|
6371
|
-
}
|
|
6372
|
-
/**
|
|
6373
|
-
* Execute a custom graphql query in the context of the answer.
|
|
6374
|
-
*
|
|
6375
|
-
* @param query graphql query
|
|
6376
|
-
* @param variables graphql variables
|
|
6377
|
-
* @returns
|
|
6378
|
-
*/
|
|
6379
|
-
async executeQuery(query, variables) {
|
|
6380
|
-
const data = await graphqlQuery({
|
|
6381
|
-
query,
|
|
6382
|
-
variables: {
|
|
6383
|
-
session: this.session,
|
|
6384
|
-
...variables,
|
|
6385
|
-
},
|
|
6386
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6387
|
-
isCompositeQuery: false,
|
|
6388
|
-
});
|
|
6389
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
6390
|
-
return data;
|
|
6391
|
-
}
|
|
6392
|
-
/**
|
|
6393
|
-
* Get the internal session details for the answer.
|
|
6394
|
-
*
|
|
6395
|
-
* @returns
|
|
6396
|
-
*/
|
|
6397
|
-
getSession() {
|
|
6398
|
-
return this.session;
|
|
6399
|
-
}
|
|
6400
|
-
}
|
|
6401
|
-
/**
|
|
6402
|
-
*
|
|
6403
|
-
* @param sourceDetail
|
|
6404
|
-
* @param colNames
|
|
6405
|
-
*/
|
|
6406
|
-
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
6407
|
-
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
6408
|
-
colSet[col.name] = col;
|
|
6409
|
-
return colSet;
|
|
6410
|
-
}, {});
|
|
6411
|
-
return new Set(colNames.map((colName) => {
|
|
6412
|
-
const col = cols[colName];
|
|
6413
|
-
return col.id;
|
|
6414
|
-
}));
|
|
6415
|
-
}
|
|
6416
|
-
/**
|
|
6417
|
-
*
|
|
6418
|
-
* @param selectedPoints
|
|
6419
|
-
*/
|
|
6420
|
-
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
6421
|
-
const underlyingDataPoint = [];
|
|
6422
|
-
/**
|
|
6423
|
-
*
|
|
6424
|
-
* @param colVal
|
|
6425
|
-
*/
|
|
6426
|
-
function addPointFromColVal(colVal) {
|
|
6427
|
-
var _a;
|
|
6428
|
-
const dataType = colVal.column.dataType;
|
|
6429
|
-
const id = colVal.column.id;
|
|
6430
|
-
let dataValue;
|
|
6431
|
-
if (dataType === 'DATE') {
|
|
6432
|
-
if (Number.isFinite(colVal.value)) {
|
|
6433
|
-
dataValue = [{
|
|
6434
|
-
epochRange: {
|
|
6435
|
-
startEpoch: colVal.value,
|
|
6436
|
-
},
|
|
6437
|
-
}];
|
|
6438
|
-
// Case for custom calendar.
|
|
6439
|
-
}
|
|
6440
|
-
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
6441
|
-
dataValue = [{
|
|
6442
|
-
epochRange: {
|
|
6443
|
-
startEpoch: colVal.value.v.s,
|
|
6444
|
-
endEpoch: colVal.value.v.e,
|
|
6445
|
-
},
|
|
6446
|
-
}];
|
|
6447
|
-
}
|
|
6448
|
-
}
|
|
6449
|
-
else {
|
|
6450
|
-
dataValue = [{ value: colVal.value }];
|
|
6451
|
-
}
|
|
6452
|
-
underlyingDataPoint.push({
|
|
6453
|
-
columnId: colVal.column.id,
|
|
6454
|
-
dataValue,
|
|
6455
|
-
});
|
|
6456
|
-
}
|
|
6457
|
-
selectedPoints.forEach((p) => {
|
|
6458
|
-
p.selectedAttributes.forEach(addPointFromColVal);
|
|
6459
|
-
});
|
|
6460
|
-
return underlyingDataPoint;
|
|
6461
|
-
}
|
|
6462
|
-
|
|
6463
|
-
const ERROR_MESSAGE = {
|
|
6464
|
-
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
6465
|
-
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
6466
|
-
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
6467
|
-
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
6468
|
-
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
6163
|
+
_.extend = function(obj) {
|
|
6164
|
+
_.each(slice.call(arguments, 1), function(source) {
|
|
6165
|
+
for (var prop in source) {
|
|
6166
|
+
if (source[prop] !== void 0) {
|
|
6167
|
+
obj[prop] = source[prop];
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
});
|
|
6171
|
+
return obj;
|
|
6469
6172
|
};
|
|
6470
6173
|
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
* Utilities related to reading configuration objects
|
|
6475
|
-
*
|
|
6476
|
-
* @summary Config-related utils
|
|
6477
|
-
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
6478
|
-
*/
|
|
6479
|
-
const urlRegex = new RegExp([
|
|
6480
|
-
'(^(https?:)//)?',
|
|
6481
|
-
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
6482
|
-
'(/{0,1}[^?#]*)',
|
|
6483
|
-
'(\\?[^#]*|)',
|
|
6484
|
-
'(#.*|)$', // hash
|
|
6485
|
-
].join(''));
|
|
6486
|
-
/**
|
|
6487
|
-
* Parse and construct the ThoughtSpot hostname or IP address
|
|
6488
|
-
* from the embed configuration object.
|
|
6489
|
-
*
|
|
6490
|
-
* @param config
|
|
6491
|
-
*/
|
|
6492
|
-
const getThoughtSpotHost = (config) => {
|
|
6493
|
-
if (!config.thoughtSpotHost) {
|
|
6494
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6495
|
-
}
|
|
6496
|
-
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
6497
|
-
if (!urlParts) {
|
|
6498
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6499
|
-
}
|
|
6500
|
-
const protocol = urlParts[2] || window.location.protocol;
|
|
6501
|
-
const host = urlParts[3];
|
|
6502
|
-
let path = urlParts[6];
|
|
6503
|
-
// Lose the trailing / if any
|
|
6504
|
-
if (path.charAt(path.length - 1) === '/') {
|
|
6505
|
-
path = path.substring(0, path.length - 1);
|
|
6506
|
-
}
|
|
6507
|
-
// const urlParams = urlParts[7];
|
|
6508
|
-
// const hash = urlParts[8];
|
|
6509
|
-
return `${protocol}//${host}${path}`;
|
|
6510
|
-
};
|
|
6511
|
-
const getV2BasePath = (config) => {
|
|
6512
|
-
if (config.basepath) {
|
|
6513
|
-
return config.basepath;
|
|
6514
|
-
}
|
|
6515
|
-
const tsHost = getThoughtSpotHost(config);
|
|
6516
|
-
// This is to handle when e2e's. Search is run on pods for
|
|
6517
|
-
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
6518
|
-
// This is to handle when the developer is developing in their local
|
|
6519
|
-
// environment.
|
|
6520
|
-
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
6521
|
-
return '';
|
|
6522
|
-
}
|
|
6523
|
-
return 'v2';
|
|
6524
|
-
};
|
|
6525
|
-
/**
|
|
6526
|
-
* It is a good idea to keep URLs under 2000 chars.
|
|
6527
|
-
* If this is ever breached, since we pass view configuration through
|
|
6528
|
-
* URL params, we would like to log a warning.
|
|
6529
|
-
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
6530
|
-
*/
|
|
6531
|
-
const URL_MAX_LENGTH = 2000;
|
|
6532
|
-
/**
|
|
6533
|
-
* The default CSS dimensions of the embedded app
|
|
6534
|
-
*/
|
|
6535
|
-
const DEFAULT_EMBED_WIDTH = '100%';
|
|
6536
|
-
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
6174
|
+
_.isArray = nativeIsArray || function(obj) {
|
|
6175
|
+
return toString.call(obj) === '[object Array]';
|
|
6176
|
+
};
|
|
6537
6177
|
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6178
|
+
// from a comment on http://dbj.org/dbj/?p=286
|
|
6179
|
+
// fails on only one very rare and deliberate custom object:
|
|
6180
|
+
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6181
|
+
_.isFunction = function(f) {
|
|
6182
|
+
try {
|
|
6183
|
+
return /^\s*\bfunction\b/.test(f);
|
|
6184
|
+
} catch (x) {
|
|
6185
|
+
return false;
|
|
6186
|
+
}
|
|
6541
6187
|
};
|
|
6542
6188
|
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
var loc = {
|
|
6547
|
-
hostname: ''
|
|
6548
|
-
};
|
|
6549
|
-
window$1 = {
|
|
6550
|
-
navigator: { userAgent: '' },
|
|
6551
|
-
document: {
|
|
6552
|
-
location: loc,
|
|
6553
|
-
referrer: ''
|
|
6554
|
-
},
|
|
6555
|
-
screen: { width: 0, height: 0 },
|
|
6556
|
-
location: loc
|
|
6557
|
-
};
|
|
6558
|
-
} else {
|
|
6559
|
-
window$1 = window;
|
|
6560
|
-
}
|
|
6189
|
+
_.isArguments = function(obj) {
|
|
6190
|
+
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6191
|
+
};
|
|
6561
6192
|
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6193
|
+
_.toArray = function(iterable) {
|
|
6194
|
+
if (!iterable) {
|
|
6195
|
+
return [];
|
|
6196
|
+
}
|
|
6197
|
+
if (iterable.toArray) {
|
|
6198
|
+
return iterable.toArray();
|
|
6199
|
+
}
|
|
6200
|
+
if (_.isArray(iterable)) {
|
|
6201
|
+
return slice.call(iterable);
|
|
6202
|
+
}
|
|
6203
|
+
if (_.isArguments(iterable)) {
|
|
6204
|
+
return slice.call(iterable);
|
|
6205
|
+
}
|
|
6206
|
+
return _.values(iterable);
|
|
6207
|
+
};
|
|
6566
6208
|
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
var
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
var windowOpera = window$1.opera;
|
|
6577
|
-
var screen = window$1.screen;
|
|
6578
|
-
var userAgent = navigator.userAgent;
|
|
6579
|
-
var nativeBind = FuncProto.bind;
|
|
6580
|
-
var nativeForEach = ArrayProto.forEach;
|
|
6581
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
6582
|
-
var nativeMap = ArrayProto.map;
|
|
6583
|
-
var nativeIsArray = Array.isArray;
|
|
6584
|
-
var breaker = {};
|
|
6585
|
-
var _ = {
|
|
6586
|
-
trim: function(str) {
|
|
6587
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6588
|
-
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6589
|
-
}
|
|
6590
|
-
};
|
|
6591
|
-
|
|
6592
|
-
// Console override
|
|
6593
|
-
var console$1 = {
|
|
6594
|
-
/** @type {function(...*)} */
|
|
6595
|
-
log: function() {
|
|
6596
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6597
|
-
try {
|
|
6598
|
-
windowConsole.log.apply(windowConsole, arguments);
|
|
6599
|
-
} catch (err) {
|
|
6600
|
-
_.each(arguments, function(arg) {
|
|
6601
|
-
windowConsole.log(arg);
|
|
6602
|
-
});
|
|
6603
|
-
}
|
|
6604
|
-
}
|
|
6605
|
-
},
|
|
6606
|
-
/** @type {function(...*)} */
|
|
6607
|
-
warn: function() {
|
|
6608
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6609
|
-
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6610
|
-
try {
|
|
6611
|
-
windowConsole.warn.apply(windowConsole, args);
|
|
6612
|
-
} catch (err) {
|
|
6613
|
-
_.each(args, function(arg) {
|
|
6614
|
-
windowConsole.warn(arg);
|
|
6615
|
-
});
|
|
6616
|
-
}
|
|
6617
|
-
}
|
|
6618
|
-
},
|
|
6619
|
-
/** @type {function(...*)} */
|
|
6620
|
-
error: function() {
|
|
6621
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6622
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6623
|
-
try {
|
|
6624
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6625
|
-
} catch (err) {
|
|
6626
|
-
_.each(args, function(arg) {
|
|
6627
|
-
windowConsole.error(arg);
|
|
6628
|
-
});
|
|
6629
|
-
}
|
|
6630
|
-
}
|
|
6631
|
-
},
|
|
6632
|
-
/** @type {function(...*)} */
|
|
6633
|
-
critical: function() {
|
|
6634
|
-
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6635
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6636
|
-
try {
|
|
6637
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6638
|
-
} catch (err) {
|
|
6639
|
-
_.each(args, function(arg) {
|
|
6640
|
-
windowConsole.error(arg);
|
|
6641
|
-
});
|
|
6642
|
-
}
|
|
6643
|
-
}
|
|
6644
|
-
}
|
|
6645
|
-
};
|
|
6646
|
-
|
|
6647
|
-
var log_func_with_prefix = function(func, prefix) {
|
|
6648
|
-
return function() {
|
|
6649
|
-
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6650
|
-
return func.apply(console$1, arguments);
|
|
6651
|
-
};
|
|
6652
|
-
};
|
|
6653
|
-
var console_with_prefix = function(prefix) {
|
|
6654
|
-
return {
|
|
6655
|
-
log: log_func_with_prefix(console$1.log, prefix),
|
|
6656
|
-
error: log_func_with_prefix(console$1.error, prefix),
|
|
6657
|
-
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6658
|
-
};
|
|
6659
|
-
};
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
// UNDERSCORE
|
|
6663
|
-
// Embed part of the Underscore Library
|
|
6664
|
-
_.bind = function(func, context) {
|
|
6665
|
-
var args, bound;
|
|
6666
|
-
if (nativeBind && func.bind === nativeBind) {
|
|
6667
|
-
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6668
|
-
}
|
|
6669
|
-
if (!_.isFunction(func)) {
|
|
6670
|
-
throw new TypeError();
|
|
6671
|
-
}
|
|
6672
|
-
args = slice.call(arguments, 2);
|
|
6673
|
-
bound = function() {
|
|
6674
|
-
if (!(this instanceof bound)) {
|
|
6675
|
-
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6676
|
-
}
|
|
6677
|
-
var ctor = {};
|
|
6678
|
-
ctor.prototype = func.prototype;
|
|
6679
|
-
var self = new ctor();
|
|
6680
|
-
ctor.prototype = null;
|
|
6681
|
-
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6682
|
-
if (Object(result) === result) {
|
|
6683
|
-
return result;
|
|
6684
|
-
}
|
|
6685
|
-
return self;
|
|
6686
|
-
};
|
|
6687
|
-
return bound;
|
|
6688
|
-
};
|
|
6689
|
-
|
|
6690
|
-
/**
|
|
6691
|
-
* @param {*=} obj
|
|
6692
|
-
* @param {function(...*)=} iterator
|
|
6693
|
-
* @param {Object=} context
|
|
6694
|
-
*/
|
|
6695
|
-
_.each = function(obj, iterator, context) {
|
|
6696
|
-
if (obj === null || obj === undefined) {
|
|
6697
|
-
return;
|
|
6698
|
-
}
|
|
6699
|
-
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6700
|
-
obj.forEach(iterator, context);
|
|
6701
|
-
} else if (obj.length === +obj.length) {
|
|
6702
|
-
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6703
|
-
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6704
|
-
return;
|
|
6705
|
-
}
|
|
6706
|
-
}
|
|
6707
|
-
} else {
|
|
6708
|
-
for (var key in obj) {
|
|
6709
|
-
if (hasOwnProperty$9.call(obj, key)) {
|
|
6710
|
-
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6711
|
-
return;
|
|
6712
|
-
}
|
|
6713
|
-
}
|
|
6714
|
-
}
|
|
6715
|
-
}
|
|
6716
|
-
};
|
|
6717
|
-
|
|
6718
|
-
_.extend = function(obj) {
|
|
6719
|
-
_.each(slice.call(arguments, 1), function(source) {
|
|
6720
|
-
for (var prop in source) {
|
|
6721
|
-
if (source[prop] !== void 0) {
|
|
6722
|
-
obj[prop] = source[prop];
|
|
6723
|
-
}
|
|
6724
|
-
}
|
|
6725
|
-
});
|
|
6726
|
-
return obj;
|
|
6727
|
-
};
|
|
6728
|
-
|
|
6729
|
-
_.isArray = nativeIsArray || function(obj) {
|
|
6730
|
-
return toString.call(obj) === '[object Array]';
|
|
6731
|
-
};
|
|
6732
|
-
|
|
6733
|
-
// from a comment on http://dbj.org/dbj/?p=286
|
|
6734
|
-
// fails on only one very rare and deliberate custom object:
|
|
6735
|
-
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6736
|
-
_.isFunction = function(f) {
|
|
6737
|
-
try {
|
|
6738
|
-
return /^\s*\bfunction\b/.test(f);
|
|
6739
|
-
} catch (x) {
|
|
6740
|
-
return false;
|
|
6741
|
-
}
|
|
6742
|
-
};
|
|
6743
|
-
|
|
6744
|
-
_.isArguments = function(obj) {
|
|
6745
|
-
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6746
|
-
};
|
|
6747
|
-
|
|
6748
|
-
_.toArray = function(iterable) {
|
|
6749
|
-
if (!iterable) {
|
|
6750
|
-
return [];
|
|
6751
|
-
}
|
|
6752
|
-
if (iterable.toArray) {
|
|
6753
|
-
return iterable.toArray();
|
|
6754
|
-
}
|
|
6755
|
-
if (_.isArray(iterable)) {
|
|
6756
|
-
return slice.call(iterable);
|
|
6757
|
-
}
|
|
6758
|
-
if (_.isArguments(iterable)) {
|
|
6759
|
-
return slice.call(iterable);
|
|
6760
|
-
}
|
|
6761
|
-
return _.values(iterable);
|
|
6762
|
-
};
|
|
6763
|
-
|
|
6764
|
-
_.map = function(arr, callback, context) {
|
|
6765
|
-
if (nativeMap && arr.map === nativeMap) {
|
|
6766
|
-
return arr.map(callback, context);
|
|
6767
|
-
} else {
|
|
6768
|
-
var results = [];
|
|
6769
|
-
_.each(arr, function(item) {
|
|
6770
|
-
results.push(callback.call(context, item));
|
|
6771
|
-
});
|
|
6772
|
-
return results;
|
|
6209
|
+
_.map = function(arr, callback, context) {
|
|
6210
|
+
if (nativeMap && arr.map === nativeMap) {
|
|
6211
|
+
return arr.map(callback, context);
|
|
6212
|
+
} else {
|
|
6213
|
+
var results = [];
|
|
6214
|
+
_.each(arr, function(item) {
|
|
6215
|
+
results.push(callback.call(context, item));
|
|
6216
|
+
});
|
|
6217
|
+
return results;
|
|
6773
6218
|
}
|
|
6774
6219
|
};
|
|
6775
6220
|
|
|
@@ -12514,7 +11959,7 @@ var mixpanel = init_as_module();
|
|
|
12514
11959
|
var mixpanel_cjs = mixpanel;
|
|
12515
11960
|
|
|
12516
11961
|
var mixpanel$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), mixpanel_cjs, {
|
|
12517
|
-
|
|
11962
|
+
'default': mixpanel_cjs
|
|
12518
11963
|
}));
|
|
12519
11964
|
|
|
12520
11965
|
// Needed to avoid error in CJS builds on some bundlers.
|
|
@@ -12592,1010 +12037,1563 @@ function initMixpanel(sessionInfo) {
|
|
|
12592
12037
|
}
|
|
12593
12038
|
}
|
|
12594
12039
|
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
*
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
*
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
|
|
12616
|
-
if (Object.create) {
|
|
12617
|
-
Events.prototype = Object.create(null);
|
|
12040
|
+
let config = {};
|
|
12041
|
+
/**
|
|
12042
|
+
* Gets the configuration embed was initialized with.
|
|
12043
|
+
*
|
|
12044
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
12045
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
12046
|
+
* @group Global methods
|
|
12047
|
+
*/
|
|
12048
|
+
const getEmbedConfig = () => config;
|
|
12049
|
+
/**
|
|
12050
|
+
* Sets the configuration embed was initialized with.
|
|
12051
|
+
* And returns the new configuration.
|
|
12052
|
+
*
|
|
12053
|
+
* @param newConfig The configuration to set.
|
|
12054
|
+
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
12055
|
+
* @group Global methods
|
|
12056
|
+
*/
|
|
12057
|
+
const setEmbedConfig = (newConfig) => {
|
|
12058
|
+
config = newConfig;
|
|
12059
|
+
return newConfig;
|
|
12060
|
+
};
|
|
12618
12061
|
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12062
|
+
/**
|
|
12063
|
+
* Fetch wrapper that adds the authentication token to the request.
|
|
12064
|
+
* Use this to call the ThoughtSpot APIs when using the visual embed sdk.
|
|
12065
|
+
*
|
|
12066
|
+
* @param input
|
|
12067
|
+
* @param init
|
|
12068
|
+
* @version SDK: 1.28.0
|
|
12069
|
+
* @group Global methods
|
|
12070
|
+
*/
|
|
12071
|
+
const tokenizedFetch = async (input, init) => {
|
|
12072
|
+
const embedConfig = getEmbedConfig();
|
|
12073
|
+
if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
|
|
12074
|
+
return fetch(input, init);
|
|
12075
|
+
}
|
|
12076
|
+
const req = new Request(input, init);
|
|
12077
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12078
|
+
if (authToken) {
|
|
12079
|
+
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
12080
|
+
}
|
|
12081
|
+
return fetch(req);
|
|
12082
|
+
};
|
|
12625
12083
|
|
|
12626
|
-
/**
|
|
12627
|
-
*
|
|
12628
|
-
*
|
|
12629
|
-
* @param
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
}
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
*
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
*
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
12662
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
12663
|
-
|
|
12664
|
-
return emitter;
|
|
12665
|
-
}
|
|
12666
|
-
|
|
12667
|
-
/**
|
|
12668
|
-
* Clear event by name.
|
|
12669
|
-
*
|
|
12670
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
12671
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
12672
|
-
* @private
|
|
12673
|
-
*/
|
|
12674
|
-
function clearEvent(emitter, evt) {
|
|
12675
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
12676
|
-
else delete emitter._events[evt];
|
|
12677
|
-
}
|
|
12678
|
-
|
|
12679
|
-
/**
|
|
12680
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
12681
|
-
* `EventEmitter` interface.
|
|
12682
|
-
*
|
|
12683
|
-
* @constructor
|
|
12684
|
-
* @public
|
|
12685
|
-
*/
|
|
12686
|
-
function EventEmitter() {
|
|
12687
|
-
this._events = new Events();
|
|
12688
|
-
this._eventsCount = 0;
|
|
12084
|
+
/**
|
|
12085
|
+
*
|
|
12086
|
+
* @param url
|
|
12087
|
+
* @param options
|
|
12088
|
+
*/
|
|
12089
|
+
function tokenisedFailureLoggedFetch(url, options = {}) {
|
|
12090
|
+
return tokenizedFetch(url, options).then(async (r) => {
|
|
12091
|
+
var _a;
|
|
12092
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
12093
|
+
logger.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
12094
|
+
}
|
|
12095
|
+
return r;
|
|
12096
|
+
});
|
|
12097
|
+
}
|
|
12098
|
+
/**
|
|
12099
|
+
*
|
|
12100
|
+
* @param authVerificationUrl
|
|
12101
|
+
*/
|
|
12102
|
+
function fetchSessionInfoService(authVerificationUrl) {
|
|
12103
|
+
return tokenisedFailureLoggedFetch(authVerificationUrl, {
|
|
12104
|
+
credentials: 'include',
|
|
12105
|
+
});
|
|
12106
|
+
}
|
|
12107
|
+
/**
|
|
12108
|
+
*
|
|
12109
|
+
* @param thoughtSpotHost
|
|
12110
|
+
*/
|
|
12111
|
+
async function fetchLogoutService(thoughtSpotHost) {
|
|
12112
|
+
return tokenisedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
12113
|
+
credentials: 'include',
|
|
12114
|
+
method: 'POST',
|
|
12115
|
+
headers: {
|
|
12116
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12117
|
+
},
|
|
12118
|
+
});
|
|
12689
12119
|
}
|
|
12690
12120
|
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
*
|
|
12719
|
-
*
|
|
12720
|
-
* @
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
}
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
};
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
*
|
|
12840
|
-
*
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
*
|
|
12892
|
-
*
|
|
12893
|
-
* @
|
|
12894
|
-
*/
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
//
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
return value !== value;
|
|
12967
|
-
}
|
|
12968
|
-
|
|
12969
|
-
var _baseIsNaN = baseIsNaN;
|
|
12970
|
-
|
|
12971
|
-
/**
|
|
12972
|
-
* A specialized version of `_.indexOf` which performs strict equality
|
|
12973
|
-
* comparisons of values, i.e. `===`.
|
|
12974
|
-
*
|
|
12975
|
-
* @private
|
|
12976
|
-
* @param {Array} array The array to inspect.
|
|
12977
|
-
* @param {*} value The value to search for.
|
|
12978
|
-
* @param {number} fromIndex The index to search from.
|
|
12979
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
12980
|
-
*/
|
|
12981
|
-
function strictIndexOf(array, value, fromIndex) {
|
|
12982
|
-
var index = fromIndex - 1,
|
|
12983
|
-
length = array.length;
|
|
12984
|
-
|
|
12985
|
-
while (++index < length) {
|
|
12986
|
-
if (array[index] === value) {
|
|
12987
|
-
return index;
|
|
12988
|
-
}
|
|
12989
|
-
}
|
|
12990
|
-
return -1;
|
|
12991
|
-
}
|
|
12992
|
-
|
|
12993
|
-
var _strictIndexOf = strictIndexOf;
|
|
12994
|
-
|
|
12995
|
-
/**
|
|
12996
|
-
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
12997
|
-
*
|
|
12998
|
-
* @private
|
|
12999
|
-
* @param {Array} array The array to inspect.
|
|
13000
|
-
* @param {*} value The value to search for.
|
|
13001
|
-
* @param {number} fromIndex The index to search from.
|
|
13002
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
13003
|
-
*/
|
|
13004
|
-
function baseIndexOf(array, value, fromIndex) {
|
|
13005
|
-
return value === value
|
|
13006
|
-
? _strictIndexOf(array, value, fromIndex)
|
|
13007
|
-
: _baseFindIndex(array, _baseIsNaN, fromIndex);
|
|
13008
|
-
}
|
|
13009
|
-
|
|
13010
|
-
var _baseIndexOf = baseIndexOf;
|
|
13011
|
-
|
|
13012
|
-
/**
|
|
13013
|
-
* A specialized version of `_.includes` for arrays without support for
|
|
13014
|
-
* specifying an index to search from.
|
|
13015
|
-
*
|
|
13016
|
-
* @private
|
|
13017
|
-
* @param {Array} [array] The array to inspect.
|
|
13018
|
-
* @param {*} target The value to search for.
|
|
13019
|
-
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
13020
|
-
*/
|
|
13021
|
-
function arrayIncludes(array, value) {
|
|
13022
|
-
var length = array == null ? 0 : array.length;
|
|
13023
|
-
return !!length && _baseIndexOf(array, value, 0) > -1;
|
|
13024
|
-
}
|
|
13025
|
-
|
|
13026
|
-
var _arrayIncludes = arrayIncludes;
|
|
13027
|
-
|
|
13028
|
-
/**
|
|
13029
|
-
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
13030
|
-
*
|
|
13031
|
-
* @private
|
|
13032
|
-
* @param {Array} [array] The array to inspect.
|
|
13033
|
-
* @param {*} target The value to search for.
|
|
13034
|
-
* @param {Function} comparator The comparator invoked per element.
|
|
13035
|
-
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
13036
|
-
*/
|
|
13037
|
-
function arrayIncludesWith(array, value, comparator) {
|
|
13038
|
-
var index = -1,
|
|
13039
|
-
length = array == null ? 0 : array.length;
|
|
13040
|
-
|
|
13041
|
-
while (++index < length) {
|
|
13042
|
-
if (comparator(value, array[index])) {
|
|
13043
|
-
return true;
|
|
13044
|
-
}
|
|
13045
|
-
}
|
|
13046
|
-
return false;
|
|
13047
|
-
}
|
|
13048
|
-
|
|
13049
|
-
var _arrayIncludesWith = arrayIncludesWith;
|
|
13050
|
-
|
|
13051
|
-
/** Used as references for various `Number` constants. */
|
|
13052
|
-
var INFINITY = 1 / 0;
|
|
13053
|
-
|
|
13054
|
-
/**
|
|
13055
|
-
* Creates a set object of `values`.
|
|
13056
|
-
*
|
|
13057
|
-
* @private
|
|
13058
|
-
* @param {Array} values The values to add to the set.
|
|
13059
|
-
* @returns {Object} Returns the new set.
|
|
13060
|
-
*/
|
|
13061
|
-
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
13062
|
-
return new _Set(values);
|
|
13063
|
-
};
|
|
13064
|
-
|
|
13065
|
-
var _createSet = createSet;
|
|
13066
|
-
|
|
13067
|
-
/** Used as the size to enable large array optimizations. */
|
|
13068
|
-
var LARGE_ARRAY_SIZE$1 = 200;
|
|
13069
|
-
|
|
13070
|
-
/**
|
|
13071
|
-
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
13072
|
-
*
|
|
13073
|
-
* @private
|
|
13074
|
-
* @param {Array} array The array to inspect.
|
|
13075
|
-
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
13076
|
-
* @param {Function} [comparator] The comparator invoked per element.
|
|
13077
|
-
* @returns {Array} Returns the new duplicate free array.
|
|
13078
|
-
*/
|
|
13079
|
-
function baseUniq(array, iteratee, comparator) {
|
|
13080
|
-
var index = -1,
|
|
13081
|
-
includes = _arrayIncludes,
|
|
13082
|
-
length = array.length,
|
|
13083
|
-
isCommon = true,
|
|
13084
|
-
result = [],
|
|
13085
|
-
seen = result;
|
|
13086
|
-
|
|
13087
|
-
if (comparator) {
|
|
13088
|
-
isCommon = false;
|
|
13089
|
-
includes = _arrayIncludesWith;
|
|
13090
|
-
}
|
|
13091
|
-
else if (length >= LARGE_ARRAY_SIZE$1) {
|
|
13092
|
-
var set = iteratee ? null : _createSet(array);
|
|
13093
|
-
if (set) {
|
|
13094
|
-
return _setToArray(set);
|
|
13095
|
-
}
|
|
13096
|
-
isCommon = false;
|
|
13097
|
-
includes = _cacheHas;
|
|
13098
|
-
seen = new _SetCache;
|
|
13099
|
-
}
|
|
13100
|
-
else {
|
|
13101
|
-
seen = iteratee ? [] : result;
|
|
13102
|
-
}
|
|
13103
|
-
outer:
|
|
13104
|
-
while (++index < length) {
|
|
13105
|
-
var value = array[index],
|
|
13106
|
-
computed = iteratee ? iteratee(value) : value;
|
|
13107
|
-
|
|
13108
|
-
value = (comparator || value !== 0) ? value : 0;
|
|
13109
|
-
if (isCommon && computed === computed) {
|
|
13110
|
-
var seenIndex = seen.length;
|
|
13111
|
-
while (seenIndex--) {
|
|
13112
|
-
if (seen[seenIndex] === computed) {
|
|
13113
|
-
continue outer;
|
|
13114
|
-
}
|
|
13115
|
-
}
|
|
13116
|
-
if (iteratee) {
|
|
13117
|
-
seen.push(computed);
|
|
13118
|
-
}
|
|
13119
|
-
result.push(value);
|
|
13120
|
-
}
|
|
13121
|
-
else if (!includes(seen, computed, comparator)) {
|
|
13122
|
-
if (seen !== result) {
|
|
13123
|
-
seen.push(computed);
|
|
13124
|
-
}
|
|
13125
|
-
result.push(value);
|
|
13126
|
-
}
|
|
13127
|
-
}
|
|
13128
|
-
return result;
|
|
13129
|
-
}
|
|
13130
|
-
|
|
13131
|
-
var _baseUniq = baseUniq;
|
|
13132
|
-
|
|
13133
|
-
/**
|
|
13134
|
-
* Creates a duplicate-free version of an array, using
|
|
13135
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
13136
|
-
* for equality comparisons, in which only the first occurrence of each element
|
|
13137
|
-
* is kept. The order of result values is determined by the order they occur
|
|
13138
|
-
* in the array.
|
|
13139
|
-
*
|
|
13140
|
-
* @static
|
|
13141
|
-
* @memberOf _
|
|
13142
|
-
* @since 0.1.0
|
|
13143
|
-
* @category Array
|
|
13144
|
-
* @param {Array} array The array to inspect.
|
|
13145
|
-
* @returns {Array} Returns the new duplicate free array.
|
|
13146
|
-
* @example
|
|
13147
|
-
*
|
|
13148
|
-
* _.uniq([2, 1, 2]);
|
|
13149
|
-
* // => [2, 1]
|
|
13150
|
-
*/
|
|
13151
|
-
function uniq(array) {
|
|
13152
|
-
return (array && array.length) ? _baseUniq(array) : [];
|
|
13153
|
-
}
|
|
13154
|
-
|
|
13155
|
-
var uniq_1 = uniq;
|
|
13156
|
-
|
|
12121
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12122
|
+
let loggedInStatus = false;
|
|
12123
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12124
|
+
let samlAuthWindow = null;
|
|
12125
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12126
|
+
let samlCompletionPromise = null;
|
|
12127
|
+
let sessionInfo = null;
|
|
12128
|
+
let sessionInfoResolver = null;
|
|
12129
|
+
const sessionInfoPromise = new Promise((resolve) => {
|
|
12130
|
+
sessionInfoResolver = resolve;
|
|
12131
|
+
});
|
|
12132
|
+
let releaseVersion = '';
|
|
12133
|
+
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
12134
|
+
/**
|
|
12135
|
+
* Enum for auth failure types. This is the parameter passed to the listner
|
|
12136
|
+
* of {@link AuthStatus.FAILURE}.
|
|
12137
|
+
*
|
|
12138
|
+
* @group Authentication / Init
|
|
12139
|
+
*/
|
|
12140
|
+
var AuthFailureType;
|
|
12141
|
+
(function (AuthFailureType) {
|
|
12142
|
+
AuthFailureType["SDK"] = "SDK";
|
|
12143
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
12144
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
12145
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
12146
|
+
})(AuthFailureType || (AuthFailureType = {}));
|
|
12147
|
+
/**
|
|
12148
|
+
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
12149
|
+
*
|
|
12150
|
+
* @group Authentication / Init
|
|
12151
|
+
*/
|
|
12152
|
+
var AuthStatus;
|
|
12153
|
+
(function (AuthStatus) {
|
|
12154
|
+
/**
|
|
12155
|
+
* Emits when the SDK fails to authenticate
|
|
12156
|
+
*/
|
|
12157
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
12158
|
+
/**
|
|
12159
|
+
* Emits when the SDK authenticates successfully
|
|
12160
|
+
*/
|
|
12161
|
+
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
12162
|
+
/**
|
|
12163
|
+
* Emits when the app sends an authentication success message
|
|
12164
|
+
*/
|
|
12165
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
12166
|
+
/**
|
|
12167
|
+
* Emits when a user logs out
|
|
12168
|
+
*/
|
|
12169
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
12170
|
+
/**
|
|
12171
|
+
* Emitted when inPopup is true in the SAMLRedirect flow and the
|
|
12172
|
+
* popup is waiting to be triggered either programmatically
|
|
12173
|
+
* or by the trigger button.
|
|
12174
|
+
*
|
|
12175
|
+
* @version SDK: 1.19.0
|
|
12176
|
+
*/
|
|
12177
|
+
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
12178
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
12179
|
+
/**
|
|
12180
|
+
* Events which can be triggered on the emitter returned from {@link init}.
|
|
12181
|
+
*
|
|
12182
|
+
* @group Authentication / Init
|
|
12183
|
+
*/
|
|
12184
|
+
var AuthEvent;
|
|
12185
|
+
(function (AuthEvent) {
|
|
12186
|
+
/**
|
|
12187
|
+
* Manually trigger the SSO popup. This is useful when
|
|
12188
|
+
* authStatus is SAMLRedirect/OIDCRedirect and inPopup is set to true
|
|
12189
|
+
*/
|
|
12190
|
+
AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
|
|
12191
|
+
})(AuthEvent || (AuthEvent = {}));
|
|
12192
|
+
let authEE;
|
|
12193
|
+
/**
|
|
12194
|
+
*
|
|
12195
|
+
* @param eventEmitter
|
|
12196
|
+
*/
|
|
12197
|
+
function setAuthEE(eventEmitter) {
|
|
12198
|
+
authEE = eventEmitter;
|
|
12199
|
+
}
|
|
12200
|
+
/**
|
|
12201
|
+
*
|
|
12202
|
+
*/
|
|
12203
|
+
function notifyAuthSDKSuccess() {
|
|
12204
|
+
if (!authEE) {
|
|
12205
|
+
logger.error('SDK not initialized');
|
|
12206
|
+
return;
|
|
12207
|
+
}
|
|
12208
|
+
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
12209
|
+
}
|
|
12210
|
+
/**
|
|
12211
|
+
*
|
|
12212
|
+
*/
|
|
12213
|
+
function notifyAuthSuccess() {
|
|
12214
|
+
if (!authEE) {
|
|
12215
|
+
logger.error('SDK not initialized');
|
|
12216
|
+
return;
|
|
12217
|
+
}
|
|
12218
|
+
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
12219
|
+
}
|
|
12220
|
+
/**
|
|
12221
|
+
*
|
|
12222
|
+
* @param failureType
|
|
12223
|
+
*/
|
|
12224
|
+
function notifyAuthFailure(failureType) {
|
|
12225
|
+
if (!authEE) {
|
|
12226
|
+
logger.error('SDK not initialized');
|
|
12227
|
+
return;
|
|
12228
|
+
}
|
|
12229
|
+
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
12230
|
+
}
|
|
12231
|
+
/**
|
|
12232
|
+
*
|
|
12233
|
+
*/
|
|
12234
|
+
function notifyLogout() {
|
|
12235
|
+
if (!authEE) {
|
|
12236
|
+
logger.error('SDK not initialized');
|
|
12237
|
+
return;
|
|
12238
|
+
}
|
|
12239
|
+
authEE.emit(AuthStatus.LOGOUT);
|
|
12240
|
+
}
|
|
12241
|
+
const initSession = (sessionDetails) => {
|
|
12242
|
+
const embedConfig = getEmbedConfig();
|
|
12243
|
+
if (sessionInfo == null) {
|
|
12244
|
+
sessionInfo = sessionDetails;
|
|
12245
|
+
if (!embedConfig.disableSDKTracking) {
|
|
12246
|
+
initMixpanel(sessionInfo);
|
|
12247
|
+
}
|
|
12248
|
+
sessionInfoResolver(sessionInfo);
|
|
12249
|
+
}
|
|
12250
|
+
};
|
|
12251
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
12252
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
12253
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
12254
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
12255
|
+
? prodMixpanelToken
|
|
12256
|
+
: devMixpanelToken;
|
|
12257
|
+
return {
|
|
12258
|
+
userGUID: sessionInfoResp.userGUID,
|
|
12259
|
+
mixpanelToken,
|
|
12260
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
12261
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
12262
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
12263
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
12264
|
+
...sessionInfoResp,
|
|
12265
|
+
};
|
|
12266
|
+
};
|
|
12267
|
+
/**
|
|
12268
|
+
* Check if we are logged into the ThoughtSpot cluster
|
|
12269
|
+
*
|
|
12270
|
+
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
12271
|
+
*/
|
|
12272
|
+
async function isLoggedIn(thoughtSpotHost) {
|
|
12273
|
+
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
12274
|
+
let response = null;
|
|
12275
|
+
try {
|
|
12276
|
+
response = await fetchSessionInfoService(authVerificationUrl);
|
|
12277
|
+
const sessionInfoResp = await response.json();
|
|
12278
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
12279
|
+
// Store user session details from session info
|
|
12280
|
+
initSession(sessionDetails);
|
|
12281
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12282
|
+
}
|
|
12283
|
+
catch (e) {
|
|
12284
|
+
return false;
|
|
12285
|
+
}
|
|
12286
|
+
return response.status === 200;
|
|
12287
|
+
}
|
|
12288
|
+
/**
|
|
12289
|
+
* Return releaseVersion if available
|
|
12290
|
+
*/
|
|
12291
|
+
function getReleaseVersion() {
|
|
12292
|
+
return releaseVersion;
|
|
12293
|
+
}
|
|
12294
|
+
/**
|
|
12295
|
+
* Return a promise that resolves with the session information when
|
|
12296
|
+
* authentication is successful. And info is available.
|
|
12297
|
+
*
|
|
12298
|
+
* @group Global methods
|
|
12299
|
+
*/
|
|
12300
|
+
function getSessionInfo() {
|
|
12301
|
+
return sessionInfoPromise;
|
|
12302
|
+
}
|
|
12303
|
+
/**
|
|
12304
|
+
* Check if we are stuck at the SSO redirect URL
|
|
12305
|
+
*/
|
|
12306
|
+
function isAtSSORedirectUrl() {
|
|
12307
|
+
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
12308
|
+
}
|
|
12309
|
+
/**
|
|
12310
|
+
* Remove the SSO redirect URL marker
|
|
12311
|
+
*/
|
|
12312
|
+
function removeSSORedirectUrlMarker() {
|
|
12313
|
+
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
12314
|
+
// to begin with. Trying to remove the hash by changing window.location will
|
|
12315
|
+
// reload the page which we don't want. We'll live with adding an
|
|
12316
|
+
// unnecessary hash to the parent page URL until we find any use case where
|
|
12317
|
+
// that creates an issue.
|
|
12318
|
+
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
12319
|
+
}
|
|
12320
|
+
/**
|
|
12321
|
+
* Perform token based authentication
|
|
12322
|
+
*
|
|
12323
|
+
* @param embedConfig The embed configuration
|
|
12324
|
+
*/
|
|
12325
|
+
const doTokenAuth = async (embedConfig) => {
|
|
12326
|
+
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
12327
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12328
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12329
|
+
}
|
|
12330
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12331
|
+
if (!loggedInStatus) {
|
|
12332
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12333
|
+
let resp;
|
|
12334
|
+
try {
|
|
12335
|
+
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
12336
|
+
}
|
|
12337
|
+
catch (e) {
|
|
12338
|
+
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
12339
|
+
}
|
|
12340
|
+
// token login issues a 302 when successful
|
|
12341
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
12342
|
+
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
12343
|
+
// When 3rd party cookie access is blocked, this will fail because
|
|
12344
|
+
// cookies will not be sent with the call.
|
|
12345
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12346
|
+
}
|
|
12347
|
+
}
|
|
12348
|
+
return loggedInStatus;
|
|
12349
|
+
};
|
|
12350
|
+
/**
|
|
12351
|
+
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
12352
|
+
*
|
|
12353
|
+
* @param embedConfig The embed configuration
|
|
12354
|
+
*/
|
|
12355
|
+
const doCookielessTokenAuth = async (embedConfig) => {
|
|
12356
|
+
const { authEndpoint, getAuthToken } = embedConfig;
|
|
12357
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12358
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12359
|
+
}
|
|
12360
|
+
let authSuccess = false;
|
|
12361
|
+
try {
|
|
12362
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12363
|
+
if (authToken) {
|
|
12364
|
+
authSuccess = true;
|
|
12365
|
+
}
|
|
12366
|
+
}
|
|
12367
|
+
catch {
|
|
12368
|
+
authSuccess = false;
|
|
12369
|
+
}
|
|
12370
|
+
return authSuccess;
|
|
12371
|
+
};
|
|
12372
|
+
/**
|
|
12373
|
+
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
12374
|
+
* credentials.
|
|
12375
|
+
*
|
|
12376
|
+
* Warning: This feature is primarily intended for developer testing. It is
|
|
12377
|
+
* strongly advised not to use this authentication method in production.
|
|
12378
|
+
*
|
|
12379
|
+
* @param embedConfig The embed configuration
|
|
12380
|
+
*/
|
|
12381
|
+
const doBasicAuth = async (embedConfig) => {
|
|
12382
|
+
const { thoughtSpotHost, username, password } = embedConfig;
|
|
12383
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12384
|
+
if (!loggedIn) {
|
|
12385
|
+
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
12386
|
+
loggedInStatus = response.ok;
|
|
12387
|
+
if (embedConfig.detectCookieAccessSlow) {
|
|
12388
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12389
|
+
}
|
|
12390
|
+
}
|
|
12391
|
+
else {
|
|
12392
|
+
loggedInStatus = true;
|
|
12393
|
+
}
|
|
12394
|
+
return loggedInStatus;
|
|
12395
|
+
};
|
|
13157
12396
|
/**
|
|
13158
12397
|
*
|
|
13159
|
-
* @param
|
|
13160
|
-
* @param
|
|
12398
|
+
* @param ssoURL
|
|
12399
|
+
* @param triggerContainer
|
|
12400
|
+
* @param triggerText
|
|
13161
12401
|
*/
|
|
13162
|
-
function
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
logger.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
12402
|
+
async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
12403
|
+
const openPopup = () => {
|
|
12404
|
+
if (samlAuthWindow === null || samlAuthWindow.closed) {
|
|
12405
|
+
samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
|
|
13167
12406
|
}
|
|
13168
|
-
|
|
13169
|
-
|
|
12407
|
+
else {
|
|
12408
|
+
samlAuthWindow.focus();
|
|
12409
|
+
}
|
|
12410
|
+
};
|
|
12411
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
|
|
12412
|
+
const containerEl = getDOMNode(triggerContainer);
|
|
12413
|
+
if (containerEl) {
|
|
12414
|
+
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
12415
|
+
const authElem = document.getElementById('ts-auth-btn');
|
|
12416
|
+
authElem.textContent = triggerText;
|
|
12417
|
+
authElem.addEventListener('click', openPopup, { once: true });
|
|
12418
|
+
}
|
|
12419
|
+
samlCompletionPromise = samlCompletionPromise
|
|
12420
|
+
|| new Promise((resolve, reject) => {
|
|
12421
|
+
window.addEventListener('message', (e) => {
|
|
12422
|
+
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
12423
|
+
e.source.close();
|
|
12424
|
+
resolve();
|
|
12425
|
+
}
|
|
12426
|
+
});
|
|
12427
|
+
});
|
|
12428
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
|
|
12429
|
+
return samlCompletionPromise;
|
|
13170
12430
|
}
|
|
13171
12431
|
/**
|
|
12432
|
+
* Perform SAML authentication
|
|
13172
12433
|
*
|
|
13173
|
-
* @param
|
|
12434
|
+
* @param embedConfig The embed configuration
|
|
12435
|
+
* @param ssoEndPoint
|
|
13174
12436
|
*/
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
12437
|
+
const doSSOAuth = async (embedConfig, ssoEndPoint) => {
|
|
12438
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12439
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12440
|
+
if (loggedIn) {
|
|
12441
|
+
if (isAtSSORedirectUrl()) {
|
|
12442
|
+
removeSSORedirectUrlMarker();
|
|
12443
|
+
}
|
|
12444
|
+
loggedInStatus = true;
|
|
12445
|
+
return;
|
|
12446
|
+
}
|
|
12447
|
+
// we have already tried authentication and it did not succeed, restore
|
|
12448
|
+
// the current URL to the original one and invoke the callback.
|
|
12449
|
+
if (isAtSSORedirectUrl()) {
|
|
12450
|
+
removeSSORedirectUrlMarker();
|
|
12451
|
+
loggedInStatus = false;
|
|
12452
|
+
return;
|
|
12453
|
+
}
|
|
12454
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
12455
|
+
if (embedConfig.inPopup) {
|
|
12456
|
+
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
12457
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12458
|
+
return;
|
|
12459
|
+
}
|
|
12460
|
+
window.location.href = ssoURL;
|
|
12461
|
+
};
|
|
12462
|
+
const doSamlAuth = async (embedConfig) => {
|
|
12463
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12464
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12465
|
+
// loaded again and the same JS will execute again.
|
|
12466
|
+
const ssoRedirectUrl = embedConfig.inPopup
|
|
12467
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12468
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12469
|
+
// bring back the page to the same URL
|
|
12470
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12471
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12472
|
+
return loggedInStatus;
|
|
12473
|
+
};
|
|
12474
|
+
const doOIDCAuth = async (embedConfig) => {
|
|
12475
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12476
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12477
|
+
// loaded again and the same JS will execute again.
|
|
12478
|
+
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
12479
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12480
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12481
|
+
// bring back the page to the same URL
|
|
12482
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12483
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12484
|
+
return loggedInStatus;
|
|
12485
|
+
};
|
|
12486
|
+
const logout = async (embedConfig) => {
|
|
12487
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12488
|
+
await fetchLogoutService(thoughtSpotHost);
|
|
12489
|
+
resetCachedAuthToken();
|
|
12490
|
+
const thoughtspotIframes = document.querySelectorAll("[data-ts-iframe='true']");
|
|
12491
|
+
if (thoughtspotIframes === null || thoughtspotIframes === void 0 ? void 0 : thoughtspotIframes.length) {
|
|
12492
|
+
thoughtspotIframes.forEach((el) => {
|
|
12493
|
+
el.parentElement.innerHTML = embedConfig.loginFailedMessage;
|
|
12494
|
+
});
|
|
12495
|
+
}
|
|
12496
|
+
loggedInStatus = false;
|
|
12497
|
+
return loggedInStatus;
|
|
12498
|
+
};
|
|
13180
12499
|
/**
|
|
12500
|
+
* Perform authentication on the ThoughtSpot cluster
|
|
13181
12501
|
*
|
|
13182
|
-
* @param
|
|
12502
|
+
* @param embedConfig The embed configuration
|
|
13183
12503
|
*/
|
|
13184
|
-
async
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
12504
|
+
const authenticate = async (embedConfig) => {
|
|
12505
|
+
const { authType } = embedConfig;
|
|
12506
|
+
switch (authType) {
|
|
12507
|
+
case AuthType.SSO:
|
|
12508
|
+
case AuthType.SAMLRedirect:
|
|
12509
|
+
case AuthType.SAML:
|
|
12510
|
+
return doSamlAuth(embedConfig);
|
|
12511
|
+
case AuthType.OIDC:
|
|
12512
|
+
case AuthType.OIDCRedirect:
|
|
12513
|
+
return doOIDCAuth(embedConfig);
|
|
12514
|
+
case AuthType.AuthServer:
|
|
12515
|
+
case AuthType.TrustedAuthToken:
|
|
12516
|
+
return doTokenAuth(embedConfig);
|
|
12517
|
+
case AuthType.TrustedAuthTokenCookieless:
|
|
12518
|
+
return doCookielessTokenAuth(embedConfig);
|
|
12519
|
+
case AuthType.Basic:
|
|
12520
|
+
return doBasicAuth(embedConfig);
|
|
12521
|
+
default:
|
|
12522
|
+
return Promise.resolve(true);
|
|
12523
|
+
}
|
|
12524
|
+
};
|
|
12525
|
+
|
|
12526
|
+
const ERROR_MESSAGE = {
|
|
12527
|
+
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
12528
|
+
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
12529
|
+
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
12530
|
+
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
12531
|
+
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
12532
|
+
};
|
|
13193
12533
|
|
|
13194
|
-
// eslint-disable-next-line import/no-mutable-exports
|
|
13195
|
-
let loggedInStatus = false;
|
|
13196
|
-
// eslint-disable-next-line import/no-mutable-exports
|
|
13197
|
-
let samlAuthWindow = null;
|
|
13198
|
-
// eslint-disable-next-line import/no-mutable-exports
|
|
13199
|
-
let samlCompletionPromise = null;
|
|
13200
|
-
let sessionInfo = null;
|
|
13201
|
-
let sessionInfoResolver = null;
|
|
13202
|
-
const sessionInfoPromise = new Promise((resolve) => {
|
|
13203
|
-
sessionInfoResolver = resolve;
|
|
13204
|
-
});
|
|
13205
|
-
let releaseVersion = '';
|
|
13206
|
-
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
13207
12534
|
/**
|
|
13208
|
-
*
|
|
13209
|
-
* of {@link AuthStatus.FAILURE}.
|
|
12535
|
+
* Copyright (c) 2023
|
|
13210
12536
|
*
|
|
13211
|
-
*
|
|
13212
|
-
*/
|
|
13213
|
-
var AuthFailureType;
|
|
13214
|
-
(function (AuthFailureType) {
|
|
13215
|
-
AuthFailureType["SDK"] = "SDK";
|
|
13216
|
-
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
13217
|
-
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
13218
|
-
AuthFailureType["OTHER"] = "OTHER";
|
|
13219
|
-
})(AuthFailureType || (AuthFailureType = {}));
|
|
13220
|
-
/**
|
|
13221
|
-
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
12537
|
+
* Utilities related to reading configuration objects
|
|
13222
12538
|
*
|
|
13223
|
-
* @
|
|
12539
|
+
* @summary Config-related utils
|
|
12540
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
13224
12541
|
*/
|
|
13225
|
-
|
|
13226
|
-
(
|
|
13227
|
-
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
* Emits when the SDK authenticates successfully
|
|
13233
|
-
*/
|
|
13234
|
-
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
13235
|
-
/**
|
|
13236
|
-
* Emits when the app sends an authentication success message
|
|
13237
|
-
*/
|
|
13238
|
-
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
13239
|
-
/**
|
|
13240
|
-
* Emits when a user logs out
|
|
13241
|
-
*/
|
|
13242
|
-
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
13243
|
-
/**
|
|
13244
|
-
* Emitted when inPopup is true in the SAMLRedirect flow and the
|
|
13245
|
-
* popup is waiting to be triggered either programmatically
|
|
13246
|
-
* or by the trigger button.
|
|
13247
|
-
*
|
|
13248
|
-
* @version SDK: 1.19.0
|
|
13249
|
-
*/
|
|
13250
|
-
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
13251
|
-
})(AuthStatus || (AuthStatus = {}));
|
|
12542
|
+
const urlRegex = new RegExp([
|
|
12543
|
+
'(^(https?:)//)?',
|
|
12544
|
+
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
12545
|
+
'(/{0,1}[^?#]*)',
|
|
12546
|
+
'(\\?[^#]*|)',
|
|
12547
|
+
'(#.*|)$', // hash
|
|
12548
|
+
].join(''));
|
|
13252
12549
|
/**
|
|
13253
|
-
*
|
|
12550
|
+
* Parse and construct the ThoughtSpot hostname or IP address
|
|
12551
|
+
* from the embed configuration object.
|
|
13254
12552
|
*
|
|
13255
|
-
* @
|
|
12553
|
+
* @param config
|
|
13256
12554
|
*/
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
}
|
|
13265
|
-
|
|
12555
|
+
const getThoughtSpotHost = (config) => {
|
|
12556
|
+
if (!config.thoughtSpotHost) {
|
|
12557
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12558
|
+
}
|
|
12559
|
+
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
12560
|
+
if (!urlParts) {
|
|
12561
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12562
|
+
}
|
|
12563
|
+
const protocol = urlParts[2] || window.location.protocol;
|
|
12564
|
+
const host = urlParts[3];
|
|
12565
|
+
let path = urlParts[6];
|
|
12566
|
+
// Lose the trailing / if any
|
|
12567
|
+
if (path.charAt(path.length - 1) === '/') {
|
|
12568
|
+
path = path.substring(0, path.length - 1);
|
|
12569
|
+
}
|
|
12570
|
+
// const urlParams = urlParts[7];
|
|
12571
|
+
// const hash = urlParts[8];
|
|
12572
|
+
return `${protocol}//${host}${path}`;
|
|
12573
|
+
};
|
|
12574
|
+
const getV2BasePath = (config) => {
|
|
12575
|
+
if (config.basepath) {
|
|
12576
|
+
return config.basepath;
|
|
12577
|
+
}
|
|
12578
|
+
const tsHost = getThoughtSpotHost(config);
|
|
12579
|
+
// This is to handle when e2e's. Search is run on pods for
|
|
12580
|
+
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
12581
|
+
// This is to handle when the developer is developing in their local
|
|
12582
|
+
// environment.
|
|
12583
|
+
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
12584
|
+
return '';
|
|
12585
|
+
}
|
|
12586
|
+
return 'v2';
|
|
12587
|
+
};
|
|
13266
12588
|
/**
|
|
13267
|
-
*
|
|
13268
|
-
*
|
|
12589
|
+
* It is a good idea to keep URLs under 2000 chars.
|
|
12590
|
+
* If this is ever breached, since we pass view configuration through
|
|
12591
|
+
* URL params, we would like to log a warning.
|
|
12592
|
+
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
13269
12593
|
*/
|
|
13270
|
-
|
|
13271
|
-
authEE = eventEmitter;
|
|
13272
|
-
}
|
|
12594
|
+
const URL_MAX_LENGTH = 2000;
|
|
13273
12595
|
/**
|
|
13274
|
-
*
|
|
12596
|
+
* The default CSS dimensions of the embedded app
|
|
13275
12597
|
*/
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
return;
|
|
13280
|
-
}
|
|
13281
|
-
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
13282
|
-
}
|
|
12598
|
+
const DEFAULT_EMBED_WIDTH = '100%';
|
|
12599
|
+
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
12600
|
+
|
|
13283
12601
|
/**
|
|
13284
12602
|
*
|
|
12603
|
+
* @param root0
|
|
12604
|
+
* @param root0.query
|
|
12605
|
+
* @param root0.variables
|
|
12606
|
+
* @param root0.thoughtSpotHost
|
|
12607
|
+
* @param root0.isCompositeQuery
|
|
13285
12608
|
*/
|
|
13286
|
-
function
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
12609
|
+
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
12610
|
+
const operationName = getOperationNameFromQuery(query);
|
|
12611
|
+
try {
|
|
12612
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
12613
|
+
method: 'POST',
|
|
12614
|
+
headers: {
|
|
12615
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
12616
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12617
|
+
accept: '*/*',
|
|
12618
|
+
'accept-language': 'en-us',
|
|
12619
|
+
},
|
|
12620
|
+
body: JSON.stringify({
|
|
12621
|
+
operationName,
|
|
12622
|
+
query,
|
|
12623
|
+
variables,
|
|
12624
|
+
}),
|
|
12625
|
+
credentials: 'include',
|
|
12626
|
+
});
|
|
12627
|
+
const result = await response.json();
|
|
12628
|
+
const dataValues = Object.values(result.data);
|
|
12629
|
+
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
13290
12630
|
}
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
/**
|
|
13294
|
-
*
|
|
13295
|
-
* @param failureType
|
|
13296
|
-
*/
|
|
13297
|
-
function notifyAuthFailure(failureType) {
|
|
13298
|
-
if (!authEE) {
|
|
13299
|
-
logger.error('SDK not initialized');
|
|
13300
|
-
return;
|
|
12631
|
+
catch (error) {
|
|
12632
|
+
return error;
|
|
13301
12633
|
}
|
|
13302
|
-
|
|
13303
|
-
|
|
12634
|
+
}
|
|
12635
|
+
|
|
12636
|
+
const getSourceDetailQuery = `
|
|
12637
|
+
query GetSourceDetail($ids: [GUID!]!) {
|
|
12638
|
+
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
12639
|
+
id
|
|
12640
|
+
name
|
|
12641
|
+
description
|
|
12642
|
+
authorName
|
|
12643
|
+
authorDisplayName
|
|
12644
|
+
isExternal
|
|
12645
|
+
type
|
|
12646
|
+
created
|
|
12647
|
+
modified
|
|
12648
|
+
columns {
|
|
12649
|
+
id
|
|
12650
|
+
name
|
|
12651
|
+
author
|
|
12652
|
+
authorDisplayName
|
|
12653
|
+
description
|
|
12654
|
+
dataType
|
|
12655
|
+
type
|
|
12656
|
+
modified
|
|
12657
|
+
ownerName
|
|
12658
|
+
owner
|
|
12659
|
+
dataRecency
|
|
12660
|
+
sources {
|
|
12661
|
+
tableId
|
|
12662
|
+
tableName
|
|
12663
|
+
columnId
|
|
12664
|
+
columnName
|
|
12665
|
+
__typename
|
|
12666
|
+
}
|
|
12667
|
+
synonyms
|
|
12668
|
+
cohortAnswerId
|
|
12669
|
+
__typename
|
|
12670
|
+
}
|
|
12671
|
+
relationships
|
|
12672
|
+
destinationRelationships
|
|
12673
|
+
dataSourceId
|
|
12674
|
+
__typename
|
|
12675
|
+
}
|
|
12676
|
+
}
|
|
12677
|
+
`;
|
|
12678
|
+
const sourceDetailCache = new Map();
|
|
13304
12679
|
/**
|
|
13305
12680
|
*
|
|
12681
|
+
* @param thoughtSpotHost
|
|
12682
|
+
* @param sourceId
|
|
13306
12683
|
*/
|
|
13307
|
-
function
|
|
13308
|
-
if (
|
|
13309
|
-
|
|
13310
|
-
return;
|
|
12684
|
+
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
12685
|
+
if (sourceDetailCache.get(sourceId)) {
|
|
12686
|
+
return sourceDetailCache.get(sourceId);
|
|
13311
12687
|
}
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
12688
|
+
const details = await graphqlQuery({
|
|
12689
|
+
query: getSourceDetailQuery,
|
|
12690
|
+
variables: {
|
|
12691
|
+
ids: [sourceId],
|
|
12692
|
+
},
|
|
12693
|
+
thoughtSpotHost,
|
|
12694
|
+
});
|
|
12695
|
+
const souceDetails = details[0];
|
|
12696
|
+
if (souceDetails) {
|
|
12697
|
+
sourceDetailCache.set(sourceId, souceDetails);
|
|
13322
12698
|
}
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
}
|
|
12699
|
+
return souceDetails;
|
|
12700
|
+
}
|
|
12701
|
+
|
|
12702
|
+
const bachSessionId = `
|
|
12703
|
+
id {
|
|
12704
|
+
sessionId
|
|
12705
|
+
genNo
|
|
12706
|
+
acSession {
|
|
12707
|
+
sessionId
|
|
12708
|
+
genNo
|
|
12709
|
+
}
|
|
12710
|
+
}
|
|
12711
|
+
`;
|
|
12712
|
+
const getUnaggregatedAnswerSession = `
|
|
12713
|
+
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
12714
|
+
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
12715
|
+
${bachSessionId}
|
|
12716
|
+
answer {
|
|
12717
|
+
visualizations {
|
|
12718
|
+
... on TableViz {
|
|
12719
|
+
columns {
|
|
12720
|
+
column {
|
|
12721
|
+
id
|
|
12722
|
+
name
|
|
12723
|
+
referencedColumns {
|
|
12724
|
+
guid
|
|
12725
|
+
displayName
|
|
12726
|
+
}
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
}
|
|
12731
|
+
}
|
|
12732
|
+
}
|
|
12733
|
+
}
|
|
12734
|
+
`;
|
|
12735
|
+
const removeColumns = `
|
|
12736
|
+
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
12737
|
+
Answer__removeColumns(
|
|
12738
|
+
session: $session
|
|
12739
|
+
logicalColumnIds: $logicalColumnIds
|
|
12740
|
+
columnIds: $columnIds
|
|
12741
|
+
) {
|
|
12742
|
+
${bachSessionId}
|
|
12743
|
+
}
|
|
12744
|
+
}
|
|
12745
|
+
`;
|
|
12746
|
+
const addColumns = `
|
|
12747
|
+
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
12748
|
+
Answer__addColumn(session: $session, columns: $columns) {
|
|
12749
|
+
${bachSessionId}
|
|
12750
|
+
}
|
|
12751
|
+
}
|
|
12752
|
+
`;
|
|
12753
|
+
const getAnswerData = `
|
|
12754
|
+
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
12755
|
+
getAnswer(session: $session) {
|
|
12756
|
+
${bachSessionId}
|
|
12757
|
+
answer {
|
|
12758
|
+
id
|
|
12759
|
+
visualizations {
|
|
12760
|
+
id
|
|
12761
|
+
... on TableViz {
|
|
12762
|
+
columns {
|
|
12763
|
+
column {
|
|
12764
|
+
id
|
|
12765
|
+
name
|
|
12766
|
+
type
|
|
12767
|
+
aggregationType
|
|
12768
|
+
dataType
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12774
|
+
}
|
|
12775
|
+
}
|
|
12776
|
+
}
|
|
12777
|
+
`;
|
|
12778
|
+
|
|
12779
|
+
// eslint-disable-next-line no-shadow
|
|
12780
|
+
var OperationType;
|
|
12781
|
+
(function (OperationType) {
|
|
12782
|
+
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
12783
|
+
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
12784
|
+
})(OperationType || (OperationType = {}));
|
|
13340
12785
|
/**
|
|
13341
|
-
*
|
|
12786
|
+
* Class representing the answer service provided with the
|
|
12787
|
+
* custom action payload. This service could be used to run
|
|
12788
|
+
* graphql queries in the context of the answer on which the
|
|
12789
|
+
* custom action was triggered.
|
|
13342
12790
|
*
|
|
13343
|
-
* @
|
|
12791
|
+
* @example
|
|
12792
|
+
* ```js
|
|
12793
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12794
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12795
|
+
* 'col name 1'
|
|
12796
|
+
* ]);
|
|
12797
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12798
|
+
* })
|
|
12799
|
+
* ```
|
|
12800
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12801
|
+
* @group Events
|
|
13344
12802
|
*/
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
12803
|
+
class AnswerService {
|
|
12804
|
+
/**
|
|
12805
|
+
* Should not need to be called directly.
|
|
12806
|
+
*
|
|
12807
|
+
* @param session
|
|
12808
|
+
* @param answer
|
|
12809
|
+
* @param thoughtSpotHost
|
|
12810
|
+
* @param selectedPoints
|
|
12811
|
+
*/
|
|
12812
|
+
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
12813
|
+
this.session = session;
|
|
12814
|
+
this.answer = answer;
|
|
12815
|
+
this.thoughtSpotHost = thoughtSpotHost;
|
|
12816
|
+
this.selectedPoints = selectedPoints;
|
|
12817
|
+
this.session = removeTypename(session);
|
|
13355
12818
|
}
|
|
13356
|
-
|
|
13357
|
-
|
|
12819
|
+
/**
|
|
12820
|
+
* Get the details about the source used in the answer.
|
|
12821
|
+
* This can be used to get the list of all columns in the data source for example.
|
|
12822
|
+
*/
|
|
12823
|
+
async getSourceDetail() {
|
|
12824
|
+
const sourceId = this.answer.sources[0].header.guid;
|
|
12825
|
+
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
13358
12826
|
}
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
* authentication is successful. And info is available.
|
|
13370
|
-
*
|
|
13371
|
-
* @group Global methods
|
|
13372
|
-
*/
|
|
13373
|
-
function getSessionInfo() {
|
|
13374
|
-
return sessionInfoPromise;
|
|
13375
|
-
}
|
|
13376
|
-
/**
|
|
13377
|
-
* Check if we are stuck at the SSO redirect URL
|
|
13378
|
-
*/
|
|
13379
|
-
function isAtSSORedirectUrl() {
|
|
13380
|
-
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
13381
|
-
}
|
|
13382
|
-
/**
|
|
13383
|
-
* Remove the SSO redirect URL marker
|
|
13384
|
-
*/
|
|
13385
|
-
function removeSSORedirectUrlMarker() {
|
|
13386
|
-
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
13387
|
-
// to begin with. Trying to remove the hash by changing window.location will
|
|
13388
|
-
// reload the page which we don't want. We'll live with adding an
|
|
13389
|
-
// unnecessary hash to the parent page URL until we find any use case where
|
|
13390
|
-
// that creates an issue.
|
|
13391
|
-
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
13392
|
-
}
|
|
13393
|
-
/**
|
|
13394
|
-
* Perform token based authentication
|
|
13395
|
-
*
|
|
13396
|
-
* @param embedConfig The embed configuration
|
|
13397
|
-
*/
|
|
13398
|
-
const doTokenAuth = async (embedConfig) => {
|
|
13399
|
-
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
13400
|
-
if (!authEndpoint && !getAuthToken) {
|
|
13401
|
-
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12827
|
+
/**
|
|
12828
|
+
* Remove columnIds and return updated answer session.
|
|
12829
|
+
*
|
|
12830
|
+
* @param columnIds
|
|
12831
|
+
* @returns
|
|
12832
|
+
*/
|
|
12833
|
+
async removeColumns(columnIds) {
|
|
12834
|
+
return this.executeQuery(removeColumns, {
|
|
12835
|
+
logicalColumnIds: columnIds,
|
|
12836
|
+
});
|
|
13402
12837
|
}
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
}
|
|
13413
|
-
// token login issues a 302 when successful
|
|
13414
|
-
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
13415
|
-
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
13416
|
-
// When 3rd party cookie access is blocked, this will fail because
|
|
13417
|
-
// cookies will not be sent with the call.
|
|
13418
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13419
|
-
}
|
|
12838
|
+
/**
|
|
12839
|
+
* Add columnIds and return updated answer session.
|
|
12840
|
+
*
|
|
12841
|
+
* @param columnIds
|
|
12842
|
+
* @returns
|
|
12843
|
+
*/
|
|
12844
|
+
async addColumns(columnIds) {
|
|
12845
|
+
return this.executeQuery(addColumns, {
|
|
12846
|
+
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
12847
|
+
});
|
|
13420
12848
|
}
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
12849
|
+
/**
|
|
12850
|
+
* Fetch data from the answer.
|
|
12851
|
+
*
|
|
12852
|
+
* @param offset
|
|
12853
|
+
* @param size
|
|
12854
|
+
* @returns
|
|
12855
|
+
*/
|
|
12856
|
+
async fetchData(offset = 0, size = 1000) {
|
|
12857
|
+
const { answer } = await this.executeQuery(getAnswerData, {
|
|
12858
|
+
deadline: 0,
|
|
12859
|
+
dataPaginationParams: {
|
|
12860
|
+
isClientPaginated: true,
|
|
12861
|
+
offset,
|
|
12862
|
+
size,
|
|
12863
|
+
},
|
|
12864
|
+
});
|
|
12865
|
+
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
12866
|
+
return {
|
|
12867
|
+
columns,
|
|
12868
|
+
data,
|
|
12869
|
+
};
|
|
13432
12870
|
}
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
12871
|
+
/**
|
|
12872
|
+
* Fetch the data for the answer as a CSV blob. This might be
|
|
12873
|
+
* quicker for larger data.
|
|
12874
|
+
*
|
|
12875
|
+
* @param userLocale
|
|
12876
|
+
* @param includeInfo Include the CSV header in the output
|
|
12877
|
+
* @returns Response
|
|
12878
|
+
*/
|
|
12879
|
+
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
12880
|
+
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
12881
|
+
return tokenizedFetch(fetchUrl, {
|
|
12882
|
+
credentials: 'include',
|
|
12883
|
+
});
|
|
13439
12884
|
}
|
|
13440
|
-
|
|
13441
|
-
|
|
12885
|
+
/**
|
|
12886
|
+
* Just get the internal URL for this answer's data
|
|
12887
|
+
* as a CSV blob.
|
|
12888
|
+
*
|
|
12889
|
+
* @param userLocale
|
|
12890
|
+
* @param includeInfo
|
|
12891
|
+
* @returns
|
|
12892
|
+
*/
|
|
12893
|
+
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
12894
|
+
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
13442
12895
|
}
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
12896
|
+
/**
|
|
12897
|
+
* Get underlying data given a point and the output column names.
|
|
12898
|
+
* In case of a context menu action, the selectedPoints are
|
|
12899
|
+
* automatically passed.
|
|
12900
|
+
*
|
|
12901
|
+
* @param outputColumnNames
|
|
12902
|
+
* @param selectedPoints
|
|
12903
|
+
* @example
|
|
12904
|
+
* ```js
|
|
12905
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12906
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12907
|
+
* 'col name 1' // The column should exist in the data source.
|
|
12908
|
+
* ]);
|
|
12909
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12910
|
+
* })
|
|
12911
|
+
* ```
|
|
12912
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12913
|
+
*/
|
|
12914
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
12915
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
12916
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
12917
|
+
}
|
|
12918
|
+
if (!selectedPoints) {
|
|
12919
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
12920
|
+
}
|
|
12921
|
+
const sourceDetail = await this.getSourceDetail();
|
|
12922
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
12923
|
+
const unAggAnswer = await graphqlQuery({
|
|
12924
|
+
query: getUnaggregatedAnswerSession,
|
|
12925
|
+
variables: {
|
|
12926
|
+
session: this.session,
|
|
12927
|
+
columns: selectedPoints,
|
|
12928
|
+
},
|
|
12929
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12930
|
+
});
|
|
12931
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
12932
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
12933
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
12934
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
12935
|
+
if (columnsToAdd.length) {
|
|
12936
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
12937
|
+
}
|
|
12938
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
12939
|
+
if (columnsToRemove.length) {
|
|
12940
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
13462
12941
|
}
|
|
12942
|
+
return unaggAnswerSession;
|
|
13463
12943
|
}
|
|
13464
|
-
|
|
13465
|
-
|
|
12944
|
+
/**
|
|
12945
|
+
* Execute a custom graphql query in the context of the answer.
|
|
12946
|
+
*
|
|
12947
|
+
* @param query graphql query
|
|
12948
|
+
* @param variables graphql variables
|
|
12949
|
+
* @returns
|
|
12950
|
+
*/
|
|
12951
|
+
async executeQuery(query, variables) {
|
|
12952
|
+
const data = await graphqlQuery({
|
|
12953
|
+
query,
|
|
12954
|
+
variables: {
|
|
12955
|
+
session: this.session,
|
|
12956
|
+
...variables,
|
|
12957
|
+
},
|
|
12958
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12959
|
+
isCompositeQuery: false,
|
|
12960
|
+
});
|
|
12961
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
12962
|
+
return data;
|
|
13466
12963
|
}
|
|
13467
|
-
|
|
13468
|
-
|
|
12964
|
+
/**
|
|
12965
|
+
* Get the internal session details for the answer.
|
|
12966
|
+
*
|
|
12967
|
+
* @returns
|
|
12968
|
+
*/
|
|
12969
|
+
getSession() {
|
|
12970
|
+
return this.session;
|
|
12971
|
+
}
|
|
12972
|
+
}
|
|
13469
12973
|
/**
|
|
13470
12974
|
*
|
|
13471
|
-
* @param
|
|
13472
|
-
* @param
|
|
13473
|
-
* @param triggerText
|
|
12975
|
+
* @param sourceDetail
|
|
12976
|
+
* @param colNames
|
|
13474
12977
|
*/
|
|
13475
|
-
|
|
13476
|
-
const
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
};
|
|
13484
|
-
authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
|
|
13485
|
-
const containerEl = getDOMNode(triggerContainer);
|
|
13486
|
-
if (containerEl) {
|
|
13487
|
-
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
13488
|
-
const authElem = document.getElementById('ts-auth-btn');
|
|
13489
|
-
authElem.textContent = triggerText;
|
|
13490
|
-
authElem.addEventListener('click', openPopup, { once: true });
|
|
13491
|
-
}
|
|
13492
|
-
samlCompletionPromise = samlCompletionPromise
|
|
13493
|
-
|| new Promise((resolve, reject) => {
|
|
13494
|
-
window.addEventListener('message', (e) => {
|
|
13495
|
-
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
13496
|
-
e.source.close();
|
|
13497
|
-
resolve();
|
|
13498
|
-
}
|
|
13499
|
-
});
|
|
13500
|
-
});
|
|
13501
|
-
authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
|
|
13502
|
-
return samlCompletionPromise;
|
|
12978
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
12979
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
12980
|
+
colSet[col.name] = col;
|
|
12981
|
+
return colSet;
|
|
12982
|
+
}, {});
|
|
12983
|
+
return new Set(colNames.map((colName) => {
|
|
12984
|
+
const col = cols[colName];
|
|
12985
|
+
return col.id;
|
|
12986
|
+
}));
|
|
13503
12987
|
}
|
|
13504
12988
|
/**
|
|
13505
|
-
* Perform SAML authentication
|
|
13506
12989
|
*
|
|
13507
|
-
* @param
|
|
13508
|
-
* @param ssoEndPoint
|
|
12990
|
+
* @param selectedPoints
|
|
13509
12991
|
*/
|
|
13510
|
-
|
|
13511
|
-
const
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
12992
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
12993
|
+
const underlyingDataPoint = [];
|
|
12994
|
+
/**
|
|
12995
|
+
*
|
|
12996
|
+
* @param colVal
|
|
12997
|
+
*/
|
|
12998
|
+
function addPointFromColVal(colVal) {
|
|
12999
|
+
var _a;
|
|
13000
|
+
const dataType = colVal.column.dataType;
|
|
13001
|
+
const id = colVal.column.id;
|
|
13002
|
+
let dataValue;
|
|
13003
|
+
if (dataType === 'DATE') {
|
|
13004
|
+
if (Number.isFinite(colVal.value)) {
|
|
13005
|
+
dataValue = [{
|
|
13006
|
+
epochRange: {
|
|
13007
|
+
startEpoch: colVal.value,
|
|
13008
|
+
},
|
|
13009
|
+
}];
|
|
13010
|
+
// Case for custom calendar.
|
|
13011
|
+
}
|
|
13012
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
13013
|
+
dataValue = [{
|
|
13014
|
+
epochRange: {
|
|
13015
|
+
startEpoch: colVal.value.v.s,
|
|
13016
|
+
endEpoch: colVal.value.v.e,
|
|
13017
|
+
},
|
|
13018
|
+
}];
|
|
13019
|
+
}
|
|
13516
13020
|
}
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
removeSSORedirectUrlMarker();
|
|
13524
|
-
loggedInStatus = false;
|
|
13525
|
-
return;
|
|
13526
|
-
}
|
|
13527
|
-
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
13528
|
-
if (embedConfig.inPopup) {
|
|
13529
|
-
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
13530
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13531
|
-
return;
|
|
13532
|
-
}
|
|
13533
|
-
window.location.href = ssoURL;
|
|
13534
|
-
};
|
|
13535
|
-
const doSamlAuth = async (embedConfig) => {
|
|
13536
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13537
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13538
|
-
// loaded again and the same JS will execute again.
|
|
13539
|
-
const ssoRedirectUrl = embedConfig.inPopup
|
|
13540
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13541
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13542
|
-
// bring back the page to the same URL
|
|
13543
|
-
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13544
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13545
|
-
return loggedInStatus;
|
|
13546
|
-
};
|
|
13547
|
-
const doOIDCAuth = async (embedConfig) => {
|
|
13548
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13549
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13550
|
-
// loaded again and the same JS will execute again.
|
|
13551
|
-
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
13552
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13553
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13554
|
-
// bring back the page to the same URL
|
|
13555
|
-
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13556
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13557
|
-
return loggedInStatus;
|
|
13558
|
-
};
|
|
13559
|
-
const logout = async (embedConfig) => {
|
|
13560
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13561
|
-
await fetchLogoutService(thoughtSpotHost);
|
|
13562
|
-
resetCachedAuthToken();
|
|
13563
|
-
const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
|
|
13564
|
-
if (thoughtspotIframes === null || thoughtspotIframes === void 0 ? void 0 : thoughtspotIframes.length) {
|
|
13565
|
-
thoughtspotIframes.forEach((el) => {
|
|
13566
|
-
el.parentElement.innerHTML = embedConfig.loginFailedMessage;
|
|
13021
|
+
else {
|
|
13022
|
+
dataValue = [{ value: colVal.value }];
|
|
13023
|
+
}
|
|
13024
|
+
underlyingDataPoint.push({
|
|
13025
|
+
columnId: colVal.column.id,
|
|
13026
|
+
dataValue,
|
|
13567
13027
|
});
|
|
13568
13028
|
}
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
};
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13029
|
+
selectedPoints.forEach((p) => {
|
|
13030
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
13031
|
+
});
|
|
13032
|
+
return underlyingDataPoint;
|
|
13033
|
+
}
|
|
13034
|
+
|
|
13035
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
13036
|
+
|
|
13037
|
+
var has = Object.prototype.hasOwnProperty
|
|
13038
|
+
, prefix = '~';
|
|
13039
|
+
|
|
13040
|
+
/**
|
|
13041
|
+
* Constructor to create a storage for our `EE` objects.
|
|
13042
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
13043
|
+
*
|
|
13044
|
+
* @constructor
|
|
13045
|
+
* @private
|
|
13046
|
+
*/
|
|
13047
|
+
function Events() {}
|
|
13048
|
+
|
|
13049
|
+
//
|
|
13050
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
13051
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
13052
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
13053
|
+
// character to make sure that the built-in object properties are not
|
|
13054
|
+
// overridden or used as an attack vector.
|
|
13055
|
+
//
|
|
13056
|
+
if (Object.create) {
|
|
13057
|
+
Events.prototype = Object.create(null);
|
|
13058
|
+
|
|
13059
|
+
//
|
|
13060
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
13061
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
13062
|
+
//
|
|
13063
|
+
if (!new Events().__proto__) prefix = false;
|
|
13064
|
+
}
|
|
13065
|
+
|
|
13066
|
+
/**
|
|
13067
|
+
* Representation of a single event listener.
|
|
13068
|
+
*
|
|
13069
|
+
* @param {Function} fn The listener function.
|
|
13070
|
+
* @param {*} context The context to invoke the listener with.
|
|
13071
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
13072
|
+
* @constructor
|
|
13073
|
+
* @private
|
|
13074
|
+
*/
|
|
13075
|
+
function EE(fn, context, once) {
|
|
13076
|
+
this.fn = fn;
|
|
13077
|
+
this.context = context;
|
|
13078
|
+
this.once = once || false;
|
|
13079
|
+
}
|
|
13080
|
+
|
|
13081
|
+
/**
|
|
13082
|
+
* Add a listener for a given event.
|
|
13083
|
+
*
|
|
13084
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13085
|
+
* @param {(String|Symbol)} event The event name.
|
|
13086
|
+
* @param {Function} fn The listener function.
|
|
13087
|
+
* @param {*} context The context to invoke the listener with.
|
|
13088
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
13089
|
+
* @returns {EventEmitter}
|
|
13090
|
+
* @private
|
|
13091
|
+
*/
|
|
13092
|
+
function addListener(emitter, event, fn, context, once) {
|
|
13093
|
+
if (typeof fn !== 'function') {
|
|
13094
|
+
throw new TypeError('The listener must be a function');
|
|
13095
|
+
}
|
|
13096
|
+
|
|
13097
|
+
var listener = new EE(fn, context || emitter, once)
|
|
13098
|
+
, evt = prefix ? prefix + event : event;
|
|
13099
|
+
|
|
13100
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
13101
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
13102
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
13103
|
+
|
|
13104
|
+
return emitter;
|
|
13105
|
+
}
|
|
13106
|
+
|
|
13107
|
+
/**
|
|
13108
|
+
* Clear event by name.
|
|
13109
|
+
*
|
|
13110
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13111
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
13112
|
+
* @private
|
|
13113
|
+
*/
|
|
13114
|
+
function clearEvent(emitter, evt) {
|
|
13115
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
13116
|
+
else delete emitter._events[evt];
|
|
13117
|
+
}
|
|
13118
|
+
|
|
13119
|
+
/**
|
|
13120
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
13121
|
+
* `EventEmitter` interface.
|
|
13122
|
+
*
|
|
13123
|
+
* @constructor
|
|
13124
|
+
* @public
|
|
13125
|
+
*/
|
|
13126
|
+
function EventEmitter() {
|
|
13127
|
+
this._events = new Events();
|
|
13128
|
+
this._eventsCount = 0;
|
|
13129
|
+
}
|
|
13130
|
+
|
|
13131
|
+
/**
|
|
13132
|
+
* Return an array listing the events for which the emitter has registered
|
|
13133
|
+
* listeners.
|
|
13134
|
+
*
|
|
13135
|
+
* @returns {Array}
|
|
13136
|
+
* @public
|
|
13137
|
+
*/
|
|
13138
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
13139
|
+
var names = []
|
|
13140
|
+
, events
|
|
13141
|
+
, name;
|
|
13142
|
+
|
|
13143
|
+
if (this._eventsCount === 0) return names;
|
|
13144
|
+
|
|
13145
|
+
for (name in (events = this._events)) {
|
|
13146
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
13147
|
+
}
|
|
13148
|
+
|
|
13149
|
+
if (Object.getOwnPropertySymbols) {
|
|
13150
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
13151
|
+
}
|
|
13152
|
+
|
|
13153
|
+
return names;
|
|
13154
|
+
};
|
|
13155
|
+
|
|
13156
|
+
/**
|
|
13157
|
+
* Return the listeners registered for a given event.
|
|
13158
|
+
*
|
|
13159
|
+
* @param {(String|Symbol)} event The event name.
|
|
13160
|
+
* @returns {Array} The registered listeners.
|
|
13161
|
+
* @public
|
|
13162
|
+
*/
|
|
13163
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
13164
|
+
var evt = prefix ? prefix + event : event
|
|
13165
|
+
, handlers = this._events[evt];
|
|
13166
|
+
|
|
13167
|
+
if (!handlers) return [];
|
|
13168
|
+
if (handlers.fn) return [handlers.fn];
|
|
13169
|
+
|
|
13170
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
13171
|
+
ee[i] = handlers[i].fn;
|
|
13172
|
+
}
|
|
13173
|
+
|
|
13174
|
+
return ee;
|
|
13175
|
+
};
|
|
13176
|
+
|
|
13177
|
+
/**
|
|
13178
|
+
* Return the number of listeners listening to a given event.
|
|
13179
|
+
*
|
|
13180
|
+
* @param {(String|Symbol)} event The event name.
|
|
13181
|
+
* @returns {Number} The number of listeners.
|
|
13182
|
+
* @public
|
|
13183
|
+
*/
|
|
13184
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
13185
|
+
var evt = prefix ? prefix + event : event
|
|
13186
|
+
, listeners = this._events[evt];
|
|
13187
|
+
|
|
13188
|
+
if (!listeners) return 0;
|
|
13189
|
+
if (listeners.fn) return 1;
|
|
13190
|
+
return listeners.length;
|
|
13191
|
+
};
|
|
13192
|
+
|
|
13193
|
+
/**
|
|
13194
|
+
* Calls each of the listeners registered for a given event.
|
|
13195
|
+
*
|
|
13196
|
+
* @param {(String|Symbol)} event The event name.
|
|
13197
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
13198
|
+
* @public
|
|
13199
|
+
*/
|
|
13200
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
13201
|
+
var evt = prefix ? prefix + event : event;
|
|
13202
|
+
|
|
13203
|
+
if (!this._events[evt]) return false;
|
|
13204
|
+
|
|
13205
|
+
var listeners = this._events[evt]
|
|
13206
|
+
, len = arguments.length
|
|
13207
|
+
, args
|
|
13208
|
+
, i;
|
|
13209
|
+
|
|
13210
|
+
if (listeners.fn) {
|
|
13211
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
13212
|
+
|
|
13213
|
+
switch (len) {
|
|
13214
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
13215
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
13216
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
13217
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
13218
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
13219
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
13220
|
+
}
|
|
13221
|
+
|
|
13222
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
13223
|
+
args[i - 1] = arguments[i];
|
|
13224
|
+
}
|
|
13225
|
+
|
|
13226
|
+
listeners.fn.apply(listeners.context, args);
|
|
13227
|
+
} else {
|
|
13228
|
+
var length = listeners.length
|
|
13229
|
+
, j;
|
|
13230
|
+
|
|
13231
|
+
for (i = 0; i < length; i++) {
|
|
13232
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
13233
|
+
|
|
13234
|
+
switch (len) {
|
|
13235
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
13236
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
13237
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
13238
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
13239
|
+
default:
|
|
13240
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
13241
|
+
args[j - 1] = arguments[j];
|
|
13242
|
+
}
|
|
13243
|
+
|
|
13244
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
13245
|
+
}
|
|
13246
|
+
}
|
|
13247
|
+
}
|
|
13248
|
+
|
|
13249
|
+
return true;
|
|
13250
|
+
};
|
|
13251
|
+
|
|
13252
|
+
/**
|
|
13253
|
+
* Add a listener for a given event.
|
|
13254
|
+
*
|
|
13255
|
+
* @param {(String|Symbol)} event The event name.
|
|
13256
|
+
* @param {Function} fn The listener function.
|
|
13257
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13258
|
+
* @returns {EventEmitter} `this`.
|
|
13259
|
+
* @public
|
|
13260
|
+
*/
|
|
13261
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
13262
|
+
return addListener(this, event, fn, context, false);
|
|
13263
|
+
};
|
|
13264
|
+
|
|
13265
|
+
/**
|
|
13266
|
+
* Add a one-time listener for a given event.
|
|
13267
|
+
*
|
|
13268
|
+
* @param {(String|Symbol)} event The event name.
|
|
13269
|
+
* @param {Function} fn The listener function.
|
|
13270
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13271
|
+
* @returns {EventEmitter} `this`.
|
|
13272
|
+
* @public
|
|
13273
|
+
*/
|
|
13274
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
13275
|
+
return addListener(this, event, fn, context, true);
|
|
13276
|
+
};
|
|
13277
|
+
|
|
13278
|
+
/**
|
|
13279
|
+
* Remove the listeners of a given event.
|
|
13280
|
+
*
|
|
13281
|
+
* @param {(String|Symbol)} event The event name.
|
|
13282
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
13283
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
13284
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
13285
|
+
* @returns {EventEmitter} `this`.
|
|
13286
|
+
* @public
|
|
13287
|
+
*/
|
|
13288
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
13289
|
+
var evt = prefix ? prefix + event : event;
|
|
13290
|
+
|
|
13291
|
+
if (!this._events[evt]) return this;
|
|
13292
|
+
if (!fn) {
|
|
13293
|
+
clearEvent(this, evt);
|
|
13294
|
+
return this;
|
|
13295
|
+
}
|
|
13296
|
+
|
|
13297
|
+
var listeners = this._events[evt];
|
|
13298
|
+
|
|
13299
|
+
if (listeners.fn) {
|
|
13300
|
+
if (
|
|
13301
|
+
listeners.fn === fn &&
|
|
13302
|
+
(!once || listeners.once) &&
|
|
13303
|
+
(!context || listeners.context === context)
|
|
13304
|
+
) {
|
|
13305
|
+
clearEvent(this, evt);
|
|
13306
|
+
}
|
|
13307
|
+
} else {
|
|
13308
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
13309
|
+
if (
|
|
13310
|
+
listeners[i].fn !== fn ||
|
|
13311
|
+
(once && !listeners[i].once) ||
|
|
13312
|
+
(context && listeners[i].context !== context)
|
|
13313
|
+
) {
|
|
13314
|
+
events.push(listeners[i]);
|
|
13315
|
+
}
|
|
13316
|
+
}
|
|
13317
|
+
|
|
13318
|
+
//
|
|
13319
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
13320
|
+
//
|
|
13321
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
13322
|
+
else clearEvent(this, evt);
|
|
13323
|
+
}
|
|
13324
|
+
|
|
13325
|
+
return this;
|
|
13326
|
+
};
|
|
13327
|
+
|
|
13328
|
+
/**
|
|
13329
|
+
* Remove all listeners, or those of the specified event.
|
|
13330
|
+
*
|
|
13331
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
13332
|
+
* @returns {EventEmitter} `this`.
|
|
13333
|
+
* @public
|
|
13334
|
+
*/
|
|
13335
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
13336
|
+
var evt;
|
|
13337
|
+
|
|
13338
|
+
if (event) {
|
|
13339
|
+
evt = prefix ? prefix + event : event;
|
|
13340
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
13341
|
+
} else {
|
|
13342
|
+
this._events = new Events();
|
|
13343
|
+
this._eventsCount = 0;
|
|
13344
|
+
}
|
|
13345
|
+
|
|
13346
|
+
return this;
|
|
13347
|
+
};
|
|
13348
|
+
|
|
13349
|
+
//
|
|
13350
|
+
// Alias methods names because people roll like that.
|
|
13351
|
+
//
|
|
13352
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
13353
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
13354
|
+
|
|
13355
|
+
//
|
|
13356
|
+
// Expose the prefix.
|
|
13357
|
+
//
|
|
13358
|
+
EventEmitter.prefixed = prefix;
|
|
13359
|
+
|
|
13360
|
+
//
|
|
13361
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
13362
|
+
//
|
|
13363
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
13364
|
+
|
|
13365
|
+
//
|
|
13366
|
+
// Expose the module.
|
|
13367
|
+
//
|
|
13368
|
+
{
|
|
13369
|
+
module.exports = EventEmitter;
|
|
13370
|
+
}
|
|
13371
|
+
});
|
|
13372
|
+
|
|
13373
|
+
/**
|
|
13374
|
+
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
13375
|
+
* support for iteratee shorthands.
|
|
13376
|
+
*
|
|
13377
|
+
* @private
|
|
13378
|
+
* @param {Array} array The array to inspect.
|
|
13379
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
13380
|
+
* @param {number} fromIndex The index to search from.
|
|
13381
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
13382
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
13383
|
+
*/
|
|
13384
|
+
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
13385
|
+
var length = array.length,
|
|
13386
|
+
index = fromIndex + (fromRight ? 1 : -1);
|
|
13387
|
+
|
|
13388
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
13389
|
+
if (predicate(array[index], index, array)) {
|
|
13390
|
+
return index;
|
|
13391
|
+
}
|
|
13392
|
+
}
|
|
13393
|
+
return -1;
|
|
13394
|
+
}
|
|
13395
|
+
|
|
13396
|
+
var _baseFindIndex = baseFindIndex;
|
|
13397
|
+
|
|
13398
|
+
/**
|
|
13399
|
+
* The base implementation of `_.isNaN` without support for number objects.
|
|
13400
|
+
*
|
|
13401
|
+
* @private
|
|
13402
|
+
* @param {*} value The value to check.
|
|
13403
|
+
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
13404
|
+
*/
|
|
13405
|
+
function baseIsNaN(value) {
|
|
13406
|
+
return value !== value;
|
|
13407
|
+
}
|
|
13408
|
+
|
|
13409
|
+
var _baseIsNaN = baseIsNaN;
|
|
13410
|
+
|
|
13411
|
+
/**
|
|
13412
|
+
* A specialized version of `_.indexOf` which performs strict equality
|
|
13413
|
+
* comparisons of values, i.e. `===`.
|
|
13414
|
+
*
|
|
13415
|
+
* @private
|
|
13416
|
+
* @param {Array} array The array to inspect.
|
|
13417
|
+
* @param {*} value The value to search for.
|
|
13418
|
+
* @param {number} fromIndex The index to search from.
|
|
13419
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
13420
|
+
*/
|
|
13421
|
+
function strictIndexOf(array, value, fromIndex) {
|
|
13422
|
+
var index = fromIndex - 1,
|
|
13423
|
+
length = array.length;
|
|
13424
|
+
|
|
13425
|
+
while (++index < length) {
|
|
13426
|
+
if (array[index] === value) {
|
|
13427
|
+
return index;
|
|
13428
|
+
}
|
|
13429
|
+
}
|
|
13430
|
+
return -1;
|
|
13431
|
+
}
|
|
13432
|
+
|
|
13433
|
+
var _strictIndexOf = strictIndexOf;
|
|
13434
|
+
|
|
13435
|
+
/**
|
|
13436
|
+
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
13437
|
+
*
|
|
13438
|
+
* @private
|
|
13439
|
+
* @param {Array} array The array to inspect.
|
|
13440
|
+
* @param {*} value The value to search for.
|
|
13441
|
+
* @param {number} fromIndex The index to search from.
|
|
13442
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
13443
|
+
*/
|
|
13444
|
+
function baseIndexOf(array, value, fromIndex) {
|
|
13445
|
+
return value === value
|
|
13446
|
+
? _strictIndexOf(array, value, fromIndex)
|
|
13447
|
+
: _baseFindIndex(array, _baseIsNaN, fromIndex);
|
|
13448
|
+
}
|
|
13449
|
+
|
|
13450
|
+
var _baseIndexOf = baseIndexOf;
|
|
13451
|
+
|
|
13452
|
+
/**
|
|
13453
|
+
* A specialized version of `_.includes` for arrays without support for
|
|
13454
|
+
* specifying an index to search from.
|
|
13455
|
+
*
|
|
13456
|
+
* @private
|
|
13457
|
+
* @param {Array} [array] The array to inspect.
|
|
13458
|
+
* @param {*} target The value to search for.
|
|
13459
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
13460
|
+
*/
|
|
13461
|
+
function arrayIncludes(array, value) {
|
|
13462
|
+
var length = array == null ? 0 : array.length;
|
|
13463
|
+
return !!length && _baseIndexOf(array, value, 0) > -1;
|
|
13464
|
+
}
|
|
13465
|
+
|
|
13466
|
+
var _arrayIncludes = arrayIncludes;
|
|
13467
|
+
|
|
13468
|
+
/**
|
|
13469
|
+
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
13470
|
+
*
|
|
13471
|
+
* @private
|
|
13472
|
+
* @param {Array} [array] The array to inspect.
|
|
13473
|
+
* @param {*} target The value to search for.
|
|
13474
|
+
* @param {Function} comparator The comparator invoked per element.
|
|
13475
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
13476
|
+
*/
|
|
13477
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
13478
|
+
var index = -1,
|
|
13479
|
+
length = array == null ? 0 : array.length;
|
|
13480
|
+
|
|
13481
|
+
while (++index < length) {
|
|
13482
|
+
if (comparator(value, array[index])) {
|
|
13483
|
+
return true;
|
|
13484
|
+
}
|
|
13485
|
+
}
|
|
13486
|
+
return false;
|
|
13487
|
+
}
|
|
13488
|
+
|
|
13489
|
+
var _arrayIncludesWith = arrayIncludesWith;
|
|
13490
|
+
|
|
13491
|
+
/** Used as references for various `Number` constants. */
|
|
13492
|
+
var INFINITY = 1 / 0;
|
|
13493
|
+
|
|
13494
|
+
/**
|
|
13495
|
+
* Creates a set object of `values`.
|
|
13496
|
+
*
|
|
13497
|
+
* @private
|
|
13498
|
+
* @param {Array} values The values to add to the set.
|
|
13499
|
+
* @returns {Object} Returns the new set.
|
|
13500
|
+
*/
|
|
13501
|
+
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
13502
|
+
return new _Set(values);
|
|
13597
13503
|
};
|
|
13598
13504
|
|
|
13505
|
+
var _createSet = createSet;
|
|
13506
|
+
|
|
13507
|
+
/** Used as the size to enable large array optimizations. */
|
|
13508
|
+
var LARGE_ARRAY_SIZE$1 = 200;
|
|
13509
|
+
|
|
13510
|
+
/**
|
|
13511
|
+
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
13512
|
+
*
|
|
13513
|
+
* @private
|
|
13514
|
+
* @param {Array} array The array to inspect.
|
|
13515
|
+
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
13516
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
13517
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
13518
|
+
*/
|
|
13519
|
+
function baseUniq(array, iteratee, comparator) {
|
|
13520
|
+
var index = -1,
|
|
13521
|
+
includes = _arrayIncludes,
|
|
13522
|
+
length = array.length,
|
|
13523
|
+
isCommon = true,
|
|
13524
|
+
result = [],
|
|
13525
|
+
seen = result;
|
|
13526
|
+
|
|
13527
|
+
if (comparator) {
|
|
13528
|
+
isCommon = false;
|
|
13529
|
+
includes = _arrayIncludesWith;
|
|
13530
|
+
}
|
|
13531
|
+
else if (length >= LARGE_ARRAY_SIZE$1) {
|
|
13532
|
+
var set = iteratee ? null : _createSet(array);
|
|
13533
|
+
if (set) {
|
|
13534
|
+
return _setToArray(set);
|
|
13535
|
+
}
|
|
13536
|
+
isCommon = false;
|
|
13537
|
+
includes = _cacheHas;
|
|
13538
|
+
seen = new _SetCache;
|
|
13539
|
+
}
|
|
13540
|
+
else {
|
|
13541
|
+
seen = iteratee ? [] : result;
|
|
13542
|
+
}
|
|
13543
|
+
outer:
|
|
13544
|
+
while (++index < length) {
|
|
13545
|
+
var value = array[index],
|
|
13546
|
+
computed = iteratee ? iteratee(value) : value;
|
|
13547
|
+
|
|
13548
|
+
value = (comparator || value !== 0) ? value : 0;
|
|
13549
|
+
if (isCommon && computed === computed) {
|
|
13550
|
+
var seenIndex = seen.length;
|
|
13551
|
+
while (seenIndex--) {
|
|
13552
|
+
if (seen[seenIndex] === computed) {
|
|
13553
|
+
continue outer;
|
|
13554
|
+
}
|
|
13555
|
+
}
|
|
13556
|
+
if (iteratee) {
|
|
13557
|
+
seen.push(computed);
|
|
13558
|
+
}
|
|
13559
|
+
result.push(value);
|
|
13560
|
+
}
|
|
13561
|
+
else if (!includes(seen, computed, comparator)) {
|
|
13562
|
+
if (seen !== result) {
|
|
13563
|
+
seen.push(computed);
|
|
13564
|
+
}
|
|
13565
|
+
result.push(value);
|
|
13566
|
+
}
|
|
13567
|
+
}
|
|
13568
|
+
return result;
|
|
13569
|
+
}
|
|
13570
|
+
|
|
13571
|
+
var _baseUniq = baseUniq;
|
|
13572
|
+
|
|
13573
|
+
/**
|
|
13574
|
+
* Creates a duplicate-free version of an array, using
|
|
13575
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
13576
|
+
* for equality comparisons, in which only the first occurrence of each element
|
|
13577
|
+
* is kept. The order of result values is determined by the order they occur
|
|
13578
|
+
* in the array.
|
|
13579
|
+
*
|
|
13580
|
+
* @static
|
|
13581
|
+
* @memberOf _
|
|
13582
|
+
* @since 0.1.0
|
|
13583
|
+
* @category Array
|
|
13584
|
+
* @param {Array} array The array to inspect.
|
|
13585
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
13586
|
+
* @example
|
|
13587
|
+
*
|
|
13588
|
+
* _.uniq([2, 1, 2]);
|
|
13589
|
+
* // => [2, 1]
|
|
13590
|
+
*/
|
|
13591
|
+
function uniq(array) {
|
|
13592
|
+
return (array && array.length) ? _baseUniq(array) : [];
|
|
13593
|
+
}
|
|
13594
|
+
|
|
13595
|
+
var uniq_1 = uniq;
|
|
13596
|
+
|
|
13599
13597
|
/* eslint-disable camelcase */
|
|
13600
13598
|
const CONFIG_DEFAULTS = {
|
|
13601
13599
|
loginFailedMessage: 'Not logged in',
|
|
@@ -14054,8 +14052,6 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
14054
14052
|
});
|
|
14055
14053
|
}
|
|
14056
14054
|
|
|
14057
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.28.1-alpha.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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",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-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",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 --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","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",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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","current-git-branch":"^1.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.13.1","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":"6.7.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","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,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"45 kB"}],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};
|
|
14058
|
-
|
|
14059
14055
|
/**
|
|
14060
14056
|
* Copyright (c) 2022
|
|
14061
14057
|
*
|
|
@@ -14179,7 +14175,7 @@ class TsEmbed {
|
|
|
14179
14175
|
if (viewConfig.preRenderId) {
|
|
14180
14176
|
const allOtherKeys = Object.keys(viewConfig).filter((key) => !preRenderAllowedKeys.includes(key) && !key.startsWith('on'));
|
|
14181
14177
|
allOtherKeys.forEach((key) => {
|
|
14182
|
-
if (!isUndefined
|
|
14178
|
+
if (!isUndefined(viewConfig[key])
|
|
14183
14179
|
&& !isEqual_1(viewConfig[key], preRenderedObject.viewConfig[key])) {
|
|
14184
14180
|
logger.warn(`${viewConfig.embedComponentType || 'Component'} was pre-rendered with `
|
|
14185
14181
|
+ `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
|
|
@@ -15455,7 +15451,7 @@ class LiveboardEmbed extends V1Embed {
|
|
|
15455
15451
|
beforePrerenderVisible() {
|
|
15456
15452
|
var _a;
|
|
15457
15453
|
const embedObj = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
|
|
15458
|
-
if (isUndefined
|
|
15454
|
+
if (isUndefined(embedObj))
|
|
15459
15455
|
return;
|
|
15460
15456
|
const showDifferentLib = this.viewConfig.liveboardId
|
|
15461
15457
|
&& embedObj.viewConfig.liveboardId !== this.viewConfig.liveboardId;
|
|
@@ -15465,7 +15461,7 @@ class LiveboardEmbed extends V1Embed {
|
|
|
15465
15461
|
}
|
|
15466
15462
|
}
|
|
15467
15463
|
handleRenderForPrerender() {
|
|
15468
|
-
if (isUndefined
|
|
15464
|
+
if (isUndefined(this.viewConfig.liveboardId)) {
|
|
15469
15465
|
this.prerenderGeneric();
|
|
15470
15466
|
return;
|
|
15471
15467
|
}
|
|
@@ -15563,7 +15559,7 @@ class SearchEmbed extends TsEmbed {
|
|
|
15563
15559
|
}
|
|
15564
15560
|
getEmbedParams() {
|
|
15565
15561
|
var _a;
|
|
15566
|
-
const { hideResults, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
15562
|
+
const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
15567
15563
|
const queryParams = this.getBaseQueryParams();
|
|
15568
15564
|
queryParams[Param.HideActions] = [
|
|
15569
15565
|
...((_a = queryParams[Param.HideActions]) !== null && _a !== void 0 ? _a : []),
|