@kusto/monaco-kusto 4.1.0 → 4.1.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kusto/monaco-kusto",
3
- "version": "4.1.0",
3
+ "version": "4.1.4",
4
4
  "description": "CSL, KQL plugin for the Monaco Editor",
5
5
  "author": {
6
6
  "name": "Microsoft"
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@kusto/language-service": "2.0.0-beta.0",
58
- "@kusto/language-service-next": "0.0.51"
58
+ "@kusto/language-service-next": "0.0.53"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "monaco-editor": "^0.24.0"
@@ -6535,6 +6535,8 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6535
6535
  */
6536
6536
  set: function (globalState) {
6537
6537
  this.__kustoJsSchemaV2 = globalState;
6538
+ this._clustersSetInGlobalState.clear();
6539
+ this._nonEmptyDatabaseSetInGlobalState.clear();
6538
6540
  // create 2 Sets with cluster names and database names based on the updated Global State.
6539
6541
  for (var i = 0; i < globalState.Clusters.Count; i++) {
6540
6542
  var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
@@ -6775,14 +6777,14 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6775
6777
  // Keep only unique clusters that aren't already exist in the Global State
6776
6778
  for (var i = 0; i < clusterReferences.Count; i++) {
6777
6779
  var clusterReference = clusterReferences.getItem(i);
6778
- var clusterHostName = clusterReference.Cluster;
6780
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
6779
6781
  // ignore duplicates
6780
6782
  if (newClustersReferencesSet.has(clusterHostName)) {
6781
6783
  continue;
6782
6784
  }
6783
6785
  newClustersReferencesSet.add(clusterHostName);
6784
6786
  // ignore references that are already in the GlobalState.
6785
- if (!this._clustersSetInGlobalState.has(clusterHostName.toLowerCase())) {
6787
+ if (!this._clustersSetInGlobalState.has(clusterHostName)) {
6786
6788
  newClustersReferences.push({ clusterName: clusterHostName });
6787
6789
  }
6788
6790
  }
@@ -6800,8 +6802,9 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6800
6802
  var newDatabasesReferencesSet = new Set();
6801
6803
  for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
6802
6804
  var databaseReference = databasesReferences.getItem(i1);
6805
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
6803
6806
  // ignore duplicates
6804
- var databaseReferenceUniqueId = this.createDatabaseUniqueName(databaseReference.Cluster, databaseReference.Database);
6807
+ var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
6805
6808
  if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
6806
6809
  continue;
6807
6810
  }
@@ -6983,19 +6986,16 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6983
6986
  return Promise.resolve();
6984
6987
  };
6985
6988
  KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
6986
- var _this = this;
6987
- return new Promise(function (resolve) {
6988
- var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
6989
- var cluster = _this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
6990
- if (!cluster) {
6991
- cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
6992
- }
6993
- var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
6994
- cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
6995
- _this._kustoJsSchemaV2 = _this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
6996
- _this._script = k2.CodeScript.From$1(document.getText(), _this._kustoJsSchemaV2);
6997
- resolve();
6998
- });
6989
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
6990
+ var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
6991
+ if (!cluster) {
6992
+ cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
6993
+ }
6994
+ var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
6995
+ cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
6996
+ this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
6997
+ this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
6998
+ return Promise.resolve();
6999
6999
  };
7000
7000
  KustoLanguageService.prototype.setSchema = function (schema) {
7001
7001
  var _this = this;
@@ -8034,7 +8034,7 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
8034
8034
  var document = this._getTextDocument(uri);
8035
8035
  if (!document) {
8036
8036
  console.error("addClusterToSchema: document is " + document + ". uri is " + uri);
8037
- return null;
8037
+ return Promise.resolve();
8038
8038
  }
8039
8039
  return this._languageService.addClusterToSchema(document, clusterName, databasesNames);
8040
8040
  };
@@ -8042,7 +8042,7 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
8042
8042
  var document = this._getTextDocument(uri);
8043
8043
  if (!document) {
8044
8044
  console.error("addDatabaseToSchema: document is " + document + ". uri is " + uri);
8045
- return null;
8045
+ return Promise.resolve();
8046
8046
  }
8047
8047
  return this._languageService.addDatabaseToSchema(document, clusterName, databaseSchema);
8048
8048
  };
@@ -8218,10 +8218,16 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
8218
8218
  };
8219
8219
  KustoWorker.prototype.getClusterReferences = function (uri, cursorOffset) {
8220
8220
  var document = this._getTextDocument(uri);
8221
+ if (!document) {
8222
+ return Promise.resolve(null);
8223
+ }
8221
8224
  return this._languageService.getClusterReferences(document, cursorOffset);
8222
8225
  };
8223
8226
  KustoWorker.prototype.getDatabaseReferences = function (uri, cursorOffset) {
8224
8227
  var document = this._getTextDocument(uri);
8228
+ if (!document) {
8229
+ return Promise.resolve(null);
8230
+ }
8225
8231
  return this._languageService.getDatabaseReferences(document, cursorOffset);
8226
8232
  };
8227
8233
  KustoWorker.prototype._getTextDocument = function (uri) {
@@ -15,7 +15,7 @@ var KustoWorker = /** @class */ (function () {
15
15
  var document = this._getTextDocument(uri);
16
16
  if (!document) {
17
17
  console.error("addClusterToSchema: document is " + document + ". uri is " + uri);
18
- return null;
18
+ return Promise.resolve();
19
19
  }
20
20
  return this._languageService.addClusterToSchema(document, clusterName, databasesNames);
21
21
  };
@@ -23,7 +23,7 @@ var KustoWorker = /** @class */ (function () {
23
23
  var document = this._getTextDocument(uri);
24
24
  if (!document) {
25
25
  console.error("addDatabaseToSchema: document is " + document + ". uri is " + uri);
26
- return null;
26
+ return Promise.resolve();
27
27
  }
28
28
  return this._languageService.addDatabaseToSchema(document, clusterName, databaseSchema);
29
29
  };
@@ -199,10 +199,16 @@ var KustoWorker = /** @class */ (function () {
199
199
  };
200
200
  KustoWorker.prototype.getClusterReferences = function (uri, cursorOffset) {
201
201
  var document = this._getTextDocument(uri);
202
+ if (!document) {
203
+ return Promise.resolve(null);
204
+ }
202
205
  return this._languageService.getClusterReferences(document, cursorOffset);
203
206
  };
204
207
  KustoWorker.prototype.getDatabaseReferences = function (uri, cursorOffset) {
205
208
  var document = this._getTextDocument(uri);
209
+ if (!document) {
210
+ return Promise.resolve(null);
211
+ }
206
212
  return this._languageService.getDatabaseReferences(document, cursorOffset);
207
213
  };
208
214
  KustoWorker.prototype._getTextDocument = function (uri) {
@@ -273,6 +273,8 @@ var KustoLanguageService = /** @class */ (function () {
273
273
  */
274
274
  set: function (globalState) {
275
275
  this.__kustoJsSchemaV2 = globalState;
276
+ this._clustersSetInGlobalState.clear();
277
+ this._nonEmptyDatabaseSetInGlobalState.clear();
276
278
  // create 2 Sets with cluster names and database names based on the updated Global State.
277
279
  for (var i = 0; i < globalState.Clusters.Count; i++) {
278
280
  var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
@@ -513,14 +515,14 @@ var KustoLanguageService = /** @class */ (function () {
513
515
  // Keep only unique clusters that aren't already exist in the Global State
514
516
  for (var i = 0; i < clusterReferences.Count; i++) {
515
517
  var clusterReference = clusterReferences.getItem(i);
516
- var clusterHostName = clusterReference.Cluster;
518
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
517
519
  // ignore duplicates
518
520
  if (newClustersReferencesSet.has(clusterHostName)) {
519
521
  continue;
520
522
  }
521
523
  newClustersReferencesSet.add(clusterHostName);
522
524
  // ignore references that are already in the GlobalState.
523
- if (!this._clustersSetInGlobalState.has(clusterHostName.toLowerCase())) {
525
+ if (!this._clustersSetInGlobalState.has(clusterHostName)) {
524
526
  newClustersReferences.push({ clusterName: clusterHostName });
525
527
  }
526
528
  }
@@ -538,8 +540,9 @@ var KustoLanguageService = /** @class */ (function () {
538
540
  var newDatabasesReferencesSet = new Set();
539
541
  for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
540
542
  var databaseReference = databasesReferences.getItem(i1);
543
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
541
544
  // ignore duplicates
542
- var databaseReferenceUniqueId = this.createDatabaseUniqueName(databaseReference.Cluster, databaseReference.Database);
545
+ var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
543
546
  if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
544
547
  continue;
545
548
  }
@@ -721,19 +724,16 @@ var KustoLanguageService = /** @class */ (function () {
721
724
  return Promise.resolve();
722
725
  };
723
726
  KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
724
- var _this = this;
725
- return new Promise(function (resolve) {
726
- var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
727
- var cluster = _this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
728
- if (!cluster) {
729
- cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
730
- }
731
- var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
732
- cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
733
- _this._kustoJsSchemaV2 = _this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
734
- _this._script = k2.CodeScript.From$1(document.getText(), _this._kustoJsSchemaV2);
735
- resolve();
736
- });
727
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
728
+ var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
729
+ if (!cluster) {
730
+ cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
731
+ }
732
+ var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
733
+ cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
734
+ this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
735
+ this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
736
+ return Promise.resolve();
737
737
  };
738
738
  KustoLanguageService.prototype.setSchema = function (schema) {
739
739
  var _this = this;
@@ -121,29 +121,46 @@ declare module monaco.languages.kusto {
121
121
  setParameters(parameters: ScalarParameter[]): void;
122
122
  /**
123
123
  * Get all the database references from the current command.
124
- * If database's schema is already cached it will not be returned.
124
+ * If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
125
125
  * 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.
126
126
  * @example
127
127
  * If the current command includes: cluster('help').database('Samples')
128
- * it returns [{ clusterName: 'help', databaseName 'Samples' }]
128
+ * getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
129
129
  */
130
130
  getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
131
131
  /**
132
132
  * Get all the cluster references from the current command.
133
133
  * If cluster's schema is already cached it will not be returned.
134
134
  * This method should be used to get all the cross-clusters in a command, then schema for the cluster should be fetched and added with addClusterToSchema.
135
+ * cluster name is returned exactly as written in the KQL `cluster(<cluster name>)` function.
135
136
  * @example
136
137
  * If the current command includes: cluster('help')
137
138
  * it returns [{ clusterName: 'help' }]
139
+ * @example
140
+ * If the current command includes: cluster('https://demo11.westus.kusto.windows.net')
141
+ * getClusterReferences will return [{ clusterName: 'https://demo11.westus.kusto.windows.net' }]
138
142
  */
139
143
  getClusterReferences(uri: string, cursorOffset: number): Promise<ClusterReference[]>;
140
144
  /**
141
145
  * Adds a database's scheme. Useful with getDatabaseReferences to load schema for cross-cluster commands.
146
+ * @param clusterName the name of the cluster as returned from getDatabaseReferences/getClusterReferences.
147
+ * @example
148
+ * - User enters cluster('help').database('Samples')
149
+ * - hosting app calls getDatabaseReferences which returns [{ clusterName: 'help', databaseName: 'Samples' }].
150
+ * - hosting app fetches the database Schema from https://help.kusto.windows.net
151
+ * - hosting app calls 'addDatabaseToSchema' with the database's schema.
152
+ * - now, when user types cluster('help').database('Samples') then the auto complete list will show all the tables.
142
153
  */
143
154
  addDatabaseToSchema(uri: string, clusterName: string, databaseSchema: Database): Promise<void>;
144
155
  /**
145
- * Adds a cluster's scheme (database names only). Useful with getClusterReferences to load schema for cross-cluster commands.
146
- * To load a full database schema call addDatabaseToSchema.
156
+ * Adds a cluster's databases to the schema. Useful when used with getClusterReferences in cross-cluster commands.
157
+ * @param clusterName the name of the cluster as returned in getClusterReferences.
158
+ * @example
159
+ * - User enters cluster('help')
160
+ * - hosting app calls getClusterReferences which returns [{ clusterName: 'help' }].
161
+ * - hosting app fetches the list of databases from https://help.kusto.windows.net
162
+ * - hosting app calls addClusterToSchema with the list of databases.
163
+ * - now, when user type `cluster('help').database(` then the auto complete list will show all the databases.
147
164
  */
148
165
  addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
149
166
  }