in package/src/languageServiceManager/kustoLanguageService.ts [1568:1640]
private static convertToKustoJsSchema(schema: s.Schema): k.KustoIntelliSenseQuerySchema | CmSchema | undefined {
switch (schema.clusterType) {
case 'Engine':
const currentDatabaseName = schema.database ? schema.database.name : undefined;
const kCluster = new k.KustoIntelliSenseClusterEntity();
let kDatabaseInContext: k.KustoIntelliSenseDatabaseEntity = undefined;
kCluster.ConnectionString = schema.cluster.connectionString;
const databases = [];
schema.cluster.databases.forEach((database) => {
const kDatabase = new k.KustoIntelliSenseDatabaseEntity();
kDatabase.Name = database.name;
const tables = [];
database.tables.forEach((table) => {
const kTable = new k.KustoIntelliSenseTableEntity();
kTable.Name = table.name;
const cols = [];
table.columns.forEach((column) => {
const kColumn = new k.KustoIntelliSenseColumnEntity();
kColumn.Name = column.name;
kColumn.TypeCode = k.EntityDataType[getEntityDataTypeFromCslType(column.type)];
cols.push(kColumn);
});
kTable.Columns = new Bridge.ArrayEnumerable(cols);
tables.push(kTable);
});
const functions = [];
database.functions.forEach((fn) => {
const kFunction = new k.KustoIntelliSenseFunctionEntity();
(kFunction.Name = fn.name),
(kFunction.CallName = s.getCallName(fn)),
(kFunction.Expression = s.getExpression(fn)),
functions.push(kFunction);
});
kDatabase.Tables = new Bridge.ArrayEnumerable(tables);
kDatabase.Functions = new Bridge.ArrayEnumerable(functions);
databases.push(kDatabase);
if (database.name == currentDatabaseName) {
kDatabaseInContext = kDatabase;
}
});
kCluster.Databases = new Bridge.ArrayEnumerable(databases);
const kSchema = new k.KustoIntelliSenseQuerySchema(kCluster, kDatabaseInContext);
return kSchema;
case 'ClusterManager':
const accounts = schema.accounts.map((account) => {
const kAccount = new k.KustoIntelliSenseAccountEntity();
kAccount.Name = account;
return kAccount;
});
const services = schema.services.map((service) => {
const kService = new k.KustoIntelliSenseServiceEntity();
kService.Name = service;
return kService;
});
const connectionString = schema.connectionString;
const result: CmSchema = {
accounts,
services,
connectionString,
};
return result;
case 'DataManagement':
return undefined;
default:
return assertNever(schema);
}
}