@thoughtspot/visual-embed-sdk 1.40.1 → 1.40.3
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/cjs/package.json +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +5 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +33 -3
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +2 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +22 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +12 -0
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +122 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +10 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +11 -1
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/index.d.ts +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/types.d.ts +131 -5
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +39 -11
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/custom-actions.d.ts +12 -0
- package/cjs/src/utils/custom-actions.d.ts.map +1 -0
- package/cjs/src/utils/custom-actions.js +180 -0
- package/cjs/src/utils/custom-actions.js.map +1 -0
- package/cjs/src/utils/custom-actions.spec.d.ts +2 -0
- package/cjs/src/utils/custom-actions.spec.d.ts.map +1 -0
- package/cjs/src/utils/custom-actions.spec.js +399 -0
- package/cjs/src/utils/custom-actions.spec.js.map +1 -0
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +10 -0
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +11 -0
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +7 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +11 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +28 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-P5YjBOuJ.js → index-BICLzyVL.js} +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/errors.d.ts +10 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +131 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/custom-actions.d.ts +12 -0
- package/dist/src/utils/custom-actions.d.ts.map +1 -0
- package/dist/src/utils/custom-actions.spec.d.ts +2 -0
- package/dist/src/utils/custom-actions.spec.d.ts.map +1 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils.d.ts +7 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1705 -203
- package/dist/tsembed-react.js +1704 -202
- package/dist/tsembed.es.js +1653 -151
- package/dist/tsembed.js +1652 -150
- package/dist/visual-embed-sdk-react-full.d.ts +132 -6
- package/dist/visual-embed-sdk-react.d.ts +132 -6
- package/dist/visual-embed-sdk.d.ts +132 -6
- package/lib/package.json +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +5 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +33 -3
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +2 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +22 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +12 -0
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +123 -1
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +10 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +10 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.d.ts +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +1 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/types.d.ts +131 -5
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +38 -10
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/custom-actions.d.ts +12 -0
- package/lib/src/utils/custom-actions.d.ts.map +1 -0
- package/lib/src/utils/custom-actions.js +175 -0
- package/lib/src/utils/custom-actions.js.map +1 -0
- package/lib/src/utils/custom-actions.spec.d.ts +2 -0
- package/lib/src/utils/custom-actions.spec.d.ts.map +1 -0
- package/lib/src/utils/custom-actions.spec.js +397 -0
- package/lib/src/utils/custom-actions.spec.js.map +1 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +10 -0
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +11 -0
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +7 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +9 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +29 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +133 -7
- package/package.json +1 -1
- package/src/embed/app.spec.ts +48 -3
- package/src/embed/app.ts +5 -0
- package/src/embed/liveboard.spec.ts +30 -0
- package/src/embed/liveboard.ts +2 -0
- package/src/embed/ts-embed.spec.ts +135 -1
- package/src/embed/ts-embed.ts +12 -0
- package/src/errors.ts +11 -0
- package/src/index.ts +4 -0
- package/src/react/index.tsx +1 -0
- package/src/types.ts +147 -16
- package/src/utils/custom-actions.spec.ts +431 -0
- package/src/utils/custom-actions.ts +217 -0
- package/src/utils/processData.spec.ts +12 -0
- package/src/utils/processData.ts +10 -0
- package/src/utils.spec.ts +34 -0
- package/src/utils.ts +10 -0
package/dist/tsembed-react.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @thoughtspot/visual-embed-sdk version 1.40.
|
|
1
|
+
/* @thoughtspot/visual-embed-sdk version 1.40.3 */
|
|
2
2
|
'use client';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { useRef, useCallback } from 'react';
|
|
@@ -195,7 +195,6 @@ merge.withOptions = (options, ...objects) => {
|
|
|
195
195
|
* the embedded app
|
|
196
196
|
* @group Authentication / Init
|
|
197
197
|
*/
|
|
198
|
-
// eslint-disable-next-line no-shadow
|
|
199
198
|
var AuthType;
|
|
200
199
|
(function (AuthType) {
|
|
201
200
|
/**
|
|
@@ -409,7 +408,6 @@ var HomeLeftNavItem;
|
|
|
409
408
|
/**
|
|
410
409
|
* A map of the supported runtime filter operations
|
|
411
410
|
*/
|
|
412
|
-
// eslint-disable-next-line no-shadow
|
|
413
411
|
var RuntimeFilterOp;
|
|
414
412
|
(function (RuntimeFilterOp) {
|
|
415
413
|
/**
|
|
@@ -480,7 +478,6 @@ var RuntimeFilterOp;
|
|
|
480
478
|
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
481
479
|
* @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl, 10.1.0.sw
|
|
482
480
|
*/
|
|
483
|
-
// eslint-disable-next-line no-shadow
|
|
484
481
|
var HomepageModule;
|
|
485
482
|
(function (HomepageModule) {
|
|
486
483
|
/**
|
|
@@ -513,7 +510,6 @@ var HomepageModule;
|
|
|
513
510
|
* **Note**: This option is applicable to full app embedding only.
|
|
514
511
|
* @version SDK: 1.38.0 | ThoughtSpot: 10.9.0.cl
|
|
515
512
|
*/
|
|
516
|
-
// eslint-disable-next-line no-shadow
|
|
517
513
|
var ListPageColumns;
|
|
518
514
|
(function (ListPageColumns) {
|
|
519
515
|
/**
|
|
@@ -576,7 +572,6 @@ var ListPageColumns;
|
|
|
576
572
|
* ```
|
|
577
573
|
* @group Events
|
|
578
574
|
*/
|
|
579
|
-
// eslint-disable-next-line no-shadow
|
|
580
575
|
var EmbedEvent;
|
|
581
576
|
(function (EmbedEvent) {
|
|
582
577
|
/**
|
|
@@ -1218,6 +1213,11 @@ var EmbedEvent;
|
|
|
1218
1213
|
* @hidden
|
|
1219
1214
|
*/
|
|
1220
1215
|
EmbedEvent["APP_INIT"] = "appInit";
|
|
1216
|
+
/**
|
|
1217
|
+
* Internal event to clear the cached info
|
|
1218
|
+
* @hidden
|
|
1219
|
+
*/
|
|
1220
|
+
EmbedEvent["CLEAR_INFO_CACHE"] = "clearInfoCache";
|
|
1221
1221
|
/**
|
|
1222
1222
|
* Emitted when a user clicks **Show Liveboard details** on a Liveboard
|
|
1223
1223
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
@@ -1686,6 +1686,17 @@ var EmbedEvent;
|
|
|
1686
1686
|
* ```
|
|
1687
1687
|
*/
|
|
1688
1688
|
EmbedEvent["EmbedListenerReady"] = "EmbedListenerReady";
|
|
1689
|
+
/**
|
|
1690
|
+
* Emitted when the organization is switched.
|
|
1691
|
+
* @example
|
|
1692
|
+
* ```js
|
|
1693
|
+
* appEmbed.on(EmbedEvent.OrgSwitched, (payload) => {
|
|
1694
|
+
* console.log('payload', payload);
|
|
1695
|
+
* })
|
|
1696
|
+
* ```
|
|
1697
|
+
* @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
|
|
1698
|
+
*/
|
|
1699
|
+
EmbedEvent["OrgSwitched"] = "orgSwitched";
|
|
1689
1700
|
})(EmbedEvent || (EmbedEvent = {}));
|
|
1690
1701
|
/**
|
|
1691
1702
|
* Event types that can be triggered by the host application
|
|
@@ -1740,7 +1751,6 @@ var EmbedEvent;
|
|
|
1740
1751
|
* ```
|
|
1741
1752
|
* @group Events
|
|
1742
1753
|
*/
|
|
1743
|
-
// eslint-disable-next-line no-shadow
|
|
1744
1754
|
var HostEvent;
|
|
1745
1755
|
(function (HostEvent) {
|
|
1746
1756
|
/**
|
|
@@ -2955,7 +2965,6 @@ var HostEvent;
|
|
|
2955
2965
|
* The different visual modes that the data sources panel within
|
|
2956
2966
|
* search could appear in, such as hidden, collapsed, or expanded.
|
|
2957
2967
|
*/
|
|
2958
|
-
// eslint-disable-next-line no-shadow
|
|
2959
2968
|
var DataSourceVisualMode;
|
|
2960
2969
|
(function (DataSourceVisualMode) {
|
|
2961
2970
|
/**
|
|
@@ -2975,7 +2984,6 @@ var DataSourceVisualMode;
|
|
|
2975
2984
|
* The query params passed down to the embedded ThoughtSpot app
|
|
2976
2985
|
* containing configuration and/or visual information.
|
|
2977
2986
|
*/
|
|
2978
|
-
// eslint-disable-next-line no-shadow
|
|
2979
2987
|
var Param;
|
|
2980
2988
|
(function (Param) {
|
|
2981
2989
|
Param["EmbedApp"] = "embedApp";
|
|
@@ -3097,6 +3105,7 @@ var Param;
|
|
|
3097
3105
|
Param["IsLiveboardStylingAndGroupingEnabled"] = "isLiveboardStylingAndGroupingEnabled";
|
|
3098
3106
|
Param["IsLazyLoadingForEmbedEnabled"] = "isLazyLoadingForEmbedEnabled";
|
|
3099
3107
|
Param["RootMarginForLazyLoad"] = "rootMarginForLazyLoad";
|
|
3108
|
+
Param["LiveboardXLSXCSVDownload"] = "isLiveboardXLSXCSVDownloadEnabled";
|
|
3100
3109
|
})(Param || (Param = {}));
|
|
3101
3110
|
/**
|
|
3102
3111
|
* ThoughtSpot application pages include actions and menu commands
|
|
@@ -3125,7 +3134,6 @@ var Param;
|
|
|
3125
3134
|
* ```
|
|
3126
3135
|
* See also link:https://developers.thoughtspot.com/docs/actions[Action IDs in the SDK]
|
|
3127
3136
|
*/
|
|
3128
|
-
// eslint-disable-next-line no-shadow
|
|
3129
3137
|
var Action;
|
|
3130
3138
|
(function (Action) {
|
|
3131
3139
|
/**
|
|
@@ -3670,7 +3678,7 @@ var Action;
|
|
|
3670
3678
|
* The Favorites icon (*) for Answers,
|
|
3671
3679
|
* Liveboard, and data objects like Worksheet, Model,
|
|
3672
3680
|
* Tables and Views.
|
|
3673
|
-
* Allows adding an object to the user
|
|
3681
|
+
* Allows adding an object to the user's favorites list.
|
|
3674
3682
|
* @example
|
|
3675
3683
|
* ```js
|
|
3676
3684
|
* disabledActions: [Action.AddToFavorites]
|
|
@@ -4397,6 +4405,26 @@ var ContextMenuTriggerOptions;
|
|
|
4397
4405
|
ContextMenuTriggerOptions["RIGHT_CLICK"] = "right-click";
|
|
4398
4406
|
ContextMenuTriggerOptions["BOTH_CLICKS"] = "both-clicks";
|
|
4399
4407
|
})(ContextMenuTriggerOptions || (ContextMenuTriggerOptions = {}));
|
|
4408
|
+
/**
|
|
4409
|
+
* Enum options to show custom actions at different
|
|
4410
|
+
* positions in the application.
|
|
4411
|
+
*/
|
|
4412
|
+
var CustomActionsPosition;
|
|
4413
|
+
(function (CustomActionsPosition) {
|
|
4414
|
+
CustomActionsPosition["PRIMARY"] = "PRIMARY";
|
|
4415
|
+
CustomActionsPosition["MENU"] = "MENU";
|
|
4416
|
+
CustomActionsPosition["CONTEXTMENU"] = "CONTEXTMENU";
|
|
4417
|
+
})(CustomActionsPosition || (CustomActionsPosition = {}));
|
|
4418
|
+
/**
|
|
4419
|
+
* Enum options to mention the target of the custom action.
|
|
4420
|
+
*/
|
|
4421
|
+
var CustomActionTarget;
|
|
4422
|
+
(function (CustomActionTarget) {
|
|
4423
|
+
CustomActionTarget["LIVEBOARD"] = "LIVEBOARD";
|
|
4424
|
+
CustomActionTarget["VIZ"] = "VIZ";
|
|
4425
|
+
CustomActionTarget["ANSWER"] = "ANSWER";
|
|
4426
|
+
CustomActionTarget["SPOTTER"] = "SPOTTER";
|
|
4427
|
+
})(CustomActionTarget || (CustomActionTarget = {}));
|
|
4400
4428
|
/**
|
|
4401
4429
|
* Enum options to show or suppress Visual Embed SDK and
|
|
4402
4430
|
* ThoughtSpot application logs in the console output.
|
|
@@ -4857,6 +4885,15 @@ function storeValueInWindow(key, value, options = {}) {
|
|
|
4857
4885
|
* @returns The stored value or `undefined` if the key is not found.
|
|
4858
4886
|
*/
|
|
4859
4887
|
const getValueFromWindow = (key) => { var _a; return (_a = window === null || window === void 0 ? void 0 : window[sdkWindowKey]) === null || _a === void 0 ? void 0 : _a[key]; };
|
|
4888
|
+
/**
|
|
4889
|
+
* Check if an array includes a string value
|
|
4890
|
+
* @param arr - The array to check
|
|
4891
|
+
* @param key - The string to search for
|
|
4892
|
+
* @returns boolean indicating if the string is found in the array
|
|
4893
|
+
*/
|
|
4894
|
+
const arrayIncludesString = (arr, key) => {
|
|
4895
|
+
return arr.some(item => typeof item === 'string' && item === key);
|
|
4896
|
+
};
|
|
4860
4897
|
/**
|
|
4861
4898
|
* Check if the document is currently in fullscreen mode
|
|
4862
4899
|
*/
|
|
@@ -5941,8 +5978,8 @@ function cacheHas(cache, key) {
|
|
|
5941
5978
|
var _cacheHas = cacheHas;
|
|
5942
5979
|
|
|
5943
5980
|
/** Used to compose bitmasks for value comparisons. */
|
|
5944
|
-
var COMPARE_PARTIAL_FLAG$
|
|
5945
|
-
COMPARE_UNORDERED_FLAG$
|
|
5981
|
+
var COMPARE_PARTIAL_FLAG$5 = 1,
|
|
5982
|
+
COMPARE_UNORDERED_FLAG$3 = 2;
|
|
5946
5983
|
|
|
5947
5984
|
/**
|
|
5948
5985
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
@@ -5958,7 +5995,7 @@ var COMPARE_PARTIAL_FLAG$3 = 1,
|
|
|
5958
5995
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
5959
5996
|
*/
|
|
5960
5997
|
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
5961
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
5998
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
|
|
5962
5999
|
arrLength = array.length,
|
|
5963
6000
|
othLength = other.length;
|
|
5964
6001
|
|
|
@@ -5973,7 +6010,7 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
|
5973
6010
|
}
|
|
5974
6011
|
var index = -1,
|
|
5975
6012
|
result = true,
|
|
5976
|
-
seen = (bitmask & COMPARE_UNORDERED_FLAG$
|
|
6013
|
+
seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new _SetCache : undefined;
|
|
5977
6014
|
|
|
5978
6015
|
stack.set(array, other);
|
|
5979
6016
|
stack.set(other, array);
|
|
@@ -6065,8 +6102,8 @@ function setToArray(set) {
|
|
|
6065
6102
|
var _setToArray = setToArray;
|
|
6066
6103
|
|
|
6067
6104
|
/** Used to compose bitmasks for value comparisons. */
|
|
6068
|
-
var COMPARE_PARTIAL_FLAG$
|
|
6069
|
-
COMPARE_UNORDERED_FLAG = 2;
|
|
6105
|
+
var COMPARE_PARTIAL_FLAG$4 = 1,
|
|
6106
|
+
COMPARE_UNORDERED_FLAG$2 = 2;
|
|
6070
6107
|
|
|
6071
6108
|
/** `Object#toString` result references. */
|
|
6072
6109
|
var boolTag$1 = '[object Boolean]',
|
|
@@ -6077,14 +6114,14 @@ var boolTag$1 = '[object Boolean]',
|
|
|
6077
6114
|
regexpTag$1 = '[object RegExp]',
|
|
6078
6115
|
setTag$3 = '[object Set]',
|
|
6079
6116
|
stringTag$1 = '[object String]',
|
|
6080
|
-
symbolTag = '[object Symbol]';
|
|
6117
|
+
symbolTag$1 = '[object Symbol]';
|
|
6081
6118
|
|
|
6082
6119
|
var arrayBufferTag$1 = '[object ArrayBuffer]',
|
|
6083
6120
|
dataViewTag$2 = '[object DataView]';
|
|
6084
6121
|
|
|
6085
6122
|
/** Used to convert symbols to primitives and strings. */
|
|
6086
|
-
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
|
6087
|
-
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
6123
|
+
var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
|
|
6124
|
+
symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
|
|
6088
6125
|
|
|
6089
6126
|
/**
|
|
6090
6127
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
@@ -6141,7 +6178,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
|
6141
6178
|
var convert = _mapToArray;
|
|
6142
6179
|
|
|
6143
6180
|
case setTag$3:
|
|
6144
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
6181
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
|
|
6145
6182
|
convert || (convert = _setToArray);
|
|
6146
6183
|
|
|
6147
6184
|
if (object.size != other.size && !isPartial) {
|
|
@@ -6152,7 +6189,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
|
6152
6189
|
if (stacked) {
|
|
6153
6190
|
return stacked == other;
|
|
6154
6191
|
}
|
|
6155
|
-
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
6192
|
+
bitmask |= COMPARE_UNORDERED_FLAG$2;
|
|
6156
6193
|
|
|
6157
6194
|
// Recursively compare objects (susceptible to call stack limits).
|
|
6158
6195
|
stack.set(object, other);
|
|
@@ -6160,7 +6197,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
|
6160
6197
|
stack['delete'](object);
|
|
6161
6198
|
return result;
|
|
6162
6199
|
|
|
6163
|
-
case symbolTag:
|
|
6200
|
+
case symbolTag$1:
|
|
6164
6201
|
if (symbolValueOf) {
|
|
6165
6202
|
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
6166
6203
|
}
|
|
@@ -6851,7 +6888,7 @@ function getAllKeys(object) {
|
|
|
6851
6888
|
var _getAllKeys = getAllKeys;
|
|
6852
6889
|
|
|
6853
6890
|
/** Used to compose bitmasks for value comparisons. */
|
|
6854
|
-
var COMPARE_PARTIAL_FLAG$
|
|
6891
|
+
var COMPARE_PARTIAL_FLAG$3 = 1;
|
|
6855
6892
|
|
|
6856
6893
|
/** Used for built-in method references. */
|
|
6857
6894
|
var objectProto$2 = Object.prototype;
|
|
@@ -6873,7 +6910,7 @@ var hasOwnProperty$3 = objectProto$2.hasOwnProperty;
|
|
|
6873
6910
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
6874
6911
|
*/
|
|
6875
6912
|
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
6876
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
6913
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
|
|
6877
6914
|
objProps = _getAllKeys(object),
|
|
6878
6915
|
objLength = objProps.length,
|
|
6879
6916
|
othProps = _getAllKeys(other),
|
|
@@ -7011,7 +7048,7 @@ if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
|
7011
7048
|
var _getTag = getTag;
|
|
7012
7049
|
|
|
7013
7050
|
/** Used to compose bitmasks for value comparisons. */
|
|
7014
|
-
var COMPARE_PARTIAL_FLAG = 1;
|
|
7051
|
+
var COMPARE_PARTIAL_FLAG$2 = 1;
|
|
7015
7052
|
|
|
7016
7053
|
/** `Object#toString` result references. */
|
|
7017
7054
|
var argsTag = '[object Arguments]',
|
|
@@ -7064,7 +7101,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
7064
7101
|
? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
7065
7102
|
: _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
7066
7103
|
}
|
|
7067
|
-
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
7104
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
|
|
7068
7105
|
var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, '__wrapped__'),
|
|
7069
7106
|
othIsWrapped = othIsObj && hasOwnProperty$2.call(other, '__wrapped__');
|
|
7070
7107
|
|
|
@@ -7234,6 +7271,16 @@ const ERROR_MESSAGE = {
|
|
|
7234
7271
|
MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
|
|
7235
7272
|
RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
|
|
7236
7273
|
SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
|
|
7274
|
+
};
|
|
7275
|
+
const CUSTOM_ACTIONS_ERROR_MESSAGE = {
|
|
7276
|
+
INVALID_ACTION_OBJECT: 'Custom Action Validation Error: Invalid action object provided',
|
|
7277
|
+
MISSING_REQUIRED_FIELDS: (id, missingFields) => `Custom Action Validation Error for '${id}': Missing required fields: ${missingFields.join(', ')}`,
|
|
7278
|
+
UNSUPPORTED_TARGET: (id, targetType) => `Custom Action Validation Error for '${id}': Target type '${targetType}' is not supported`,
|
|
7279
|
+
INVALID_POSITION: (position, targetType, supportedPositions) => `Position '${position}' is not supported for ${targetType.toLowerCase()}-level custom actions. Supported positions: ${supportedPositions}`,
|
|
7280
|
+
INVALID_METADATA_IDS: (targetType, invalidIds, supportedIds) => `Invalid metadata IDs for ${targetType.toLowerCase()}-level custom actions: ${invalidIds.join(', ')}. Supported metadata IDs: ${supportedIds}`,
|
|
7281
|
+
INVALID_DATA_MODEL_IDS: (targetType, invalidIds, supportedIds) => `Invalid data model IDs for ${targetType.toLowerCase()}-level custom actions: ${invalidIds.join(', ')}. Supported data model IDs: ${supportedIds}`,
|
|
7282
|
+
INVALID_FIELDS: (targetType, invalidFields, supportedFields) => `Invalid fields for ${targetType.toLowerCase()}-level custom actions: ${invalidFields.join(', ')}. Supported fields: ${supportedFields}`,
|
|
7283
|
+
DUPLICATE_IDS: (id, duplicateNames, keptName) => `Duplicate custom action ID '${id}' found. Actions with names '${duplicateNames.join("', '")}' will be ignored. Keeping '${keptName}'.`,
|
|
7237
7284
|
};
|
|
7238
7285
|
|
|
7239
7286
|
const EndPoints = {
|
|
@@ -8031,196 +8078,1626 @@ class AnswerService {
|
|
|
8031
8078
|
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
8032
8079
|
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
8033
8080
|
}
|
|
8034
|
-
/**
|
|
8035
|
-
* Just get the internal URL for this answer's data
|
|
8036
|
-
* as a PNG blob.
|
|
8037
|
-
* @param userLocale
|
|
8038
|
-
* @param omitBackground
|
|
8039
|
-
* @param deviceScaleFactor
|
|
8040
|
-
*/
|
|
8041
|
-
getFetchPNGBlobUrl(userLocale = 'en-us', omitBackground = false, deviceScaleFactor = 2) {
|
|
8042
|
-
return `${this.thoughtSpotHost}/prism/download/answer/png?sessionId=${this.session.sessionId}&deviceScaleFactor=${deviceScaleFactor}&omitBackground=${omitBackground}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data`;
|
|
8081
|
+
/**
|
|
8082
|
+
* Just get the internal URL for this answer's data
|
|
8083
|
+
* as a PNG blob.
|
|
8084
|
+
* @param userLocale
|
|
8085
|
+
* @param omitBackground
|
|
8086
|
+
* @param deviceScaleFactor
|
|
8087
|
+
*/
|
|
8088
|
+
getFetchPNGBlobUrl(userLocale = 'en-us', omitBackground = false, deviceScaleFactor = 2) {
|
|
8089
|
+
return `${this.thoughtSpotHost}/prism/download/answer/png?sessionId=${this.session.sessionId}&deviceScaleFactor=${deviceScaleFactor}&omitBackground=${omitBackground}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data`;
|
|
8090
|
+
}
|
|
8091
|
+
/**
|
|
8092
|
+
* Get underlying data given a point and the output column names.
|
|
8093
|
+
* In case of a context menu action, the selectedPoints are
|
|
8094
|
+
* automatically passed.
|
|
8095
|
+
* @param outputColumnNames
|
|
8096
|
+
* @param selectedPoints
|
|
8097
|
+
* @example
|
|
8098
|
+
* ```js
|
|
8099
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
8100
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
8101
|
+
* 'col name 1' // The column should exist in the data source.
|
|
8102
|
+
* ]);
|
|
8103
|
+
* const data = await underlying.fetchData(0, 100);
|
|
8104
|
+
* })
|
|
8105
|
+
* ```
|
|
8106
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
8107
|
+
*/
|
|
8108
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
8109
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
8110
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
8111
|
+
}
|
|
8112
|
+
if (!selectedPoints) {
|
|
8113
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
8114
|
+
}
|
|
8115
|
+
const sourceDetail = await this.getSourceDetail();
|
|
8116
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
8117
|
+
const unAggAnswer = await graphqlQuery({
|
|
8118
|
+
query: getUnaggregatedAnswerSession,
|
|
8119
|
+
variables: {
|
|
8120
|
+
session: this.session,
|
|
8121
|
+
columns: selectedPoints,
|
|
8122
|
+
},
|
|
8123
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
8124
|
+
});
|
|
8125
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
8126
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
8127
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
8128
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
8129
|
+
if (columnsToAdd.length) {
|
|
8130
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
8131
|
+
}
|
|
8132
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
8133
|
+
if (columnsToRemove.length) {
|
|
8134
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
8135
|
+
}
|
|
8136
|
+
return unaggAnswerSession;
|
|
8137
|
+
}
|
|
8138
|
+
/**
|
|
8139
|
+
* Execute a custom graphql query in the context of the answer.
|
|
8140
|
+
* @param query graphql query
|
|
8141
|
+
* @param variables graphql variables
|
|
8142
|
+
* @returns
|
|
8143
|
+
*/
|
|
8144
|
+
async executeQuery(query, variables) {
|
|
8145
|
+
const data = await graphqlQuery({
|
|
8146
|
+
query,
|
|
8147
|
+
variables: {
|
|
8148
|
+
session: this.session,
|
|
8149
|
+
...variables,
|
|
8150
|
+
},
|
|
8151
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
8152
|
+
isCompositeQuery: false,
|
|
8153
|
+
});
|
|
8154
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
8155
|
+
return data;
|
|
8156
|
+
}
|
|
8157
|
+
/**
|
|
8158
|
+
* Get the internal session details for the answer.
|
|
8159
|
+
* @returns
|
|
8160
|
+
*/
|
|
8161
|
+
getSession() {
|
|
8162
|
+
return this.session;
|
|
8163
|
+
}
|
|
8164
|
+
async getAnswer() {
|
|
8165
|
+
if (this.answer) {
|
|
8166
|
+
return this.answer;
|
|
8167
|
+
}
|
|
8168
|
+
this.answer = this.executeQuery(getAnswer, {}).then((data) => data === null || data === void 0 ? void 0 : data.answer);
|
|
8169
|
+
return this.answer;
|
|
8170
|
+
}
|
|
8171
|
+
async getTML() {
|
|
8172
|
+
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
8173
|
+
const edoc = object[0].edoc;
|
|
8174
|
+
const YAML = await import('./index-BICLzyVL.js');
|
|
8175
|
+
const parsedDoc = YAML.parse(edoc);
|
|
8176
|
+
return {
|
|
8177
|
+
answer: {
|
|
8178
|
+
...parsedDoc.answer,
|
|
8179
|
+
...this.tmlOverride,
|
|
8180
|
+
},
|
|
8181
|
+
};
|
|
8182
|
+
}
|
|
8183
|
+
async addDisplayedVizToLiveboard(liveboardId) {
|
|
8184
|
+
const { displayMode, visualizations } = await this.getAnswer();
|
|
8185
|
+
const viz = getDisplayedViz(visualizations, displayMode);
|
|
8186
|
+
return this.executeQuery(addVizToLiveboard, {
|
|
8187
|
+
liveboardId,
|
|
8188
|
+
vizId: viz.id,
|
|
8189
|
+
});
|
|
8190
|
+
}
|
|
8191
|
+
setTMLOverride(override) {
|
|
8192
|
+
this.tmlOverride = override;
|
|
8193
|
+
}
|
|
8194
|
+
}
|
|
8195
|
+
/**
|
|
8196
|
+
*
|
|
8197
|
+
* @param sourceDetail
|
|
8198
|
+
* @param colNames
|
|
8199
|
+
*/
|
|
8200
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
8201
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
8202
|
+
colSet[col.name.toLowerCase()] = col;
|
|
8203
|
+
return colSet;
|
|
8204
|
+
}, {});
|
|
8205
|
+
return new Set(colNames.map((colName) => {
|
|
8206
|
+
const col = cols[colName.toLowerCase()];
|
|
8207
|
+
return col.id;
|
|
8208
|
+
}));
|
|
8209
|
+
}
|
|
8210
|
+
/**
|
|
8211
|
+
*
|
|
8212
|
+
* @param selectedPoints
|
|
8213
|
+
*/
|
|
8214
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
8215
|
+
const underlyingDataPoint = [];
|
|
8216
|
+
/**
|
|
8217
|
+
*
|
|
8218
|
+
* @param colVal
|
|
8219
|
+
*/
|
|
8220
|
+
function addPointFromColVal(colVal) {
|
|
8221
|
+
var _a;
|
|
8222
|
+
const dataType = colVal.column.dataType;
|
|
8223
|
+
colVal.column.id;
|
|
8224
|
+
let dataValue;
|
|
8225
|
+
if (dataType === 'DATE') {
|
|
8226
|
+
if (Number.isFinite(colVal.value)) {
|
|
8227
|
+
dataValue = [{
|
|
8228
|
+
epochRange: {
|
|
8229
|
+
startEpoch: colVal.value,
|
|
8230
|
+
},
|
|
8231
|
+
}];
|
|
8232
|
+
// Case for custom calendar.
|
|
8233
|
+
}
|
|
8234
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
8235
|
+
dataValue = [{
|
|
8236
|
+
epochRange: {
|
|
8237
|
+
startEpoch: colVal.value.v.s,
|
|
8238
|
+
endEpoch: colVal.value.v.e,
|
|
8239
|
+
},
|
|
8240
|
+
}];
|
|
8241
|
+
}
|
|
8242
|
+
}
|
|
8243
|
+
else {
|
|
8244
|
+
dataValue = [{ value: colVal.value }];
|
|
8245
|
+
}
|
|
8246
|
+
underlyingDataPoint.push({
|
|
8247
|
+
columnId: colVal.column.id,
|
|
8248
|
+
dataValue,
|
|
8249
|
+
});
|
|
8250
|
+
}
|
|
8251
|
+
selectedPoints.forEach((p) => {
|
|
8252
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
8253
|
+
});
|
|
8254
|
+
return underlyingDataPoint;
|
|
8255
|
+
}
|
|
8256
|
+
/**
|
|
8257
|
+
*
|
|
8258
|
+
* @param visualizations
|
|
8259
|
+
* @param displayMode
|
|
8260
|
+
*/
|
|
8261
|
+
function getDisplayedViz(visualizations, displayMode) {
|
|
8262
|
+
if (displayMode === 'CHART_MODE') {
|
|
8263
|
+
return visualizations.find(
|
|
8264
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
8265
|
+
(viz) => viz.__typename === 'ChartViz');
|
|
8266
|
+
}
|
|
8267
|
+
return visualizations.find(
|
|
8268
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
8269
|
+
(viz) => viz.__typename === 'TableViz');
|
|
8270
|
+
}
|
|
8271
|
+
|
|
8272
|
+
/** Built-in value references. */
|
|
8273
|
+
var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
|
|
8274
|
+
|
|
8275
|
+
/**
|
|
8276
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
8277
|
+
*
|
|
8278
|
+
* @private
|
|
8279
|
+
* @param {*} value The value to check.
|
|
8280
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
8281
|
+
*/
|
|
8282
|
+
function isFlattenable(value) {
|
|
8283
|
+
return isArray_1(value) || isArguments_1(value) ||
|
|
8284
|
+
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8287
|
+
var _isFlattenable = isFlattenable;
|
|
8288
|
+
|
|
8289
|
+
/**
|
|
8290
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
8291
|
+
*
|
|
8292
|
+
* @private
|
|
8293
|
+
* @param {Array} array The array to flatten.
|
|
8294
|
+
* @param {number} depth The maximum recursion depth.
|
|
8295
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
8296
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
8297
|
+
* @param {Array} [result=[]] The initial result value.
|
|
8298
|
+
* @returns {Array} Returns the new flattened array.
|
|
8299
|
+
*/
|
|
8300
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
8301
|
+
var index = -1,
|
|
8302
|
+
length = array.length;
|
|
8303
|
+
|
|
8304
|
+
predicate || (predicate = _isFlattenable);
|
|
8305
|
+
result || (result = []);
|
|
8306
|
+
|
|
8307
|
+
while (++index < length) {
|
|
8308
|
+
var value = array[index];
|
|
8309
|
+
if (depth > 0 && predicate(value)) {
|
|
8310
|
+
if (depth > 1) {
|
|
8311
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
8312
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
8313
|
+
} else {
|
|
8314
|
+
_arrayPush(result, value);
|
|
8315
|
+
}
|
|
8316
|
+
} else if (!isStrict) {
|
|
8317
|
+
result[result.length] = value;
|
|
8318
|
+
}
|
|
8319
|
+
}
|
|
8320
|
+
return result;
|
|
8321
|
+
}
|
|
8322
|
+
|
|
8323
|
+
var _baseFlatten = baseFlatten;
|
|
8324
|
+
|
|
8325
|
+
/**
|
|
8326
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
8327
|
+
* shorthands.
|
|
8328
|
+
*
|
|
8329
|
+
* @private
|
|
8330
|
+
* @param {Array} [array] The array to iterate over.
|
|
8331
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
8332
|
+
* @returns {Array} Returns the new mapped array.
|
|
8333
|
+
*/
|
|
8334
|
+
function arrayMap(array, iteratee) {
|
|
8335
|
+
var index = -1,
|
|
8336
|
+
length = array == null ? 0 : array.length,
|
|
8337
|
+
result = Array(length);
|
|
8338
|
+
|
|
8339
|
+
while (++index < length) {
|
|
8340
|
+
result[index] = iteratee(array[index], index, array);
|
|
8341
|
+
}
|
|
8342
|
+
return result;
|
|
8343
|
+
}
|
|
8344
|
+
|
|
8345
|
+
var _arrayMap = arrayMap;
|
|
8346
|
+
|
|
8347
|
+
/** `Object#toString` result references. */
|
|
8348
|
+
var symbolTag = '[object Symbol]';
|
|
8349
|
+
|
|
8350
|
+
/**
|
|
8351
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
8352
|
+
*
|
|
8353
|
+
* @static
|
|
8354
|
+
* @memberOf _
|
|
8355
|
+
* @since 4.0.0
|
|
8356
|
+
* @category Lang
|
|
8357
|
+
* @param {*} value The value to check.
|
|
8358
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
8359
|
+
* @example
|
|
8360
|
+
*
|
|
8361
|
+
* _.isSymbol(Symbol.iterator);
|
|
8362
|
+
* // => true
|
|
8363
|
+
*
|
|
8364
|
+
* _.isSymbol('abc');
|
|
8365
|
+
* // => false
|
|
8366
|
+
*/
|
|
8367
|
+
function isSymbol(value) {
|
|
8368
|
+
return typeof value == 'symbol' ||
|
|
8369
|
+
(isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
|
|
8370
|
+
}
|
|
8371
|
+
|
|
8372
|
+
var isSymbol_1 = isSymbol;
|
|
8373
|
+
|
|
8374
|
+
/** Used to match property names within property paths. */
|
|
8375
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
8376
|
+
reIsPlainProp = /^\w*$/;
|
|
8377
|
+
|
|
8378
|
+
/**
|
|
8379
|
+
* Checks if `value` is a property name and not a property path.
|
|
8380
|
+
*
|
|
8381
|
+
* @private
|
|
8382
|
+
* @param {*} value The value to check.
|
|
8383
|
+
* @param {Object} [object] The object to query keys on.
|
|
8384
|
+
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
8385
|
+
*/
|
|
8386
|
+
function isKey(value, object) {
|
|
8387
|
+
if (isArray_1(value)) {
|
|
8388
|
+
return false;
|
|
8389
|
+
}
|
|
8390
|
+
var type = typeof value;
|
|
8391
|
+
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
|
8392
|
+
value == null || isSymbol_1(value)) {
|
|
8393
|
+
return true;
|
|
8394
|
+
}
|
|
8395
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
8396
|
+
(object != null && value in Object(object));
|
|
8397
|
+
}
|
|
8398
|
+
|
|
8399
|
+
var _isKey = isKey;
|
|
8400
|
+
|
|
8401
|
+
/** Error message constants. */
|
|
8402
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
8403
|
+
|
|
8404
|
+
/**
|
|
8405
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
8406
|
+
* provided, it determines the cache key for storing the result based on the
|
|
8407
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
8408
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
8409
|
+
* is invoked with the `this` binding of the memoized function.
|
|
8410
|
+
*
|
|
8411
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
8412
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
8413
|
+
* constructor with one whose instances implement the
|
|
8414
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
8415
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
8416
|
+
*
|
|
8417
|
+
* @static
|
|
8418
|
+
* @memberOf _
|
|
8419
|
+
* @since 0.1.0
|
|
8420
|
+
* @category Function
|
|
8421
|
+
* @param {Function} func The function to have its output memoized.
|
|
8422
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
8423
|
+
* @returns {Function} Returns the new memoized function.
|
|
8424
|
+
* @example
|
|
8425
|
+
*
|
|
8426
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
8427
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
8428
|
+
*
|
|
8429
|
+
* var values = _.memoize(_.values);
|
|
8430
|
+
* values(object);
|
|
8431
|
+
* // => [1, 2]
|
|
8432
|
+
*
|
|
8433
|
+
* values(other);
|
|
8434
|
+
* // => [3, 4]
|
|
8435
|
+
*
|
|
8436
|
+
* object.a = 2;
|
|
8437
|
+
* values(object);
|
|
8438
|
+
* // => [1, 2]
|
|
8439
|
+
*
|
|
8440
|
+
* // Modify the result cache.
|
|
8441
|
+
* values.cache.set(object, ['a', 'b']);
|
|
8442
|
+
* values(object);
|
|
8443
|
+
* // => ['a', 'b']
|
|
8444
|
+
*
|
|
8445
|
+
* // Replace `_.memoize.Cache`.
|
|
8446
|
+
* _.memoize.Cache = WeakMap;
|
|
8447
|
+
*/
|
|
8448
|
+
function memoize(func, resolver) {
|
|
8449
|
+
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
8450
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
8451
|
+
}
|
|
8452
|
+
var memoized = function() {
|
|
8453
|
+
var args = arguments,
|
|
8454
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
8455
|
+
cache = memoized.cache;
|
|
8456
|
+
|
|
8457
|
+
if (cache.has(key)) {
|
|
8458
|
+
return cache.get(key);
|
|
8459
|
+
}
|
|
8460
|
+
var result = func.apply(this, args);
|
|
8461
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
8462
|
+
return result;
|
|
8463
|
+
};
|
|
8464
|
+
memoized.cache = new (memoize.Cache || _MapCache);
|
|
8465
|
+
return memoized;
|
|
8466
|
+
}
|
|
8467
|
+
|
|
8468
|
+
// Expose `MapCache`.
|
|
8469
|
+
memoize.Cache = _MapCache;
|
|
8470
|
+
|
|
8471
|
+
var memoize_1 = memoize;
|
|
8472
|
+
|
|
8473
|
+
/** Used as the maximum memoize cache size. */
|
|
8474
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
8475
|
+
|
|
8476
|
+
/**
|
|
8477
|
+
* A specialized version of `_.memoize` which clears the memoized function's
|
|
8478
|
+
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
8479
|
+
*
|
|
8480
|
+
* @private
|
|
8481
|
+
* @param {Function} func The function to have its output memoized.
|
|
8482
|
+
* @returns {Function} Returns the new memoized function.
|
|
8483
|
+
*/
|
|
8484
|
+
function memoizeCapped(func) {
|
|
8485
|
+
var result = memoize_1(func, function(key) {
|
|
8486
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
8487
|
+
cache.clear();
|
|
8488
|
+
}
|
|
8489
|
+
return key;
|
|
8490
|
+
});
|
|
8491
|
+
|
|
8492
|
+
var cache = result.cache;
|
|
8493
|
+
return result;
|
|
8494
|
+
}
|
|
8495
|
+
|
|
8496
|
+
var _memoizeCapped = memoizeCapped;
|
|
8497
|
+
|
|
8498
|
+
/** Used to match property names within property paths. */
|
|
8499
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
8500
|
+
|
|
8501
|
+
/** Used to match backslashes in property paths. */
|
|
8502
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
8503
|
+
|
|
8504
|
+
/**
|
|
8505
|
+
* Converts `string` to a property path array.
|
|
8506
|
+
*
|
|
8507
|
+
* @private
|
|
8508
|
+
* @param {string} string The string to convert.
|
|
8509
|
+
* @returns {Array} Returns the property path array.
|
|
8510
|
+
*/
|
|
8511
|
+
var stringToPath = _memoizeCapped(function(string) {
|
|
8512
|
+
var result = [];
|
|
8513
|
+
if (string.charCodeAt(0) === 46 /* . */) {
|
|
8514
|
+
result.push('');
|
|
8515
|
+
}
|
|
8516
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
8517
|
+
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
|
8518
|
+
});
|
|
8519
|
+
return result;
|
|
8520
|
+
});
|
|
8521
|
+
|
|
8522
|
+
var _stringToPath = stringToPath;
|
|
8523
|
+
|
|
8524
|
+
/** Used as references for various `Number` constants. */
|
|
8525
|
+
var INFINITY$1 = 1 / 0;
|
|
8526
|
+
|
|
8527
|
+
/** Used to convert symbols to primitives and strings. */
|
|
8528
|
+
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
|
8529
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
8530
|
+
|
|
8531
|
+
/**
|
|
8532
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
8533
|
+
* values to empty strings.
|
|
8534
|
+
*
|
|
8535
|
+
* @private
|
|
8536
|
+
* @param {*} value The value to process.
|
|
8537
|
+
* @returns {string} Returns the string.
|
|
8538
|
+
*/
|
|
8539
|
+
function baseToString(value) {
|
|
8540
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
8541
|
+
if (typeof value == 'string') {
|
|
8542
|
+
return value;
|
|
8543
|
+
}
|
|
8544
|
+
if (isArray_1(value)) {
|
|
8545
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
8546
|
+
return _arrayMap(value, baseToString) + '';
|
|
8547
|
+
}
|
|
8548
|
+
if (isSymbol_1(value)) {
|
|
8549
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
8550
|
+
}
|
|
8551
|
+
var result = (value + '');
|
|
8552
|
+
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
var _baseToString = baseToString;
|
|
8556
|
+
|
|
8557
|
+
/**
|
|
8558
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
8559
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
8560
|
+
*
|
|
8561
|
+
* @static
|
|
8562
|
+
* @memberOf _
|
|
8563
|
+
* @since 4.0.0
|
|
8564
|
+
* @category Lang
|
|
8565
|
+
* @param {*} value The value to convert.
|
|
8566
|
+
* @returns {string} Returns the converted string.
|
|
8567
|
+
* @example
|
|
8568
|
+
*
|
|
8569
|
+
* _.toString(null);
|
|
8570
|
+
* // => ''
|
|
8571
|
+
*
|
|
8572
|
+
* _.toString(-0);
|
|
8573
|
+
* // => '-0'
|
|
8574
|
+
*
|
|
8575
|
+
* _.toString([1, 2, 3]);
|
|
8576
|
+
* // => '1,2,3'
|
|
8577
|
+
*/
|
|
8578
|
+
function toString$1(value) {
|
|
8579
|
+
return value == null ? '' : _baseToString(value);
|
|
8580
|
+
}
|
|
8581
|
+
|
|
8582
|
+
var toString_1 = toString$1;
|
|
8583
|
+
|
|
8584
|
+
/**
|
|
8585
|
+
* Casts `value` to a path array if it's not one.
|
|
8586
|
+
*
|
|
8587
|
+
* @private
|
|
8588
|
+
* @param {*} value The value to inspect.
|
|
8589
|
+
* @param {Object} [object] The object to query keys on.
|
|
8590
|
+
* @returns {Array} Returns the cast property path array.
|
|
8591
|
+
*/
|
|
8592
|
+
function castPath(value, object) {
|
|
8593
|
+
if (isArray_1(value)) {
|
|
8594
|
+
return value;
|
|
8595
|
+
}
|
|
8596
|
+
return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
|
8597
|
+
}
|
|
8598
|
+
|
|
8599
|
+
var _castPath = castPath;
|
|
8600
|
+
|
|
8601
|
+
/** Used as references for various `Number` constants. */
|
|
8602
|
+
var INFINITY = 1 / 0;
|
|
8603
|
+
|
|
8604
|
+
/**
|
|
8605
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
8606
|
+
*
|
|
8607
|
+
* @private
|
|
8608
|
+
* @param {*} value The value to inspect.
|
|
8609
|
+
* @returns {string|symbol} Returns the key.
|
|
8610
|
+
*/
|
|
8611
|
+
function toKey(value) {
|
|
8612
|
+
if (typeof value == 'string' || isSymbol_1(value)) {
|
|
8613
|
+
return value;
|
|
8614
|
+
}
|
|
8615
|
+
var result = (value + '');
|
|
8616
|
+
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
8617
|
+
}
|
|
8618
|
+
|
|
8619
|
+
var _toKey = toKey;
|
|
8620
|
+
|
|
8621
|
+
/**
|
|
8622
|
+
* The base implementation of `_.get` without support for default values.
|
|
8623
|
+
*
|
|
8624
|
+
* @private
|
|
8625
|
+
* @param {Object} object The object to query.
|
|
8626
|
+
* @param {Array|string} path The path of the property to get.
|
|
8627
|
+
* @returns {*} Returns the resolved value.
|
|
8628
|
+
*/
|
|
8629
|
+
function baseGet(object, path) {
|
|
8630
|
+
path = _castPath(path, object);
|
|
8631
|
+
|
|
8632
|
+
var index = 0,
|
|
8633
|
+
length = path.length;
|
|
8634
|
+
|
|
8635
|
+
while (object != null && index < length) {
|
|
8636
|
+
object = object[_toKey(path[index++])];
|
|
8637
|
+
}
|
|
8638
|
+
return (index && index == length) ? object : undefined;
|
|
8639
|
+
}
|
|
8640
|
+
|
|
8641
|
+
var _baseGet = baseGet;
|
|
8642
|
+
|
|
8643
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
8644
|
+
var COMPARE_PARTIAL_FLAG$1 = 1,
|
|
8645
|
+
COMPARE_UNORDERED_FLAG$1 = 2;
|
|
8646
|
+
|
|
8647
|
+
/**
|
|
8648
|
+
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
|
8649
|
+
*
|
|
8650
|
+
* @private
|
|
8651
|
+
* @param {Object} object The object to inspect.
|
|
8652
|
+
* @param {Object} source The object of property values to match.
|
|
8653
|
+
* @param {Array} matchData The property names, values, and compare flags to match.
|
|
8654
|
+
* @param {Function} [customizer] The function to customize comparisons.
|
|
8655
|
+
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
8656
|
+
*/
|
|
8657
|
+
function baseIsMatch(object, source, matchData, customizer) {
|
|
8658
|
+
var index = matchData.length,
|
|
8659
|
+
length = index,
|
|
8660
|
+
noCustomizer = !customizer;
|
|
8661
|
+
|
|
8662
|
+
if (object == null) {
|
|
8663
|
+
return !length;
|
|
8664
|
+
}
|
|
8665
|
+
object = Object(object);
|
|
8666
|
+
while (index--) {
|
|
8667
|
+
var data = matchData[index];
|
|
8668
|
+
if ((noCustomizer && data[2])
|
|
8669
|
+
? data[1] !== object[data[0]]
|
|
8670
|
+
: !(data[0] in object)
|
|
8671
|
+
) {
|
|
8672
|
+
return false;
|
|
8673
|
+
}
|
|
8674
|
+
}
|
|
8675
|
+
while (++index < length) {
|
|
8676
|
+
data = matchData[index];
|
|
8677
|
+
var key = data[0],
|
|
8678
|
+
objValue = object[key],
|
|
8679
|
+
srcValue = data[1];
|
|
8680
|
+
|
|
8681
|
+
if (noCustomizer && data[2]) {
|
|
8682
|
+
if (objValue === undefined && !(key in object)) {
|
|
8683
|
+
return false;
|
|
8684
|
+
}
|
|
8685
|
+
} else {
|
|
8686
|
+
var stack = new _Stack;
|
|
8687
|
+
if (customizer) {
|
|
8688
|
+
var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
8689
|
+
}
|
|
8690
|
+
if (!(result === undefined
|
|
8691
|
+
? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
|
|
8692
|
+
: result
|
|
8693
|
+
)) {
|
|
8694
|
+
return false;
|
|
8695
|
+
}
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
return true;
|
|
8699
|
+
}
|
|
8700
|
+
|
|
8701
|
+
var _baseIsMatch = baseIsMatch;
|
|
8702
|
+
|
|
8703
|
+
/**
|
|
8704
|
+
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
|
8705
|
+
*
|
|
8706
|
+
* @private
|
|
8707
|
+
* @param {*} value The value to check.
|
|
8708
|
+
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
|
8709
|
+
* equality comparisons, else `false`.
|
|
8710
|
+
*/
|
|
8711
|
+
function isStrictComparable(value) {
|
|
8712
|
+
return value === value && !isObject_1(value);
|
|
8713
|
+
}
|
|
8714
|
+
|
|
8715
|
+
var _isStrictComparable = isStrictComparable;
|
|
8716
|
+
|
|
8717
|
+
/**
|
|
8718
|
+
* Gets the property names, values, and compare flags of `object`.
|
|
8719
|
+
*
|
|
8720
|
+
* @private
|
|
8721
|
+
* @param {Object} object The object to query.
|
|
8722
|
+
* @returns {Array} Returns the match data of `object`.
|
|
8723
|
+
*/
|
|
8724
|
+
function getMatchData(object) {
|
|
8725
|
+
var result = keys_1(object),
|
|
8726
|
+
length = result.length;
|
|
8727
|
+
|
|
8728
|
+
while (length--) {
|
|
8729
|
+
var key = result[length],
|
|
8730
|
+
value = object[key];
|
|
8731
|
+
|
|
8732
|
+
result[length] = [key, value, _isStrictComparable(value)];
|
|
8733
|
+
}
|
|
8734
|
+
return result;
|
|
8735
|
+
}
|
|
8736
|
+
|
|
8737
|
+
var _getMatchData = getMatchData;
|
|
8738
|
+
|
|
8739
|
+
/**
|
|
8740
|
+
* A specialized version of `matchesProperty` for source values suitable
|
|
8741
|
+
* for strict equality comparisons, i.e. `===`.
|
|
8742
|
+
*
|
|
8743
|
+
* @private
|
|
8744
|
+
* @param {string} key The key of the property to get.
|
|
8745
|
+
* @param {*} srcValue The value to match.
|
|
8746
|
+
* @returns {Function} Returns the new spec function.
|
|
8747
|
+
*/
|
|
8748
|
+
function matchesStrictComparable(key, srcValue) {
|
|
8749
|
+
return function(object) {
|
|
8750
|
+
if (object == null) {
|
|
8751
|
+
return false;
|
|
8752
|
+
}
|
|
8753
|
+
return object[key] === srcValue &&
|
|
8754
|
+
(srcValue !== undefined || (key in Object(object)));
|
|
8755
|
+
};
|
|
8756
|
+
}
|
|
8757
|
+
|
|
8758
|
+
var _matchesStrictComparable = matchesStrictComparable;
|
|
8759
|
+
|
|
8760
|
+
/**
|
|
8761
|
+
* The base implementation of `_.matches` which doesn't clone `source`.
|
|
8762
|
+
*
|
|
8763
|
+
* @private
|
|
8764
|
+
* @param {Object} source The object of property values to match.
|
|
8765
|
+
* @returns {Function} Returns the new spec function.
|
|
8766
|
+
*/
|
|
8767
|
+
function baseMatches(source) {
|
|
8768
|
+
var matchData = _getMatchData(source);
|
|
8769
|
+
if (matchData.length == 1 && matchData[0][2]) {
|
|
8770
|
+
return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
8771
|
+
}
|
|
8772
|
+
return function(object) {
|
|
8773
|
+
return object === source || _baseIsMatch(object, source, matchData);
|
|
8774
|
+
};
|
|
8775
|
+
}
|
|
8776
|
+
|
|
8777
|
+
var _baseMatches = baseMatches;
|
|
8778
|
+
|
|
8779
|
+
/**
|
|
8780
|
+
* Gets the value at `path` of `object`. If the resolved value is
|
|
8781
|
+
* `undefined`, the `defaultValue` is returned in its place.
|
|
8782
|
+
*
|
|
8783
|
+
* @static
|
|
8784
|
+
* @memberOf _
|
|
8785
|
+
* @since 3.7.0
|
|
8786
|
+
* @category Object
|
|
8787
|
+
* @param {Object} object The object to query.
|
|
8788
|
+
* @param {Array|string} path The path of the property to get.
|
|
8789
|
+
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
8790
|
+
* @returns {*} Returns the resolved value.
|
|
8791
|
+
* @example
|
|
8792
|
+
*
|
|
8793
|
+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
8794
|
+
*
|
|
8795
|
+
* _.get(object, 'a[0].b.c');
|
|
8796
|
+
* // => 3
|
|
8797
|
+
*
|
|
8798
|
+
* _.get(object, ['a', '0', 'b', 'c']);
|
|
8799
|
+
* // => 3
|
|
8800
|
+
*
|
|
8801
|
+
* _.get(object, 'a.b.c', 'default');
|
|
8802
|
+
* // => 'default'
|
|
8803
|
+
*/
|
|
8804
|
+
function get(object, path, defaultValue) {
|
|
8805
|
+
var result = object == null ? undefined : _baseGet(object, path);
|
|
8806
|
+
return result === undefined ? defaultValue : result;
|
|
8807
|
+
}
|
|
8808
|
+
|
|
8809
|
+
var get_1 = get;
|
|
8810
|
+
|
|
8811
|
+
/**
|
|
8812
|
+
* The base implementation of `_.hasIn` without support for deep paths.
|
|
8813
|
+
*
|
|
8814
|
+
* @private
|
|
8815
|
+
* @param {Object} [object] The object to query.
|
|
8816
|
+
* @param {Array|string} key The key to check.
|
|
8817
|
+
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
|
8818
|
+
*/
|
|
8819
|
+
function baseHasIn(object, key) {
|
|
8820
|
+
return object != null && key in Object(object);
|
|
8821
|
+
}
|
|
8822
|
+
|
|
8823
|
+
var _baseHasIn = baseHasIn;
|
|
8824
|
+
|
|
8825
|
+
/**
|
|
8826
|
+
* Checks if `path` exists on `object`.
|
|
8827
|
+
*
|
|
8828
|
+
* @private
|
|
8829
|
+
* @param {Object} object The object to query.
|
|
8830
|
+
* @param {Array|string} path The path to check.
|
|
8831
|
+
* @param {Function} hasFunc The function to check properties.
|
|
8832
|
+
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
8833
|
+
*/
|
|
8834
|
+
function hasPath(object, path, hasFunc) {
|
|
8835
|
+
path = _castPath(path, object);
|
|
8836
|
+
|
|
8837
|
+
var index = -1,
|
|
8838
|
+
length = path.length,
|
|
8839
|
+
result = false;
|
|
8840
|
+
|
|
8841
|
+
while (++index < length) {
|
|
8842
|
+
var key = _toKey(path[index]);
|
|
8843
|
+
if (!(result = object != null && hasFunc(object, key))) {
|
|
8844
|
+
break;
|
|
8845
|
+
}
|
|
8846
|
+
object = object[key];
|
|
8847
|
+
}
|
|
8848
|
+
if (result || ++index != length) {
|
|
8849
|
+
return result;
|
|
8850
|
+
}
|
|
8851
|
+
length = object == null ? 0 : object.length;
|
|
8852
|
+
return !!length && isLength_1(length) && _isIndex(key, length) &&
|
|
8853
|
+
(isArray_1(object) || isArguments_1(object));
|
|
8854
|
+
}
|
|
8855
|
+
|
|
8856
|
+
var _hasPath = hasPath;
|
|
8857
|
+
|
|
8858
|
+
/**
|
|
8859
|
+
* Checks if `path` is a direct or inherited property of `object`.
|
|
8860
|
+
*
|
|
8861
|
+
* @static
|
|
8862
|
+
* @memberOf _
|
|
8863
|
+
* @since 4.0.0
|
|
8864
|
+
* @category Object
|
|
8865
|
+
* @param {Object} object The object to query.
|
|
8866
|
+
* @param {Array|string} path The path to check.
|
|
8867
|
+
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
8868
|
+
* @example
|
|
8869
|
+
*
|
|
8870
|
+
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
|
8871
|
+
*
|
|
8872
|
+
* _.hasIn(object, 'a');
|
|
8873
|
+
* // => true
|
|
8874
|
+
*
|
|
8875
|
+
* _.hasIn(object, 'a.b');
|
|
8876
|
+
* // => true
|
|
8877
|
+
*
|
|
8878
|
+
* _.hasIn(object, ['a', 'b']);
|
|
8879
|
+
* // => true
|
|
8880
|
+
*
|
|
8881
|
+
* _.hasIn(object, 'b');
|
|
8882
|
+
* // => false
|
|
8883
|
+
*/
|
|
8884
|
+
function hasIn(object, path) {
|
|
8885
|
+
return object != null && _hasPath(object, path, _baseHasIn);
|
|
8886
|
+
}
|
|
8887
|
+
|
|
8888
|
+
var hasIn_1 = hasIn;
|
|
8889
|
+
|
|
8890
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
8891
|
+
var COMPARE_PARTIAL_FLAG = 1,
|
|
8892
|
+
COMPARE_UNORDERED_FLAG = 2;
|
|
8893
|
+
|
|
8894
|
+
/**
|
|
8895
|
+
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
|
8896
|
+
*
|
|
8897
|
+
* @private
|
|
8898
|
+
* @param {string} path The path of the property to get.
|
|
8899
|
+
* @param {*} srcValue The value to match.
|
|
8900
|
+
* @returns {Function} Returns the new spec function.
|
|
8901
|
+
*/
|
|
8902
|
+
function baseMatchesProperty(path, srcValue) {
|
|
8903
|
+
if (_isKey(path) && _isStrictComparable(srcValue)) {
|
|
8904
|
+
return _matchesStrictComparable(_toKey(path), srcValue);
|
|
8905
|
+
}
|
|
8906
|
+
return function(object) {
|
|
8907
|
+
var objValue = get_1(object, path);
|
|
8908
|
+
return (objValue === undefined && objValue === srcValue)
|
|
8909
|
+
? hasIn_1(object, path)
|
|
8910
|
+
: _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
8911
|
+
};
|
|
8912
|
+
}
|
|
8913
|
+
|
|
8914
|
+
var _baseMatchesProperty = baseMatchesProperty;
|
|
8915
|
+
|
|
8916
|
+
/**
|
|
8917
|
+
* This method returns the first argument it receives.
|
|
8918
|
+
*
|
|
8919
|
+
* @static
|
|
8920
|
+
* @since 0.1.0
|
|
8921
|
+
* @memberOf _
|
|
8922
|
+
* @category Util
|
|
8923
|
+
* @param {*} value Any value.
|
|
8924
|
+
* @returns {*} Returns `value`.
|
|
8925
|
+
* @example
|
|
8926
|
+
*
|
|
8927
|
+
* var object = { 'a': 1 };
|
|
8928
|
+
*
|
|
8929
|
+
* console.log(_.identity(object) === object);
|
|
8930
|
+
* // => true
|
|
8931
|
+
*/
|
|
8932
|
+
function identity(value) {
|
|
8933
|
+
return value;
|
|
8934
|
+
}
|
|
8935
|
+
|
|
8936
|
+
var identity_1 = identity;
|
|
8937
|
+
|
|
8938
|
+
/**
|
|
8939
|
+
* The base implementation of `_.property` without support for deep paths.
|
|
8940
|
+
*
|
|
8941
|
+
* @private
|
|
8942
|
+
* @param {string} key The key of the property to get.
|
|
8943
|
+
* @returns {Function} Returns the new accessor function.
|
|
8944
|
+
*/
|
|
8945
|
+
function baseProperty(key) {
|
|
8946
|
+
return function(object) {
|
|
8947
|
+
return object == null ? undefined : object[key];
|
|
8948
|
+
};
|
|
8949
|
+
}
|
|
8950
|
+
|
|
8951
|
+
var _baseProperty = baseProperty;
|
|
8952
|
+
|
|
8953
|
+
/**
|
|
8954
|
+
* A specialized version of `baseProperty` which supports deep paths.
|
|
8955
|
+
*
|
|
8956
|
+
* @private
|
|
8957
|
+
* @param {Array|string} path The path of the property to get.
|
|
8958
|
+
* @returns {Function} Returns the new accessor function.
|
|
8959
|
+
*/
|
|
8960
|
+
function basePropertyDeep(path) {
|
|
8961
|
+
return function(object) {
|
|
8962
|
+
return _baseGet(object, path);
|
|
8963
|
+
};
|
|
8964
|
+
}
|
|
8965
|
+
|
|
8966
|
+
var _basePropertyDeep = basePropertyDeep;
|
|
8967
|
+
|
|
8968
|
+
/**
|
|
8969
|
+
* Creates a function that returns the value at `path` of a given object.
|
|
8970
|
+
*
|
|
8971
|
+
* @static
|
|
8972
|
+
* @memberOf _
|
|
8973
|
+
* @since 2.4.0
|
|
8974
|
+
* @category Util
|
|
8975
|
+
* @param {Array|string} path The path of the property to get.
|
|
8976
|
+
* @returns {Function} Returns the new accessor function.
|
|
8977
|
+
* @example
|
|
8978
|
+
*
|
|
8979
|
+
* var objects = [
|
|
8980
|
+
* { 'a': { 'b': 2 } },
|
|
8981
|
+
* { 'a': { 'b': 1 } }
|
|
8982
|
+
* ];
|
|
8983
|
+
*
|
|
8984
|
+
* _.map(objects, _.property('a.b'));
|
|
8985
|
+
* // => [2, 1]
|
|
8986
|
+
*
|
|
8987
|
+
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
|
8988
|
+
* // => [1, 2]
|
|
8989
|
+
*/
|
|
8990
|
+
function property(path) {
|
|
8991
|
+
return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
|
|
8992
|
+
}
|
|
8993
|
+
|
|
8994
|
+
var property_1 = property;
|
|
8995
|
+
|
|
8996
|
+
/**
|
|
8997
|
+
* The base implementation of `_.iteratee`.
|
|
8998
|
+
*
|
|
8999
|
+
* @private
|
|
9000
|
+
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|
9001
|
+
* @returns {Function} Returns the iteratee.
|
|
9002
|
+
*/
|
|
9003
|
+
function baseIteratee(value) {
|
|
9004
|
+
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
|
9005
|
+
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
|
9006
|
+
if (typeof value == 'function') {
|
|
9007
|
+
return value;
|
|
9008
|
+
}
|
|
9009
|
+
if (value == null) {
|
|
9010
|
+
return identity_1;
|
|
9011
|
+
}
|
|
9012
|
+
if (typeof value == 'object') {
|
|
9013
|
+
return isArray_1(value)
|
|
9014
|
+
? _baseMatchesProperty(value[0], value[1])
|
|
9015
|
+
: _baseMatches(value);
|
|
9016
|
+
}
|
|
9017
|
+
return property_1(value);
|
|
9018
|
+
}
|
|
9019
|
+
|
|
9020
|
+
var _baseIteratee = baseIteratee;
|
|
9021
|
+
|
|
9022
|
+
/**
|
|
9023
|
+
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
9024
|
+
*
|
|
9025
|
+
* @private
|
|
9026
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
9027
|
+
* @returns {Function} Returns the new base function.
|
|
9028
|
+
*/
|
|
9029
|
+
function createBaseFor(fromRight) {
|
|
9030
|
+
return function(object, iteratee, keysFunc) {
|
|
9031
|
+
var index = -1,
|
|
9032
|
+
iterable = Object(object),
|
|
9033
|
+
props = keysFunc(object),
|
|
9034
|
+
length = props.length;
|
|
9035
|
+
|
|
9036
|
+
while (length--) {
|
|
9037
|
+
var key = props[fromRight ? length : ++index];
|
|
9038
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
9039
|
+
break;
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
return object;
|
|
9043
|
+
};
|
|
9044
|
+
}
|
|
9045
|
+
|
|
9046
|
+
var _createBaseFor = createBaseFor;
|
|
9047
|
+
|
|
9048
|
+
/**
|
|
9049
|
+
* The base implementation of `baseForOwn` which iterates over `object`
|
|
9050
|
+
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|
9051
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
9052
|
+
*
|
|
9053
|
+
* @private
|
|
9054
|
+
* @param {Object} object The object to iterate over.
|
|
9055
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9056
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
9057
|
+
* @returns {Object} Returns `object`.
|
|
9058
|
+
*/
|
|
9059
|
+
var baseFor = _createBaseFor();
|
|
9060
|
+
|
|
9061
|
+
var _baseFor = baseFor;
|
|
9062
|
+
|
|
9063
|
+
/**
|
|
9064
|
+
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
|
9065
|
+
*
|
|
9066
|
+
* @private
|
|
9067
|
+
* @param {Object} object The object to iterate over.
|
|
9068
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9069
|
+
* @returns {Object} Returns `object`.
|
|
9070
|
+
*/
|
|
9071
|
+
function baseForOwn(object, iteratee) {
|
|
9072
|
+
return object && _baseFor(object, iteratee, keys_1);
|
|
9073
|
+
}
|
|
9074
|
+
|
|
9075
|
+
var _baseForOwn = baseForOwn;
|
|
9076
|
+
|
|
9077
|
+
/**
|
|
9078
|
+
* Creates a `baseEach` or `baseEachRight` function.
|
|
9079
|
+
*
|
|
9080
|
+
* @private
|
|
9081
|
+
* @param {Function} eachFunc The function to iterate over a collection.
|
|
9082
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
9083
|
+
* @returns {Function} Returns the new base function.
|
|
9084
|
+
*/
|
|
9085
|
+
function createBaseEach(eachFunc, fromRight) {
|
|
9086
|
+
return function(collection, iteratee) {
|
|
9087
|
+
if (collection == null) {
|
|
9088
|
+
return collection;
|
|
9089
|
+
}
|
|
9090
|
+
if (!isArrayLike_1(collection)) {
|
|
9091
|
+
return eachFunc(collection, iteratee);
|
|
9092
|
+
}
|
|
9093
|
+
var length = collection.length,
|
|
9094
|
+
index = fromRight ? length : -1,
|
|
9095
|
+
iterable = Object(collection);
|
|
9096
|
+
|
|
9097
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
9098
|
+
if (iteratee(iterable[index], index, iterable) === false) {
|
|
9099
|
+
break;
|
|
9100
|
+
}
|
|
9101
|
+
}
|
|
9102
|
+
return collection;
|
|
9103
|
+
};
|
|
9104
|
+
}
|
|
9105
|
+
|
|
9106
|
+
var _createBaseEach = createBaseEach;
|
|
9107
|
+
|
|
9108
|
+
/**
|
|
9109
|
+
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
|
9110
|
+
*
|
|
9111
|
+
* @private
|
|
9112
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9113
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9114
|
+
* @returns {Array|Object} Returns `collection`.
|
|
9115
|
+
*/
|
|
9116
|
+
var baseEach = _createBaseEach(_baseForOwn);
|
|
9117
|
+
|
|
9118
|
+
var _baseEach = baseEach;
|
|
9119
|
+
|
|
9120
|
+
/**
|
|
9121
|
+
* The base implementation of `_.map` without support for iteratee shorthands.
|
|
9122
|
+
*
|
|
9123
|
+
* @private
|
|
9124
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9125
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9126
|
+
* @returns {Array} Returns the new mapped array.
|
|
9127
|
+
*/
|
|
9128
|
+
function baseMap(collection, iteratee) {
|
|
9129
|
+
var index = -1,
|
|
9130
|
+
result = isArrayLike_1(collection) ? Array(collection.length) : [];
|
|
9131
|
+
|
|
9132
|
+
_baseEach(collection, function(value, key, collection) {
|
|
9133
|
+
result[++index] = iteratee(value, key, collection);
|
|
9134
|
+
});
|
|
9135
|
+
return result;
|
|
9136
|
+
}
|
|
9137
|
+
|
|
9138
|
+
var _baseMap = baseMap;
|
|
9139
|
+
|
|
9140
|
+
/**
|
|
9141
|
+
* The base implementation of `_.sortBy` which uses `comparer` to define the
|
|
9142
|
+
* sort order of `array` and replaces criteria objects with their corresponding
|
|
9143
|
+
* values.
|
|
9144
|
+
*
|
|
9145
|
+
* @private
|
|
9146
|
+
* @param {Array} array The array to sort.
|
|
9147
|
+
* @param {Function} comparer The function to define sort order.
|
|
9148
|
+
* @returns {Array} Returns `array`.
|
|
9149
|
+
*/
|
|
9150
|
+
function baseSortBy(array, comparer) {
|
|
9151
|
+
var length = array.length;
|
|
9152
|
+
|
|
9153
|
+
array.sort(comparer);
|
|
9154
|
+
while (length--) {
|
|
9155
|
+
array[length] = array[length].value;
|
|
9156
|
+
}
|
|
9157
|
+
return array;
|
|
9158
|
+
}
|
|
9159
|
+
|
|
9160
|
+
var _baseSortBy = baseSortBy;
|
|
9161
|
+
|
|
9162
|
+
/**
|
|
9163
|
+
* Compares values to sort them in ascending order.
|
|
9164
|
+
*
|
|
9165
|
+
* @private
|
|
9166
|
+
* @param {*} value The value to compare.
|
|
9167
|
+
* @param {*} other The other value to compare.
|
|
9168
|
+
* @returns {number} Returns the sort order indicator for `value`.
|
|
9169
|
+
*/
|
|
9170
|
+
function compareAscending(value, other) {
|
|
9171
|
+
if (value !== other) {
|
|
9172
|
+
var valIsDefined = value !== undefined,
|
|
9173
|
+
valIsNull = value === null,
|
|
9174
|
+
valIsReflexive = value === value,
|
|
9175
|
+
valIsSymbol = isSymbol_1(value);
|
|
9176
|
+
|
|
9177
|
+
var othIsDefined = other !== undefined,
|
|
9178
|
+
othIsNull = other === null,
|
|
9179
|
+
othIsReflexive = other === other,
|
|
9180
|
+
othIsSymbol = isSymbol_1(other);
|
|
9181
|
+
|
|
9182
|
+
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
|
9183
|
+
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
|
9184
|
+
(valIsNull && othIsDefined && othIsReflexive) ||
|
|
9185
|
+
(!valIsDefined && othIsReflexive) ||
|
|
9186
|
+
!valIsReflexive) {
|
|
9187
|
+
return 1;
|
|
9188
|
+
}
|
|
9189
|
+
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
|
9190
|
+
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
|
9191
|
+
(othIsNull && valIsDefined && valIsReflexive) ||
|
|
9192
|
+
(!othIsDefined && valIsReflexive) ||
|
|
9193
|
+
!othIsReflexive) {
|
|
9194
|
+
return -1;
|
|
9195
|
+
}
|
|
9196
|
+
}
|
|
9197
|
+
return 0;
|
|
9198
|
+
}
|
|
9199
|
+
|
|
9200
|
+
var _compareAscending = compareAscending;
|
|
9201
|
+
|
|
9202
|
+
/**
|
|
9203
|
+
* Used by `_.orderBy` to compare multiple properties of a value to another
|
|
9204
|
+
* and stable sort them.
|
|
9205
|
+
*
|
|
9206
|
+
* If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
|
|
9207
|
+
* specify an order of "desc" for descending or "asc" for ascending sort order
|
|
9208
|
+
* of corresponding values.
|
|
9209
|
+
*
|
|
9210
|
+
* @private
|
|
9211
|
+
* @param {Object} object The object to compare.
|
|
9212
|
+
* @param {Object} other The other object to compare.
|
|
9213
|
+
* @param {boolean[]|string[]} orders The order to sort by for each property.
|
|
9214
|
+
* @returns {number} Returns the sort order indicator for `object`.
|
|
9215
|
+
*/
|
|
9216
|
+
function compareMultiple(object, other, orders) {
|
|
9217
|
+
var index = -1,
|
|
9218
|
+
objCriteria = object.criteria,
|
|
9219
|
+
othCriteria = other.criteria,
|
|
9220
|
+
length = objCriteria.length,
|
|
9221
|
+
ordersLength = orders.length;
|
|
9222
|
+
|
|
9223
|
+
while (++index < length) {
|
|
9224
|
+
var result = _compareAscending(objCriteria[index], othCriteria[index]);
|
|
9225
|
+
if (result) {
|
|
9226
|
+
if (index >= ordersLength) {
|
|
9227
|
+
return result;
|
|
9228
|
+
}
|
|
9229
|
+
var order = orders[index];
|
|
9230
|
+
return result * (order == 'desc' ? -1 : 1);
|
|
9231
|
+
}
|
|
9232
|
+
}
|
|
9233
|
+
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
|
9234
|
+
// that causes it, under certain circumstances, to provide the same value for
|
|
9235
|
+
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
|
|
9236
|
+
// for more details.
|
|
9237
|
+
//
|
|
9238
|
+
// This also ensures a stable sort in V8 and other engines.
|
|
9239
|
+
// See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
|
|
9240
|
+
return object.index - other.index;
|
|
9241
|
+
}
|
|
9242
|
+
|
|
9243
|
+
var _compareMultiple = compareMultiple;
|
|
9244
|
+
|
|
9245
|
+
/**
|
|
9246
|
+
* The base implementation of `_.orderBy` without param guards.
|
|
9247
|
+
*
|
|
9248
|
+
* @private
|
|
9249
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9250
|
+
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
|
|
9251
|
+
* @param {string[]} orders The sort orders of `iteratees`.
|
|
9252
|
+
* @returns {Array} Returns the new sorted array.
|
|
9253
|
+
*/
|
|
9254
|
+
function baseOrderBy(collection, iteratees, orders) {
|
|
9255
|
+
if (iteratees.length) {
|
|
9256
|
+
iteratees = _arrayMap(iteratees, function(iteratee) {
|
|
9257
|
+
if (isArray_1(iteratee)) {
|
|
9258
|
+
return function(value) {
|
|
9259
|
+
return _baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
|
|
9260
|
+
}
|
|
9261
|
+
}
|
|
9262
|
+
return iteratee;
|
|
9263
|
+
});
|
|
9264
|
+
} else {
|
|
9265
|
+
iteratees = [identity_1];
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
var index = -1;
|
|
9269
|
+
iteratees = _arrayMap(iteratees, _baseUnary(_baseIteratee));
|
|
9270
|
+
|
|
9271
|
+
var result = _baseMap(collection, function(value, key, collection) {
|
|
9272
|
+
var criteria = _arrayMap(iteratees, function(iteratee) {
|
|
9273
|
+
return iteratee(value);
|
|
9274
|
+
});
|
|
9275
|
+
return { 'criteria': criteria, 'index': ++index, 'value': value };
|
|
9276
|
+
});
|
|
9277
|
+
|
|
9278
|
+
return _baseSortBy(result, function(object, other) {
|
|
9279
|
+
return _compareMultiple(object, other, orders);
|
|
9280
|
+
});
|
|
9281
|
+
}
|
|
9282
|
+
|
|
9283
|
+
var _baseOrderBy = baseOrderBy;
|
|
9284
|
+
|
|
9285
|
+
/**
|
|
9286
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
9287
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
9288
|
+
*
|
|
9289
|
+
* @private
|
|
9290
|
+
* @param {Function} func The function to invoke.
|
|
9291
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
9292
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
9293
|
+
* @returns {*} Returns the result of `func`.
|
|
9294
|
+
*/
|
|
9295
|
+
function apply(func, thisArg, args) {
|
|
9296
|
+
switch (args.length) {
|
|
9297
|
+
case 0: return func.call(thisArg);
|
|
9298
|
+
case 1: return func.call(thisArg, args[0]);
|
|
9299
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
9300
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
9301
|
+
}
|
|
9302
|
+
return func.apply(thisArg, args);
|
|
9303
|
+
}
|
|
9304
|
+
|
|
9305
|
+
var _apply = apply;
|
|
9306
|
+
|
|
9307
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
9308
|
+
var nativeMax = Math.max;
|
|
9309
|
+
|
|
9310
|
+
/**
|
|
9311
|
+
* A specialized version of `baseRest` which transforms the rest array.
|
|
9312
|
+
*
|
|
9313
|
+
* @private
|
|
9314
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
9315
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
9316
|
+
* @param {Function} transform The rest array transform.
|
|
9317
|
+
* @returns {Function} Returns the new function.
|
|
9318
|
+
*/
|
|
9319
|
+
function overRest(func, start, transform) {
|
|
9320
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
9321
|
+
return function() {
|
|
9322
|
+
var args = arguments,
|
|
9323
|
+
index = -1,
|
|
9324
|
+
length = nativeMax(args.length - start, 0),
|
|
9325
|
+
array = Array(length);
|
|
9326
|
+
|
|
9327
|
+
while (++index < length) {
|
|
9328
|
+
array[index] = args[start + index];
|
|
9329
|
+
}
|
|
9330
|
+
index = -1;
|
|
9331
|
+
var otherArgs = Array(start + 1);
|
|
9332
|
+
while (++index < start) {
|
|
9333
|
+
otherArgs[index] = args[index];
|
|
9334
|
+
}
|
|
9335
|
+
otherArgs[start] = transform(array);
|
|
9336
|
+
return _apply(func, this, otherArgs);
|
|
9337
|
+
};
|
|
9338
|
+
}
|
|
9339
|
+
|
|
9340
|
+
var _overRest = overRest;
|
|
9341
|
+
|
|
9342
|
+
/**
|
|
9343
|
+
* Creates a function that returns `value`.
|
|
9344
|
+
*
|
|
9345
|
+
* @static
|
|
9346
|
+
* @memberOf _
|
|
9347
|
+
* @since 2.4.0
|
|
9348
|
+
* @category Util
|
|
9349
|
+
* @param {*} value The value to return from the new function.
|
|
9350
|
+
* @returns {Function} Returns the new constant function.
|
|
9351
|
+
* @example
|
|
9352
|
+
*
|
|
9353
|
+
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
9354
|
+
*
|
|
9355
|
+
* console.log(objects);
|
|
9356
|
+
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
9357
|
+
*
|
|
9358
|
+
* console.log(objects[0] === objects[1]);
|
|
9359
|
+
* // => true
|
|
9360
|
+
*/
|
|
9361
|
+
function constant(value) {
|
|
9362
|
+
return function() {
|
|
9363
|
+
return value;
|
|
9364
|
+
};
|
|
9365
|
+
}
|
|
9366
|
+
|
|
9367
|
+
var constant_1 = constant;
|
|
9368
|
+
|
|
9369
|
+
var defineProperty = (function() {
|
|
9370
|
+
try {
|
|
9371
|
+
var func = _getNative(Object, 'defineProperty');
|
|
9372
|
+
func({}, '', {});
|
|
9373
|
+
return func;
|
|
9374
|
+
} catch (e) {}
|
|
9375
|
+
}());
|
|
9376
|
+
|
|
9377
|
+
var _defineProperty = defineProperty;
|
|
9378
|
+
|
|
9379
|
+
/**
|
|
9380
|
+
* The base implementation of `setToString` without support for hot loop shorting.
|
|
9381
|
+
*
|
|
9382
|
+
* @private
|
|
9383
|
+
* @param {Function} func The function to modify.
|
|
9384
|
+
* @param {Function} string The `toString` result.
|
|
9385
|
+
* @returns {Function} Returns `func`.
|
|
9386
|
+
*/
|
|
9387
|
+
var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
|
|
9388
|
+
return _defineProperty(func, 'toString', {
|
|
9389
|
+
'configurable': true,
|
|
9390
|
+
'enumerable': false,
|
|
9391
|
+
'value': constant_1(string),
|
|
9392
|
+
'writable': true
|
|
9393
|
+
});
|
|
9394
|
+
};
|
|
9395
|
+
|
|
9396
|
+
var _baseSetToString = baseSetToString;
|
|
9397
|
+
|
|
9398
|
+
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
9399
|
+
var HOT_COUNT = 800,
|
|
9400
|
+
HOT_SPAN = 16;
|
|
9401
|
+
|
|
9402
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
9403
|
+
var nativeNow = Date.now;
|
|
9404
|
+
|
|
9405
|
+
/**
|
|
9406
|
+
* Creates a function that'll short out and invoke `identity` instead
|
|
9407
|
+
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
|
9408
|
+
* milliseconds.
|
|
9409
|
+
*
|
|
9410
|
+
* @private
|
|
9411
|
+
* @param {Function} func The function to restrict.
|
|
9412
|
+
* @returns {Function} Returns the new shortable function.
|
|
9413
|
+
*/
|
|
9414
|
+
function shortOut(func) {
|
|
9415
|
+
var count = 0,
|
|
9416
|
+
lastCalled = 0;
|
|
9417
|
+
|
|
9418
|
+
return function() {
|
|
9419
|
+
var stamp = nativeNow(),
|
|
9420
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
9421
|
+
|
|
9422
|
+
lastCalled = stamp;
|
|
9423
|
+
if (remaining > 0) {
|
|
9424
|
+
if (++count >= HOT_COUNT) {
|
|
9425
|
+
return arguments[0];
|
|
9426
|
+
}
|
|
9427
|
+
} else {
|
|
9428
|
+
count = 0;
|
|
9429
|
+
}
|
|
9430
|
+
return func.apply(undefined, arguments);
|
|
9431
|
+
};
|
|
9432
|
+
}
|
|
9433
|
+
|
|
9434
|
+
var _shortOut = shortOut;
|
|
9435
|
+
|
|
9436
|
+
/**
|
|
9437
|
+
* Sets the `toString` method of `func` to return `string`.
|
|
9438
|
+
*
|
|
9439
|
+
* @private
|
|
9440
|
+
* @param {Function} func The function to modify.
|
|
9441
|
+
* @param {Function} string The `toString` result.
|
|
9442
|
+
* @returns {Function} Returns `func`.
|
|
9443
|
+
*/
|
|
9444
|
+
var setToString = _shortOut(_baseSetToString);
|
|
9445
|
+
|
|
9446
|
+
var _setToString = setToString;
|
|
9447
|
+
|
|
9448
|
+
/**
|
|
9449
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
9450
|
+
*
|
|
9451
|
+
* @private
|
|
9452
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
9453
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
9454
|
+
* @returns {Function} Returns the new function.
|
|
9455
|
+
*/
|
|
9456
|
+
function baseRest(func, start) {
|
|
9457
|
+
return _setToString(_overRest(func, start, identity_1), func + '');
|
|
9458
|
+
}
|
|
9459
|
+
|
|
9460
|
+
var _baseRest = baseRest;
|
|
9461
|
+
|
|
9462
|
+
/**
|
|
9463
|
+
* Checks if the given arguments are from an iteratee call.
|
|
9464
|
+
*
|
|
9465
|
+
* @private
|
|
9466
|
+
* @param {*} value The potential iteratee value argument.
|
|
9467
|
+
* @param {*} index The potential iteratee index or key argument.
|
|
9468
|
+
* @param {*} object The potential iteratee object argument.
|
|
9469
|
+
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|
9470
|
+
* else `false`.
|
|
9471
|
+
*/
|
|
9472
|
+
function isIterateeCall(value, index, object) {
|
|
9473
|
+
if (!isObject_1(object)) {
|
|
9474
|
+
return false;
|
|
9475
|
+
}
|
|
9476
|
+
var type = typeof index;
|
|
9477
|
+
if (type == 'number'
|
|
9478
|
+
? (isArrayLike_1(object) && _isIndex(index, object.length))
|
|
9479
|
+
: (type == 'string' && index in object)
|
|
9480
|
+
) {
|
|
9481
|
+
return eq_1(object[index], value);
|
|
9482
|
+
}
|
|
9483
|
+
return false;
|
|
9484
|
+
}
|
|
9485
|
+
|
|
9486
|
+
var _isIterateeCall = isIterateeCall;
|
|
9487
|
+
|
|
9488
|
+
/**
|
|
9489
|
+
* Creates an array of elements, sorted in ascending order by the results of
|
|
9490
|
+
* running each element in a collection thru each iteratee. This method
|
|
9491
|
+
* performs a stable sort, that is, it preserves the original sort order of
|
|
9492
|
+
* equal elements. The iteratees are invoked with one argument: (value).
|
|
9493
|
+
*
|
|
9494
|
+
* @static
|
|
9495
|
+
* @memberOf _
|
|
9496
|
+
* @since 0.1.0
|
|
9497
|
+
* @category Collection
|
|
9498
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9499
|
+
* @param {...(Function|Function[])} [iteratees=[_.identity]]
|
|
9500
|
+
* The iteratees to sort by.
|
|
9501
|
+
* @returns {Array} Returns the new sorted array.
|
|
9502
|
+
* @example
|
|
9503
|
+
*
|
|
9504
|
+
* var users = [
|
|
9505
|
+
* { 'user': 'fred', 'age': 48 },
|
|
9506
|
+
* { 'user': 'barney', 'age': 36 },
|
|
9507
|
+
* { 'user': 'fred', 'age': 30 },
|
|
9508
|
+
* { 'user': 'barney', 'age': 34 }
|
|
9509
|
+
* ];
|
|
9510
|
+
*
|
|
9511
|
+
* _.sortBy(users, [function(o) { return o.user; }]);
|
|
9512
|
+
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
|
|
9513
|
+
*
|
|
9514
|
+
* _.sortBy(users, ['user', 'age']);
|
|
9515
|
+
* // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
|
|
9516
|
+
*/
|
|
9517
|
+
var sortBy = _baseRest(function(collection, iteratees) {
|
|
9518
|
+
if (collection == null) {
|
|
9519
|
+
return [];
|
|
9520
|
+
}
|
|
9521
|
+
var length = iteratees.length;
|
|
9522
|
+
if (length > 1 && _isIterateeCall(collection, iteratees[0], iteratees[1])) {
|
|
9523
|
+
iteratees = [];
|
|
9524
|
+
} else if (length > 2 && _isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
|
9525
|
+
iteratees = [iteratees[0]];
|
|
9526
|
+
}
|
|
9527
|
+
return _baseOrderBy(collection, _baseFlatten(iteratees, 1), []);
|
|
9528
|
+
});
|
|
9529
|
+
|
|
9530
|
+
var sortBy_1 = sortBy;
|
|
9531
|
+
|
|
9532
|
+
/**
|
|
9533
|
+
* Configuration for custom action validation rules.
|
|
9534
|
+
* Defines allowed positions, metadata IDs, data model IDs, and fields for each target
|
|
9535
|
+
* type.
|
|
9536
|
+
*
|
|
9537
|
+
*/
|
|
9538
|
+
const customActionValidationConfig = {
|
|
9539
|
+
[CustomActionTarget.LIVEBOARD]: {
|
|
9540
|
+
positions: [CustomActionsPosition.PRIMARY, CustomActionsPosition.MENU],
|
|
9541
|
+
allowedMetadataIds: ['liveboardIds'],
|
|
9542
|
+
allowedDataModelIds: [],
|
|
9543
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds'],
|
|
9544
|
+
},
|
|
9545
|
+
[CustomActionTarget.VIZ]: {
|
|
9546
|
+
positions: [CustomActionsPosition.MENU, CustomActionsPosition.PRIMARY, CustomActionsPosition.CONTEXTMENU],
|
|
9547
|
+
allowedMetadataIds: ['liveboardIds', 'vizIds', 'answerIds'],
|
|
9548
|
+
allowedDataModelIds: ['modelIds', 'modelColumnNames'],
|
|
9549
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9550
|
+
},
|
|
9551
|
+
[CustomActionTarget.ANSWER]: {
|
|
9552
|
+
positions: [CustomActionsPosition.MENU, CustomActionsPosition.PRIMARY, CustomActionsPosition.CONTEXTMENU],
|
|
9553
|
+
allowedMetadataIds: ['answerIds'],
|
|
9554
|
+
allowedDataModelIds: ['modelIds', 'modelColumnNames'],
|
|
9555
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9556
|
+
},
|
|
9557
|
+
[CustomActionTarget.SPOTTER]: {
|
|
9558
|
+
positions: [CustomActionsPosition.MENU, CustomActionsPosition.CONTEXTMENU],
|
|
9559
|
+
allowedMetadataIds: [],
|
|
9560
|
+
allowedDataModelIds: ['modelIds'],
|
|
9561
|
+
allowedFields: ['name', 'id', 'position', 'target', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9562
|
+
},
|
|
9563
|
+
};
|
|
9564
|
+
/**
|
|
9565
|
+
* Validates a single custom action based on its target type
|
|
9566
|
+
* @param action - The custom action to validate
|
|
9567
|
+
* @param primaryActionsPerTarget - Map to track primary actions per target
|
|
9568
|
+
* @returns CustomActionValidation with isValid flag and reason string
|
|
9569
|
+
*
|
|
9570
|
+
* @hidden
|
|
9571
|
+
*/
|
|
9572
|
+
const validateCustomAction = (action, primaryActionsPerTarget) => {
|
|
9573
|
+
const { id: actionId, target: targetType, position, metadataIds, dataModelIds } = action;
|
|
9574
|
+
// Check if target type is supported
|
|
9575
|
+
if (!customActionValidationConfig[targetType]) {
|
|
9576
|
+
const errorMessage = CUSTOM_ACTIONS_ERROR_MESSAGE.UNSUPPORTED_TARGET(actionId, targetType);
|
|
9577
|
+
return { isValid: false, errors: [errorMessage] };
|
|
9578
|
+
}
|
|
9579
|
+
const config = customActionValidationConfig[targetType];
|
|
9580
|
+
const errors = [];
|
|
9581
|
+
// Validate position
|
|
9582
|
+
if (!arrayIncludesString(config.positions, position)) {
|
|
9583
|
+
const supportedPositions = config.positions.join(', ');
|
|
9584
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_POSITION(position, targetType, supportedPositions));
|
|
8043
9585
|
}
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
* @example
|
|
8051
|
-
* ```js
|
|
8052
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
8053
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
8054
|
-
* 'col name 1' // The column should exist in the data source.
|
|
8055
|
-
* ]);
|
|
8056
|
-
* const data = await underlying.fetchData(0, 100);
|
|
8057
|
-
* })
|
|
8058
|
-
* ```
|
|
8059
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
8060
|
-
*/
|
|
8061
|
-
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
8062
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
8063
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
8064
|
-
}
|
|
8065
|
-
if (!selectedPoints) {
|
|
8066
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
8067
|
-
}
|
|
8068
|
-
const sourceDetail = await this.getSourceDetail();
|
|
8069
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
8070
|
-
const unAggAnswer = await graphqlQuery({
|
|
8071
|
-
query: getUnaggregatedAnswerSession,
|
|
8072
|
-
variables: {
|
|
8073
|
-
session: this.session,
|
|
8074
|
-
columns: selectedPoints,
|
|
8075
|
-
},
|
|
8076
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
8077
|
-
});
|
|
8078
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
8079
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
8080
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
8081
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
8082
|
-
if (columnsToAdd.length) {
|
|
8083
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
8084
|
-
}
|
|
8085
|
-
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
8086
|
-
if (columnsToRemove.length) {
|
|
8087
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
9586
|
+
// Validate metadata IDs
|
|
9587
|
+
if (metadataIds) {
|
|
9588
|
+
const invalidMetadataIds = Object.keys(metadataIds).filter((key) => !arrayIncludesString(config.allowedMetadataIds, key));
|
|
9589
|
+
if (invalidMetadataIds.length > 0) {
|
|
9590
|
+
const supportedMetadataIds = config.allowedMetadataIds.length > 0 ? config.allowedMetadataIds.join(', ') : 'none';
|
|
9591
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_METADATA_IDS(targetType, invalidMetadataIds, supportedMetadataIds));
|
|
8088
9592
|
}
|
|
8089
|
-
return unaggAnswerSession;
|
|
8090
|
-
}
|
|
8091
|
-
/**
|
|
8092
|
-
* Execute a custom graphql query in the context of the answer.
|
|
8093
|
-
* @param query graphql query
|
|
8094
|
-
* @param variables graphql variables
|
|
8095
|
-
* @returns
|
|
8096
|
-
*/
|
|
8097
|
-
async executeQuery(query, variables) {
|
|
8098
|
-
const data = await graphqlQuery({
|
|
8099
|
-
query,
|
|
8100
|
-
variables: {
|
|
8101
|
-
session: this.session,
|
|
8102
|
-
...variables,
|
|
8103
|
-
},
|
|
8104
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
8105
|
-
isCompositeQuery: false,
|
|
8106
|
-
});
|
|
8107
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
8108
|
-
return data;
|
|
8109
|
-
}
|
|
8110
|
-
/**
|
|
8111
|
-
* Get the internal session details for the answer.
|
|
8112
|
-
* @returns
|
|
8113
|
-
*/
|
|
8114
|
-
getSession() {
|
|
8115
|
-
return this.session;
|
|
8116
9593
|
}
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
9594
|
+
// Validate data model IDs
|
|
9595
|
+
if (dataModelIds) {
|
|
9596
|
+
const invalidDataModelIds = Object.keys(dataModelIds).filter((key) => !arrayIncludesString(config.allowedDataModelIds, key));
|
|
9597
|
+
if (invalidDataModelIds.length > 0) {
|
|
9598
|
+
const supportedDataModelIds = config.allowedDataModelIds.length > 0 ? config.allowedDataModelIds.join(', ') : 'none';
|
|
9599
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_DATA_MODEL_IDS(targetType, invalidDataModelIds, supportedDataModelIds));
|
|
8120
9600
|
}
|
|
8121
|
-
this.answer = this.executeQuery(getAnswer, {}).then((data) => data === null || data === void 0 ? void 0 : data.answer);
|
|
8122
|
-
return this.answer;
|
|
8123
|
-
}
|
|
8124
|
-
async getTML() {
|
|
8125
|
-
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
8126
|
-
const edoc = object[0].edoc;
|
|
8127
|
-
const YAML = await import('./index-P5YjBOuJ.js');
|
|
8128
|
-
const parsedDoc = YAML.parse(edoc);
|
|
8129
|
-
return {
|
|
8130
|
-
answer: {
|
|
8131
|
-
...parsedDoc.answer,
|
|
8132
|
-
...this.tmlOverride,
|
|
8133
|
-
},
|
|
8134
|
-
};
|
|
8135
|
-
}
|
|
8136
|
-
async addDisplayedVizToLiveboard(liveboardId) {
|
|
8137
|
-
const { displayMode, visualizations } = await this.getAnswer();
|
|
8138
|
-
const viz = getDisplayedViz(visualizations, displayMode);
|
|
8139
|
-
return this.executeQuery(addVizToLiveboard, {
|
|
8140
|
-
liveboardId,
|
|
8141
|
-
vizId: viz.id,
|
|
8142
|
-
});
|
|
8143
9601
|
}
|
|
8144
|
-
|
|
8145
|
-
|
|
9602
|
+
// Validate allowed fields
|
|
9603
|
+
const actionKeys = Object.keys(action);
|
|
9604
|
+
const invalidFields = actionKeys.filter((key) => !arrayIncludesString(config.allowedFields, key));
|
|
9605
|
+
if (invalidFields.length > 0) {
|
|
9606
|
+
const supportedFields = config.allowedFields.join(', ');
|
|
9607
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_FIELDS(targetType, invalidFields, supportedFields));
|
|
8146
9608
|
}
|
|
8147
|
-
|
|
9609
|
+
return {
|
|
9610
|
+
isValid: errors.length === 0,
|
|
9611
|
+
errors,
|
|
9612
|
+
};
|
|
9613
|
+
};
|
|
8148
9614
|
/**
|
|
9615
|
+
* Validates basic action structure and required fields
|
|
9616
|
+
* @param action - The action to validate
|
|
9617
|
+
* @returns Object containing validation result and missing fields
|
|
8149
9618
|
*
|
|
8150
|
-
* @
|
|
8151
|
-
* @param colNames
|
|
9619
|
+
* @hidden
|
|
8152
9620
|
*/
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
}));
|
|
8162
|
-
}
|
|
9621
|
+
const validateActionStructure = (action) => {
|
|
9622
|
+
if (!action || typeof action !== 'object') {
|
|
9623
|
+
return { isValid: false, missingFields: [] };
|
|
9624
|
+
}
|
|
9625
|
+
// Check for all missing required fields
|
|
9626
|
+
const missingFields = ['id', 'name', 'target', 'position'].filter(field => !action[field]);
|
|
9627
|
+
return { isValid: missingFields.length === 0, missingFields };
|
|
9628
|
+
};
|
|
8163
9629
|
/**
|
|
9630
|
+
* Checks for duplicate IDs among actions
|
|
9631
|
+
* @param actions - Array of actions to check
|
|
9632
|
+
* @returns Object containing filtered actions and duplicate errors
|
|
8164
9633
|
*
|
|
8165
|
-
* @
|
|
9634
|
+
* @hidden
|
|
8166
9635
|
*/
|
|
8167
|
-
|
|
8168
|
-
const
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
let dataValue;
|
|
8178
|
-
if (dataType === 'DATE') {
|
|
8179
|
-
if (Number.isFinite(colVal.value)) {
|
|
8180
|
-
dataValue = [{
|
|
8181
|
-
epochRange: {
|
|
8182
|
-
startEpoch: colVal.value,
|
|
8183
|
-
},
|
|
8184
|
-
}];
|
|
8185
|
-
// Case for custom calendar.
|
|
8186
|
-
}
|
|
8187
|
-
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
8188
|
-
dataValue = [{
|
|
8189
|
-
epochRange: {
|
|
8190
|
-
startEpoch: colVal.value.v.s,
|
|
8191
|
-
endEpoch: colVal.value.v.e,
|
|
8192
|
-
},
|
|
8193
|
-
}];
|
|
8194
|
-
}
|
|
9636
|
+
const filterDuplicateIds = (actions) => {
|
|
9637
|
+
const idMap = actions.reduce((map, action) => {
|
|
9638
|
+
const list = map.get(action.id) || [];
|
|
9639
|
+
list.push(action);
|
|
9640
|
+
map.set(action.id, list);
|
|
9641
|
+
return map;
|
|
9642
|
+
}, new Map());
|
|
9643
|
+
const { actions: actionsWithUniqueIds, errors } = Array.from(idMap.entries()).reduce((acc, [id, actionsWithSameId]) => {
|
|
9644
|
+
if (actionsWithSameId.length === 1) {
|
|
9645
|
+
acc.actions.push(actionsWithSameId[0]);
|
|
8195
9646
|
}
|
|
8196
9647
|
else {
|
|
8197
|
-
|
|
9648
|
+
// Keep the first action and add error for duplicates
|
|
9649
|
+
acc.actions.push(actionsWithSameId[0]);
|
|
9650
|
+
const duplicateNames = actionsWithSameId.slice(1).map(action => action.name);
|
|
9651
|
+
acc.errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.DUPLICATE_IDS(id, duplicateNames, actionsWithSameId[0].name));
|
|
8198
9652
|
}
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
}
|
|
8204
|
-
selectedPoints.forEach((p) => {
|
|
8205
|
-
p.selectedAttributes.forEach(addPointFromColVal);
|
|
8206
|
-
});
|
|
8207
|
-
return underlyingDataPoint;
|
|
8208
|
-
}
|
|
9653
|
+
return acc;
|
|
9654
|
+
}, { actions: [], errors: [] });
|
|
9655
|
+
return { actions: actionsWithUniqueIds, errors };
|
|
9656
|
+
};
|
|
8209
9657
|
/**
|
|
8210
|
-
*
|
|
8211
|
-
* @param
|
|
8212
|
-
* @
|
|
9658
|
+
* Validates and processes custom actions
|
|
9659
|
+
* @param customActions - Array of custom actions to validate
|
|
9660
|
+
* @returns Object containing valid actions and any validation errors
|
|
8213
9661
|
*/
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
(viz) => viz.__typename === 'ChartViz');
|
|
9662
|
+
const getCustomActions = (customActions) => {
|
|
9663
|
+
const errors = [];
|
|
9664
|
+
if (!customActions || !Array.isArray(customActions)) {
|
|
9665
|
+
return { actions: [], errors: [] };
|
|
8219
9666
|
}
|
|
8220
|
-
|
|
8221
|
-
//
|
|
8222
|
-
|
|
8223
|
-
|
|
9667
|
+
// Step 1: Handle invalid actions first (null, undefined, missing required
|
|
9668
|
+
// fields)
|
|
9669
|
+
const validActions = customActions.filter(action => {
|
|
9670
|
+
const validation = validateActionStructure(action);
|
|
9671
|
+
if (!validation.isValid) {
|
|
9672
|
+
if (!action || typeof action !== 'object') {
|
|
9673
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_ACTION_OBJECT);
|
|
9674
|
+
}
|
|
9675
|
+
else {
|
|
9676
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.MISSING_REQUIRED_FIELDS(action.id, validation.missingFields));
|
|
9677
|
+
}
|
|
9678
|
+
return false;
|
|
9679
|
+
}
|
|
9680
|
+
return true;
|
|
9681
|
+
});
|
|
9682
|
+
// Step 2: Check for duplicate IDs among valid actions
|
|
9683
|
+
const { actions: actionsWithUniqueIds, errors: duplicateErrors } = filterDuplicateIds(validActions);
|
|
9684
|
+
// Add duplicate errors to the errors array
|
|
9685
|
+
duplicateErrors.forEach(error => errors.push(error));
|
|
9686
|
+
// Step 3: Validate actions with unique IDs
|
|
9687
|
+
const finalValidActions = [];
|
|
9688
|
+
actionsWithUniqueIds.forEach((action) => {
|
|
9689
|
+
const { isValid, errors: validationErrors } = validateCustomAction(action);
|
|
9690
|
+
validationErrors.forEach(error => errors.push(error));
|
|
9691
|
+
if (isValid) {
|
|
9692
|
+
finalValidActions.push(action);
|
|
9693
|
+
}
|
|
9694
|
+
});
|
|
9695
|
+
const sortedActions = sortBy_1(finalValidActions, (a) => a.name.toLocaleLowerCase());
|
|
9696
|
+
return {
|
|
9697
|
+
actions: sortedActions,
|
|
9698
|
+
errors: errors,
|
|
9699
|
+
};
|
|
9700
|
+
};
|
|
8224
9701
|
|
|
8225
9702
|
/**
|
|
8226
9703
|
* Copyright (c) 2023
|
|
@@ -15748,6 +17225,13 @@ function processExitPresentMode(e) {
|
|
|
15748
17225
|
handleExitPresentMode();
|
|
15749
17226
|
}
|
|
15750
17227
|
}
|
|
17228
|
+
/**
|
|
17229
|
+
* Clears the cached preauth and session info.
|
|
17230
|
+
*/
|
|
17231
|
+
function processClearInfoCache() {
|
|
17232
|
+
resetCachedPreauthInfo();
|
|
17233
|
+
resetCachedSessionInfo();
|
|
17234
|
+
}
|
|
15751
17235
|
/**
|
|
15752
17236
|
*
|
|
15753
17237
|
* @param e
|
|
@@ -15854,11 +17338,13 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
|
15854
17338
|
return processAuthLogout(e, containerEl);
|
|
15855
17339
|
case EmbedEvent.ExitPresentMode:
|
|
15856
17340
|
return processExitPresentMode();
|
|
17341
|
+
case EmbedEvent.CLEAR_INFO_CACHE:
|
|
17342
|
+
return processClearInfoCache();
|
|
15857
17343
|
}
|
|
15858
17344
|
return e;
|
|
15859
17345
|
}
|
|
15860
17346
|
|
|
15861
|
-
var name="@thoughtspot/visual-embed-sdk";var version$1="1.40.
|
|
17347
|
+
var name="@thoughtspot/visual-embed-sdk";var version$1="1.40.3";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","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",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | npx coveralls-next","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",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={classnames:"^2.3.1",eventemitter3:"^4.0.7",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.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":"^11.2.0","@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/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0",ajv:"^8.17.1",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1","coveralls-next":"^5.0.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^9.23.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^10.1.1","eslint-import-resolver-typescript":"^4.2.5","eslint-plugin-comment-length":"2.2.1","eslint-plugin-import":"^2.31.0","eslint-plugin-jsdoc":"^50.6.9","eslint-plugin-prettier":"^5.2.5","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^5.2.0","fs-extra":"^10.0.0","gh-pages":"6.3.0",globals:"^16.0.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^2.0.0",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.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:"4.24.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","typescript-eslint":"^8.29.1","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^6.3.5"};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","embedded","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$1,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"32 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};
|
|
15862
17348
|
|
|
15863
17349
|
/**
|
|
15864
17350
|
* Reloads the ThoughtSpot iframe.
|
|
@@ -16383,6 +17869,16 @@ class TsEmbed {
|
|
|
16383
17869
|
async getDefaultAppInitData() {
|
|
16384
17870
|
var _a, _b;
|
|
16385
17871
|
const authToken = await this.getAuthTokenForCookielessInit();
|
|
17872
|
+
const customActionsResult = getCustomActions([
|
|
17873
|
+
...(this.viewConfig.customActions || []),
|
|
17874
|
+
...(this.embedConfig.customActions || [])
|
|
17875
|
+
]);
|
|
17876
|
+
if (customActionsResult.errors.length > 0) {
|
|
17877
|
+
this.handleError({
|
|
17878
|
+
type: 'CUSTOM_ACTION_VALIDATION',
|
|
17879
|
+
message: customActionsResult.errors,
|
|
17880
|
+
});
|
|
17881
|
+
}
|
|
16386
17882
|
return {
|
|
16387
17883
|
customisations: getCustomisations(this.embedConfig, this.viewConfig),
|
|
16388
17884
|
authToken,
|
|
@@ -16400,6 +17896,7 @@ class TsEmbed {
|
|
|
16400
17896
|
: [],
|
|
16401
17897
|
customVariablesForThirdPartyTools: this.embedConfig.customVariablesForThirdPartyTools || {},
|
|
16402
17898
|
hiddenListColumns: this.viewConfig.hiddenListColumns || [],
|
|
17899
|
+
customActions: customActionsResult.actions,
|
|
16403
17900
|
};
|
|
16404
17901
|
}
|
|
16405
17902
|
async getAppInitData() {
|
|
@@ -17842,7 +19339,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17842
19339
|
* embedded Liveboard or visualization.
|
|
17843
19340
|
*/
|
|
17844
19341
|
getEmbedParams() {
|
|
17845
|
-
const { tag, hideObjects, liveboardV2, showPrimaryNavbar, disableProfileAndHelp, hideHamburger, hideObjectSearch, hideNotification, hideApplicationSwitcher, hideOrgSwitcher, enableSearchAssist, fullHeight, dataPanelV2 = false, hideLiveboardHeader = false, showLiveboardTitle = true, showLiveboardDescription = true, hideHomepageLeftNav = false, modularHomeExperience = false, isLiveboardHeaderSticky = true, enableAskSage, collapseSearchBarInitially = false, enable2ColumnLayout, enableCustomColumnGroups = false, isOnBeforeGetVizDataInterceptEnabled = false, dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL, collapseSearchBar = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, homePageSearchBarMode, isUnifiedSearchExperienceEnabled = true, enablePendoHelp = true, discoveryExperience, coverAndFilterOptionInPDF = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
19342
|
+
const { tag, hideObjects, liveboardV2, showPrimaryNavbar, disableProfileAndHelp, hideHamburger, hideObjectSearch, hideNotification, hideApplicationSwitcher, hideOrgSwitcher, enableSearchAssist, fullHeight, dataPanelV2 = false, hideLiveboardHeader = false, showLiveboardTitle = true, showLiveboardDescription = true, hideHomepageLeftNav = false, modularHomeExperience = false, isLiveboardHeaderSticky = true, enableAskSage, collapseSearchBarInitially = false, enable2ColumnLayout, enableCustomColumnGroups = false, isOnBeforeGetVizDataInterceptEnabled = false, dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL, collapseSearchBar = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, homePageSearchBarMode, isUnifiedSearchExperienceEnabled = true, enablePendoHelp = true, discoveryExperience, coverAndFilterOptionInPDF = false, liveboardXLSXCSVDownload = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
17846
19343
|
let params = {};
|
|
17847
19344
|
params[Param.PrimaryNavHidden] = !showPrimaryNavbar;
|
|
17848
19345
|
params[Param.HideProfleAndHelp] = !!disableProfileAndHelp;
|
|
@@ -17859,6 +19356,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17859
19356
|
params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
|
|
17860
19357
|
params[Param.IsUnifiedSearchExperienceEnabled] = isUnifiedSearchExperienceEnabled;
|
|
17861
19358
|
params[Param.CoverAndFilterOptionInPDF] = !!coverAndFilterOptionInPDF;
|
|
19359
|
+
params[Param.LiveboardXLSXCSVDownload] = !!liveboardXLSXCSVDownload;
|
|
17862
19360
|
params = this.getBaseQueryParams(params);
|
|
17863
19361
|
if (hideObjectSearch) {
|
|
17864
19362
|
params[Param.HideObjectSearch] = !!hideObjectSearch;
|
|
@@ -17929,6 +19427,9 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
17929
19427
|
// Set homePageVersion to v2 by default to reset the LD flag value
|
|
17930
19428
|
// for the homepageVersion.
|
|
17931
19429
|
params[Param.HomepageVersion] = 'v2';
|
|
19430
|
+
// Set listpageVersion to v2 by default to reset the LD flag value
|
|
19431
|
+
// for the listpageVersion.
|
|
19432
|
+
params[Param.ListPageVersion] = ListPage.List;
|
|
17932
19433
|
if (discoveryExperience) {
|
|
17933
19434
|
// primaryNavbarVersion v3 will enabled the new left navigation
|
|
17934
19435
|
if (discoveryExperience.primaryNavbarVersion === PrimaryNavbarVersion.Sliding) {
|
|
@@ -18252,7 +19753,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
18252
19753
|
getEmbedParams() {
|
|
18253
19754
|
let params = {};
|
|
18254
19755
|
params = this.getBaseQueryParams(params);
|
|
18255
|
-
const { enableVizTransformations, fullHeight, defaultHeight, visibleVizs, liveboardV2, vizId, hideTabPanel, activeTabId, hideLiveboardHeader, showLiveboardDescription, showLiveboardTitle, isLiveboardHeaderSticky = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, enableAskSage, enable2ColumnLayout, dataPanelV2 = false, enableCustomColumnGroups = false, oAuthPollingInterval, isForceRedirect, dataSourceId, coverAndFilterOptionInPDF = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
19756
|
+
const { enableVizTransformations, fullHeight, defaultHeight, visibleVizs, liveboardV2, vizId, hideTabPanel, activeTabId, hideLiveboardHeader, showLiveboardDescription, showLiveboardTitle, isLiveboardHeaderSticky = true, isLiveboardCompactHeaderEnabled = false, showLiveboardVerifiedBadge = true, showLiveboardReverifyBanner = true, hideIrrelevantChipsInLiveboardTabs = false, enableAskSage, enable2ColumnLayout, dataPanelV2 = false, enableCustomColumnGroups = false, oAuthPollingInterval, isForceRedirect, dataSourceId, coverAndFilterOptionInPDF = false, liveboardXLSXCSVDownload = false, isLiveboardStylingAndGroupingEnabled, } = this.viewConfig;
|
|
18256
19757
|
const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
|
|
18257
19758
|
|| this.viewConfig.preventPinboardFilterRemoval;
|
|
18258
19759
|
if (fullHeight === true) {
|
|
@@ -18319,6 +19820,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
18319
19820
|
params[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
18320
19821
|
params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
18321
19822
|
params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
|
|
19823
|
+
params[Param.LiveboardXLSXCSVDownload] = !!liveboardXLSXCSVDownload;
|
|
18322
19824
|
const queryParams = getQueryParamString(params, true);
|
|
18323
19825
|
return queryParams;
|
|
18324
19826
|
}
|
|
@@ -19502,4 +21004,4 @@ function useSpotterAgent(config) {
|
|
|
19502
21004
|
};
|
|
19503
21005
|
}
|
|
19504
21006
|
|
|
19505
|
-
export { Action, AppEmbed, ConversationEmbed, ConversationMessage, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, ListPageColumns, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, SpotterEmbed, SpotterMessage, getSessionInfo, useEmbedRef, useInit, useSpotterAgent };
|
|
21007
|
+
export { Action, AppEmbed, ConversationEmbed, ConversationMessage, CustomActionsPosition, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, ListPageColumns, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, SpotterEmbed, SpotterMessage, getSessionInfo, useEmbedRef, useInit, useSpotterAgent };
|