@fc-components/monaco-editor 0.1.15 → 0.1.17
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/dist/monaco-editor.cjs.development.js +59 -29
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +59 -29
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/completion/DataProvider.d.ts +4 -3
- package/dist/promql/index.d.ts +1 -0
- package/dist/promql/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/promql/completion/DataProvider.ts +24 -2
- package/src/promql/completion/completions.ts +17 -17
- package/src/promql/index.tsx +5 -0
- package/src/promql/types.ts +2 -0
|
@@ -12,7 +12,6 @@ var monacoPromql = require('monaco-promql');
|
|
|
12
12
|
var lezerMetricsql = require('@fc-components/lezer-metricsql');
|
|
13
13
|
var uuid = require('uuid');
|
|
14
14
|
var css = require('@emotion/css');
|
|
15
|
-
var UFuzzy = _interopDefault(require('@leeoniya/ufuzzy'));
|
|
16
15
|
|
|
17
16
|
function _arrayLikeToArray(r, a) {
|
|
18
17
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -881,6 +880,7 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
881
880
|
this.variablesNames = [];
|
|
882
881
|
this.httpMethod = 'GET';
|
|
883
882
|
this.apiPrefix = '/api/v1';
|
|
883
|
+
this.enableRequests = true;
|
|
884
884
|
this.customRequest = function (input, init) {
|
|
885
885
|
return fetch(input, init);
|
|
886
886
|
};
|
|
@@ -890,6 +890,12 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
890
890
|
return _regenerator().w(function (_context) {
|
|
891
891
|
while (1) switch (_context.n) {
|
|
892
892
|
case 0:
|
|
893
|
+
if (_this.enableRequests) {
|
|
894
|
+
_context.n = 1;
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
return _context.a(2, []);
|
|
898
|
+
case 1:
|
|
893
899
|
end = new Date();
|
|
894
900
|
start = new Date(end.getTime() - _this.lookbackInterval);
|
|
895
901
|
url = _this.apiPrefix + "/series";
|
|
@@ -906,14 +912,14 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
906
912
|
});
|
|
907
913
|
}
|
|
908
914
|
request = _this.buildRequest(url, new URLSearchParams(urlParams));
|
|
909
|
-
_context.n =
|
|
915
|
+
_context.n = 2;
|
|
910
916
|
return _this.request(request.uri, {
|
|
911
917
|
method: _this.httpMethod,
|
|
912
918
|
body: request.body
|
|
913
919
|
})["catch"](function () {
|
|
914
920
|
return [];
|
|
915
921
|
});
|
|
916
|
-
case
|
|
922
|
+
case 2:
|
|
917
923
|
return _context.a(2, _context.v);
|
|
918
924
|
}
|
|
919
925
|
}, _callee);
|
|
@@ -928,6 +934,12 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
928
934
|
return _regenerator().w(function (_context2) {
|
|
929
935
|
while (1) switch (_context2.n) {
|
|
930
936
|
case 0:
|
|
937
|
+
if (_this.enableRequests) {
|
|
938
|
+
_context2.n = 1;
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
return _context2.a(2, []);
|
|
942
|
+
case 1:
|
|
931
943
|
end = new Date();
|
|
932
944
|
start = new Date(end.getTime() - _this.lookbackInterval);
|
|
933
945
|
url = _this.apiPrefix + "/labels";
|
|
@@ -939,7 +951,7 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
939
951
|
urlParams['match[]'] = selector;
|
|
940
952
|
}
|
|
941
953
|
request = _this.buildRequest(url, new URLSearchParams(urlParams));
|
|
942
|
-
_context2.n =
|
|
954
|
+
_context2.n = 2;
|
|
943
955
|
return _this.request(request.uri, {
|
|
944
956
|
method: _this.httpMethod,
|
|
945
957
|
body: request.body
|
|
@@ -949,7 +961,7 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
949
961
|
})["catch"](function () {
|
|
950
962
|
return [];
|
|
951
963
|
});
|
|
952
|
-
case
|
|
964
|
+
case 2:
|
|
953
965
|
return _context2.a(2, _context2.v);
|
|
954
966
|
}
|
|
955
967
|
}, _callee2);
|
|
@@ -964,6 +976,12 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
964
976
|
return _regenerator().w(function (_context3) {
|
|
965
977
|
while (1) switch (_context3.n) {
|
|
966
978
|
case 0:
|
|
979
|
+
if (_this.enableRequests) {
|
|
980
|
+
_context3.n = 1;
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
return _context3.a(2, []);
|
|
984
|
+
case 1:
|
|
967
985
|
end = new Date();
|
|
968
986
|
start = new Date(end.getTime() - _this.lookbackInterval);
|
|
969
987
|
url = _this.apiPrefix + "/label/" + labelName + "/values";
|
|
@@ -975,14 +993,14 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
975
993
|
urlParams['match[]'] = selector;
|
|
976
994
|
}
|
|
977
995
|
request = _this.buildRequest(url, new URLSearchParams(urlParams));
|
|
978
|
-
_context3.n =
|
|
996
|
+
_context3.n = 2;
|
|
979
997
|
return _this.request(request.uri, {
|
|
980
998
|
method: _this.httpMethod,
|
|
981
999
|
body: request.body
|
|
982
1000
|
})["catch"](function () {
|
|
983
1001
|
return [];
|
|
984
1002
|
});
|
|
985
|
-
case
|
|
1003
|
+
case 2:
|
|
986
1004
|
return _context3.a(2, _context3.v);
|
|
987
1005
|
}
|
|
988
1006
|
}, _callee3);
|
|
@@ -1032,6 +1050,10 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
1032
1050
|
if (params.apiPrefix) {
|
|
1033
1051
|
this.apiPrefix = params.apiPrefix;
|
|
1034
1052
|
}
|
|
1053
|
+
// control whether DataProvider should actually send network requests
|
|
1054
|
+
if (typeof params.enableRequests !== 'undefined') {
|
|
1055
|
+
this.enableRequests = !!params.enableRequests;
|
|
1056
|
+
}
|
|
1035
1057
|
this.metrics = [];
|
|
1036
1058
|
this.labelKeys = [];
|
|
1037
1059
|
}
|
|
@@ -1095,18 +1117,24 @@ var DataProvider = /*#__PURE__*/function () {
|
|
|
1095
1117
|
return _regenerator().w(function (_context5) {
|
|
1096
1118
|
while (1) switch (_context5.n) {
|
|
1097
1119
|
case 0:
|
|
1120
|
+
if (this.enableRequests) {
|
|
1121
|
+
_context5.n = 1;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
this.metricsMetadata = {};
|
|
1125
|
+
return _context5.a(2, this.metricsMetadata);
|
|
1126
|
+
case 1:
|
|
1098
1127
|
request = this.buildRequest(this.apiPrefix + "/metadata", new URLSearchParams({}));
|
|
1099
|
-
_context5.n =
|
|
1128
|
+
_context5.n = 2;
|
|
1100
1129
|
return this.request(request.uri, {
|
|
1101
1130
|
method: this.httpMethod,
|
|
1102
1131
|
body: request.body
|
|
1103
1132
|
})["catch"](function () {
|
|
1104
1133
|
return {};
|
|
1105
1134
|
});
|
|
1106
|
-
case 1:
|
|
1107
|
-
this.metricsMetadata = _context5.v;
|
|
1108
1135
|
case 2:
|
|
1109
|
-
|
|
1136
|
+
this.metricsMetadata = _context5.v;
|
|
1137
|
+
return _context5.a(2, this.metricsMetadata || {});
|
|
1110
1138
|
}
|
|
1111
1139
|
}, _callee5, this);
|
|
1112
1140
|
}));
|
|
@@ -1493,24 +1521,23 @@ function notEmpty(value) {
|
|
|
1493
1521
|
return value !== null && value !== undefined;
|
|
1494
1522
|
}
|
|
1495
1523
|
|
|
1496
|
-
|
|
1497
|
-
intraMode: 1
|
|
1498
|
-
});
|
|
1524
|
+
// const metricNamesSearchClient = new UFuzzy({ intraMode: 1 });
|
|
1499
1525
|
// we order items like: history, functions, metrics
|
|
1500
1526
|
function getAllMetricNamesCompletions(dataProvider) {
|
|
1501
1527
|
var metricNames = dataProvider.getAllMetricNames();
|
|
1502
|
-
if (metricNames.length > dataProvider.metricNamesSuggestionLimit) {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1528
|
+
// if (metricNames.length > dataProvider.metricNamesSuggestionLimit) {
|
|
1529
|
+
// const { monacoSettings } = dataProvider;
|
|
1530
|
+
// monacoSettings.enableAutocompleteSuggestionsUpdate();
|
|
1531
|
+
// if (monacoSettings.inputInRange) {
|
|
1532
|
+
// metricNames =
|
|
1533
|
+
// metricNamesSearchClient
|
|
1534
|
+
// .filter(metricNames, monacoSettings.inputInRange)
|
|
1535
|
+
// ?.slice(0, dataProvider.metricNamesSuggestionLimit)
|
|
1536
|
+
// .map((idx) => metricNames[idx]) ?? [];
|
|
1537
|
+
// } else {
|
|
1538
|
+
// metricNames = metricNames.slice(0, dataProvider.metricNamesSuggestionLimit);
|
|
1539
|
+
// }
|
|
1540
|
+
// }
|
|
1514
1541
|
return dataProvider.metricNamesToMetrics(metricNames).map(function (metric) {
|
|
1515
1542
|
return {
|
|
1516
1543
|
type: 'METRIC_NAME',
|
|
@@ -1734,7 +1761,7 @@ function _getLabelValues() {
|
|
|
1734
1761
|
}
|
|
1735
1762
|
return _context6.a(3, 7);
|
|
1736
1763
|
case 6:
|
|
1737
|
-
if (key === labelName) {
|
|
1764
|
+
if (key === labelName && value) {
|
|
1738
1765
|
labelValues.add(value);
|
|
1739
1766
|
}
|
|
1740
1767
|
case 7:
|
|
@@ -2007,6 +2034,8 @@ function PromQLEditor(props) {
|
|
|
2007
2034
|
interpolateString = props.interpolateString,
|
|
2008
2035
|
_props$enableAutocomp = props.enableAutocomplete,
|
|
2009
2036
|
enableAutocomplete = _props$enableAutocomp === void 0 ? true : _props$enableAutocomp,
|
|
2037
|
+
_props$enableRequests = props.enableRequests,
|
|
2038
|
+
enableRequests = _props$enableRequests === void 0 ? true : _props$enableRequests,
|
|
2010
2039
|
_props$readOnly = props.readOnly,
|
|
2011
2040
|
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
2012
2041
|
_props$disabled = props.disabled,
|
|
@@ -2159,7 +2188,8 @@ function PromQLEditor(props) {
|
|
|
2159
2188
|
request: props.request,
|
|
2160
2189
|
httpMethod: props.httpMethod,
|
|
2161
2190
|
apiPrefix: props.apiPrefix,
|
|
2162
|
-
httpErrorHandler: props.httpErrorHandler
|
|
2191
|
+
httpErrorHandler: props.httpErrorHandler,
|
|
2192
|
+
enableRequests: enableRequests
|
|
2163
2193
|
});
|
|
2164
2194
|
dataProviderRef.current = dataProvider;
|
|
2165
2195
|
dataProvider.start();
|
|
@@ -2206,7 +2236,7 @@ function PromQLEditor(props) {
|
|
|
2206
2236
|
checkDecorators();
|
|
2207
2237
|
editor.onDidChangeModelContent(checkDecorators);
|
|
2208
2238
|
}
|
|
2209
|
-
}, [enableAutocomplete, props.url, props.lookbackInterval, JSON.stringify(props.variablesNames), props.durationVariablesCompletion, props.httpMethod, props.apiPrefix, placeholder]);
|
|
2239
|
+
}, [enableAutocomplete, props.url, props.lookbackInterval, JSON.stringify(props.variablesNames), props.durationVariablesCompletion, props.httpMethod, props.apiPrefix, placeholder, enableRequests]);
|
|
2210
2240
|
return React__default.createElement("div", {
|
|
2211
2241
|
className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '') + (disabled ? " ant-input-disabled " + containerDisabledClassName : '') + (readOnly ? " " + containerReadOnlyClassName : '')
|
|
2212
2242
|
}, React__default.createElement("div", {
|