bruce-models 7.1.41 → 7.1.43

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.
@@ -2444,16 +2444,24 @@ var AnnDocument;
2444
2444
  */
2445
2445
  function SuggestHotspotsAI(params) {
2446
2446
  return __awaiter(this, void 0, void 0, function* () {
2447
- let { api, docId, body, req: reqParams } = params;
2447
+ let { api, docId, body, req: reqParams, Prompt, Model, PageFrom, PageTo, MaxResults, MaxPages, KeepUnlabeledSymbols, SaveToDocumentSettings, ReplaceExisting } = params;
2448
2448
  if (!docId) {
2449
2449
  throw ("Doc ID is required.");
2450
2450
  }
2451
2451
  if (!api) {
2452
2452
  api = ENVIRONMENT.Api().GetBruceApi();
2453
2453
  }
2454
- if (!body) {
2455
- body = {};
2456
- }
2454
+ body = MergeSuggestHotspotsAIParams(body, {
2455
+ Prompt,
2456
+ Model,
2457
+ PageFrom,
2458
+ PageTo,
2459
+ MaxResults,
2460
+ MaxPages,
2461
+ KeepUnlabeledSymbols,
2462
+ SaveToDocumentSettings,
2463
+ ReplaceExisting
2464
+ });
2457
2465
  return api.POST(`documentView/${docId}/suggestHotspotsAI`, body, Api.PrepReqParams(reqParams));
2458
2466
  });
2459
2467
  }
@@ -2512,6 +2520,24 @@ var AnnDocument;
2512
2520
  }
2513
2521
  return Object.assign(Object.assign({}, formData), { DetectHotspots: "true" });
2514
2522
  }
2523
+ function MergeSuggestHotspotsAIParams(body, params) {
2524
+ const merged = Object.assign({}, (body || {}));
2525
+ AddDefinedRequestParam(merged, "Prompt", params === null || params === void 0 ? void 0 : params.Prompt);
2526
+ AddDefinedRequestParam(merged, "Model", params === null || params === void 0 ? void 0 : params.Model);
2527
+ AddDefinedRequestParam(merged, "PageFrom", params === null || params === void 0 ? void 0 : params.PageFrom);
2528
+ AddDefinedRequestParam(merged, "PageTo", params === null || params === void 0 ? void 0 : params.PageTo);
2529
+ AddDefinedRequestParam(merged, "MaxResults", params === null || params === void 0 ? void 0 : params.MaxResults);
2530
+ AddDefinedRequestParam(merged, "MaxPages", params === null || params === void 0 ? void 0 : params.MaxPages);
2531
+ AddDefinedRequestParam(merged, "KeepUnlabeledSymbols", params === null || params === void 0 ? void 0 : params.KeepUnlabeledSymbols);
2532
+ AddDefinedRequestParam(merged, "SaveToDocumentSettings", params === null || params === void 0 ? void 0 : params.SaveToDocumentSettings);
2533
+ AddDefinedRequestParam(merged, "ReplaceExisting", params === null || params === void 0 ? void 0 : params.ReplaceExisting);
2534
+ return merged;
2535
+ }
2536
+ function AddDefinedRequestParam(body, key, value) {
2537
+ if (value !== undefined) {
2538
+ body[key] = value;
2539
+ }
2540
+ }
2515
2541
  })(AnnDocument || (AnnDocument = {}));
2516
2542
 
2517
2543
  /**
@@ -9010,19 +9036,46 @@ var EntityCoords;
9010
9036
  */
9011
9037
  function GetEntityCoords(params) {
9012
9038
  return __awaiter(this, void 0, void 0, function* () {
9013
- let { api, rootEntityId: entityId, req: reqParams } = params;
9039
+ let { api, rootEntityId, req: reqParams } = params;
9014
9040
  if (!api) {
9015
9041
  api = ENVIRONMENT.Api().GetBruceApi();
9016
9042
  }
9017
- const cache = api.GetCacheItem(GetCacheKey(entityId), reqParams);
9043
+ const entityIds = (Array.isArray(rootEntityId) ? rootEntityId : [rootEntityId]).filter(id => !!id);
9044
+ if (!entityIds.length) {
9045
+ throw ("Root Entity ID is required.");
9046
+ }
9047
+ const cacheKey = GetCacheKey(Array.isArray(rootEntityId) ? entityIds : entityIds[0]);
9048
+ const cache = api.GetCacheItem(cacheKey, reqParams);
9018
9049
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9019
9050
  return cache.data;
9020
9051
  }
9021
9052
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
9053
+ var _a;
9022
9054
  try {
9023
- const data = yield api.GET(`entity/${entityId}/ucs`, reqParams);
9055
+ if (entityIds.length == 1) {
9056
+ const data = yield api.GET(`entity/${entityIds[0]}/ucs`, reqParams);
9057
+ res({
9058
+ coords: data,
9059
+ coordsMap: {
9060
+ [entityIds[0]]: data
9061
+ }
9062
+ });
9063
+ return;
9064
+ }
9065
+ const data = yield api.GET(`entity/ucs?rootId=${entityIds.map(encodeURIComponent).join(",")}`, reqParams);
9066
+ const coords = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0];
9067
+ if (!coords) {
9068
+ throw ("No Entity coordinates found.");
9069
+ }
9070
+ const coordsMap = {};
9071
+ for (const item of data.Items || []) {
9072
+ if (item === null || item === void 0 ? void 0 : item["Entity.ID"]) {
9073
+ coordsMap[item["Entity.ID"]] = item;
9074
+ }
9075
+ }
9024
9076
  res({
9025
- coords: data
9077
+ coords,
9078
+ coordsMap
9026
9079
  });
9027
9080
  }
9028
9081
  catch (e) {
@@ -9030,7 +9083,7 @@ var EntityCoords;
9030
9083
  }
9031
9084
  }));
9032
9085
  api.SetCacheItem({
9033
- key: GetCacheKey(entityId),
9086
+ key: cacheKey,
9034
9087
  value: prom,
9035
9088
  req: reqParams
9036
9089
  });
@@ -9074,7 +9127,7 @@ var EntityCoords;
9074
9127
  "test": params.test
9075
9128
  }, reqParams);
9076
9129
  if (!params.test) {
9077
- api.Cache.Remove(GetCacheKey(entityId));
9130
+ InvalidateCoordsCache(api, entityId);
9078
9131
  }
9079
9132
  return {
9080
9133
  coords: res
@@ -9121,7 +9174,7 @@ var EntityCoords;
9121
9174
  "test": params.test
9122
9175
  }, reqParams);
9123
9176
  if (!params.test) {
9124
- api.Cache.Remove(GetCacheKey(entityId));
9177
+ InvalidateCoordsCache(api, entityId);
9125
9178
  }
9126
9179
  return {
9127
9180
  coords: res
@@ -9155,7 +9208,7 @@ var EntityCoords;
9155
9208
  "test": params.test
9156
9209
  }, reqParams);
9157
9210
  if (!params.test) {
9158
- api.Cache.Remove(GetCacheKey(entityId));
9211
+ InvalidateCoordsCache(api, entityId);
9159
9212
  }
9160
9213
  return {
9161
9214
  coords: res
@@ -9174,7 +9227,8 @@ var EntityCoords;
9174
9227
  if (!api) {
9175
9228
  api = ENVIRONMENT.Api().GetBruceApi();
9176
9229
  }
9177
- return api.DELETE(`entity/${entityId}/ucs`, reqParams);
9230
+ yield api.DELETE(`entity/${entityId}/ucs`, reqParams);
9231
+ InvalidateCoordsCache(api, entityId);
9178
9232
  });
9179
9233
  }
9180
9234
  EntityCoords.UnlinkCoords = UnlinkCoords;
@@ -9189,9 +9243,36 @@ var EntityCoords;
9189
9243
  * @returns
9190
9244
  */
9191
9245
  function GetCacheKey(entityId) {
9192
- return Api.ECacheKey.EntityCoords + Api.ECacheKey.Entity + Api.ECacheKey.Id + entityId;
9246
+ const isList = Array.isArray(entityId);
9247
+ const id = isList ? entityId.join(",") : entityId;
9248
+ return Api.ECacheKey.EntityCoords + Api.ECacheKey.Entity + (isList ? Api.ECacheKey.ListId : Api.ECacheKey.Id) + id;
9193
9249
  }
9194
9250
  EntityCoords.GetCacheKey = GetCacheKey;
9251
+ /**
9252
+ * Invalidates all cached coords that involve the given Entity ID.
9253
+ *
9254
+ * Example:
9255
+ * ```
9256
+ * const api: BruceApi.Api = ...;
9257
+ * InvalidateCoordsCache(api, "123");
9258
+ * ```
9259
+ * @param api
9260
+ * @param entityId Single Entity whose cached coords should be invalidated.
9261
+ */
9262
+ function InvalidateCoordsCache(api, entityId) {
9263
+ // Remove the exact single-entity cache entry.
9264
+ api.Cache.Remove(GetCacheKey(entityId));
9265
+ // Remove any multi-Entity cache entries whose ID list includes this Entity.
9266
+ const multiPrefix = Api.ECacheKey.EntityCoords + Api.ECacheKey.Entity + Api.ECacheKey.ListId;
9267
+ api.Cache.RemoveBy(key => {
9268
+ const k = String(key);
9269
+ if (!k.startsWith(multiPrefix)) {
9270
+ return false;
9271
+ }
9272
+ return k.slice(multiPrefix.length).split(",").includes(entityId);
9273
+ });
9274
+ }
9275
+ EntityCoords.InvalidateCoordsCache = InvalidateCoordsCache;
9195
9276
  })(EntityCoords || (EntityCoords = {}));
9196
9277
 
9197
9278
  /**
@@ -18511,7 +18592,7 @@ var ChangeSet;
18511
18592
  })(ChangeSet || (ChangeSet = {}));
18512
18593
 
18513
18594
  // This is updated with the package.json version on build.
18514
- const VERSION = "7.1.41";
18595
+ const VERSION = "7.1.43";
18515
18596
 
18516
18597
  export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityTypeTrigger, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, DashboardView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountConcept, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataTransform, DataLabGroup, DataFeed, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportLcc, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
18517
18598
  //# sourceMappingURL=bruce-models.es5.js.map