bruce-models 7.1.106 → 7.1.108

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.
@@ -1255,6 +1255,7 @@ class AbstractApi {
1255
1255
  * This will NOT prepend the base URL to the provided URL.
1256
1256
  * @param url
1257
1257
  * @param params
1258
+ * @param data Optional request body.
1258
1259
  * @returns
1259
1260
  */
1260
1261
  get(url, params) {
@@ -1279,7 +1280,7 @@ class AbstractApi {
1279
1280
  * @param params
1280
1281
  * @returns
1281
1282
  */
1282
- delete(url, params) {
1283
+ delete(url, params, data) {
1283
1284
  return __awaiter(this, void 0, void 0, function* () {
1284
1285
  if (!params) {
1285
1286
  params = {};
@@ -1287,9 +1288,13 @@ class AbstractApi {
1287
1288
  params.headers = params.headers || {};
1288
1289
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1289
1290
  this.applyAuthHeader(params.headers);
1291
+ if (data != null && typeof data != "string") {
1292
+ data = JSON.stringify(data);
1293
+ }
1290
1294
  const res = yield fetch(url, {
1291
1295
  headers: params.headers,
1292
1296
  method: "DELETE",
1297
+ body: data,
1293
1298
  signal: params.abortSignal
1294
1299
  });
1295
1300
  return parseResult(res);
@@ -1912,16 +1917,17 @@ var BruceApi;
1912
1917
  * This will prepend the base url to the url.
1913
1918
  * @param url
1914
1919
  * @param params
1920
+ * @param data Optional request body.
1915
1921
  * @returns
1916
1922
  */
1917
- DELETE(url, params) {
1923
+ DELETE(url, params, data) {
1918
1924
  return __awaiter(this, void 0, void 0, function* () {
1919
1925
  return new Promise((res, rej) => {
1920
1926
  this.loadProm.then(() => {
1921
1927
  const full = this.ConstructUrl({
1922
1928
  url: url
1923
1929
  });
1924
- this.delete(full, params).then(res).catch(rej);
1930
+ this.delete(full, params, data).then(res).catch(rej);
1925
1931
  }).catch(rej);
1926
1932
  });
1927
1933
  });
@@ -2749,6 +2755,19 @@ var Account;
2749
2755
  });
2750
2756
  }
2751
2757
  Account.Cleanup = Cleanup;
2758
+ /**
2759
+ * Returns file counts and sizes for each storage category in the current account.
2760
+ */
2761
+ function GetFilesSummary(params) {
2762
+ return __awaiter(this, void 0, void 0, function* () {
2763
+ let { api, req: reqParams } = params !== null && params !== void 0 ? params : {};
2764
+ if (!api) {
2765
+ api = ENVIRONMENT.Api().GetBruceApi();
2766
+ }
2767
+ return api.GET("account/filesSummary", Api.PrepReqParams(reqParams));
2768
+ });
2769
+ }
2770
+ Account.GetFilesSummary = GetFilesSummary;
2752
2771
  /**
2753
2772
  * Returns cache identifier for an account by ID.
2754
2773
  * Example: {
@@ -17853,6 +17872,11 @@ var ExportCsv;
17853
17872
 
17854
17873
  var ExportNsx;
17855
17874
  (function (ExportNsx) {
17875
+ let EAccountBackupFileType;
17876
+ (function (EAccountBackupFileType) {
17877
+ EAccountBackupFileType["DatabaseDump"] = "DatabaseDump";
17878
+ EAccountBackupFileType["NSX"] = "NSX";
17879
+ })(EAccountBackupFileType = ExportNsx.EAccountBackupFileType || (ExportNsx.EAccountBackupFileType = {}));
17856
17880
  /**
17857
17881
  * Starts a whole-account NSX backup export job.
17858
17882
  * The generated NSX file is stored in the account's configured backup file store.
@@ -17880,6 +17904,38 @@ var ExportNsx;
17880
17904
  });
17881
17905
  }
17882
17906
  ExportNsx.GetAccountBackupList = GetAccountBackupList;
17907
+ /**
17908
+ * Returns account database dump and NSX backup files with storage metadata.
17909
+ */
17910
+ function GetAccountBackupFilesList(params) {
17911
+ return __awaiter(this, void 0, void 0, function* () {
17912
+ let { api, req: reqParams } = params !== null && params !== void 0 ? params : {};
17913
+ if (!api) {
17914
+ api = ENVIRONMENT.Api().GetBruceApi();
17915
+ }
17916
+ return api.GET("account/backupFilesList", Api.PrepReqParams(reqParams));
17917
+ });
17918
+ }
17919
+ ExportNsx.GetAccountBackupFilesList = GetAccountBackupFilesList;
17920
+ /**
17921
+ * Deletes selected account database dump and NSX backup files.
17922
+ */
17923
+ function DeleteAccountBackupFiles(params) {
17924
+ return __awaiter(this, void 0, void 0, function* () {
17925
+ let { api, fileNames, req: reqParams } = params;
17926
+ if (!(fileNames === null || fileNames === void 0 ? void 0 : fileNames.length)) {
17927
+ throw new Error("At least one backup file name is required.");
17928
+ }
17929
+ if (!api) {
17930
+ api = ENVIRONMENT.Api().GetBruceApi();
17931
+ }
17932
+ const data = {
17933
+ Files: fileNames
17934
+ };
17935
+ return api.DELETE("account/backupFiles", Api.PrepReqParams(reqParams), data);
17936
+ });
17937
+ }
17938
+ ExportNsx.DeleteAccountBackupFiles = DeleteAccountBackupFiles;
17883
17939
  /**
17884
17940
  * Downloads a saved whole-account NSX backup file.
17885
17941
  */
@@ -19135,6 +19191,8 @@ class NavigatorMcpWebSocketClient {
19135
19191
  constructor(toolHandler, options = {}) {
19136
19192
  this.ws = null;
19137
19193
  this.isConnecting = false;
19194
+ this.responseGeneration = 0;
19195
+ this.pendingResponses = [];
19138
19196
  this.toolHandler = toolHandler;
19139
19197
  this.options = options;
19140
19198
  this.currentAuth = options.auth;
@@ -19145,7 +19203,7 @@ class NavigatorMcpWebSocketClient {
19145
19203
  connect(auth) {
19146
19204
  var _a, _b, _c, _d, _e, _f, _g;
19147
19205
  if (auth) {
19148
- this.currentAuth = auth;
19206
+ this.setAuth(auth);
19149
19207
  }
19150
19208
  if (this.isConnecting || ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN) {
19151
19209
  (_c = (_b = this.logger()).debug) === null || _c === void 0 ? void 0 : _c.call(_b, "[NavigatorMcpWS] Connection already active or in-flight; skipping connect.");
@@ -19156,24 +19214,34 @@ class NavigatorMcpWebSocketClient {
19156
19214
  const url = this.buildUrl();
19157
19215
  (_e = (_d = this.logger()).log) === null || _e === void 0 ? void 0 : _e.call(_d, "[NavigatorMcpWS] Connecting to", url);
19158
19216
  this.ws = new WebSocket(url);
19217
+ const socket = this.ws;
19159
19218
  this.ws.onopen = (event) => {
19160
19219
  var _a, _b, _c, _d;
19220
+ if (this.ws !== socket)
19221
+ return;
19161
19222
  (_b = (_a = this.logger()).log) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Connected");
19162
19223
  this.isConnecting = false;
19163
19224
  this.send({ method: "server_ready" });
19225
+ this.flushResponses();
19164
19226
  (_d = (_c = this.options).onOpen) === null || _d === void 0 ? void 0 : _d.call(_c, event);
19165
19227
  };
19166
19228
  this.ws.onmessage = (event) => {
19229
+ if (this.ws !== socket)
19230
+ return;
19167
19231
  this.handleMessage(event.data);
19168
19232
  };
19169
19233
  this.ws.onerror = (event) => {
19170
19234
  var _a, _b, _c, _d;
19235
+ if (this.ws !== socket)
19236
+ return;
19171
19237
  (_b = (_a = this.logger()).error) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Error", event);
19172
19238
  (_d = (_c = this.options).onError) === null || _d === void 0 ? void 0 : _d.call(_c, event);
19173
19239
  this.isConnecting = false;
19174
19240
  };
19175
19241
  this.ws.onclose = (event) => {
19176
19242
  var _a, _b, _c, _d;
19243
+ if (this.ws !== socket)
19244
+ return;
19177
19245
  (_b = (_a = this.logger()).log) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Disconnected");
19178
19246
  this.ws = null;
19179
19247
  this.isConnecting = false;
@@ -19187,6 +19255,9 @@ class NavigatorMcpWebSocketClient {
19187
19255
  }
19188
19256
  disconnect() {
19189
19257
  var _a, _b;
19258
+ // An explicit disconnect ends the logical session; never replay its results.
19259
+ this.responseGeneration++;
19260
+ this.pendingResponses = [];
19190
19261
  if (this.ws) {
19191
19262
  (_b = (_a = this.logger()).debug) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Closing connection");
19192
19263
  this.ws.close();
@@ -19203,6 +19274,16 @@ class NavigatorMcpWebSocketClient {
19203
19274
  * Call connect() afterwards to establish a connection with the new auth.
19204
19275
  */
19205
19276
  setAuth(auth) {
19277
+ const key = (value) => JSON.stringify([
19278
+ value === null || value === void 0 ? void 0 : value.accountId,
19279
+ value === null || value === void 0 ? void 0 : value.sessionId,
19280
+ value === null || value === void 0 ? void 0 : value.fingerprint,
19281
+ value === null || value === void 0 ? void 0 : value.apiBaseUrl
19282
+ ]);
19283
+ if (key(auth) !== key(this.currentAuth)) {
19284
+ this.responseGeneration++;
19285
+ this.pendingResponses = [];
19286
+ }
19206
19287
  this.currentAuth = auth;
19207
19288
  }
19208
19289
  sendChatEvent(event) {
@@ -19247,7 +19328,7 @@ class NavigatorMcpWebSocketClient {
19247
19328
  return urlInstance.toString();
19248
19329
  }
19249
19330
  handleMessage(raw) {
19250
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
19331
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
19251
19332
  return __awaiter(this, void 0, void 0, function* () {
19252
19333
  try {
19253
19334
  const message = typeof raw === "string" ? JSON.parse(raw) : raw;
@@ -19269,6 +19350,7 @@ class NavigatorMcpWebSocketClient {
19269
19350
  return;
19270
19351
  }
19271
19352
  let result;
19353
+ const generation = this.responseGeneration;
19272
19354
  try {
19273
19355
  result = yield this.toolHandler({
19274
19356
  name: toolName,
@@ -19280,23 +19362,62 @@ class NavigatorMcpWebSocketClient {
19280
19362
  (_l = (_k = this.logger()).error) === null || _l === void 0 ? void 0 : _l.call(_k, "[NavigatorMcpWS] Tool handler threw", error);
19281
19363
  result = `Error: ${error instanceof Error ? error.message : String(error)}`;
19282
19364
  }
19283
- this.send({
19365
+ if (generation !== this.responseGeneration) {
19366
+ (_o = (_m = this.logger()).warn) === null || _o === void 0 ? void 0 : _o.call(_m, "[NavigatorMcpWS] Discarding result from a previous session", messageId);
19367
+ return;
19368
+ }
19369
+ this.sendResponse({
19284
19370
  method: "tool_response",
19285
19371
  id: messageId,
19286
19372
  result
19287
19373
  });
19288
19374
  }
19289
19375
  catch (error) {
19290
- (_o = (_m = this.logger()).error) === null || _o === void 0 ? void 0 : _o.call(_m, "[NavigatorMcpWS] Invalid message", error);
19376
+ (_q = (_p = this.logger()).error) === null || _q === void 0 ? void 0 : _q.call(_p, "[NavigatorMcpWS] Invalid message", error);
19291
19377
  }
19292
19378
  });
19293
19379
  }
19380
+ sendResponse(message) {
19381
+ var _a, _b, _c, _d, _e;
19382
+ if (this.send(message))
19383
+ return;
19384
+ this.pendingResponses = this.pendingResponses.filter((entry) => entry.expiresAt > Date.now());
19385
+ if (this.pendingResponses.length >= NavigatorMcpWebSocketClient.MAX_PENDING_RESPONSES) {
19386
+ const dropped = this.pendingResponses.shift();
19387
+ (_b = (_a = this.logger()).warn) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Response queue full; dropping oldest result", (_c = dropped === null || dropped === void 0 ? void 0 : dropped.message) === null || _c === void 0 ? void 0 : _c.id);
19388
+ }
19389
+ this.pendingResponses.push({ message, expiresAt: Date.now() + NavigatorMcpWebSocketClient.RESPONSE_TTL_MS });
19390
+ (_e = (_d = this.logger()).warn) === null || _e === void 0 ? void 0 : _e.call(_d, "[NavigatorMcpWS] Tool result queued until reconnect", message.id);
19391
+ }
19392
+ flushResponses() {
19393
+ var _a, _b;
19394
+ const pending = this.pendingResponses;
19395
+ this.pendingResponses = [];
19396
+ for (const entry of pending) {
19397
+ if (entry.expiresAt <= Date.now()) {
19398
+ (_b = (_a = this.logger()).warn) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Tool result expired before reconnect", entry.message.id);
19399
+ }
19400
+ else if (!this.send(entry.message)) {
19401
+ this.pendingResponses.push(entry);
19402
+ }
19403
+ }
19404
+ }
19294
19405
  send(message) {
19295
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
19406
+ var _a, _b;
19407
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
19408
+ return false;
19409
+ try {
19296
19410
  this.ws.send(JSON.stringify(message));
19411
+ return true;
19412
+ }
19413
+ catch (error) {
19414
+ (_b = (_a = this.logger()).error) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Send failed", error);
19415
+ return false;
19297
19416
  }
19298
19417
  }
19299
19418
  }
19419
+ NavigatorMcpWebSocketClient.RESPONSE_TTL_MS = 60000;
19420
+ NavigatorMcpWebSocketClient.MAX_PENDING_RESPONSES = 32;
19300
19421
 
19301
19422
  var Plugin;
19302
19423
  (function (Plugin) {
@@ -24690,7 +24811,7 @@ function getFirstWrappedArray(data, wrapperKeys) {
24690
24811
  }
24691
24812
 
24692
24813
  // This is updated with the package.json version on build.
24693
- const VERSION = "7.1.106";
24814
+ const VERSION = "7.1.108";
24694
24815
 
24695
24816
  export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, ClientFileValueMap, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, RequestLane, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportNsx, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportTif, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, PluginAiTool, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, WorkflowItem, WorkflowSchedule, WorkflowType, WorkflowItemType };
24696
24817
  //# sourceMappingURL=bruce-models.es5.js.map