@kusto/monaco-kusto 5.3.9 → 5.3.11
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/package.json +7 -12
- package/release/dev/kustoMode.js +88 -34
- package/release/dev/kustoWorker.js +86 -58
- package/release/dev/monaco.contribution.js +9 -8
- package/release/esm/extendedEditor.js +3 -3
- package/release/esm/kustoMode.js +6 -3
- package/release/esm/kustoWorker.js +11 -11
- package/release/esm/languageFeatures.js +10 -10
- package/release/esm/languageService/kustoLanguageService.js +53 -33
- package/release/esm/languageService/kustoMonarchLanguageDefinition.js +72 -21
- package/release/esm/languageService/schema.js +8 -8
- package/release/esm/monaco.contribution.d.ts +1 -0
- package/release/esm/monaco.contribution.js +5 -4
- package/release/esm/monaco.d.ts +29 -14
- package/release/min/kustoMode.js +2 -11
- package/release/min/kustoWorker.js +2 -55
- package/release/min/monaco.contribution.d.ts +1 -0
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/monaco.d.ts +29 -14
- package/scripts/bundle.js +55 -48
- package/scripts/release.js +13 -20
- package/tsconfig.esm.json +18 -0
- package/tsconfig.json +20 -0
- package/tsconfig.watch.json +8 -0
|
@@ -3,7 +3,6 @@ import * as _ from './_deps/lodash/lodash';
|
|
|
3
3
|
var Uri = monaco.Uri;
|
|
4
4
|
var Range = monaco.Range;
|
|
5
5
|
var ClassificationKind = Kusto.Language.Editor.ClassificationKind;
|
|
6
|
-
// --- diagnostics ---
|
|
7
6
|
var DiagnosticsAdapter = /** @class */ (function () {
|
|
8
7
|
function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
9
8
|
var _this = this;
|
|
@@ -146,9 +145,9 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
146
145
|
}
|
|
147
146
|
else {
|
|
148
147
|
// Add custom popup for syntax error: icon, header and message as markdown
|
|
149
|
-
var header = syntaxErrorAsMarkDown.header ? "**"
|
|
150
|
-
var icon = syntaxErrorAsMarkDown.icon ? " : '';
|
|
149
|
+
var icon = syntaxErrorAsMarkDown.icon ? "") : '';
|
|
150
|
+
var popupErrorHoverHeaderMessage_1 = "".concat(icon, " ").concat(header);
|
|
152
151
|
var newDecorations = markers.map(function (marker) {
|
|
153
152
|
return {
|
|
154
153
|
range: {
|
|
@@ -175,8 +174,7 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
175
174
|
},
|
|
176
175
|
};
|
|
177
176
|
});
|
|
178
|
-
var oldMarkers = monaco.editor
|
|
179
|
-
.getModelMarkers({
|
|
177
|
+
var oldMarkers = monaco.editor.getModelMarkers({
|
|
180
178
|
owner: languageId,
|
|
181
179
|
resource: resource,
|
|
182
180
|
});
|
|
@@ -482,7 +480,7 @@ function getCssForClassification() {
|
|
|
482
480
|
var classificationColorTriplets = getClassificationColorTriplets();
|
|
483
481
|
var cssInnerHtml = classificationColorTriplets
|
|
484
482
|
.map(function (pair) {
|
|
485
|
-
return ".vs ."
|
|
483
|
+
return ".vs .".concat(pair.classification, " {color: #").concat(pair.colorLight, ";} .vs-dark .").concat(pair.classification, " {color: #").concat(pair.colorDark, ";}");
|
|
486
484
|
})
|
|
487
485
|
.join('\n');
|
|
488
486
|
return cssInnerHtml;
|
|
@@ -583,7 +581,7 @@ function toTextEdit(textEdit) {
|
|
|
583
581
|
text: textEdit.newText,
|
|
584
582
|
};
|
|
585
583
|
}
|
|
586
|
-
var DOCS_BASE_URL =
|
|
584
|
+
var DOCS_BASE_URL = 'https://learn.microsoft.com/azure/data-explorer/kusto/query';
|
|
587
585
|
function formatDocLink(docString) {
|
|
588
586
|
// If the docString is empty, we want to return undefined to prevent an empty documentation popup.
|
|
589
587
|
if (!docString) {
|
|
@@ -593,9 +591,11 @@ function formatDocLink(docString) {
|
|
|
593
591
|
var urisProxy = new Proxy(target, {
|
|
594
592
|
get: function (_target, prop, _receiver) {
|
|
595
593
|
// The link comes with a postfix of ".md" that we want to remove
|
|
596
|
-
var linkWithoutPostfix = prop.toString().replace(
|
|
594
|
+
var linkWithoutPostfix = prop.toString().replace('.md', '');
|
|
597
595
|
// Sometimes we get the link as a full URL. For example in the main doc link of the item
|
|
598
|
-
var fullURL = linkWithoutPostfix.startsWith(
|
|
596
|
+
var fullURL = linkWithoutPostfix.startsWith('https')
|
|
597
|
+
? linkWithoutPostfix
|
|
598
|
+
: "".concat(DOCS_BASE_URL, "/").concat(linkWithoutPostfix);
|
|
599
599
|
return monaco.Uri.parse(fullURL);
|
|
600
600
|
},
|
|
601
601
|
});
|
|
@@ -9,9 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
15
21
|
import * as s from './schema';
|
|
16
22
|
// polyfill string endsWith
|
|
17
23
|
if (!String.prototype.endsWith) {
|
|
@@ -117,7 +123,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
117
123
|
/**
|
|
118
124
|
* Taken from:
|
|
119
125
|
* https://msazure.visualstudio.com/One/_git/Azure-Kusto-Service?path=/Src/Tools/Kusto.Explorer.Control/QueryEditors/KustoScriptEditor/KustoScriptEditorControl2.xaml.cs&version=GBdev&line=2075&lineEnd=2075&lineStartColumn=9&lineEndColumn=77&lineStyle=plain&_a=contents
|
|
120
|
-
|
|
126
|
+
*/
|
|
121
127
|
this._toOptionKind = (_a = {},
|
|
122
128
|
_a[k2.CompletionKind.AggregateFunction] = k.OptionKind.FunctionAggregation,
|
|
123
129
|
_a[k2.CompletionKind.BuiltInFunction] = k.OptionKind.FunctionScalar,
|
|
@@ -264,7 +270,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
264
270
|
this._newlineAppendPipePolicy.Text = '\n| ';
|
|
265
271
|
}
|
|
266
272
|
KustoLanguageService.prototype.createDatabaseUniqueName = function (clusterName, databaseName) {
|
|
267
|
-
return clusterName
|
|
273
|
+
return "".concat(clusterName, "_").concat(databaseName);
|
|
268
274
|
};
|
|
269
275
|
Object.defineProperty(KustoLanguageService.prototype, "_kustoJsSchemaV2", {
|
|
270
276
|
/**
|
|
@@ -311,20 +317,20 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
311
317
|
*/
|
|
312
318
|
KustoLanguageService.prototype.debugGlobalState = function (globals) {
|
|
313
319
|
// iterate over clusters
|
|
314
|
-
console.log("globals.Clusters.Count: "
|
|
320
|
+
console.log("globals.Clusters.Count: ".concat(globals.Clusters.Count));
|
|
315
321
|
for (var i = 0; i < globals.Clusters.Count; i++) {
|
|
316
322
|
var cluster = globals.Clusters.getItem(i);
|
|
317
|
-
console.log("cluster: "
|
|
323
|
+
console.log("cluster: ".concat(cluster.Name));
|
|
318
324
|
// iterate over databases
|
|
319
|
-
console.log("cluster.Databases.Count: "
|
|
325
|
+
console.log("cluster.Databases.Count: ".concat(cluster.Databases.Count));
|
|
320
326
|
for (var i2 = 0; i2 < cluster.Databases.Count; i2++) {
|
|
321
327
|
var database = cluster.Databases.getItem(i2);
|
|
322
|
-
console.log("cluster.database: ["
|
|
328
|
+
console.log("cluster.database: [".concat(cluster.Name, "].[").concat(database.Name, "]"));
|
|
323
329
|
// iterate over tables
|
|
324
|
-
console.log("cluster.Databases.Tables.Count: "
|
|
330
|
+
console.log("cluster.Databases.Tables.Count: ".concat(database.Tables.Count));
|
|
325
331
|
for (var i3 = 0; i3 < database.Tables.Count; i3++) {
|
|
326
332
|
var table = database.Tables.getItem(i3);
|
|
327
|
-
console.log("cluster.database.table: ["
|
|
333
|
+
console.log("cluster.database.table: [".concat(cluster.Name, "].[").concat(database.Name, "].[").concat(table.Name, "]"));
|
|
328
334
|
}
|
|
329
335
|
}
|
|
330
336
|
}
|
|
@@ -333,7 +339,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
333
339
|
* Prepending the doc of the actual topic at the top
|
|
334
340
|
*/
|
|
335
341
|
KustoLanguageService.prototype.formatHelpTopic = function (helpTopic) {
|
|
336
|
-
return "**"
|
|
342
|
+
return "**".concat(helpTopic.Name, " [(view online)](").concat(helpTopic.Url, ")**\n\n").concat(helpTopic.LongDescription);
|
|
337
343
|
};
|
|
338
344
|
KustoLanguageService.prototype.doCompleteV2 = function (document, position) {
|
|
339
345
|
var _this = this;
|
|
@@ -375,7 +381,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
375
381
|
? {
|
|
376
382
|
// Need to escape dollar sign since it is used as a placeholder in snippet.
|
|
377
383
|
// Usually dollar sign is not a valid character in a function name, but grafana uses macros that start with dollars.
|
|
378
|
-
textToInsert: kItem.EditText.replace('$', '\\$')
|
|
384
|
+
textToInsert: "".concat(kItem.EditText.replace('$', '\\$'), "$0").concat(kItem.AfterText),
|
|
379
385
|
format: ls.InsertTextFormat.Snippet,
|
|
380
386
|
}
|
|
381
387
|
: {
|
|
@@ -785,7 +791,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
785
791
|
this._script = undefined;
|
|
786
792
|
this._parsePropertiesV2 = undefined;
|
|
787
793
|
}
|
|
788
|
-
// since V2 doesn't support control commands, we're initializing V1 intellisense for both cases and we'll going to use V1 intellisense for
|
|
794
|
+
// since V2 doesn't support control commands, we're initializing V1 intellisense for both cases and we'll going to use V1 intellisense for control commands.
|
|
789
795
|
return new Promise(function (resolve, reject) {
|
|
790
796
|
var kustoJsSchema = schema ? KustoLanguageService.convertToKustoJsSchema(schema) : undefined;
|
|
791
797
|
_this._kustoJsSchema = kustoJsSchema;
|
|
@@ -793,13 +799,17 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
793
799
|
resolve(undefined);
|
|
794
800
|
});
|
|
795
801
|
};
|
|
796
|
-
KustoLanguageService.prototype.setParameters = function (
|
|
802
|
+
KustoLanguageService.prototype.setParameters = function (scalarParameters, tabularParameters) {
|
|
797
803
|
if (!this._languageSettings.useIntellisenseV2 || this._schema.clusterType !== 'Engine') {
|
|
798
804
|
throw new Error('setParameters requires intellisense V2 and Engine cluster');
|
|
799
805
|
}
|
|
800
|
-
this._schema.
|
|
801
|
-
|
|
802
|
-
|
|
806
|
+
this._schema.globalScalarParameters = scalarParameters;
|
|
807
|
+
this._schema.globalTabularParameters = tabularParameters;
|
|
808
|
+
var scalarSymbols = scalarParameters.map(function (param) { return KustoLanguageService.createParameterSymbol(param); });
|
|
809
|
+
var tabularSymbols = tabularParameters.map(function (param) {
|
|
810
|
+
return KustoLanguageService.createTabularParameterSymbol(param);
|
|
811
|
+
});
|
|
812
|
+
this._kustoJsSchemaV2 = this._kustoJsSchemaV2.WithParameters(KustoLanguageService.toBridgeList(__spreadArray(__spreadArray([], scalarSymbols, true), tabularSymbols, true)));
|
|
803
813
|
return Promise.resolve(undefined);
|
|
804
814
|
};
|
|
805
815
|
/**
|
|
@@ -808,10 +818,10 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
808
818
|
* @param clusterConnectionString cluster connection string
|
|
809
819
|
* @param databaseInContextName name of database in context
|
|
810
820
|
*/
|
|
811
|
-
KustoLanguageService.prototype.setSchemaFromShowSchema = function (schema, clusterConnectionString, databaseInContextName,
|
|
821
|
+
KustoLanguageService.prototype.setSchemaFromShowSchema = function (schema, clusterConnectionString, databaseInContextName, globalScalarParameters, globalTabularParameters) {
|
|
812
822
|
var _this = this;
|
|
813
823
|
return this.normalizeSchema(schema, clusterConnectionString, databaseInContextName).then(function (normalized) {
|
|
814
|
-
return _this.setSchema(__assign(__assign({}, normalized), {
|
|
824
|
+
return _this.setSchema(__assign(__assign({}, normalized), { globalScalarParameters: globalScalarParameters, globalTabularParameters: globalTabularParameters }));
|
|
815
825
|
});
|
|
816
826
|
};
|
|
817
827
|
/**
|
|
@@ -1446,8 +1456,8 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1446
1456
|
* @param params scalar parameters
|
|
1447
1457
|
*/
|
|
1448
1458
|
KustoLanguageService.scalarParametersToSignature = function (params) {
|
|
1449
|
-
var signatureWithoutParens = params.map(function (param) { return param.name
|
|
1450
|
-
return "("
|
|
1459
|
+
var signatureWithoutParens = params.map(function (param) { return "".concat(param.name, ": ").concat(param.cslType); }).join(', ');
|
|
1460
|
+
return "(".concat(signatureWithoutParens, ")");
|
|
1451
1461
|
};
|
|
1452
1462
|
/**
|
|
1453
1463
|
* Returns something like '(x: string, T: (y: int))'
|
|
@@ -1459,14 +1469,14 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1459
1469
|
.map(function (param) {
|
|
1460
1470
|
if (param.columns) {
|
|
1461
1471
|
var tableSignature = _this.scalarParametersToSignature(param.columns);
|
|
1462
|
-
return param.name
|
|
1472
|
+
return "".concat(param.name, ": ").concat(tableSignature);
|
|
1463
1473
|
}
|
|
1464
1474
|
else {
|
|
1465
|
-
return param.name
|
|
1475
|
+
return "".concat(param.name, ": ").concat(param.cslType);
|
|
1466
1476
|
}
|
|
1467
1477
|
})
|
|
1468
1478
|
.join(', ');
|
|
1469
|
-
return "("
|
|
1479
|
+
return "(".concat(signatureWithoutParens, ")");
|
|
1470
1480
|
};
|
|
1471
1481
|
/**
|
|
1472
1482
|
* converts a function definition to a let statement.
|
|
@@ -1474,7 +1484,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1474
1484
|
*/
|
|
1475
1485
|
KustoLanguageService.toLetStatement = function (fn) {
|
|
1476
1486
|
var signature = this.inputParameterToSignature(fn.inputParameters);
|
|
1477
|
-
return "let "
|
|
1487
|
+
return "let ".concat(fn.name, " = ").concat(signature, " ").concat(fn.body);
|
|
1478
1488
|
};
|
|
1479
1489
|
KustoLanguageService.createColumnSymbol = function (col) {
|
|
1480
1490
|
return new sym.ColumnSymbol(col.name, sym.ScalarTypes.GetSymbol(getCslTypeNameFromClrType(col.type)), col.docstring, null, null, col.examples ? KustoLanguageService.toBridgeList(col.examples) : null);
|
|
@@ -1483,6 +1493,11 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1483
1493
|
var paramSymbol = Kusto.Language.Symbols.ScalarTypes.GetSymbol(getCslTypeNameFromClrType(param.type));
|
|
1484
1494
|
return new sym.ParameterSymbol(param.name, paramSymbol, null);
|
|
1485
1495
|
};
|
|
1496
|
+
KustoLanguageService.createTabularParameterSymbol = function (param) {
|
|
1497
|
+
var columnSymbols = param.columns.map(function (col) { return KustoLanguageService.createColumnSymbol(col); });
|
|
1498
|
+
var para = new Kusto.Language.Symbols.TableSymbol.$ctor4(param.name, columnSymbols);
|
|
1499
|
+
return new sym.ParameterSymbol(param.name, para, param.docstring);
|
|
1500
|
+
};
|
|
1486
1501
|
KustoLanguageService.createParameter = function (param) {
|
|
1487
1502
|
if (!param.columns) {
|
|
1488
1503
|
var paramSymbol = Kusto.Language.Symbols.ScalarTypes.GetSymbol(getCslTypeNameFromClrType(param.type));
|
|
@@ -1532,6 +1547,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1532
1547
|
return databaseSymbol;
|
|
1533
1548
|
};
|
|
1534
1549
|
KustoLanguageService.prototype.convertToKustoJsSchemaV2 = function (schema) {
|
|
1550
|
+
var _a, _b;
|
|
1535
1551
|
var cached = this._schemaCache[schema.cluster.connectionString];
|
|
1536
1552
|
// create a cache entry for the cluster if non yet exists.
|
|
1537
1553
|
if (!cached) {
|
|
@@ -1575,12 +1591,16 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1575
1591
|
if (databaseInContext) {
|
|
1576
1592
|
globalState = globalState.WithDatabase(databaseInContext);
|
|
1577
1593
|
}
|
|
1578
|
-
// Inject global parameters to global scope.
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1594
|
+
// Inject global scalar parameters to global scope.
|
|
1595
|
+
var scalarParameters = ((_a = schema.globalScalarParameters) !== null && _a !== void 0 ? _a : []).map(function (param) {
|
|
1596
|
+
return KustoLanguageService.createParameterSymbol(param);
|
|
1597
|
+
});
|
|
1598
|
+
// Inject global tabular parameters to global scope.
|
|
1599
|
+
var tabularParameters = ((_b = schema.globalTabularParameters) !== null && _b !== void 0 ? _b : []).map(function (param) {
|
|
1600
|
+
return KustoLanguageService.createTabularParameterSymbol(param);
|
|
1601
|
+
});
|
|
1602
|
+
if (tabularParameters.length || scalarParameters.length) {
|
|
1603
|
+
globalState = globalState.WithParameters(KustoLanguageService.toBridgeList(__spreadArray(__spreadArray([], scalarParameters, true), tabularParameters, true)));
|
|
1584
1604
|
}
|
|
1585
1605
|
return globalState;
|
|
1586
1606
|
};
|
|
@@ -1617,7 +1637,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1617
1637
|
*/
|
|
1618
1638
|
KustoLanguageService.prototype.getSortText = function (order) {
|
|
1619
1639
|
if (order <= 0) {
|
|
1620
|
-
throw new RangeError("order should be a number >= 1. instead got "
|
|
1640
|
+
throw new RangeError("order should be a number >= 1. instead got ".concat(order));
|
|
1621
1641
|
}
|
|
1622
1642
|
var sortText = '';
|
|
1623
1643
|
var numCharacters = 26; // "z" - "a" + 1;
|
|
@@ -1,23 +1,69 @@
|
|
|
1
1
|
export var KustoLanguageDefinition = {
|
|
2
2
|
name: 'kusto',
|
|
3
3
|
mimeTypes: ['text/kusto'],
|
|
4
|
-
displayName:
|
|
5
|
-
defaultToken:
|
|
6
|
-
brackets: [
|
|
7
|
-
['
|
|
4
|
+
displayName: 'Kusto',
|
|
5
|
+
defaultToken: 'invalid',
|
|
6
|
+
brackets: [
|
|
7
|
+
['[', ']', 'delimiter.square'],
|
|
8
|
+
['(', ')', 'delimiter.parenthesis'],
|
|
9
|
+
],
|
|
8
10
|
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
9
11
|
// .slice() call is for creating a shallow copy of the array since bridge.net shoves a $type property on the array which monaco doesn't like.
|
|
10
12
|
promotedOperatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
|
|
11
13
|
operatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.OperatorCommandTokens.slice(0),
|
|
12
14
|
keywords: [
|
|
13
|
-
'by',
|
|
14
|
-
'
|
|
15
|
+
'by',
|
|
16
|
+
'on',
|
|
17
|
+
'contains',
|
|
18
|
+
'notcontains',
|
|
19
|
+
'containscs',
|
|
20
|
+
'notcontainscs',
|
|
21
|
+
'startswith',
|
|
22
|
+
'has',
|
|
23
|
+
'matches',
|
|
24
|
+
'regex',
|
|
25
|
+
'true',
|
|
26
|
+
'false',
|
|
27
|
+
'and',
|
|
28
|
+
'or',
|
|
29
|
+
'typeof',
|
|
30
|
+
'int',
|
|
31
|
+
'string',
|
|
32
|
+
'date',
|
|
33
|
+
'datetime',
|
|
34
|
+
'time',
|
|
35
|
+
'long',
|
|
36
|
+
'real',
|
|
37
|
+
'boolean',
|
|
38
|
+
'bool',
|
|
15
39
|
],
|
|
16
40
|
operators: ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'],
|
|
17
41
|
builtinFunctions: [
|
|
18
|
-
'countof',
|
|
19
|
-
'
|
|
20
|
-
'
|
|
42
|
+
'countof',
|
|
43
|
+
'bin',
|
|
44
|
+
'extentid',
|
|
45
|
+
'extract',
|
|
46
|
+
'extractjson',
|
|
47
|
+
'floor',
|
|
48
|
+
'iif',
|
|
49
|
+
'isnull',
|
|
50
|
+
'isnotnull',
|
|
51
|
+
'notnull',
|
|
52
|
+
'isempty',
|
|
53
|
+
'isnotempty',
|
|
54
|
+
'notempty',
|
|
55
|
+
'now',
|
|
56
|
+
're2',
|
|
57
|
+
'strcat',
|
|
58
|
+
'strlen',
|
|
59
|
+
'toupper',
|
|
60
|
+
'tostring',
|
|
61
|
+
'count',
|
|
62
|
+
'cnt',
|
|
63
|
+
'sum',
|
|
64
|
+
'min',
|
|
65
|
+
'max',
|
|
66
|
+
'avg',
|
|
21
67
|
],
|
|
22
68
|
tokenizer: {
|
|
23
69
|
root: [
|
|
@@ -30,7 +76,9 @@ export var KustoLanguageDefinition = {
|
|
|
30
76
|
[/[;,.]/, 'delimiter'],
|
|
31
77
|
[/[()\[\]]/, '@brackets'],
|
|
32
78
|
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
|
33
|
-
[
|
|
79
|
+
[
|
|
80
|
+
/[\w@#\-$]+/,
|
|
81
|
+
{
|
|
34
82
|
cases: {
|
|
35
83
|
'@keywords': 'keyword',
|
|
36
84
|
'@promotedOperatorCommandTokens': 'operator.sql',
|
|
@@ -38,39 +86,42 @@ export var KustoLanguageDefinition = {
|
|
|
38
86
|
'@operators': 'operator',
|
|
39
87
|
'@builtinFunctions': 'predefined',
|
|
40
88
|
'@default': 'identifier',
|
|
41
|
-
}
|
|
42
|
-
}
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
43
92
|
],
|
|
44
93
|
whitespace: [[/\s+/, 'white']],
|
|
45
|
-
comments: [[
|
|
94
|
+
comments: [['\\/\\/+.*', 'comment']],
|
|
46
95
|
numbers: [
|
|
47
96
|
[/0[xX][0-9a-fA-F]*/, 'number'],
|
|
48
97
|
[/[$][+-]*\d*(\.\d*)?/, 'number'],
|
|
49
|
-
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
|
|
98
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number'],
|
|
50
99
|
],
|
|
51
100
|
strings: [
|
|
52
101
|
[/H'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
53
102
|
[/h'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
54
|
-
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
|
103
|
+
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
55
104
|
],
|
|
56
105
|
string: [
|
|
57
106
|
[/[^']+/, 'string'],
|
|
58
107
|
[/''/, 'string'],
|
|
59
|
-
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
108
|
+
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
|
|
60
109
|
],
|
|
61
110
|
dqstrings: [
|
|
62
111
|
[/H"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
63
112
|
[/h"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
64
|
-
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }]
|
|
113
|
+
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
65
114
|
],
|
|
66
115
|
dqstring: [
|
|
67
116
|
[/[^"]+/, 'string'],
|
|
68
117
|
[/""/, 'string'],
|
|
69
|
-
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
118
|
+
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
|
|
70
119
|
],
|
|
71
|
-
literals: [
|
|
120
|
+
literals: [
|
|
121
|
+
[/datetime\(\d{4}-\d{2}-\d{2}(\s+\d{2}:\d{2}(:\d{2}(\.\d{0,3})?)?)?\)/, 'number'],
|
|
72
122
|
[/time\((\d+(s(ec(onds?)?)?|m(in(utes?)?)?|h(ours?)?|d(ays?)?)|(\s*(('[^']+')|("[^"]+"))\s*))\)/, 'number'],
|
|
73
123
|
[/guid\([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}\)/, 'number'],
|
|
74
|
-
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number']
|
|
75
|
-
|
|
124
|
+
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number'],
|
|
125
|
+
],
|
|
126
|
+
},
|
|
76
127
|
};
|
|
@@ -19,7 +19,7 @@ var dotnetTypeToKustoType = {
|
|
|
19
19
|
'Newtonsoft.Json.Linq.JObject': 'dynamic',
|
|
20
20
|
'Newtonsoft.Json.Linq.JToken': 'dynamic',
|
|
21
21
|
'System.Object': 'dynamic',
|
|
22
|
-
'System.Data.SqlTypes.SqlDecimal': 'decimal'
|
|
22
|
+
'System.Data.SqlTypes.SqlDecimal': 'decimal',
|
|
23
23
|
};
|
|
24
24
|
export var getCslTypeNameFromClrType = function (clrType) { return dotnetTypeToKustoType[clrType] || clrType; };
|
|
25
25
|
var kustoTypeToEntityDataType = {
|
|
@@ -38,27 +38,27 @@ var kustoTypeToEntityDataType = {
|
|
|
38
38
|
datetime: 'DateTime',
|
|
39
39
|
string: 'String',
|
|
40
40
|
dynamic: 'Dynamic',
|
|
41
|
-
timespan: 'TimeSpan'
|
|
41
|
+
timespan: 'TimeSpan',
|
|
42
42
|
};
|
|
43
43
|
export var getEntityDataTypeFromCslType = function (cslType) { return kustoTypeToEntityDataType[cslType] || cslType; };
|
|
44
44
|
export var getCallName = function (fn) {
|
|
45
|
-
return fn.name
|
|
45
|
+
return "".concat(fn.name, "(").concat(fn.inputParameters.map(function (p) { return "{".concat(p.name, "}"); }).join(','), ")");
|
|
46
46
|
};
|
|
47
47
|
export var getExpression = function (fn) {
|
|
48
|
-
return "let "
|
|
48
|
+
return "let ".concat(fn.name, " = ").concat(getInputParametersAsCslString(fn.inputParameters), " ").concat(fn.body);
|
|
49
49
|
};
|
|
50
50
|
export var getInputParametersAsCslString = function (inputParameters) {
|
|
51
|
-
return "("
|
|
51
|
+
return "(".concat(inputParameters.map(function (inputParameter) { return getInputParameterAsCslString(inputParameter); }).join(','), ")");
|
|
52
52
|
};
|
|
53
53
|
var getInputParameterAsCslString = function (inputParameter) {
|
|
54
54
|
// If this is a tabular parameter
|
|
55
55
|
if (inputParameter.columns && inputParameter.columns.length > 0) {
|
|
56
56
|
var attributesAsString = inputParameter.columns
|
|
57
|
-
.map(function (col) { return col.name
|
|
57
|
+
.map(function (col) { return "".concat(col.name, ":").concat(col.cslType || getCslTypeNameFromClrType(col.type)); })
|
|
58
58
|
.join(',');
|
|
59
|
-
return inputParameter.name
|
|
59
|
+
return "".concat(inputParameter.name, ":").concat(attributesAsString === '' ? '*' : attributesAsString);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
return inputParameter.name
|
|
62
|
+
return "".concat(inputParameter.name, ":").concat(inputParameter.cslType || getCslTypeNameFromClrType(inputParameter.type));
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -61,7 +61,7 @@ var defaultLanguageSettings = {
|
|
|
61
61
|
},
|
|
62
62
|
enableQueryWarnings: false,
|
|
63
63
|
enableQuerySuggestions: false,
|
|
64
|
-
|
|
64
|
+
disabledDiagnosticCodes: [],
|
|
65
65
|
};
|
|
66
66
|
function getKustoWorker() {
|
|
67
67
|
return new Promise(function (resolve, reject) {
|
|
@@ -89,7 +89,7 @@ export function setupMonacoKusto(monacoInstance) {
|
|
|
89
89
|
id: 'kusto',
|
|
90
90
|
extensions: ['.csl', '.kql'],
|
|
91
91
|
});
|
|
92
|
-
// TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution
|
|
92
|
+
// TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution registrar but it's no exposed in the API.
|
|
93
93
|
// https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
|
|
94
94
|
var commandHighlighter;
|
|
95
95
|
var commandFormatter;
|
|
@@ -164,14 +164,15 @@ export function setupMonacoKusto(monacoInstance) {
|
|
|
164
164
|
});
|
|
165
165
|
function triggerSuggestDialogWhenCompletionItemSelected(editor) {
|
|
166
166
|
editor.onDidChangeCursorSelection(function (event) {
|
|
167
|
-
// checking the condition inside the event makes sure we will stay up to date
|
|
167
|
+
// checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
|
|
168
168
|
if (kustoDefaults &&
|
|
169
169
|
kustoDefaults.languageSettings &&
|
|
170
170
|
kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
171
171
|
var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
|
|
172
172
|
// If the word at the current position is not null - meaning we did not add a space after completion.
|
|
173
173
|
// In this case we don't want to activate the eager mode, since it will display the current selected word..
|
|
174
|
-
if (!didAcceptSuggestion ||
|
|
174
|
+
if (!didAcceptSuggestion ||
|
|
175
|
+
editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
event.selection;
|
package/release/esm/monaco.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare module monaco.languages.kusto {
|
|
|
25
25
|
formatter?: FormatterOptions;
|
|
26
26
|
enableQueryWarnings?: boolean;
|
|
27
27
|
enableQuerySuggestions?: boolean;
|
|
28
|
-
|
|
28
|
+
disabledDiagnosticCodes?: string[];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface SyntaxErrorAsMarkDownOptions {
|
|
@@ -38,7 +38,7 @@ declare module monaco.languages.kusto {
|
|
|
38
38
|
indentationSize?: number;
|
|
39
39
|
pipeOperatorStyle?: FormatterPlacementStyle;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
export type FormatterPlacementStyle = 'None' | 'NewLine' | 'Smart';
|
|
43
43
|
|
|
44
44
|
export interface LanguageServiceDefaults {
|
|
@@ -73,7 +73,8 @@ declare module monaco.languages.kusto {
|
|
|
73
73
|
schema: any,
|
|
74
74
|
clusterConnectionString: string,
|
|
75
75
|
databaseInContextName: string,
|
|
76
|
-
|
|
76
|
+
globalScalarParameters: ScalarParameter[],
|
|
77
|
+
globalTabularParameters: TabularParameter[]
|
|
77
78
|
): Promise<void>;
|
|
78
79
|
normalizeSchema(
|
|
79
80
|
schema: any,
|
|
@@ -98,7 +99,7 @@ declare module monaco.languages.kusto {
|
|
|
98
99
|
|
|
99
100
|
/**
|
|
100
101
|
* Get all the ambient parameters defined in global scope.
|
|
101
|
-
* Ambient parameters are parameters that are not defined in the syntax such as in a query
|
|
102
|
+
* Ambient parameters are parameters that are not defined in the syntax such as in a query parameter declaration.
|
|
102
103
|
* These are parameters that are injected from outside, usually by a UX application that would like to offer
|
|
103
104
|
* the user intellisense for a symbol, without forcing them to write a query declaration statement.
|
|
104
105
|
* Usually the same application injects the query declaration statement and the parameter values when
|
|
@@ -120,14 +121,22 @@ declare module monaco.languages.kusto {
|
|
|
120
121
|
doDocumentFormat(uri: string): Promise<ls.TextEdit[]>;
|
|
121
122
|
doRangeFormat(uri: string, range: ls.Range): Promise<ls.TextEdit[]>;
|
|
122
123
|
doCurrentCommandFormat(uri: string, caretPosition: ls.Position): Promise<ls.TextEdit[]>;
|
|
123
|
-
doValidation(
|
|
124
|
-
|
|
124
|
+
doValidation(
|
|
125
|
+
uri: string,
|
|
126
|
+
intervals: { start: number; end: number }[],
|
|
127
|
+
includeWarnings?: boolean,
|
|
128
|
+
includeSuggestions?: boolean
|
|
129
|
+
): Promise<ls.Diagnostic[]>;
|
|
130
|
+
setParameters(
|
|
131
|
+
scalarParameters: readonly ScalarParameter[],
|
|
132
|
+
tabularParameters: readonly TabularParameter[]
|
|
133
|
+
): void;
|
|
125
134
|
/**
|
|
126
|
-
* Get all the database references from the current command.
|
|
135
|
+
* Get all the database references from the current command.
|
|
127
136
|
* If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
|
|
128
137
|
* This method should be used to get all the cross-databases in a command, then schema for the database should be fetched and added with addDatabaseToSchema.
|
|
129
138
|
* @example
|
|
130
|
-
* If the current command includes: cluster('help').database('Samples')
|
|
139
|
+
* If the current command includes: cluster('help').database('Samples')
|
|
131
140
|
* getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
|
|
132
141
|
*/
|
|
133
142
|
getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
|
|
@@ -149,7 +158,7 @@ declare module monaco.languages.kusto {
|
|
|
149
158
|
* @param clusterName the name of the cluster as returned from getDatabaseReferences/getClusterReferences.
|
|
150
159
|
* @example
|
|
151
160
|
* - User enters cluster('help').database('Samples')
|
|
152
|
-
* - hosting app calls getDatabaseReferences which returns [{ clusterName: 'help', databaseName: 'Samples' }].
|
|
161
|
+
* - hosting app calls getDatabaseReferences which returns [{ clusterName: 'help', databaseName: 'Samples' }].
|
|
153
162
|
* - hosting app fetches the database Schema from https://help.kusto.windows.net
|
|
154
163
|
* - hosting app calls 'addDatabaseToSchema' with the database's schema.
|
|
155
164
|
* - now, when user types cluster('help').database('Samples') then the auto complete list will show all the tables.
|
|
@@ -160,12 +169,12 @@ declare module monaco.languages.kusto {
|
|
|
160
169
|
* @param clusterName the name of the cluster as returned in getClusterReferences.
|
|
161
170
|
* @example
|
|
162
171
|
* - User enters cluster('help')
|
|
163
|
-
* - hosting app calls getClusterReferences which returns [{ clusterName: 'help' }].
|
|
172
|
+
* - hosting app calls getClusterReferences which returns [{ clusterName: 'help' }].
|
|
164
173
|
* - hosting app fetches the list of databases from https://help.kusto.windows.net
|
|
165
174
|
* - hosting app calls addClusterToSchema with the list of databases.
|
|
166
175
|
* - now, when user type `cluster('help').database(` then the auto complete list will show all the databases.
|
|
167
176
|
*/
|
|
168
|
-
addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
|
|
177
|
+
addClusterToSchema(uri: string, clusterName: string, databasesNames: readonly string[]): Promise<void>;
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
/**
|
|
@@ -193,6 +202,12 @@ declare module monaco.languages.kusto {
|
|
|
193
202
|
cslDefaultValue?: string;
|
|
194
203
|
}
|
|
195
204
|
|
|
205
|
+
export interface TabularParameter {
|
|
206
|
+
name: string;
|
|
207
|
+
columns: Column[];
|
|
208
|
+
docstring?: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
196
211
|
// an input parameter either be a scalar in which case it has a name, type and cslType, or it can be columnar, in which case
|
|
197
212
|
// it will have a name, and a list of scalar types which are the column types.
|
|
198
213
|
export type InputParameter = ScalarParameter & { columns?: ScalarParameter[] };
|
|
@@ -283,11 +298,11 @@ declare module monaco.languages.kusto {
|
|
|
283
298
|
|
|
284
299
|
export interface DatabaseReference {
|
|
285
300
|
databaseName: string;
|
|
286
|
-
clusterName: string;
|
|
287
|
-
}
|
|
301
|
+
clusterName: string;
|
|
302
|
+
}
|
|
288
303
|
|
|
289
304
|
export interface ClusterReference {
|
|
290
|
-
clusterName: string;
|
|
305
|
+
clusterName: string;
|
|
291
306
|
}
|
|
292
307
|
|
|
293
308
|
export type RenderOptionKeys = keyof RenderOptions;
|