@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.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
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
@@ -217,7 +217,6 @@
|
|
|
217
217
|
* the embedded app
|
|
218
218
|
* @group Authentication / Init
|
|
219
219
|
*/
|
|
220
|
-
// eslint-disable-next-line no-shadow
|
|
221
220
|
var AuthType;
|
|
222
221
|
(function (AuthType) {
|
|
223
222
|
/**
|
|
@@ -431,7 +430,6 @@
|
|
|
431
430
|
/**
|
|
432
431
|
* A map of the supported runtime filter operations
|
|
433
432
|
*/
|
|
434
|
-
// eslint-disable-next-line no-shadow
|
|
435
433
|
exports.RuntimeFilterOp = void 0;
|
|
436
434
|
(function (RuntimeFilterOp) {
|
|
437
435
|
/**
|
|
@@ -502,7 +500,6 @@
|
|
|
502
500
|
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
503
501
|
* @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl, 10.1.0.sw
|
|
504
502
|
*/
|
|
505
|
-
// eslint-disable-next-line no-shadow
|
|
506
503
|
exports.HomepageModule = void 0;
|
|
507
504
|
(function (HomepageModule) {
|
|
508
505
|
/**
|
|
@@ -535,7 +532,6 @@
|
|
|
535
532
|
* **Note**: This option is applicable to full app embedding only.
|
|
536
533
|
* @version SDK: 1.38.0 | ThoughtSpot: 10.9.0.cl
|
|
537
534
|
*/
|
|
538
|
-
// eslint-disable-next-line no-shadow
|
|
539
535
|
exports.ListPageColumns = void 0;
|
|
540
536
|
(function (ListPageColumns) {
|
|
541
537
|
/**
|
|
@@ -598,7 +594,6 @@
|
|
|
598
594
|
* ```
|
|
599
595
|
* @group Events
|
|
600
596
|
*/
|
|
601
|
-
// eslint-disable-next-line no-shadow
|
|
602
597
|
exports.EmbedEvent = void 0;
|
|
603
598
|
(function (EmbedEvent) {
|
|
604
599
|
/**
|
|
@@ -1240,6 +1235,11 @@
|
|
|
1240
1235
|
* @hidden
|
|
1241
1236
|
*/
|
|
1242
1237
|
EmbedEvent["APP_INIT"] = "appInit";
|
|
1238
|
+
/**
|
|
1239
|
+
* Internal event to clear the cached info
|
|
1240
|
+
* @hidden
|
|
1241
|
+
*/
|
|
1242
|
+
EmbedEvent["CLEAR_INFO_CACHE"] = "clearInfoCache";
|
|
1243
1243
|
/**
|
|
1244
1244
|
* Emitted when a user clicks **Show Liveboard details** on a Liveboard
|
|
1245
1245
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
@@ -1708,6 +1708,17 @@
|
|
|
1708
1708
|
* ```
|
|
1709
1709
|
*/
|
|
1710
1710
|
EmbedEvent["EmbedListenerReady"] = "EmbedListenerReady";
|
|
1711
|
+
/**
|
|
1712
|
+
* Emitted when the organization is switched.
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```js
|
|
1715
|
+
* appEmbed.on(EmbedEvent.OrgSwitched, (payload) => {
|
|
1716
|
+
* console.log('payload', payload);
|
|
1717
|
+
* })
|
|
1718
|
+
* ```
|
|
1719
|
+
* @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
|
|
1720
|
+
*/
|
|
1721
|
+
EmbedEvent["OrgSwitched"] = "orgSwitched";
|
|
1711
1722
|
})(exports.EmbedEvent || (exports.EmbedEvent = {}));
|
|
1712
1723
|
/**
|
|
1713
1724
|
* Event types that can be triggered by the host application
|
|
@@ -1762,7 +1773,6 @@
|
|
|
1762
1773
|
* ```
|
|
1763
1774
|
* @group Events
|
|
1764
1775
|
*/
|
|
1765
|
-
// eslint-disable-next-line no-shadow
|
|
1766
1776
|
exports.HostEvent = void 0;
|
|
1767
1777
|
(function (HostEvent) {
|
|
1768
1778
|
/**
|
|
@@ -2977,7 +2987,6 @@
|
|
|
2977
2987
|
* The different visual modes that the data sources panel within
|
|
2978
2988
|
* search could appear in, such as hidden, collapsed, or expanded.
|
|
2979
2989
|
*/
|
|
2980
|
-
// eslint-disable-next-line no-shadow
|
|
2981
2990
|
var DataSourceVisualMode;
|
|
2982
2991
|
(function (DataSourceVisualMode) {
|
|
2983
2992
|
/**
|
|
@@ -2997,7 +3006,6 @@
|
|
|
2997
3006
|
* The query params passed down to the embedded ThoughtSpot app
|
|
2998
3007
|
* containing configuration and/or visual information.
|
|
2999
3008
|
*/
|
|
3000
|
-
// eslint-disable-next-line no-shadow
|
|
3001
3009
|
var Param;
|
|
3002
3010
|
(function (Param) {
|
|
3003
3011
|
Param["EmbedApp"] = "embedApp";
|
|
@@ -3119,6 +3127,7 @@
|
|
|
3119
3127
|
Param["IsLiveboardStylingAndGroupingEnabled"] = "isLiveboardStylingAndGroupingEnabled";
|
|
3120
3128
|
Param["IsLazyLoadingForEmbedEnabled"] = "isLazyLoadingForEmbedEnabled";
|
|
3121
3129
|
Param["RootMarginForLazyLoad"] = "rootMarginForLazyLoad";
|
|
3130
|
+
Param["LiveboardXLSXCSVDownload"] = "isLiveboardXLSXCSVDownloadEnabled";
|
|
3122
3131
|
})(Param || (Param = {}));
|
|
3123
3132
|
/**
|
|
3124
3133
|
* ThoughtSpot application pages include actions and menu commands
|
|
@@ -3147,7 +3156,6 @@
|
|
|
3147
3156
|
* ```
|
|
3148
3157
|
* See also link:https://developers.thoughtspot.com/docs/actions[Action IDs in the SDK]
|
|
3149
3158
|
*/
|
|
3150
|
-
// eslint-disable-next-line no-shadow
|
|
3151
3159
|
exports.Action = void 0;
|
|
3152
3160
|
(function (Action) {
|
|
3153
3161
|
/**
|
|
@@ -3692,7 +3700,7 @@
|
|
|
3692
3700
|
* The Favorites icon (*) for Answers,
|
|
3693
3701
|
* Liveboard, and data objects like Worksheet, Model,
|
|
3694
3702
|
* Tables and Views.
|
|
3695
|
-
* Allows adding an object to the user
|
|
3703
|
+
* Allows adding an object to the user's favorites list.
|
|
3696
3704
|
* @example
|
|
3697
3705
|
* ```js
|
|
3698
3706
|
* disabledActions: [Action.AddToFavorites]
|
|
@@ -4419,6 +4427,26 @@
|
|
|
4419
4427
|
ContextMenuTriggerOptions["RIGHT_CLICK"] = "right-click";
|
|
4420
4428
|
ContextMenuTriggerOptions["BOTH_CLICKS"] = "both-clicks";
|
|
4421
4429
|
})(ContextMenuTriggerOptions || (ContextMenuTriggerOptions = {}));
|
|
4430
|
+
/**
|
|
4431
|
+
* Enum options to show custom actions at different
|
|
4432
|
+
* positions in the application.
|
|
4433
|
+
*/
|
|
4434
|
+
exports.CustomActionsPosition = void 0;
|
|
4435
|
+
(function (CustomActionsPosition) {
|
|
4436
|
+
CustomActionsPosition["PRIMARY"] = "PRIMARY";
|
|
4437
|
+
CustomActionsPosition["MENU"] = "MENU";
|
|
4438
|
+
CustomActionsPosition["CONTEXTMENU"] = "CONTEXTMENU";
|
|
4439
|
+
})(exports.CustomActionsPosition || (exports.CustomActionsPosition = {}));
|
|
4440
|
+
/**
|
|
4441
|
+
* Enum options to mention the target of the custom action.
|
|
4442
|
+
*/
|
|
4443
|
+
var CustomActionTarget;
|
|
4444
|
+
(function (CustomActionTarget) {
|
|
4445
|
+
CustomActionTarget["LIVEBOARD"] = "LIVEBOARD";
|
|
4446
|
+
CustomActionTarget["VIZ"] = "VIZ";
|
|
4447
|
+
CustomActionTarget["ANSWER"] = "ANSWER";
|
|
4448
|
+
CustomActionTarget["SPOTTER"] = "SPOTTER";
|
|
4449
|
+
})(CustomActionTarget || (CustomActionTarget = {}));
|
|
4422
4450
|
/**
|
|
4423
4451
|
* Enum options to show or suppress Visual Embed SDK and
|
|
4424
4452
|
* ThoughtSpot application logs in the console output.
|
|
@@ -4879,6 +4907,15 @@
|
|
|
4879
4907
|
* @returns The stored value or `undefined` if the key is not found.
|
|
4880
4908
|
*/
|
|
4881
4909
|
const getValueFromWindow = (key) => { var _a; return (_a = window === null || window === void 0 ? void 0 : window[sdkWindowKey]) === null || _a === void 0 ? void 0 : _a[key]; };
|
|
4910
|
+
/**
|
|
4911
|
+
* Check if an array includes a string value
|
|
4912
|
+
* @param arr - The array to check
|
|
4913
|
+
* @param key - The string to search for
|
|
4914
|
+
* @returns boolean indicating if the string is found in the array
|
|
4915
|
+
*/
|
|
4916
|
+
const arrayIncludesString = (arr, key) => {
|
|
4917
|
+
return arr.some(item => typeof item === 'string' && item === key);
|
|
4918
|
+
};
|
|
4882
4919
|
/**
|
|
4883
4920
|
* Check if the document is currently in fullscreen mode
|
|
4884
4921
|
*/
|
|
@@ -5963,8 +6000,8 @@
|
|
|
5963
6000
|
var _cacheHas = cacheHas;
|
|
5964
6001
|
|
|
5965
6002
|
/** Used to compose bitmasks for value comparisons. */
|
|
5966
|
-
var COMPARE_PARTIAL_FLAG$
|
|
5967
|
-
COMPARE_UNORDERED_FLAG$
|
|
6003
|
+
var COMPARE_PARTIAL_FLAG$5 = 1,
|
|
6004
|
+
COMPARE_UNORDERED_FLAG$3 = 2;
|
|
5968
6005
|
|
|
5969
6006
|
/**
|
|
5970
6007
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
@@ -5980,7 +6017,7 @@
|
|
|
5980
6017
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
5981
6018
|
*/
|
|
5982
6019
|
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
5983
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
6020
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
|
|
5984
6021
|
arrLength = array.length,
|
|
5985
6022
|
othLength = other.length;
|
|
5986
6023
|
|
|
@@ -5995,7 +6032,7 @@
|
|
|
5995
6032
|
}
|
|
5996
6033
|
var index = -1,
|
|
5997
6034
|
result = true,
|
|
5998
|
-
seen = (bitmask & COMPARE_UNORDERED_FLAG$
|
|
6035
|
+
seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new _SetCache : undefined;
|
|
5999
6036
|
|
|
6000
6037
|
stack.set(array, other);
|
|
6001
6038
|
stack.set(other, array);
|
|
@@ -6087,8 +6124,8 @@
|
|
|
6087
6124
|
var _setToArray = setToArray;
|
|
6088
6125
|
|
|
6089
6126
|
/** Used to compose bitmasks for value comparisons. */
|
|
6090
|
-
var COMPARE_PARTIAL_FLAG$
|
|
6091
|
-
COMPARE_UNORDERED_FLAG = 2;
|
|
6127
|
+
var COMPARE_PARTIAL_FLAG$4 = 1,
|
|
6128
|
+
COMPARE_UNORDERED_FLAG$2 = 2;
|
|
6092
6129
|
|
|
6093
6130
|
/** `Object#toString` result references. */
|
|
6094
6131
|
var boolTag$2 = '[object Boolean]',
|
|
@@ -6099,14 +6136,14 @@
|
|
|
6099
6136
|
regexpTag$1 = '[object RegExp]',
|
|
6100
6137
|
setTag$3 = '[object Set]',
|
|
6101
6138
|
stringTag$1 = '[object String]',
|
|
6102
|
-
symbolTag = '[object Symbol]';
|
|
6139
|
+
symbolTag$1 = '[object Symbol]';
|
|
6103
6140
|
|
|
6104
6141
|
var arrayBufferTag$1 = '[object ArrayBuffer]',
|
|
6105
6142
|
dataViewTag$2 = '[object DataView]';
|
|
6106
6143
|
|
|
6107
6144
|
/** Used to convert symbols to primitives and strings. */
|
|
6108
|
-
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
|
6109
|
-
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
6145
|
+
var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
|
|
6146
|
+
symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
|
|
6110
6147
|
|
|
6111
6148
|
/**
|
|
6112
6149
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
@@ -6163,7 +6200,7 @@
|
|
|
6163
6200
|
var convert = _mapToArray;
|
|
6164
6201
|
|
|
6165
6202
|
case setTag$3:
|
|
6166
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
6203
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
|
|
6167
6204
|
convert || (convert = _setToArray);
|
|
6168
6205
|
|
|
6169
6206
|
if (object.size != other.size && !isPartial) {
|
|
@@ -6174,7 +6211,7 @@
|
|
|
6174
6211
|
if (stacked) {
|
|
6175
6212
|
return stacked == other;
|
|
6176
6213
|
}
|
|
6177
|
-
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
6214
|
+
bitmask |= COMPARE_UNORDERED_FLAG$2;
|
|
6178
6215
|
|
|
6179
6216
|
// Recursively compare objects (susceptible to call stack limits).
|
|
6180
6217
|
stack.set(object, other);
|
|
@@ -6182,7 +6219,7 @@
|
|
|
6182
6219
|
stack['delete'](object);
|
|
6183
6220
|
return result;
|
|
6184
6221
|
|
|
6185
|
-
case symbolTag:
|
|
6222
|
+
case symbolTag$1:
|
|
6186
6223
|
if (symbolValueOf) {
|
|
6187
6224
|
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
6188
6225
|
}
|
|
@@ -6873,7 +6910,7 @@
|
|
|
6873
6910
|
var _getAllKeys = getAllKeys;
|
|
6874
6911
|
|
|
6875
6912
|
/** Used to compose bitmasks for value comparisons. */
|
|
6876
|
-
var COMPARE_PARTIAL_FLAG$
|
|
6913
|
+
var COMPARE_PARTIAL_FLAG$3 = 1;
|
|
6877
6914
|
|
|
6878
6915
|
/** Used for built-in method references. */
|
|
6879
6916
|
var objectProto$2 = Object.prototype;
|
|
@@ -6895,7 +6932,7 @@
|
|
|
6895
6932
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
6896
6933
|
*/
|
|
6897
6934
|
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
6898
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$
|
|
6935
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
|
|
6899
6936
|
objProps = _getAllKeys(object),
|
|
6900
6937
|
objLength = objProps.length,
|
|
6901
6938
|
othProps = _getAllKeys(other),
|
|
@@ -7033,7 +7070,7 @@
|
|
|
7033
7070
|
var _getTag = getTag;
|
|
7034
7071
|
|
|
7035
7072
|
/** Used to compose bitmasks for value comparisons. */
|
|
7036
|
-
var COMPARE_PARTIAL_FLAG = 1;
|
|
7073
|
+
var COMPARE_PARTIAL_FLAG$2 = 1;
|
|
7037
7074
|
|
|
7038
7075
|
/** `Object#toString` result references. */
|
|
7039
7076
|
var argsTag = '[object Arguments]',
|
|
@@ -7086,7 +7123,7 @@
|
|
|
7086
7123
|
? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
7087
7124
|
: _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
7088
7125
|
}
|
|
7089
|
-
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
7126
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
|
|
7090
7127
|
var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, '__wrapped__'),
|
|
7091
7128
|
othIsWrapped = othIsObj && hasOwnProperty$2.call(other, '__wrapped__');
|
|
7092
7129
|
|
|
@@ -7256,6 +7293,16 @@
|
|
|
7256
7293
|
MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
|
|
7257
7294
|
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',
|
|
7258
7295
|
SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
|
|
7296
|
+
};
|
|
7297
|
+
const CUSTOM_ACTIONS_ERROR_MESSAGE = {
|
|
7298
|
+
INVALID_ACTION_OBJECT: 'Custom Action Validation Error: Invalid action object provided',
|
|
7299
|
+
MISSING_REQUIRED_FIELDS: (id, missingFields) => `Custom Action Validation Error for '${id}': Missing required fields: ${missingFields.join(', ')}`,
|
|
7300
|
+
UNSUPPORTED_TARGET: (id, targetType) => `Custom Action Validation Error for '${id}': Target type '${targetType}' is not supported`,
|
|
7301
|
+
INVALID_POSITION: (position, targetType, supportedPositions) => `Position '${position}' is not supported for ${targetType.toLowerCase()}-level custom actions. Supported positions: ${supportedPositions}`,
|
|
7302
|
+
INVALID_METADATA_IDS: (targetType, invalidIds, supportedIds) => `Invalid metadata IDs for ${targetType.toLowerCase()}-level custom actions: ${invalidIds.join(', ')}. Supported metadata IDs: ${supportedIds}`,
|
|
7303
|
+
INVALID_DATA_MODEL_IDS: (targetType, invalidIds, supportedIds) => `Invalid data model IDs for ${targetType.toLowerCase()}-level custom actions: ${invalidIds.join(', ')}. Supported data model IDs: ${supportedIds}`,
|
|
7304
|
+
INVALID_FIELDS: (targetType, invalidFields, supportedFields) => `Invalid fields for ${targetType.toLowerCase()}-level custom actions: ${invalidFields.join(', ')}. Supported fields: ${supportedFields}`,
|
|
7305
|
+
DUPLICATE_IDS: (id, duplicateNames, keptName) => `Duplicate custom action ID '${id}' found. Actions with names '${duplicateNames.join("', '")}' will be ignored. Keeping '${keptName}'.`,
|
|
7259
7306
|
};
|
|
7260
7307
|
|
|
7261
7308
|
const EndPoints = {
|
|
@@ -8053,196 +8100,1626 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
8053
8100
|
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
8054
8101
|
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
8055
8102
|
}
|
|
8056
|
-
/**
|
|
8057
|
-
* Just get the internal URL for this answer's data
|
|
8058
|
-
* as a PNG blob.
|
|
8059
|
-
* @param userLocale
|
|
8060
|
-
* @param omitBackground
|
|
8061
|
-
* @param deviceScaleFactor
|
|
8062
|
-
*/
|
|
8063
|
-
getFetchPNGBlobUrl(userLocale = 'en-us', omitBackground = false, deviceScaleFactor = 2) {
|
|
8064
|
-
return `${this.thoughtSpotHost}/prism/download/answer/png?sessionId=${this.session.sessionId}&deviceScaleFactor=${deviceScaleFactor}&omitBackground=${omitBackground}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data`;
|
|
8103
|
+
/**
|
|
8104
|
+
* Just get the internal URL for this answer's data
|
|
8105
|
+
* as a PNG blob.
|
|
8106
|
+
* @param userLocale
|
|
8107
|
+
* @param omitBackground
|
|
8108
|
+
* @param deviceScaleFactor
|
|
8109
|
+
*/
|
|
8110
|
+
getFetchPNGBlobUrl(userLocale = 'en-us', omitBackground = false, deviceScaleFactor = 2) {
|
|
8111
|
+
return `${this.thoughtSpotHost}/prism/download/answer/png?sessionId=${this.session.sessionId}&deviceScaleFactor=${deviceScaleFactor}&omitBackground=${omitBackground}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data`;
|
|
8112
|
+
}
|
|
8113
|
+
/**
|
|
8114
|
+
* Get underlying data given a point and the output column names.
|
|
8115
|
+
* In case of a context menu action, the selectedPoints are
|
|
8116
|
+
* automatically passed.
|
|
8117
|
+
* @param outputColumnNames
|
|
8118
|
+
* @param selectedPoints
|
|
8119
|
+
* @example
|
|
8120
|
+
* ```js
|
|
8121
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
8122
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
8123
|
+
* 'col name 1' // The column should exist in the data source.
|
|
8124
|
+
* ]);
|
|
8125
|
+
* const data = await underlying.fetchData(0, 100);
|
|
8126
|
+
* })
|
|
8127
|
+
* ```
|
|
8128
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
8129
|
+
*/
|
|
8130
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
8131
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
8132
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
8133
|
+
}
|
|
8134
|
+
if (!selectedPoints) {
|
|
8135
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
8136
|
+
}
|
|
8137
|
+
const sourceDetail = await this.getSourceDetail();
|
|
8138
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
8139
|
+
const unAggAnswer = await graphqlQuery({
|
|
8140
|
+
query: getUnaggregatedAnswerSession,
|
|
8141
|
+
variables: {
|
|
8142
|
+
session: this.session,
|
|
8143
|
+
columns: selectedPoints,
|
|
8144
|
+
},
|
|
8145
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
8146
|
+
});
|
|
8147
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
8148
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
8149
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
8150
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
8151
|
+
if (columnsToAdd.length) {
|
|
8152
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
8153
|
+
}
|
|
8154
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
8155
|
+
if (columnsToRemove.length) {
|
|
8156
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
8157
|
+
}
|
|
8158
|
+
return unaggAnswerSession;
|
|
8159
|
+
}
|
|
8160
|
+
/**
|
|
8161
|
+
* Execute a custom graphql query in the context of the answer.
|
|
8162
|
+
* @param query graphql query
|
|
8163
|
+
* @param variables graphql variables
|
|
8164
|
+
* @returns
|
|
8165
|
+
*/
|
|
8166
|
+
async executeQuery(query, variables) {
|
|
8167
|
+
const data = await graphqlQuery({
|
|
8168
|
+
query,
|
|
8169
|
+
variables: {
|
|
8170
|
+
session: this.session,
|
|
8171
|
+
...variables,
|
|
8172
|
+
},
|
|
8173
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
8174
|
+
isCompositeQuery: false,
|
|
8175
|
+
});
|
|
8176
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
8177
|
+
return data;
|
|
8178
|
+
}
|
|
8179
|
+
/**
|
|
8180
|
+
* Get the internal session details for the answer.
|
|
8181
|
+
* @returns
|
|
8182
|
+
*/
|
|
8183
|
+
getSession() {
|
|
8184
|
+
return this.session;
|
|
8185
|
+
}
|
|
8186
|
+
async getAnswer() {
|
|
8187
|
+
if (this.answer) {
|
|
8188
|
+
return this.answer;
|
|
8189
|
+
}
|
|
8190
|
+
this.answer = this.executeQuery(getAnswer, {}).then((data) => data === null || data === void 0 ? void 0 : data.answer);
|
|
8191
|
+
return this.answer;
|
|
8192
|
+
}
|
|
8193
|
+
async getTML() {
|
|
8194
|
+
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
8195
|
+
const edoc = object[0].edoc;
|
|
8196
|
+
const YAML = await Promise.resolve().then(function () { return index; });
|
|
8197
|
+
const parsedDoc = YAML.parse(edoc);
|
|
8198
|
+
return {
|
|
8199
|
+
answer: {
|
|
8200
|
+
...parsedDoc.answer,
|
|
8201
|
+
...this.tmlOverride,
|
|
8202
|
+
},
|
|
8203
|
+
};
|
|
8204
|
+
}
|
|
8205
|
+
async addDisplayedVizToLiveboard(liveboardId) {
|
|
8206
|
+
const { displayMode, visualizations } = await this.getAnswer();
|
|
8207
|
+
const viz = getDisplayedViz(visualizations, displayMode);
|
|
8208
|
+
return this.executeQuery(addVizToLiveboard, {
|
|
8209
|
+
liveboardId,
|
|
8210
|
+
vizId: viz.id,
|
|
8211
|
+
});
|
|
8212
|
+
}
|
|
8213
|
+
setTMLOverride(override) {
|
|
8214
|
+
this.tmlOverride = override;
|
|
8215
|
+
}
|
|
8216
|
+
}
|
|
8217
|
+
/**
|
|
8218
|
+
*
|
|
8219
|
+
* @param sourceDetail
|
|
8220
|
+
* @param colNames
|
|
8221
|
+
*/
|
|
8222
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
8223
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
8224
|
+
colSet[col.name.toLowerCase()] = col;
|
|
8225
|
+
return colSet;
|
|
8226
|
+
}, {});
|
|
8227
|
+
return new Set(colNames.map((colName) => {
|
|
8228
|
+
const col = cols[colName.toLowerCase()];
|
|
8229
|
+
return col.id;
|
|
8230
|
+
}));
|
|
8231
|
+
}
|
|
8232
|
+
/**
|
|
8233
|
+
*
|
|
8234
|
+
* @param selectedPoints
|
|
8235
|
+
*/
|
|
8236
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
8237
|
+
const underlyingDataPoint = [];
|
|
8238
|
+
/**
|
|
8239
|
+
*
|
|
8240
|
+
* @param colVal
|
|
8241
|
+
*/
|
|
8242
|
+
function addPointFromColVal(colVal) {
|
|
8243
|
+
var _a;
|
|
8244
|
+
const dataType = colVal.column.dataType;
|
|
8245
|
+
colVal.column.id;
|
|
8246
|
+
let dataValue;
|
|
8247
|
+
if (dataType === 'DATE') {
|
|
8248
|
+
if (Number.isFinite(colVal.value)) {
|
|
8249
|
+
dataValue = [{
|
|
8250
|
+
epochRange: {
|
|
8251
|
+
startEpoch: colVal.value,
|
|
8252
|
+
},
|
|
8253
|
+
}];
|
|
8254
|
+
// Case for custom calendar.
|
|
8255
|
+
}
|
|
8256
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
8257
|
+
dataValue = [{
|
|
8258
|
+
epochRange: {
|
|
8259
|
+
startEpoch: colVal.value.v.s,
|
|
8260
|
+
endEpoch: colVal.value.v.e,
|
|
8261
|
+
},
|
|
8262
|
+
}];
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
else {
|
|
8266
|
+
dataValue = [{ value: colVal.value }];
|
|
8267
|
+
}
|
|
8268
|
+
underlyingDataPoint.push({
|
|
8269
|
+
columnId: colVal.column.id,
|
|
8270
|
+
dataValue,
|
|
8271
|
+
});
|
|
8272
|
+
}
|
|
8273
|
+
selectedPoints.forEach((p) => {
|
|
8274
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
8275
|
+
});
|
|
8276
|
+
return underlyingDataPoint;
|
|
8277
|
+
}
|
|
8278
|
+
/**
|
|
8279
|
+
*
|
|
8280
|
+
* @param visualizations
|
|
8281
|
+
* @param displayMode
|
|
8282
|
+
*/
|
|
8283
|
+
function getDisplayedViz(visualizations, displayMode) {
|
|
8284
|
+
if (displayMode === 'CHART_MODE') {
|
|
8285
|
+
return visualizations.find(
|
|
8286
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
8287
|
+
(viz) => viz.__typename === 'ChartViz');
|
|
8288
|
+
}
|
|
8289
|
+
return visualizations.find(
|
|
8290
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
8291
|
+
(viz) => viz.__typename === 'TableViz');
|
|
8292
|
+
}
|
|
8293
|
+
|
|
8294
|
+
/** Built-in value references. */
|
|
8295
|
+
var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
|
|
8296
|
+
|
|
8297
|
+
/**
|
|
8298
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
8299
|
+
*
|
|
8300
|
+
* @private
|
|
8301
|
+
* @param {*} value The value to check.
|
|
8302
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
8303
|
+
*/
|
|
8304
|
+
function isFlattenable(value) {
|
|
8305
|
+
return isArray_1(value) || isArguments_1(value) ||
|
|
8306
|
+
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
8307
|
+
}
|
|
8308
|
+
|
|
8309
|
+
var _isFlattenable = isFlattenable;
|
|
8310
|
+
|
|
8311
|
+
/**
|
|
8312
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
8313
|
+
*
|
|
8314
|
+
* @private
|
|
8315
|
+
* @param {Array} array The array to flatten.
|
|
8316
|
+
* @param {number} depth The maximum recursion depth.
|
|
8317
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
8318
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
8319
|
+
* @param {Array} [result=[]] The initial result value.
|
|
8320
|
+
* @returns {Array} Returns the new flattened array.
|
|
8321
|
+
*/
|
|
8322
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
8323
|
+
var index = -1,
|
|
8324
|
+
length = array.length;
|
|
8325
|
+
|
|
8326
|
+
predicate || (predicate = _isFlattenable);
|
|
8327
|
+
result || (result = []);
|
|
8328
|
+
|
|
8329
|
+
while (++index < length) {
|
|
8330
|
+
var value = array[index];
|
|
8331
|
+
if (depth > 0 && predicate(value)) {
|
|
8332
|
+
if (depth > 1) {
|
|
8333
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
8334
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
8335
|
+
} else {
|
|
8336
|
+
_arrayPush(result, value);
|
|
8337
|
+
}
|
|
8338
|
+
} else if (!isStrict) {
|
|
8339
|
+
result[result.length] = value;
|
|
8340
|
+
}
|
|
8341
|
+
}
|
|
8342
|
+
return result;
|
|
8343
|
+
}
|
|
8344
|
+
|
|
8345
|
+
var _baseFlatten = baseFlatten;
|
|
8346
|
+
|
|
8347
|
+
/**
|
|
8348
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
8349
|
+
* shorthands.
|
|
8350
|
+
*
|
|
8351
|
+
* @private
|
|
8352
|
+
* @param {Array} [array] The array to iterate over.
|
|
8353
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
8354
|
+
* @returns {Array} Returns the new mapped array.
|
|
8355
|
+
*/
|
|
8356
|
+
function arrayMap(array, iteratee) {
|
|
8357
|
+
var index = -1,
|
|
8358
|
+
length = array == null ? 0 : array.length,
|
|
8359
|
+
result = Array(length);
|
|
8360
|
+
|
|
8361
|
+
while (++index < length) {
|
|
8362
|
+
result[index] = iteratee(array[index], index, array);
|
|
8363
|
+
}
|
|
8364
|
+
return result;
|
|
8365
|
+
}
|
|
8366
|
+
|
|
8367
|
+
var _arrayMap = arrayMap;
|
|
8368
|
+
|
|
8369
|
+
/** `Object#toString` result references. */
|
|
8370
|
+
var symbolTag = '[object Symbol]';
|
|
8371
|
+
|
|
8372
|
+
/**
|
|
8373
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
8374
|
+
*
|
|
8375
|
+
* @static
|
|
8376
|
+
* @memberOf _
|
|
8377
|
+
* @since 4.0.0
|
|
8378
|
+
* @category Lang
|
|
8379
|
+
* @param {*} value The value to check.
|
|
8380
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
8381
|
+
* @example
|
|
8382
|
+
*
|
|
8383
|
+
* _.isSymbol(Symbol.iterator);
|
|
8384
|
+
* // => true
|
|
8385
|
+
*
|
|
8386
|
+
* _.isSymbol('abc');
|
|
8387
|
+
* // => false
|
|
8388
|
+
*/
|
|
8389
|
+
function isSymbol(value) {
|
|
8390
|
+
return typeof value == 'symbol' ||
|
|
8391
|
+
(isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
|
|
8392
|
+
}
|
|
8393
|
+
|
|
8394
|
+
var isSymbol_1 = isSymbol;
|
|
8395
|
+
|
|
8396
|
+
/** Used to match property names within property paths. */
|
|
8397
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
8398
|
+
reIsPlainProp = /^\w*$/;
|
|
8399
|
+
|
|
8400
|
+
/**
|
|
8401
|
+
* Checks if `value` is a property name and not a property path.
|
|
8402
|
+
*
|
|
8403
|
+
* @private
|
|
8404
|
+
* @param {*} value The value to check.
|
|
8405
|
+
* @param {Object} [object] The object to query keys on.
|
|
8406
|
+
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
8407
|
+
*/
|
|
8408
|
+
function isKey(value, object) {
|
|
8409
|
+
if (isArray_1(value)) {
|
|
8410
|
+
return false;
|
|
8411
|
+
}
|
|
8412
|
+
var type = typeof value;
|
|
8413
|
+
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
|
8414
|
+
value == null || isSymbol_1(value)) {
|
|
8415
|
+
return true;
|
|
8416
|
+
}
|
|
8417
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
8418
|
+
(object != null && value in Object(object));
|
|
8419
|
+
}
|
|
8420
|
+
|
|
8421
|
+
var _isKey = isKey;
|
|
8422
|
+
|
|
8423
|
+
/** Error message constants. */
|
|
8424
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
8425
|
+
|
|
8426
|
+
/**
|
|
8427
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
8428
|
+
* provided, it determines the cache key for storing the result based on the
|
|
8429
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
8430
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
8431
|
+
* is invoked with the `this` binding of the memoized function.
|
|
8432
|
+
*
|
|
8433
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
8434
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
8435
|
+
* constructor with one whose instances implement the
|
|
8436
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
8437
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
8438
|
+
*
|
|
8439
|
+
* @static
|
|
8440
|
+
* @memberOf _
|
|
8441
|
+
* @since 0.1.0
|
|
8442
|
+
* @category Function
|
|
8443
|
+
* @param {Function} func The function to have its output memoized.
|
|
8444
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
8445
|
+
* @returns {Function} Returns the new memoized function.
|
|
8446
|
+
* @example
|
|
8447
|
+
*
|
|
8448
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
8449
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
8450
|
+
*
|
|
8451
|
+
* var values = _.memoize(_.values);
|
|
8452
|
+
* values(object);
|
|
8453
|
+
* // => [1, 2]
|
|
8454
|
+
*
|
|
8455
|
+
* values(other);
|
|
8456
|
+
* // => [3, 4]
|
|
8457
|
+
*
|
|
8458
|
+
* object.a = 2;
|
|
8459
|
+
* values(object);
|
|
8460
|
+
* // => [1, 2]
|
|
8461
|
+
*
|
|
8462
|
+
* // Modify the result cache.
|
|
8463
|
+
* values.cache.set(object, ['a', 'b']);
|
|
8464
|
+
* values(object);
|
|
8465
|
+
* // => ['a', 'b']
|
|
8466
|
+
*
|
|
8467
|
+
* // Replace `_.memoize.Cache`.
|
|
8468
|
+
* _.memoize.Cache = WeakMap;
|
|
8469
|
+
*/
|
|
8470
|
+
function memoize(func, resolver) {
|
|
8471
|
+
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
8472
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
8473
|
+
}
|
|
8474
|
+
var memoized = function() {
|
|
8475
|
+
var args = arguments,
|
|
8476
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
8477
|
+
cache = memoized.cache;
|
|
8478
|
+
|
|
8479
|
+
if (cache.has(key)) {
|
|
8480
|
+
return cache.get(key);
|
|
8481
|
+
}
|
|
8482
|
+
var result = func.apply(this, args);
|
|
8483
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
8484
|
+
return result;
|
|
8485
|
+
};
|
|
8486
|
+
memoized.cache = new (memoize.Cache || _MapCache);
|
|
8487
|
+
return memoized;
|
|
8488
|
+
}
|
|
8489
|
+
|
|
8490
|
+
// Expose `MapCache`.
|
|
8491
|
+
memoize.Cache = _MapCache;
|
|
8492
|
+
|
|
8493
|
+
var memoize_1 = memoize;
|
|
8494
|
+
|
|
8495
|
+
/** Used as the maximum memoize cache size. */
|
|
8496
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
8497
|
+
|
|
8498
|
+
/**
|
|
8499
|
+
* A specialized version of `_.memoize` which clears the memoized function's
|
|
8500
|
+
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
8501
|
+
*
|
|
8502
|
+
* @private
|
|
8503
|
+
* @param {Function} func The function to have its output memoized.
|
|
8504
|
+
* @returns {Function} Returns the new memoized function.
|
|
8505
|
+
*/
|
|
8506
|
+
function memoizeCapped(func) {
|
|
8507
|
+
var result = memoize_1(func, function(key) {
|
|
8508
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
8509
|
+
cache.clear();
|
|
8510
|
+
}
|
|
8511
|
+
return key;
|
|
8512
|
+
});
|
|
8513
|
+
|
|
8514
|
+
var cache = result.cache;
|
|
8515
|
+
return result;
|
|
8516
|
+
}
|
|
8517
|
+
|
|
8518
|
+
var _memoizeCapped = memoizeCapped;
|
|
8519
|
+
|
|
8520
|
+
/** Used to match property names within property paths. */
|
|
8521
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
8522
|
+
|
|
8523
|
+
/** Used to match backslashes in property paths. */
|
|
8524
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
8525
|
+
|
|
8526
|
+
/**
|
|
8527
|
+
* Converts `string` to a property path array.
|
|
8528
|
+
*
|
|
8529
|
+
* @private
|
|
8530
|
+
* @param {string} string The string to convert.
|
|
8531
|
+
* @returns {Array} Returns the property path array.
|
|
8532
|
+
*/
|
|
8533
|
+
var stringToPath = _memoizeCapped(function(string) {
|
|
8534
|
+
var result = [];
|
|
8535
|
+
if (string.charCodeAt(0) === 46 /* . */) {
|
|
8536
|
+
result.push('');
|
|
8537
|
+
}
|
|
8538
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
8539
|
+
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
|
8540
|
+
});
|
|
8541
|
+
return result;
|
|
8542
|
+
});
|
|
8543
|
+
|
|
8544
|
+
var _stringToPath = stringToPath;
|
|
8545
|
+
|
|
8546
|
+
/** Used as references for various `Number` constants. */
|
|
8547
|
+
var INFINITY$1 = 1 / 0;
|
|
8548
|
+
|
|
8549
|
+
/** Used to convert symbols to primitives and strings. */
|
|
8550
|
+
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
|
8551
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
8552
|
+
|
|
8553
|
+
/**
|
|
8554
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
8555
|
+
* values to empty strings.
|
|
8556
|
+
*
|
|
8557
|
+
* @private
|
|
8558
|
+
* @param {*} value The value to process.
|
|
8559
|
+
* @returns {string} Returns the string.
|
|
8560
|
+
*/
|
|
8561
|
+
function baseToString(value) {
|
|
8562
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
8563
|
+
if (typeof value == 'string') {
|
|
8564
|
+
return value;
|
|
8565
|
+
}
|
|
8566
|
+
if (isArray_1(value)) {
|
|
8567
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
8568
|
+
return _arrayMap(value, baseToString) + '';
|
|
8569
|
+
}
|
|
8570
|
+
if (isSymbol_1(value)) {
|
|
8571
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
8572
|
+
}
|
|
8573
|
+
var result = (value + '');
|
|
8574
|
+
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
8575
|
+
}
|
|
8576
|
+
|
|
8577
|
+
var _baseToString = baseToString;
|
|
8578
|
+
|
|
8579
|
+
/**
|
|
8580
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
8581
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
8582
|
+
*
|
|
8583
|
+
* @static
|
|
8584
|
+
* @memberOf _
|
|
8585
|
+
* @since 4.0.0
|
|
8586
|
+
* @category Lang
|
|
8587
|
+
* @param {*} value The value to convert.
|
|
8588
|
+
* @returns {string} Returns the converted string.
|
|
8589
|
+
* @example
|
|
8590
|
+
*
|
|
8591
|
+
* _.toString(null);
|
|
8592
|
+
* // => ''
|
|
8593
|
+
*
|
|
8594
|
+
* _.toString(-0);
|
|
8595
|
+
* // => '-0'
|
|
8596
|
+
*
|
|
8597
|
+
* _.toString([1, 2, 3]);
|
|
8598
|
+
* // => '1,2,3'
|
|
8599
|
+
*/
|
|
8600
|
+
function toString$1(value) {
|
|
8601
|
+
return value == null ? '' : _baseToString(value);
|
|
8602
|
+
}
|
|
8603
|
+
|
|
8604
|
+
var toString_1 = toString$1;
|
|
8605
|
+
|
|
8606
|
+
/**
|
|
8607
|
+
* Casts `value` to a path array if it's not one.
|
|
8608
|
+
*
|
|
8609
|
+
* @private
|
|
8610
|
+
* @param {*} value The value to inspect.
|
|
8611
|
+
* @param {Object} [object] The object to query keys on.
|
|
8612
|
+
* @returns {Array} Returns the cast property path array.
|
|
8613
|
+
*/
|
|
8614
|
+
function castPath(value, object) {
|
|
8615
|
+
if (isArray_1(value)) {
|
|
8616
|
+
return value;
|
|
8617
|
+
}
|
|
8618
|
+
return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
|
8619
|
+
}
|
|
8620
|
+
|
|
8621
|
+
var _castPath = castPath;
|
|
8622
|
+
|
|
8623
|
+
/** Used as references for various `Number` constants. */
|
|
8624
|
+
var INFINITY = 1 / 0;
|
|
8625
|
+
|
|
8626
|
+
/**
|
|
8627
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
8628
|
+
*
|
|
8629
|
+
* @private
|
|
8630
|
+
* @param {*} value The value to inspect.
|
|
8631
|
+
* @returns {string|symbol} Returns the key.
|
|
8632
|
+
*/
|
|
8633
|
+
function toKey(value) {
|
|
8634
|
+
if (typeof value == 'string' || isSymbol_1(value)) {
|
|
8635
|
+
return value;
|
|
8636
|
+
}
|
|
8637
|
+
var result = (value + '');
|
|
8638
|
+
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
8639
|
+
}
|
|
8640
|
+
|
|
8641
|
+
var _toKey = toKey;
|
|
8642
|
+
|
|
8643
|
+
/**
|
|
8644
|
+
* The base implementation of `_.get` without support for default values.
|
|
8645
|
+
*
|
|
8646
|
+
* @private
|
|
8647
|
+
* @param {Object} object The object to query.
|
|
8648
|
+
* @param {Array|string} path The path of the property to get.
|
|
8649
|
+
* @returns {*} Returns the resolved value.
|
|
8650
|
+
*/
|
|
8651
|
+
function baseGet(object, path) {
|
|
8652
|
+
path = _castPath(path, object);
|
|
8653
|
+
|
|
8654
|
+
var index = 0,
|
|
8655
|
+
length = path.length;
|
|
8656
|
+
|
|
8657
|
+
while (object != null && index < length) {
|
|
8658
|
+
object = object[_toKey(path[index++])];
|
|
8659
|
+
}
|
|
8660
|
+
return (index && index == length) ? object : undefined;
|
|
8661
|
+
}
|
|
8662
|
+
|
|
8663
|
+
var _baseGet = baseGet;
|
|
8664
|
+
|
|
8665
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
8666
|
+
var COMPARE_PARTIAL_FLAG$1 = 1,
|
|
8667
|
+
COMPARE_UNORDERED_FLAG$1 = 2;
|
|
8668
|
+
|
|
8669
|
+
/**
|
|
8670
|
+
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
|
8671
|
+
*
|
|
8672
|
+
* @private
|
|
8673
|
+
* @param {Object} object The object to inspect.
|
|
8674
|
+
* @param {Object} source The object of property values to match.
|
|
8675
|
+
* @param {Array} matchData The property names, values, and compare flags to match.
|
|
8676
|
+
* @param {Function} [customizer] The function to customize comparisons.
|
|
8677
|
+
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
8678
|
+
*/
|
|
8679
|
+
function baseIsMatch(object, source, matchData, customizer) {
|
|
8680
|
+
var index = matchData.length,
|
|
8681
|
+
length = index,
|
|
8682
|
+
noCustomizer = !customizer;
|
|
8683
|
+
|
|
8684
|
+
if (object == null) {
|
|
8685
|
+
return !length;
|
|
8686
|
+
}
|
|
8687
|
+
object = Object(object);
|
|
8688
|
+
while (index--) {
|
|
8689
|
+
var data = matchData[index];
|
|
8690
|
+
if ((noCustomizer && data[2])
|
|
8691
|
+
? data[1] !== object[data[0]]
|
|
8692
|
+
: !(data[0] in object)
|
|
8693
|
+
) {
|
|
8694
|
+
return false;
|
|
8695
|
+
}
|
|
8696
|
+
}
|
|
8697
|
+
while (++index < length) {
|
|
8698
|
+
data = matchData[index];
|
|
8699
|
+
var key = data[0],
|
|
8700
|
+
objValue = object[key],
|
|
8701
|
+
srcValue = data[1];
|
|
8702
|
+
|
|
8703
|
+
if (noCustomizer && data[2]) {
|
|
8704
|
+
if (objValue === undefined && !(key in object)) {
|
|
8705
|
+
return false;
|
|
8706
|
+
}
|
|
8707
|
+
} else {
|
|
8708
|
+
var stack = new _Stack;
|
|
8709
|
+
if (customizer) {
|
|
8710
|
+
var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
8711
|
+
}
|
|
8712
|
+
if (!(result === undefined
|
|
8713
|
+
? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
|
|
8714
|
+
: result
|
|
8715
|
+
)) {
|
|
8716
|
+
return false;
|
|
8717
|
+
}
|
|
8718
|
+
}
|
|
8719
|
+
}
|
|
8720
|
+
return true;
|
|
8721
|
+
}
|
|
8722
|
+
|
|
8723
|
+
var _baseIsMatch = baseIsMatch;
|
|
8724
|
+
|
|
8725
|
+
/**
|
|
8726
|
+
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
|
8727
|
+
*
|
|
8728
|
+
* @private
|
|
8729
|
+
* @param {*} value The value to check.
|
|
8730
|
+
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
|
8731
|
+
* equality comparisons, else `false`.
|
|
8732
|
+
*/
|
|
8733
|
+
function isStrictComparable(value) {
|
|
8734
|
+
return value === value && !isObject_1(value);
|
|
8735
|
+
}
|
|
8736
|
+
|
|
8737
|
+
var _isStrictComparable = isStrictComparable;
|
|
8738
|
+
|
|
8739
|
+
/**
|
|
8740
|
+
* Gets the property names, values, and compare flags of `object`.
|
|
8741
|
+
*
|
|
8742
|
+
* @private
|
|
8743
|
+
* @param {Object} object The object to query.
|
|
8744
|
+
* @returns {Array} Returns the match data of `object`.
|
|
8745
|
+
*/
|
|
8746
|
+
function getMatchData(object) {
|
|
8747
|
+
var result = keys_1(object),
|
|
8748
|
+
length = result.length;
|
|
8749
|
+
|
|
8750
|
+
while (length--) {
|
|
8751
|
+
var key = result[length],
|
|
8752
|
+
value = object[key];
|
|
8753
|
+
|
|
8754
|
+
result[length] = [key, value, _isStrictComparable(value)];
|
|
8755
|
+
}
|
|
8756
|
+
return result;
|
|
8757
|
+
}
|
|
8758
|
+
|
|
8759
|
+
var _getMatchData = getMatchData;
|
|
8760
|
+
|
|
8761
|
+
/**
|
|
8762
|
+
* A specialized version of `matchesProperty` for source values suitable
|
|
8763
|
+
* for strict equality comparisons, i.e. `===`.
|
|
8764
|
+
*
|
|
8765
|
+
* @private
|
|
8766
|
+
* @param {string} key The key of the property to get.
|
|
8767
|
+
* @param {*} srcValue The value to match.
|
|
8768
|
+
* @returns {Function} Returns the new spec function.
|
|
8769
|
+
*/
|
|
8770
|
+
function matchesStrictComparable(key, srcValue) {
|
|
8771
|
+
return function(object) {
|
|
8772
|
+
if (object == null) {
|
|
8773
|
+
return false;
|
|
8774
|
+
}
|
|
8775
|
+
return object[key] === srcValue &&
|
|
8776
|
+
(srcValue !== undefined || (key in Object(object)));
|
|
8777
|
+
};
|
|
8778
|
+
}
|
|
8779
|
+
|
|
8780
|
+
var _matchesStrictComparable = matchesStrictComparable;
|
|
8781
|
+
|
|
8782
|
+
/**
|
|
8783
|
+
* The base implementation of `_.matches` which doesn't clone `source`.
|
|
8784
|
+
*
|
|
8785
|
+
* @private
|
|
8786
|
+
* @param {Object} source The object of property values to match.
|
|
8787
|
+
* @returns {Function} Returns the new spec function.
|
|
8788
|
+
*/
|
|
8789
|
+
function baseMatches(source) {
|
|
8790
|
+
var matchData = _getMatchData(source);
|
|
8791
|
+
if (matchData.length == 1 && matchData[0][2]) {
|
|
8792
|
+
return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
8793
|
+
}
|
|
8794
|
+
return function(object) {
|
|
8795
|
+
return object === source || _baseIsMatch(object, source, matchData);
|
|
8796
|
+
};
|
|
8797
|
+
}
|
|
8798
|
+
|
|
8799
|
+
var _baseMatches = baseMatches;
|
|
8800
|
+
|
|
8801
|
+
/**
|
|
8802
|
+
* Gets the value at `path` of `object`. If the resolved value is
|
|
8803
|
+
* `undefined`, the `defaultValue` is returned in its place.
|
|
8804
|
+
*
|
|
8805
|
+
* @static
|
|
8806
|
+
* @memberOf _
|
|
8807
|
+
* @since 3.7.0
|
|
8808
|
+
* @category Object
|
|
8809
|
+
* @param {Object} object The object to query.
|
|
8810
|
+
* @param {Array|string} path The path of the property to get.
|
|
8811
|
+
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
8812
|
+
* @returns {*} Returns the resolved value.
|
|
8813
|
+
* @example
|
|
8814
|
+
*
|
|
8815
|
+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
8816
|
+
*
|
|
8817
|
+
* _.get(object, 'a[0].b.c');
|
|
8818
|
+
* // => 3
|
|
8819
|
+
*
|
|
8820
|
+
* _.get(object, ['a', '0', 'b', 'c']);
|
|
8821
|
+
* // => 3
|
|
8822
|
+
*
|
|
8823
|
+
* _.get(object, 'a.b.c', 'default');
|
|
8824
|
+
* // => 'default'
|
|
8825
|
+
*/
|
|
8826
|
+
function get(object, path, defaultValue) {
|
|
8827
|
+
var result = object == null ? undefined : _baseGet(object, path);
|
|
8828
|
+
return result === undefined ? defaultValue : result;
|
|
8829
|
+
}
|
|
8830
|
+
|
|
8831
|
+
var get_1 = get;
|
|
8832
|
+
|
|
8833
|
+
/**
|
|
8834
|
+
* The base implementation of `_.hasIn` without support for deep paths.
|
|
8835
|
+
*
|
|
8836
|
+
* @private
|
|
8837
|
+
* @param {Object} [object] The object to query.
|
|
8838
|
+
* @param {Array|string} key The key to check.
|
|
8839
|
+
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
|
8840
|
+
*/
|
|
8841
|
+
function baseHasIn(object, key) {
|
|
8842
|
+
return object != null && key in Object(object);
|
|
8843
|
+
}
|
|
8844
|
+
|
|
8845
|
+
var _baseHasIn = baseHasIn;
|
|
8846
|
+
|
|
8847
|
+
/**
|
|
8848
|
+
* Checks if `path` exists on `object`.
|
|
8849
|
+
*
|
|
8850
|
+
* @private
|
|
8851
|
+
* @param {Object} object The object to query.
|
|
8852
|
+
* @param {Array|string} path The path to check.
|
|
8853
|
+
* @param {Function} hasFunc The function to check properties.
|
|
8854
|
+
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
8855
|
+
*/
|
|
8856
|
+
function hasPath(object, path, hasFunc) {
|
|
8857
|
+
path = _castPath(path, object);
|
|
8858
|
+
|
|
8859
|
+
var index = -1,
|
|
8860
|
+
length = path.length,
|
|
8861
|
+
result = false;
|
|
8862
|
+
|
|
8863
|
+
while (++index < length) {
|
|
8864
|
+
var key = _toKey(path[index]);
|
|
8865
|
+
if (!(result = object != null && hasFunc(object, key))) {
|
|
8866
|
+
break;
|
|
8867
|
+
}
|
|
8868
|
+
object = object[key];
|
|
8869
|
+
}
|
|
8870
|
+
if (result || ++index != length) {
|
|
8871
|
+
return result;
|
|
8872
|
+
}
|
|
8873
|
+
length = object == null ? 0 : object.length;
|
|
8874
|
+
return !!length && isLength_1(length) && _isIndex(key, length) &&
|
|
8875
|
+
(isArray_1(object) || isArguments_1(object));
|
|
8876
|
+
}
|
|
8877
|
+
|
|
8878
|
+
var _hasPath = hasPath;
|
|
8879
|
+
|
|
8880
|
+
/**
|
|
8881
|
+
* Checks if `path` is a direct or inherited property of `object`.
|
|
8882
|
+
*
|
|
8883
|
+
* @static
|
|
8884
|
+
* @memberOf _
|
|
8885
|
+
* @since 4.0.0
|
|
8886
|
+
* @category Object
|
|
8887
|
+
* @param {Object} object The object to query.
|
|
8888
|
+
* @param {Array|string} path The path to check.
|
|
8889
|
+
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
8890
|
+
* @example
|
|
8891
|
+
*
|
|
8892
|
+
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
|
8893
|
+
*
|
|
8894
|
+
* _.hasIn(object, 'a');
|
|
8895
|
+
* // => true
|
|
8896
|
+
*
|
|
8897
|
+
* _.hasIn(object, 'a.b');
|
|
8898
|
+
* // => true
|
|
8899
|
+
*
|
|
8900
|
+
* _.hasIn(object, ['a', 'b']);
|
|
8901
|
+
* // => true
|
|
8902
|
+
*
|
|
8903
|
+
* _.hasIn(object, 'b');
|
|
8904
|
+
* // => false
|
|
8905
|
+
*/
|
|
8906
|
+
function hasIn(object, path) {
|
|
8907
|
+
return object != null && _hasPath(object, path, _baseHasIn);
|
|
8908
|
+
}
|
|
8909
|
+
|
|
8910
|
+
var hasIn_1 = hasIn;
|
|
8911
|
+
|
|
8912
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
8913
|
+
var COMPARE_PARTIAL_FLAG = 1,
|
|
8914
|
+
COMPARE_UNORDERED_FLAG = 2;
|
|
8915
|
+
|
|
8916
|
+
/**
|
|
8917
|
+
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
|
8918
|
+
*
|
|
8919
|
+
* @private
|
|
8920
|
+
* @param {string} path The path of the property to get.
|
|
8921
|
+
* @param {*} srcValue The value to match.
|
|
8922
|
+
* @returns {Function} Returns the new spec function.
|
|
8923
|
+
*/
|
|
8924
|
+
function baseMatchesProperty(path, srcValue) {
|
|
8925
|
+
if (_isKey(path) && _isStrictComparable(srcValue)) {
|
|
8926
|
+
return _matchesStrictComparable(_toKey(path), srcValue);
|
|
8927
|
+
}
|
|
8928
|
+
return function(object) {
|
|
8929
|
+
var objValue = get_1(object, path);
|
|
8930
|
+
return (objValue === undefined && objValue === srcValue)
|
|
8931
|
+
? hasIn_1(object, path)
|
|
8932
|
+
: _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
8933
|
+
};
|
|
8934
|
+
}
|
|
8935
|
+
|
|
8936
|
+
var _baseMatchesProperty = baseMatchesProperty;
|
|
8937
|
+
|
|
8938
|
+
/**
|
|
8939
|
+
* This method returns the first argument it receives.
|
|
8940
|
+
*
|
|
8941
|
+
* @static
|
|
8942
|
+
* @since 0.1.0
|
|
8943
|
+
* @memberOf _
|
|
8944
|
+
* @category Util
|
|
8945
|
+
* @param {*} value Any value.
|
|
8946
|
+
* @returns {*} Returns `value`.
|
|
8947
|
+
* @example
|
|
8948
|
+
*
|
|
8949
|
+
* var object = { 'a': 1 };
|
|
8950
|
+
*
|
|
8951
|
+
* console.log(_.identity(object) === object);
|
|
8952
|
+
* // => true
|
|
8953
|
+
*/
|
|
8954
|
+
function identity(value) {
|
|
8955
|
+
return value;
|
|
8956
|
+
}
|
|
8957
|
+
|
|
8958
|
+
var identity_1 = identity;
|
|
8959
|
+
|
|
8960
|
+
/**
|
|
8961
|
+
* The base implementation of `_.property` without support for deep paths.
|
|
8962
|
+
*
|
|
8963
|
+
* @private
|
|
8964
|
+
* @param {string} key The key of the property to get.
|
|
8965
|
+
* @returns {Function} Returns the new accessor function.
|
|
8966
|
+
*/
|
|
8967
|
+
function baseProperty(key) {
|
|
8968
|
+
return function(object) {
|
|
8969
|
+
return object == null ? undefined : object[key];
|
|
8970
|
+
};
|
|
8971
|
+
}
|
|
8972
|
+
|
|
8973
|
+
var _baseProperty = baseProperty;
|
|
8974
|
+
|
|
8975
|
+
/**
|
|
8976
|
+
* A specialized version of `baseProperty` which supports deep paths.
|
|
8977
|
+
*
|
|
8978
|
+
* @private
|
|
8979
|
+
* @param {Array|string} path The path of the property to get.
|
|
8980
|
+
* @returns {Function} Returns the new accessor function.
|
|
8981
|
+
*/
|
|
8982
|
+
function basePropertyDeep(path) {
|
|
8983
|
+
return function(object) {
|
|
8984
|
+
return _baseGet(object, path);
|
|
8985
|
+
};
|
|
8986
|
+
}
|
|
8987
|
+
|
|
8988
|
+
var _basePropertyDeep = basePropertyDeep;
|
|
8989
|
+
|
|
8990
|
+
/**
|
|
8991
|
+
* Creates a function that returns the value at `path` of a given object.
|
|
8992
|
+
*
|
|
8993
|
+
* @static
|
|
8994
|
+
* @memberOf _
|
|
8995
|
+
* @since 2.4.0
|
|
8996
|
+
* @category Util
|
|
8997
|
+
* @param {Array|string} path The path of the property to get.
|
|
8998
|
+
* @returns {Function} Returns the new accessor function.
|
|
8999
|
+
* @example
|
|
9000
|
+
*
|
|
9001
|
+
* var objects = [
|
|
9002
|
+
* { 'a': { 'b': 2 } },
|
|
9003
|
+
* { 'a': { 'b': 1 } }
|
|
9004
|
+
* ];
|
|
9005
|
+
*
|
|
9006
|
+
* _.map(objects, _.property('a.b'));
|
|
9007
|
+
* // => [2, 1]
|
|
9008
|
+
*
|
|
9009
|
+
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
|
9010
|
+
* // => [1, 2]
|
|
9011
|
+
*/
|
|
9012
|
+
function property(path) {
|
|
9013
|
+
return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
|
|
9014
|
+
}
|
|
9015
|
+
|
|
9016
|
+
var property_1 = property;
|
|
9017
|
+
|
|
9018
|
+
/**
|
|
9019
|
+
* The base implementation of `_.iteratee`.
|
|
9020
|
+
*
|
|
9021
|
+
* @private
|
|
9022
|
+
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|
9023
|
+
* @returns {Function} Returns the iteratee.
|
|
9024
|
+
*/
|
|
9025
|
+
function baseIteratee(value) {
|
|
9026
|
+
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
|
9027
|
+
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
|
9028
|
+
if (typeof value == 'function') {
|
|
9029
|
+
return value;
|
|
9030
|
+
}
|
|
9031
|
+
if (value == null) {
|
|
9032
|
+
return identity_1;
|
|
9033
|
+
}
|
|
9034
|
+
if (typeof value == 'object') {
|
|
9035
|
+
return isArray_1(value)
|
|
9036
|
+
? _baseMatchesProperty(value[0], value[1])
|
|
9037
|
+
: _baseMatches(value);
|
|
9038
|
+
}
|
|
9039
|
+
return property_1(value);
|
|
9040
|
+
}
|
|
9041
|
+
|
|
9042
|
+
var _baseIteratee = baseIteratee;
|
|
9043
|
+
|
|
9044
|
+
/**
|
|
9045
|
+
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
9046
|
+
*
|
|
9047
|
+
* @private
|
|
9048
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
9049
|
+
* @returns {Function} Returns the new base function.
|
|
9050
|
+
*/
|
|
9051
|
+
function createBaseFor(fromRight) {
|
|
9052
|
+
return function(object, iteratee, keysFunc) {
|
|
9053
|
+
var index = -1,
|
|
9054
|
+
iterable = Object(object),
|
|
9055
|
+
props = keysFunc(object),
|
|
9056
|
+
length = props.length;
|
|
9057
|
+
|
|
9058
|
+
while (length--) {
|
|
9059
|
+
var key = props[fromRight ? length : ++index];
|
|
9060
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
9061
|
+
break;
|
|
9062
|
+
}
|
|
9063
|
+
}
|
|
9064
|
+
return object;
|
|
9065
|
+
};
|
|
9066
|
+
}
|
|
9067
|
+
|
|
9068
|
+
var _createBaseFor = createBaseFor;
|
|
9069
|
+
|
|
9070
|
+
/**
|
|
9071
|
+
* The base implementation of `baseForOwn` which iterates over `object`
|
|
9072
|
+
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|
9073
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
9074
|
+
*
|
|
9075
|
+
* @private
|
|
9076
|
+
* @param {Object} object The object to iterate over.
|
|
9077
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9078
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
9079
|
+
* @returns {Object} Returns `object`.
|
|
9080
|
+
*/
|
|
9081
|
+
var baseFor = _createBaseFor();
|
|
9082
|
+
|
|
9083
|
+
var _baseFor = baseFor;
|
|
9084
|
+
|
|
9085
|
+
/**
|
|
9086
|
+
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
|
9087
|
+
*
|
|
9088
|
+
* @private
|
|
9089
|
+
* @param {Object} object The object to iterate over.
|
|
9090
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9091
|
+
* @returns {Object} Returns `object`.
|
|
9092
|
+
*/
|
|
9093
|
+
function baseForOwn(object, iteratee) {
|
|
9094
|
+
return object && _baseFor(object, iteratee, keys_1);
|
|
9095
|
+
}
|
|
9096
|
+
|
|
9097
|
+
var _baseForOwn = baseForOwn;
|
|
9098
|
+
|
|
9099
|
+
/**
|
|
9100
|
+
* Creates a `baseEach` or `baseEachRight` function.
|
|
9101
|
+
*
|
|
9102
|
+
* @private
|
|
9103
|
+
* @param {Function} eachFunc The function to iterate over a collection.
|
|
9104
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
9105
|
+
* @returns {Function} Returns the new base function.
|
|
9106
|
+
*/
|
|
9107
|
+
function createBaseEach(eachFunc, fromRight) {
|
|
9108
|
+
return function(collection, iteratee) {
|
|
9109
|
+
if (collection == null) {
|
|
9110
|
+
return collection;
|
|
9111
|
+
}
|
|
9112
|
+
if (!isArrayLike_1(collection)) {
|
|
9113
|
+
return eachFunc(collection, iteratee);
|
|
9114
|
+
}
|
|
9115
|
+
var length = collection.length,
|
|
9116
|
+
index = fromRight ? length : -1,
|
|
9117
|
+
iterable = Object(collection);
|
|
9118
|
+
|
|
9119
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
9120
|
+
if (iteratee(iterable[index], index, iterable) === false) {
|
|
9121
|
+
break;
|
|
9122
|
+
}
|
|
9123
|
+
}
|
|
9124
|
+
return collection;
|
|
9125
|
+
};
|
|
9126
|
+
}
|
|
9127
|
+
|
|
9128
|
+
var _createBaseEach = createBaseEach;
|
|
9129
|
+
|
|
9130
|
+
/**
|
|
9131
|
+
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
|
9132
|
+
*
|
|
9133
|
+
* @private
|
|
9134
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9135
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9136
|
+
* @returns {Array|Object} Returns `collection`.
|
|
9137
|
+
*/
|
|
9138
|
+
var baseEach = _createBaseEach(_baseForOwn);
|
|
9139
|
+
|
|
9140
|
+
var _baseEach = baseEach;
|
|
9141
|
+
|
|
9142
|
+
/**
|
|
9143
|
+
* The base implementation of `_.map` without support for iteratee shorthands.
|
|
9144
|
+
*
|
|
9145
|
+
* @private
|
|
9146
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9147
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
9148
|
+
* @returns {Array} Returns the new mapped array.
|
|
9149
|
+
*/
|
|
9150
|
+
function baseMap(collection, iteratee) {
|
|
9151
|
+
var index = -1,
|
|
9152
|
+
result = isArrayLike_1(collection) ? Array(collection.length) : [];
|
|
9153
|
+
|
|
9154
|
+
_baseEach(collection, function(value, key, collection) {
|
|
9155
|
+
result[++index] = iteratee(value, key, collection);
|
|
9156
|
+
});
|
|
9157
|
+
return result;
|
|
9158
|
+
}
|
|
9159
|
+
|
|
9160
|
+
var _baseMap = baseMap;
|
|
9161
|
+
|
|
9162
|
+
/**
|
|
9163
|
+
* The base implementation of `_.sortBy` which uses `comparer` to define the
|
|
9164
|
+
* sort order of `array` and replaces criteria objects with their corresponding
|
|
9165
|
+
* values.
|
|
9166
|
+
*
|
|
9167
|
+
* @private
|
|
9168
|
+
* @param {Array} array The array to sort.
|
|
9169
|
+
* @param {Function} comparer The function to define sort order.
|
|
9170
|
+
* @returns {Array} Returns `array`.
|
|
9171
|
+
*/
|
|
9172
|
+
function baseSortBy(array, comparer) {
|
|
9173
|
+
var length = array.length;
|
|
9174
|
+
|
|
9175
|
+
array.sort(comparer);
|
|
9176
|
+
while (length--) {
|
|
9177
|
+
array[length] = array[length].value;
|
|
9178
|
+
}
|
|
9179
|
+
return array;
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
var _baseSortBy = baseSortBy;
|
|
9183
|
+
|
|
9184
|
+
/**
|
|
9185
|
+
* Compares values to sort them in ascending order.
|
|
9186
|
+
*
|
|
9187
|
+
* @private
|
|
9188
|
+
* @param {*} value The value to compare.
|
|
9189
|
+
* @param {*} other The other value to compare.
|
|
9190
|
+
* @returns {number} Returns the sort order indicator for `value`.
|
|
9191
|
+
*/
|
|
9192
|
+
function compareAscending(value, other) {
|
|
9193
|
+
if (value !== other) {
|
|
9194
|
+
var valIsDefined = value !== undefined,
|
|
9195
|
+
valIsNull = value === null,
|
|
9196
|
+
valIsReflexive = value === value,
|
|
9197
|
+
valIsSymbol = isSymbol_1(value);
|
|
9198
|
+
|
|
9199
|
+
var othIsDefined = other !== undefined,
|
|
9200
|
+
othIsNull = other === null,
|
|
9201
|
+
othIsReflexive = other === other,
|
|
9202
|
+
othIsSymbol = isSymbol_1(other);
|
|
9203
|
+
|
|
9204
|
+
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
|
9205
|
+
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
|
9206
|
+
(valIsNull && othIsDefined && othIsReflexive) ||
|
|
9207
|
+
(!valIsDefined && othIsReflexive) ||
|
|
9208
|
+
!valIsReflexive) {
|
|
9209
|
+
return 1;
|
|
9210
|
+
}
|
|
9211
|
+
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
|
9212
|
+
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
|
9213
|
+
(othIsNull && valIsDefined && valIsReflexive) ||
|
|
9214
|
+
(!othIsDefined && valIsReflexive) ||
|
|
9215
|
+
!othIsReflexive) {
|
|
9216
|
+
return -1;
|
|
9217
|
+
}
|
|
9218
|
+
}
|
|
9219
|
+
return 0;
|
|
9220
|
+
}
|
|
9221
|
+
|
|
9222
|
+
var _compareAscending = compareAscending;
|
|
9223
|
+
|
|
9224
|
+
/**
|
|
9225
|
+
* Used by `_.orderBy` to compare multiple properties of a value to another
|
|
9226
|
+
* and stable sort them.
|
|
9227
|
+
*
|
|
9228
|
+
* If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
|
|
9229
|
+
* specify an order of "desc" for descending or "asc" for ascending sort order
|
|
9230
|
+
* of corresponding values.
|
|
9231
|
+
*
|
|
9232
|
+
* @private
|
|
9233
|
+
* @param {Object} object The object to compare.
|
|
9234
|
+
* @param {Object} other The other object to compare.
|
|
9235
|
+
* @param {boolean[]|string[]} orders The order to sort by for each property.
|
|
9236
|
+
* @returns {number} Returns the sort order indicator for `object`.
|
|
9237
|
+
*/
|
|
9238
|
+
function compareMultiple(object, other, orders) {
|
|
9239
|
+
var index = -1,
|
|
9240
|
+
objCriteria = object.criteria,
|
|
9241
|
+
othCriteria = other.criteria,
|
|
9242
|
+
length = objCriteria.length,
|
|
9243
|
+
ordersLength = orders.length;
|
|
9244
|
+
|
|
9245
|
+
while (++index < length) {
|
|
9246
|
+
var result = _compareAscending(objCriteria[index], othCriteria[index]);
|
|
9247
|
+
if (result) {
|
|
9248
|
+
if (index >= ordersLength) {
|
|
9249
|
+
return result;
|
|
9250
|
+
}
|
|
9251
|
+
var order = orders[index];
|
|
9252
|
+
return result * (order == 'desc' ? -1 : 1);
|
|
9253
|
+
}
|
|
9254
|
+
}
|
|
9255
|
+
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
|
9256
|
+
// that causes it, under certain circumstances, to provide the same value for
|
|
9257
|
+
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
|
|
9258
|
+
// for more details.
|
|
9259
|
+
//
|
|
9260
|
+
// This also ensures a stable sort in V8 and other engines.
|
|
9261
|
+
// See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
|
|
9262
|
+
return object.index - other.index;
|
|
9263
|
+
}
|
|
9264
|
+
|
|
9265
|
+
var _compareMultiple = compareMultiple;
|
|
9266
|
+
|
|
9267
|
+
/**
|
|
9268
|
+
* The base implementation of `_.orderBy` without param guards.
|
|
9269
|
+
*
|
|
9270
|
+
* @private
|
|
9271
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9272
|
+
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
|
|
9273
|
+
* @param {string[]} orders The sort orders of `iteratees`.
|
|
9274
|
+
* @returns {Array} Returns the new sorted array.
|
|
9275
|
+
*/
|
|
9276
|
+
function baseOrderBy(collection, iteratees, orders) {
|
|
9277
|
+
if (iteratees.length) {
|
|
9278
|
+
iteratees = _arrayMap(iteratees, function(iteratee) {
|
|
9279
|
+
if (isArray_1(iteratee)) {
|
|
9280
|
+
return function(value) {
|
|
9281
|
+
return _baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
return iteratee;
|
|
9285
|
+
});
|
|
9286
|
+
} else {
|
|
9287
|
+
iteratees = [identity_1];
|
|
9288
|
+
}
|
|
9289
|
+
|
|
9290
|
+
var index = -1;
|
|
9291
|
+
iteratees = _arrayMap(iteratees, _baseUnary(_baseIteratee));
|
|
9292
|
+
|
|
9293
|
+
var result = _baseMap(collection, function(value, key, collection) {
|
|
9294
|
+
var criteria = _arrayMap(iteratees, function(iteratee) {
|
|
9295
|
+
return iteratee(value);
|
|
9296
|
+
});
|
|
9297
|
+
return { 'criteria': criteria, 'index': ++index, 'value': value };
|
|
9298
|
+
});
|
|
9299
|
+
|
|
9300
|
+
return _baseSortBy(result, function(object, other) {
|
|
9301
|
+
return _compareMultiple(object, other, orders);
|
|
9302
|
+
});
|
|
9303
|
+
}
|
|
9304
|
+
|
|
9305
|
+
var _baseOrderBy = baseOrderBy;
|
|
9306
|
+
|
|
9307
|
+
/**
|
|
9308
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
9309
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
9310
|
+
*
|
|
9311
|
+
* @private
|
|
9312
|
+
* @param {Function} func The function to invoke.
|
|
9313
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
9314
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
9315
|
+
* @returns {*} Returns the result of `func`.
|
|
9316
|
+
*/
|
|
9317
|
+
function apply(func, thisArg, args) {
|
|
9318
|
+
switch (args.length) {
|
|
9319
|
+
case 0: return func.call(thisArg);
|
|
9320
|
+
case 1: return func.call(thisArg, args[0]);
|
|
9321
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
9322
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
9323
|
+
}
|
|
9324
|
+
return func.apply(thisArg, args);
|
|
9325
|
+
}
|
|
9326
|
+
|
|
9327
|
+
var _apply = apply;
|
|
9328
|
+
|
|
9329
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
9330
|
+
var nativeMax = Math.max;
|
|
9331
|
+
|
|
9332
|
+
/**
|
|
9333
|
+
* A specialized version of `baseRest` which transforms the rest array.
|
|
9334
|
+
*
|
|
9335
|
+
* @private
|
|
9336
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
9337
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
9338
|
+
* @param {Function} transform The rest array transform.
|
|
9339
|
+
* @returns {Function} Returns the new function.
|
|
9340
|
+
*/
|
|
9341
|
+
function overRest(func, start, transform) {
|
|
9342
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
9343
|
+
return function() {
|
|
9344
|
+
var args = arguments,
|
|
9345
|
+
index = -1,
|
|
9346
|
+
length = nativeMax(args.length - start, 0),
|
|
9347
|
+
array = Array(length);
|
|
9348
|
+
|
|
9349
|
+
while (++index < length) {
|
|
9350
|
+
array[index] = args[start + index];
|
|
9351
|
+
}
|
|
9352
|
+
index = -1;
|
|
9353
|
+
var otherArgs = Array(start + 1);
|
|
9354
|
+
while (++index < start) {
|
|
9355
|
+
otherArgs[index] = args[index];
|
|
9356
|
+
}
|
|
9357
|
+
otherArgs[start] = transform(array);
|
|
9358
|
+
return _apply(func, this, otherArgs);
|
|
9359
|
+
};
|
|
9360
|
+
}
|
|
9361
|
+
|
|
9362
|
+
var _overRest = overRest;
|
|
9363
|
+
|
|
9364
|
+
/**
|
|
9365
|
+
* Creates a function that returns `value`.
|
|
9366
|
+
*
|
|
9367
|
+
* @static
|
|
9368
|
+
* @memberOf _
|
|
9369
|
+
* @since 2.4.0
|
|
9370
|
+
* @category Util
|
|
9371
|
+
* @param {*} value The value to return from the new function.
|
|
9372
|
+
* @returns {Function} Returns the new constant function.
|
|
9373
|
+
* @example
|
|
9374
|
+
*
|
|
9375
|
+
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
9376
|
+
*
|
|
9377
|
+
* console.log(objects);
|
|
9378
|
+
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
9379
|
+
*
|
|
9380
|
+
* console.log(objects[0] === objects[1]);
|
|
9381
|
+
* // => true
|
|
9382
|
+
*/
|
|
9383
|
+
function constant(value) {
|
|
9384
|
+
return function() {
|
|
9385
|
+
return value;
|
|
9386
|
+
};
|
|
9387
|
+
}
|
|
9388
|
+
|
|
9389
|
+
var constant_1 = constant;
|
|
9390
|
+
|
|
9391
|
+
var defineProperty = (function() {
|
|
9392
|
+
try {
|
|
9393
|
+
var func = _getNative(Object, 'defineProperty');
|
|
9394
|
+
func({}, '', {});
|
|
9395
|
+
return func;
|
|
9396
|
+
} catch (e) {}
|
|
9397
|
+
}());
|
|
9398
|
+
|
|
9399
|
+
var _defineProperty = defineProperty;
|
|
9400
|
+
|
|
9401
|
+
/**
|
|
9402
|
+
* The base implementation of `setToString` without support for hot loop shorting.
|
|
9403
|
+
*
|
|
9404
|
+
* @private
|
|
9405
|
+
* @param {Function} func The function to modify.
|
|
9406
|
+
* @param {Function} string The `toString` result.
|
|
9407
|
+
* @returns {Function} Returns `func`.
|
|
9408
|
+
*/
|
|
9409
|
+
var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
|
|
9410
|
+
return _defineProperty(func, 'toString', {
|
|
9411
|
+
'configurable': true,
|
|
9412
|
+
'enumerable': false,
|
|
9413
|
+
'value': constant_1(string),
|
|
9414
|
+
'writable': true
|
|
9415
|
+
});
|
|
9416
|
+
};
|
|
9417
|
+
|
|
9418
|
+
var _baseSetToString = baseSetToString;
|
|
9419
|
+
|
|
9420
|
+
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
9421
|
+
var HOT_COUNT = 800,
|
|
9422
|
+
HOT_SPAN = 16;
|
|
9423
|
+
|
|
9424
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
9425
|
+
var nativeNow = Date.now;
|
|
9426
|
+
|
|
9427
|
+
/**
|
|
9428
|
+
* Creates a function that'll short out and invoke `identity` instead
|
|
9429
|
+
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
|
9430
|
+
* milliseconds.
|
|
9431
|
+
*
|
|
9432
|
+
* @private
|
|
9433
|
+
* @param {Function} func The function to restrict.
|
|
9434
|
+
* @returns {Function} Returns the new shortable function.
|
|
9435
|
+
*/
|
|
9436
|
+
function shortOut(func) {
|
|
9437
|
+
var count = 0,
|
|
9438
|
+
lastCalled = 0;
|
|
9439
|
+
|
|
9440
|
+
return function() {
|
|
9441
|
+
var stamp = nativeNow(),
|
|
9442
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
9443
|
+
|
|
9444
|
+
lastCalled = stamp;
|
|
9445
|
+
if (remaining > 0) {
|
|
9446
|
+
if (++count >= HOT_COUNT) {
|
|
9447
|
+
return arguments[0];
|
|
9448
|
+
}
|
|
9449
|
+
} else {
|
|
9450
|
+
count = 0;
|
|
9451
|
+
}
|
|
9452
|
+
return func.apply(undefined, arguments);
|
|
9453
|
+
};
|
|
9454
|
+
}
|
|
9455
|
+
|
|
9456
|
+
var _shortOut = shortOut;
|
|
9457
|
+
|
|
9458
|
+
/**
|
|
9459
|
+
* Sets the `toString` method of `func` to return `string`.
|
|
9460
|
+
*
|
|
9461
|
+
* @private
|
|
9462
|
+
* @param {Function} func The function to modify.
|
|
9463
|
+
* @param {Function} string The `toString` result.
|
|
9464
|
+
* @returns {Function} Returns `func`.
|
|
9465
|
+
*/
|
|
9466
|
+
var setToString = _shortOut(_baseSetToString);
|
|
9467
|
+
|
|
9468
|
+
var _setToString = setToString;
|
|
9469
|
+
|
|
9470
|
+
/**
|
|
9471
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
9472
|
+
*
|
|
9473
|
+
* @private
|
|
9474
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
9475
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
9476
|
+
* @returns {Function} Returns the new function.
|
|
9477
|
+
*/
|
|
9478
|
+
function baseRest(func, start) {
|
|
9479
|
+
return _setToString(_overRest(func, start, identity_1), func + '');
|
|
9480
|
+
}
|
|
9481
|
+
|
|
9482
|
+
var _baseRest = baseRest;
|
|
9483
|
+
|
|
9484
|
+
/**
|
|
9485
|
+
* Checks if the given arguments are from an iteratee call.
|
|
9486
|
+
*
|
|
9487
|
+
* @private
|
|
9488
|
+
* @param {*} value The potential iteratee value argument.
|
|
9489
|
+
* @param {*} index The potential iteratee index or key argument.
|
|
9490
|
+
* @param {*} object The potential iteratee object argument.
|
|
9491
|
+
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|
9492
|
+
* else `false`.
|
|
9493
|
+
*/
|
|
9494
|
+
function isIterateeCall(value, index, object) {
|
|
9495
|
+
if (!isObject_1(object)) {
|
|
9496
|
+
return false;
|
|
9497
|
+
}
|
|
9498
|
+
var type = typeof index;
|
|
9499
|
+
if (type == 'number'
|
|
9500
|
+
? (isArrayLike_1(object) && _isIndex(index, object.length))
|
|
9501
|
+
: (type == 'string' && index in object)
|
|
9502
|
+
) {
|
|
9503
|
+
return eq_1(object[index], value);
|
|
9504
|
+
}
|
|
9505
|
+
return false;
|
|
9506
|
+
}
|
|
9507
|
+
|
|
9508
|
+
var _isIterateeCall = isIterateeCall;
|
|
9509
|
+
|
|
9510
|
+
/**
|
|
9511
|
+
* Creates an array of elements, sorted in ascending order by the results of
|
|
9512
|
+
* running each element in a collection thru each iteratee. This method
|
|
9513
|
+
* performs a stable sort, that is, it preserves the original sort order of
|
|
9514
|
+
* equal elements. The iteratees are invoked with one argument: (value).
|
|
9515
|
+
*
|
|
9516
|
+
* @static
|
|
9517
|
+
* @memberOf _
|
|
9518
|
+
* @since 0.1.0
|
|
9519
|
+
* @category Collection
|
|
9520
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
9521
|
+
* @param {...(Function|Function[])} [iteratees=[_.identity]]
|
|
9522
|
+
* The iteratees to sort by.
|
|
9523
|
+
* @returns {Array} Returns the new sorted array.
|
|
9524
|
+
* @example
|
|
9525
|
+
*
|
|
9526
|
+
* var users = [
|
|
9527
|
+
* { 'user': 'fred', 'age': 48 },
|
|
9528
|
+
* { 'user': 'barney', 'age': 36 },
|
|
9529
|
+
* { 'user': 'fred', 'age': 30 },
|
|
9530
|
+
* { 'user': 'barney', 'age': 34 }
|
|
9531
|
+
* ];
|
|
9532
|
+
*
|
|
9533
|
+
* _.sortBy(users, [function(o) { return o.user; }]);
|
|
9534
|
+
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
|
|
9535
|
+
*
|
|
9536
|
+
* _.sortBy(users, ['user', 'age']);
|
|
9537
|
+
* // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
|
|
9538
|
+
*/
|
|
9539
|
+
var sortBy = _baseRest(function(collection, iteratees) {
|
|
9540
|
+
if (collection == null) {
|
|
9541
|
+
return [];
|
|
9542
|
+
}
|
|
9543
|
+
var length = iteratees.length;
|
|
9544
|
+
if (length > 1 && _isIterateeCall(collection, iteratees[0], iteratees[1])) {
|
|
9545
|
+
iteratees = [];
|
|
9546
|
+
} else if (length > 2 && _isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
|
9547
|
+
iteratees = [iteratees[0]];
|
|
9548
|
+
}
|
|
9549
|
+
return _baseOrderBy(collection, _baseFlatten(iteratees, 1), []);
|
|
9550
|
+
});
|
|
9551
|
+
|
|
9552
|
+
var sortBy_1 = sortBy;
|
|
9553
|
+
|
|
9554
|
+
/**
|
|
9555
|
+
* Configuration for custom action validation rules.
|
|
9556
|
+
* Defines allowed positions, metadata IDs, data model IDs, and fields for each target
|
|
9557
|
+
* type.
|
|
9558
|
+
*
|
|
9559
|
+
*/
|
|
9560
|
+
const customActionValidationConfig = {
|
|
9561
|
+
[CustomActionTarget.LIVEBOARD]: {
|
|
9562
|
+
positions: [exports.CustomActionsPosition.PRIMARY, exports.CustomActionsPosition.MENU],
|
|
9563
|
+
allowedMetadataIds: ['liveboardIds'],
|
|
9564
|
+
allowedDataModelIds: [],
|
|
9565
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds'],
|
|
9566
|
+
},
|
|
9567
|
+
[CustomActionTarget.VIZ]: {
|
|
9568
|
+
positions: [exports.CustomActionsPosition.MENU, exports.CustomActionsPosition.PRIMARY, exports.CustomActionsPosition.CONTEXTMENU],
|
|
9569
|
+
allowedMetadataIds: ['liveboardIds', 'vizIds', 'answerIds'],
|
|
9570
|
+
allowedDataModelIds: ['modelIds', 'modelColumnNames'],
|
|
9571
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9572
|
+
},
|
|
9573
|
+
[CustomActionTarget.ANSWER]: {
|
|
9574
|
+
positions: [exports.CustomActionsPosition.MENU, exports.CustomActionsPosition.PRIMARY, exports.CustomActionsPosition.CONTEXTMENU],
|
|
9575
|
+
allowedMetadataIds: ['answerIds'],
|
|
9576
|
+
allowedDataModelIds: ['modelIds', 'modelColumnNames'],
|
|
9577
|
+
allowedFields: ['name', 'id', 'position', 'target', 'metadataIds', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9578
|
+
},
|
|
9579
|
+
[CustomActionTarget.SPOTTER]: {
|
|
9580
|
+
positions: [exports.CustomActionsPosition.MENU, exports.CustomActionsPosition.CONTEXTMENU],
|
|
9581
|
+
allowedMetadataIds: [],
|
|
9582
|
+
allowedDataModelIds: ['modelIds'],
|
|
9583
|
+
allowedFields: ['name', 'id', 'position', 'target', 'orgIds', 'groupIds', 'dataModelIds'],
|
|
9584
|
+
},
|
|
9585
|
+
};
|
|
9586
|
+
/**
|
|
9587
|
+
* Validates a single custom action based on its target type
|
|
9588
|
+
* @param action - The custom action to validate
|
|
9589
|
+
* @param primaryActionsPerTarget - Map to track primary actions per target
|
|
9590
|
+
* @returns CustomActionValidation with isValid flag and reason string
|
|
9591
|
+
*
|
|
9592
|
+
* @hidden
|
|
9593
|
+
*/
|
|
9594
|
+
const validateCustomAction = (action, primaryActionsPerTarget) => {
|
|
9595
|
+
const { id: actionId, target: targetType, position, metadataIds, dataModelIds } = action;
|
|
9596
|
+
// Check if target type is supported
|
|
9597
|
+
if (!customActionValidationConfig[targetType]) {
|
|
9598
|
+
const errorMessage = CUSTOM_ACTIONS_ERROR_MESSAGE.UNSUPPORTED_TARGET(actionId, targetType);
|
|
9599
|
+
return { isValid: false, errors: [errorMessage] };
|
|
9600
|
+
}
|
|
9601
|
+
const config = customActionValidationConfig[targetType];
|
|
9602
|
+
const errors = [];
|
|
9603
|
+
// Validate position
|
|
9604
|
+
if (!arrayIncludesString(config.positions, position)) {
|
|
9605
|
+
const supportedPositions = config.positions.join(', ');
|
|
9606
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_POSITION(position, targetType, supportedPositions));
|
|
8065
9607
|
}
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
* @example
|
|
8073
|
-
* ```js
|
|
8074
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
8075
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
8076
|
-
* 'col name 1' // The column should exist in the data source.
|
|
8077
|
-
* ]);
|
|
8078
|
-
* const data = await underlying.fetchData(0, 100);
|
|
8079
|
-
* })
|
|
8080
|
-
* ```
|
|
8081
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
8082
|
-
*/
|
|
8083
|
-
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
8084
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
8085
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
8086
|
-
}
|
|
8087
|
-
if (!selectedPoints) {
|
|
8088
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
8089
|
-
}
|
|
8090
|
-
const sourceDetail = await this.getSourceDetail();
|
|
8091
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
8092
|
-
const unAggAnswer = await graphqlQuery({
|
|
8093
|
-
query: getUnaggregatedAnswerSession,
|
|
8094
|
-
variables: {
|
|
8095
|
-
session: this.session,
|
|
8096
|
-
columns: selectedPoints,
|
|
8097
|
-
},
|
|
8098
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
8099
|
-
});
|
|
8100
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
8101
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
8102
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
8103
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
8104
|
-
if (columnsToAdd.length) {
|
|
8105
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
8106
|
-
}
|
|
8107
|
-
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
8108
|
-
if (columnsToRemove.length) {
|
|
8109
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
9608
|
+
// Validate metadata IDs
|
|
9609
|
+
if (metadataIds) {
|
|
9610
|
+
const invalidMetadataIds = Object.keys(metadataIds).filter((key) => !arrayIncludesString(config.allowedMetadataIds, key));
|
|
9611
|
+
if (invalidMetadataIds.length > 0) {
|
|
9612
|
+
const supportedMetadataIds = config.allowedMetadataIds.length > 0 ? config.allowedMetadataIds.join(', ') : 'none';
|
|
9613
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_METADATA_IDS(targetType, invalidMetadataIds, supportedMetadataIds));
|
|
8110
9614
|
}
|
|
8111
|
-
return unaggAnswerSession;
|
|
8112
|
-
}
|
|
8113
|
-
/**
|
|
8114
|
-
* Execute a custom graphql query in the context of the answer.
|
|
8115
|
-
* @param query graphql query
|
|
8116
|
-
* @param variables graphql variables
|
|
8117
|
-
* @returns
|
|
8118
|
-
*/
|
|
8119
|
-
async executeQuery(query, variables) {
|
|
8120
|
-
const data = await graphqlQuery({
|
|
8121
|
-
query,
|
|
8122
|
-
variables: {
|
|
8123
|
-
session: this.session,
|
|
8124
|
-
...variables,
|
|
8125
|
-
},
|
|
8126
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
8127
|
-
isCompositeQuery: false,
|
|
8128
|
-
});
|
|
8129
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
8130
|
-
return data;
|
|
8131
|
-
}
|
|
8132
|
-
/**
|
|
8133
|
-
* Get the internal session details for the answer.
|
|
8134
|
-
* @returns
|
|
8135
|
-
*/
|
|
8136
|
-
getSession() {
|
|
8137
|
-
return this.session;
|
|
8138
9615
|
}
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
9616
|
+
// Validate data model IDs
|
|
9617
|
+
if (dataModelIds) {
|
|
9618
|
+
const invalidDataModelIds = Object.keys(dataModelIds).filter((key) => !arrayIncludesString(config.allowedDataModelIds, key));
|
|
9619
|
+
if (invalidDataModelIds.length > 0) {
|
|
9620
|
+
const supportedDataModelIds = config.allowedDataModelIds.length > 0 ? config.allowedDataModelIds.join(', ') : 'none';
|
|
9621
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_DATA_MODEL_IDS(targetType, invalidDataModelIds, supportedDataModelIds));
|
|
8142
9622
|
}
|
|
8143
|
-
this.answer = this.executeQuery(getAnswer, {}).then((data) => data === null || data === void 0 ? void 0 : data.answer);
|
|
8144
|
-
return this.answer;
|
|
8145
|
-
}
|
|
8146
|
-
async getTML() {
|
|
8147
|
-
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
8148
|
-
const edoc = object[0].edoc;
|
|
8149
|
-
const YAML = await Promise.resolve().then(function () { return index; });
|
|
8150
|
-
const parsedDoc = YAML.parse(edoc);
|
|
8151
|
-
return {
|
|
8152
|
-
answer: {
|
|
8153
|
-
...parsedDoc.answer,
|
|
8154
|
-
...this.tmlOverride,
|
|
8155
|
-
},
|
|
8156
|
-
};
|
|
8157
|
-
}
|
|
8158
|
-
async addDisplayedVizToLiveboard(liveboardId) {
|
|
8159
|
-
const { displayMode, visualizations } = await this.getAnswer();
|
|
8160
|
-
const viz = getDisplayedViz(visualizations, displayMode);
|
|
8161
|
-
return this.executeQuery(addVizToLiveboard, {
|
|
8162
|
-
liveboardId,
|
|
8163
|
-
vizId: viz.id,
|
|
8164
|
-
});
|
|
8165
9623
|
}
|
|
8166
|
-
|
|
8167
|
-
|
|
9624
|
+
// Validate allowed fields
|
|
9625
|
+
const actionKeys = Object.keys(action);
|
|
9626
|
+
const invalidFields = actionKeys.filter((key) => !arrayIncludesString(config.allowedFields, key));
|
|
9627
|
+
if (invalidFields.length > 0) {
|
|
9628
|
+
const supportedFields = config.allowedFields.join(', ');
|
|
9629
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_FIELDS(targetType, invalidFields, supportedFields));
|
|
8168
9630
|
}
|
|
8169
|
-
|
|
9631
|
+
return {
|
|
9632
|
+
isValid: errors.length === 0,
|
|
9633
|
+
errors,
|
|
9634
|
+
};
|
|
9635
|
+
};
|
|
8170
9636
|
/**
|
|
9637
|
+
* Validates basic action structure and required fields
|
|
9638
|
+
* @param action - The action to validate
|
|
9639
|
+
* @returns Object containing validation result and missing fields
|
|
8171
9640
|
*
|
|
8172
|
-
* @
|
|
8173
|
-
* @param colNames
|
|
9641
|
+
* @hidden
|
|
8174
9642
|
*/
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
}));
|
|
8184
|
-
}
|
|
9643
|
+
const validateActionStructure = (action) => {
|
|
9644
|
+
if (!action || typeof action !== 'object') {
|
|
9645
|
+
return { isValid: false, missingFields: [] };
|
|
9646
|
+
}
|
|
9647
|
+
// Check for all missing required fields
|
|
9648
|
+
const missingFields = ['id', 'name', 'target', 'position'].filter(field => !action[field]);
|
|
9649
|
+
return { isValid: missingFields.length === 0, missingFields };
|
|
9650
|
+
};
|
|
8185
9651
|
/**
|
|
9652
|
+
* Checks for duplicate IDs among actions
|
|
9653
|
+
* @param actions - Array of actions to check
|
|
9654
|
+
* @returns Object containing filtered actions and duplicate errors
|
|
8186
9655
|
*
|
|
8187
|
-
* @
|
|
9656
|
+
* @hidden
|
|
8188
9657
|
*/
|
|
8189
|
-
|
|
8190
|
-
const
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
let dataValue;
|
|
8200
|
-
if (dataType === 'DATE') {
|
|
8201
|
-
if (Number.isFinite(colVal.value)) {
|
|
8202
|
-
dataValue = [{
|
|
8203
|
-
epochRange: {
|
|
8204
|
-
startEpoch: colVal.value,
|
|
8205
|
-
},
|
|
8206
|
-
}];
|
|
8207
|
-
// Case for custom calendar.
|
|
8208
|
-
}
|
|
8209
|
-
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
8210
|
-
dataValue = [{
|
|
8211
|
-
epochRange: {
|
|
8212
|
-
startEpoch: colVal.value.v.s,
|
|
8213
|
-
endEpoch: colVal.value.v.e,
|
|
8214
|
-
},
|
|
8215
|
-
}];
|
|
8216
|
-
}
|
|
9658
|
+
const filterDuplicateIds = (actions) => {
|
|
9659
|
+
const idMap = actions.reduce((map, action) => {
|
|
9660
|
+
const list = map.get(action.id) || [];
|
|
9661
|
+
list.push(action);
|
|
9662
|
+
map.set(action.id, list);
|
|
9663
|
+
return map;
|
|
9664
|
+
}, new Map());
|
|
9665
|
+
const { actions: actionsWithUniqueIds, errors } = Array.from(idMap.entries()).reduce((acc, [id, actionsWithSameId]) => {
|
|
9666
|
+
if (actionsWithSameId.length === 1) {
|
|
9667
|
+
acc.actions.push(actionsWithSameId[0]);
|
|
8217
9668
|
}
|
|
8218
9669
|
else {
|
|
8219
|
-
|
|
9670
|
+
// Keep the first action and add error for duplicates
|
|
9671
|
+
acc.actions.push(actionsWithSameId[0]);
|
|
9672
|
+
const duplicateNames = actionsWithSameId.slice(1).map(action => action.name);
|
|
9673
|
+
acc.errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.DUPLICATE_IDS(id, duplicateNames, actionsWithSameId[0].name));
|
|
8220
9674
|
}
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
}
|
|
8226
|
-
selectedPoints.forEach((p) => {
|
|
8227
|
-
p.selectedAttributes.forEach(addPointFromColVal);
|
|
8228
|
-
});
|
|
8229
|
-
return underlyingDataPoint;
|
|
8230
|
-
}
|
|
9675
|
+
return acc;
|
|
9676
|
+
}, { actions: [], errors: [] });
|
|
9677
|
+
return { actions: actionsWithUniqueIds, errors };
|
|
9678
|
+
};
|
|
8231
9679
|
/**
|
|
8232
|
-
*
|
|
8233
|
-
* @param
|
|
8234
|
-
* @
|
|
9680
|
+
* Validates and processes custom actions
|
|
9681
|
+
* @param customActions - Array of custom actions to validate
|
|
9682
|
+
* @returns Object containing valid actions and any validation errors
|
|
8235
9683
|
*/
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
(viz) => viz.__typename === 'ChartViz');
|
|
9684
|
+
const getCustomActions = (customActions) => {
|
|
9685
|
+
const errors = [];
|
|
9686
|
+
if (!customActions || !Array.isArray(customActions)) {
|
|
9687
|
+
return { actions: [], errors: [] };
|
|
8241
9688
|
}
|
|
8242
|
-
|
|
8243
|
-
//
|
|
8244
|
-
|
|
8245
|
-
|
|
9689
|
+
// Step 1: Handle invalid actions first (null, undefined, missing required
|
|
9690
|
+
// fields)
|
|
9691
|
+
const validActions = customActions.filter(action => {
|
|
9692
|
+
const validation = validateActionStructure(action);
|
|
9693
|
+
if (!validation.isValid) {
|
|
9694
|
+
if (!action || typeof action !== 'object') {
|
|
9695
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.INVALID_ACTION_OBJECT);
|
|
9696
|
+
}
|
|
9697
|
+
else {
|
|
9698
|
+
errors.push(CUSTOM_ACTIONS_ERROR_MESSAGE.MISSING_REQUIRED_FIELDS(action.id, validation.missingFields));
|
|
9699
|
+
}
|
|
9700
|
+
return false;
|
|
9701
|
+
}
|
|
9702
|
+
return true;
|
|
9703
|
+
});
|
|
9704
|
+
// Step 2: Check for duplicate IDs among valid actions
|
|
9705
|
+
const { actions: actionsWithUniqueIds, errors: duplicateErrors } = filterDuplicateIds(validActions);
|
|
9706
|
+
// Add duplicate errors to the errors array
|
|
9707
|
+
duplicateErrors.forEach(error => errors.push(error));
|
|
9708
|
+
// Step 3: Validate actions with unique IDs
|
|
9709
|
+
const finalValidActions = [];
|
|
9710
|
+
actionsWithUniqueIds.forEach((action) => {
|
|
9711
|
+
const { isValid, errors: validationErrors } = validateCustomAction(action);
|
|
9712
|
+
validationErrors.forEach(error => errors.push(error));
|
|
9713
|
+
if (isValid) {
|
|
9714
|
+
finalValidActions.push(action);
|
|
9715
|
+
}
|
|
9716
|
+
});
|
|
9717
|
+
const sortedActions = sortBy_1(finalValidActions, (a) => a.name.toLocaleLowerCase());
|
|
9718
|
+
return {
|
|
9719
|
+
actions: sortedActions,
|
|
9720
|
+
errors: errors,
|
|
9721
|
+
};
|
|
9722
|
+
};
|
|
8246
9723
|
|
|
8247
9724
|
/**
|
|
8248
9725
|
* Copyright (c) 2023
|
|
@@ -15770,6 +17247,13 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
15770
17247
|
handleExitPresentMode();
|
|
15771
17248
|
}
|
|
15772
17249
|
}
|
|
17250
|
+
/**
|
|
17251
|
+
* Clears the cached preauth and session info.
|
|
17252
|
+
*/
|
|
17253
|
+
function processClearInfoCache() {
|
|
17254
|
+
resetCachedPreauthInfo();
|
|
17255
|
+
resetCachedSessionInfo();
|
|
17256
|
+
}
|
|
15773
17257
|
/**
|
|
15774
17258
|
*
|
|
15775
17259
|
* @param e
|
|
@@ -15876,11 +17360,13 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
15876
17360
|
return processAuthLogout(e, containerEl);
|
|
15877
17361
|
case exports.EmbedEvent.ExitPresentMode:
|
|
15878
17362
|
return processExitPresentMode();
|
|
17363
|
+
case exports.EmbedEvent.CLEAR_INFO_CACHE:
|
|
17364
|
+
return processClearInfoCache();
|
|
15879
17365
|
}
|
|
15880
17366
|
return e;
|
|
15881
17367
|
}
|
|
15882
17368
|
|
|
15883
|
-
var name="@thoughtspot/visual-embed-sdk";var version$1="1.40.
|
|
17369
|
+
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$1={".":{"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$1,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};
|
|
15884
17370
|
|
|
15885
17371
|
/**
|
|
15886
17372
|
* Reloads the ThoughtSpot iframe.
|
|
@@ -16405,6 +17891,16 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
16405
17891
|
async getDefaultAppInitData() {
|
|
16406
17892
|
var _a, _b;
|
|
16407
17893
|
const authToken = await this.getAuthTokenForCookielessInit();
|
|
17894
|
+
const customActionsResult = getCustomActions([
|
|
17895
|
+
...(this.viewConfig.customActions || []),
|
|
17896
|
+
...(this.embedConfig.customActions || [])
|
|
17897
|
+
]);
|
|
17898
|
+
if (customActionsResult.errors.length > 0) {
|
|
17899
|
+
this.handleError({
|
|
17900
|
+
type: 'CUSTOM_ACTION_VALIDATION',
|
|
17901
|
+
message: customActionsResult.errors,
|
|
17902
|
+
});
|
|
17903
|
+
}
|
|
16408
17904
|
return {
|
|
16409
17905
|
customisations: getCustomisations(this.embedConfig, this.viewConfig),
|
|
16410
17906
|
authToken,
|
|
@@ -16422,6 +17918,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
16422
17918
|
: [],
|
|
16423
17919
|
customVariablesForThirdPartyTools: this.embedConfig.customVariablesForThirdPartyTools || {},
|
|
16424
17920
|
hiddenListColumns: this.viewConfig.hiddenListColumns || [],
|
|
17921
|
+
customActions: customActionsResult.actions,
|
|
16425
17922
|
};
|
|
16426
17923
|
}
|
|
16427
17924
|
async getAppInitData() {
|
|
@@ -17864,7 +19361,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
17864
19361
|
* embedded Liveboard or visualization.
|
|
17865
19362
|
*/
|
|
17866
19363
|
getEmbedParams() {
|
|
17867
|
-
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;
|
|
19364
|
+
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;
|
|
17868
19365
|
let params = {};
|
|
17869
19366
|
params[Param.PrimaryNavHidden] = !showPrimaryNavbar;
|
|
17870
19367
|
params[Param.HideProfleAndHelp] = !!disableProfileAndHelp;
|
|
@@ -17881,6 +19378,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
17881
19378
|
params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
|
|
17882
19379
|
params[Param.IsUnifiedSearchExperienceEnabled] = isUnifiedSearchExperienceEnabled;
|
|
17883
19380
|
params[Param.CoverAndFilterOptionInPDF] = !!coverAndFilterOptionInPDF;
|
|
19381
|
+
params[Param.LiveboardXLSXCSVDownload] = !!liveboardXLSXCSVDownload;
|
|
17884
19382
|
params = this.getBaseQueryParams(params);
|
|
17885
19383
|
if (hideObjectSearch) {
|
|
17886
19384
|
params[Param.HideObjectSearch] = !!hideObjectSearch;
|
|
@@ -17951,6 +19449,9 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
17951
19449
|
// Set homePageVersion to v2 by default to reset the LD flag value
|
|
17952
19450
|
// for the homepageVersion.
|
|
17953
19451
|
params[Param.HomepageVersion] = 'v2';
|
|
19452
|
+
// Set listpageVersion to v2 by default to reset the LD flag value
|
|
19453
|
+
// for the listpageVersion.
|
|
19454
|
+
params[Param.ListPageVersion] = ListPage.List;
|
|
17954
19455
|
if (discoveryExperience) {
|
|
17955
19456
|
// primaryNavbarVersion v3 will enabled the new left navigation
|
|
17956
19457
|
if (discoveryExperience.primaryNavbarVersion === PrimaryNavbarVersion.Sliding) {
|
|
@@ -18274,7 +19775,7 @@ query GetEurekaVizSnapshots(
|
|
|
18274
19775
|
getEmbedParams() {
|
|
18275
19776
|
let params = {};
|
|
18276
19777
|
params = this.getBaseQueryParams(params);
|
|
18277
|
-
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;
|
|
19778
|
+
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;
|
|
18278
19779
|
const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
|
|
18279
19780
|
|| this.viewConfig.preventPinboardFilterRemoval;
|
|
18280
19781
|
if (fullHeight === true) {
|
|
@@ -18341,6 +19842,7 @@ query GetEurekaVizSnapshots(
|
|
|
18341
19842
|
params[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
18342
19843
|
params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
18343
19844
|
params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
|
|
19845
|
+
params[Param.LiveboardXLSXCSVDownload] = !!liveboardXLSXCSVDownload;
|
|
18344
19846
|
const queryParams = getQueryParamString(params, true);
|
|
18345
19847
|
return queryParams;
|
|
18346
19848
|
}
|