@kusto/monaco-kusto
Version:
CSL, KQL plugin for the Monaco Editor
110 lines (101 loc) • 4.45 kB
JavaScript
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* monaco-kusto version: 13.1.1(178105a761985a9b7c16d45b528f829e1c112ff0)
* Released under the MIT license
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
*-----------------------------------------------------------------------------*/
define('vs/language/kusto/schema-46504958', ['exports'], (function (exports) { 'use strict';
// Definition of schema object in the context of language services. This model is exposed to consumers of this library.
/**
* 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 it will have a name, and a list
* of scalar types which are the column types.
*/
/**
* Schema types:
* Engine – The main schema type. Contains clusters, databases, tables, table columns and functions.
* Cluster Manager – Internal only. A schema for clusters that manages other clusters.
* Data Management – Internal only. A schema for ingestion point operations.
*/
var dotnetTypeToKustoType = {
'System.SByte': 'bool',
'System.Byte': 'uint8',
'System.Int16': 'int16',
'System.UInt16': 'uint16',
'System.Int32': 'int',
'System.UInt32': 'uint',
'System.Int64': 'long',
'System.UInt64': 'ulong',
'System.String': 'string',
'System.Single': 'float',
'System.Double': 'real',
'System.DateTime': 'datetime',
'System.TimeSpan': 'timespan',
'System.Guid': 'guid',
'System.Boolean': 'bool',
'Newtonsoft.Json.Linq.JArray': 'dynamic',
'Newtonsoft.Json.Linq.JObject': 'dynamic',
'Newtonsoft.Json.Linq.JToken': 'dynamic',
'System.Object': 'dynamic',
'System.Data.SqlTypes.SqlDecimal': 'decimal'
};
var getCslTypeNameFromClrType = function getCslTypeNameFromClrType(clrType) {
return dotnetTypeToKustoType[clrType] || clrType;
};
var kustoTypeToEntityDataType = {
object: 'Object',
bool: 'Boolean',
uint8: 'Byte',
int16: 'Int16',
uint16: 'UInt16',
int: 'Int32',
uint: 'UInt32',
long: 'Int64',
ulong: 'UInt64',
float: 'Single',
real: 'Double',
decimal: 'Decimal',
datetime: 'DateTime',
string: 'String',
dynamic: 'Dynamic',
timespan: 'TimeSpan'
};
var getEntityDataTypeFromCslType = function getEntityDataTypeFromCslType(cslType) {
return kustoTypeToEntityDataType[cslType] || cslType;
};
var getCallName = function getCallName(fn) {
return "".concat(fn.name, "(").concat(fn.inputParameters.map(function (p) {
return "{".concat(p.name, "}");
}).join(','), ")");
};
var getExpression = function getExpression(fn) {
return "let ".concat(fn.name, " = ").concat(getInputParametersAsCslString(fn.inputParameters), " ").concat(fn.body);
};
var getInputParametersAsCslString = function getInputParametersAsCslString(inputParameters) {
return "(".concat(inputParameters.map(function (inputParameter) {
return getInputParameterAsCslString(inputParameter);
}).join(','), ")");
};
var getInputParameterAsCslString = function getInputParameterAsCslString(inputParameter) {
// If this is a tabular parameter
if (inputParameter.columns && inputParameter.columns.length > 0) {
var attributesAsString = inputParameter.columns.map(function (col) {
return "".concat(col.name, ":").concat(col.cslType || getCslTypeNameFromClrType(col.type));
}).join(',');
return "".concat(inputParameter.name, ":").concat(attributesAsString === '' ? '*' : attributesAsString);
} else {
return "".concat(inputParameter.name, ":").concat(inputParameter.cslType || getCslTypeNameFromClrType(inputParameter.type));
}
};
/**
* This is the schema of the output of kusto command
* .show schema as json
*/
var showSchema;
exports.getCallName = getCallName;
exports.getCslTypeNameFromClrType = getCslTypeNameFromClrType;
exports.getEntityDataTypeFromCslType = getEntityDataTypeFromCslType;
exports.getExpression = getExpression;
exports.getInputParametersAsCslString = getInputParametersAsCslString;
exports.showSchema = showSchema;
}));