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.
@@ -2417,16 +2417,24 @@
2417
2417
  */
2418
2418
  function SuggestHotspotsAI(params) {
2419
2419
  return __awaiter(this, void 0, void 0, function* () {
2420
- let { api, docId, body, req: reqParams } = params;
2420
+ let { api, docId, body, req: reqParams, Prompt, Model, PageFrom, PageTo, MaxResults, MaxPages, KeepUnlabeledSymbols, SaveToDocumentSettings, ReplaceExisting } = params;
2421
2421
  if (!docId) {
2422
2422
  throw ("Doc ID is required.");
2423
2423
  }
2424
2424
  if (!api) {
2425
2425
  api = exports.ENVIRONMENT.Api().GetBruceApi();
2426
2426
  }
2427
- if (!body) {
2428
- body = {};
2429
- }
2427
+ body = MergeSuggestHotspotsAIParams(body, {
2428
+ Prompt,
2429
+ Model,
2430
+ PageFrom,
2431
+ PageTo,
2432
+ MaxResults,
2433
+ MaxPages,
2434
+ KeepUnlabeledSymbols,
2435
+ SaveToDocumentSettings,
2436
+ ReplaceExisting
2437
+ });
2430
2438
  return api.POST(`documentView/${docId}/suggestHotspotsAI`, body, exports.Api.PrepReqParams(reqParams));
2431
2439
  });
2432
2440
  }
@@ -2485,6 +2493,24 @@
2485
2493
  }
2486
2494
  return Object.assign(Object.assign({}, formData), { DetectHotspots: "true" });
2487
2495
  }
2496
+ function MergeSuggestHotspotsAIParams(body, params) {
2497
+ const merged = Object.assign({}, (body || {}));
2498
+ AddDefinedRequestParam(merged, "Prompt", params === null || params === void 0 ? void 0 : params.Prompt);
2499
+ AddDefinedRequestParam(merged, "Model", params === null || params === void 0 ? void 0 : params.Model);
2500
+ AddDefinedRequestParam(merged, "PageFrom", params === null || params === void 0 ? void 0 : params.PageFrom);
2501
+ AddDefinedRequestParam(merged, "PageTo", params === null || params === void 0 ? void 0 : params.PageTo);
2502
+ AddDefinedRequestParam(merged, "MaxResults", params === null || params === void 0 ? void 0 : params.MaxResults);
2503
+ AddDefinedRequestParam(merged, "MaxPages", params === null || params === void 0 ? void 0 : params.MaxPages);
2504
+ AddDefinedRequestParam(merged, "KeepUnlabeledSymbols", params === null || params === void 0 ? void 0 : params.KeepUnlabeledSymbols);
2505
+ AddDefinedRequestParam(merged, "SaveToDocumentSettings", params === null || params === void 0 ? void 0 : params.SaveToDocumentSettings);
2506
+ AddDefinedRequestParam(merged, "ReplaceExisting", params === null || params === void 0 ? void 0 : params.ReplaceExisting);
2507
+ return merged;
2508
+ }
2509
+ function AddDefinedRequestParam(body, key, value) {
2510
+ if (value !== undefined) {
2511
+ body[key] = value;
2512
+ }
2513
+ }
2488
2514
  })(exports.AnnDocument || (exports.AnnDocument = {}));
2489
2515
 
2490
2516
  (function (CustomForm) {
@@ -8869,19 +8895,46 @@
8869
8895
  */
8870
8896
  function GetEntityCoords(params) {
8871
8897
  return __awaiter(this, void 0, void 0, function* () {
8872
- let { api, rootEntityId: entityId, req: reqParams } = params;
8898
+ let { api, rootEntityId, req: reqParams } = params;
8873
8899
  if (!api) {
8874
8900
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8875
8901
  }
8876
- const cache = api.GetCacheItem(GetCacheKey(entityId), reqParams);
8902
+ const entityIds = (Array.isArray(rootEntityId) ? rootEntityId : [rootEntityId]).filter(id => !!id);
8903
+ if (!entityIds.length) {
8904
+ throw ("Root Entity ID is required.");
8905
+ }
8906
+ const cacheKey = GetCacheKey(Array.isArray(rootEntityId) ? entityIds : entityIds[0]);
8907
+ const cache = api.GetCacheItem(cacheKey, reqParams);
8877
8908
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
8878
8909
  return cache.data;
8879
8910
  }
8880
8911
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8912
+ var _a;
8881
8913
  try {
8882
- const data = yield api.GET(`entity/${entityId}/ucs`, reqParams);
8914
+ if (entityIds.length == 1) {
8915
+ const data = yield api.GET(`entity/${entityIds[0]}/ucs`, reqParams);
8916
+ res({
8917
+ coords: data,
8918
+ coordsMap: {
8919
+ [entityIds[0]]: data
8920
+ }
8921
+ });
8922
+ return;
8923
+ }
8924
+ const data = yield api.GET(`entity/ucs?rootId=${entityIds.map(encodeURIComponent).join(",")}`, reqParams);
8925
+ const coords = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0];
8926
+ if (!coords) {
8927
+ throw ("No Entity coordinates found.");
8928
+ }
8929
+ const coordsMap = {};
8930
+ for (const item of data.Items || []) {
8931
+ if (item === null || item === void 0 ? void 0 : item["Entity.ID"]) {
8932
+ coordsMap[item["Entity.ID"]] = item;
8933
+ }
8934
+ }
8883
8935
  res({
8884
- coords: data
8936
+ coords,
8937
+ coordsMap
8885
8938
  });
8886
8939
  }
8887
8940
  catch (e) {
@@ -8889,7 +8942,7 @@
8889
8942
  }
8890
8943
  }));
8891
8944
  api.SetCacheItem({
8892
- key: GetCacheKey(entityId),
8945
+ key: cacheKey,
8893
8946
  value: prom,
8894
8947
  req: reqParams
8895
8948
  });
@@ -8933,7 +8986,7 @@
8933
8986
  "test": params.test
8934
8987
  }, reqParams);
8935
8988
  if (!params.test) {
8936
- api.Cache.Remove(GetCacheKey(entityId));
8989
+ InvalidateCoordsCache(api, entityId);
8937
8990
  }
8938
8991
  return {
8939
8992
  coords: res
@@ -8980,7 +9033,7 @@
8980
9033
  "test": params.test
8981
9034
  }, reqParams);
8982
9035
  if (!params.test) {
8983
- api.Cache.Remove(GetCacheKey(entityId));
9036
+ InvalidateCoordsCache(api, entityId);
8984
9037
  }
8985
9038
  return {
8986
9039
  coords: res
@@ -9014,7 +9067,7 @@
9014
9067
  "test": params.test
9015
9068
  }, reqParams);
9016
9069
  if (!params.test) {
9017
- api.Cache.Remove(GetCacheKey(entityId));
9070
+ InvalidateCoordsCache(api, entityId);
9018
9071
  }
9019
9072
  return {
9020
9073
  coords: res
@@ -9033,7 +9086,8 @@
9033
9086
  if (!api) {
9034
9087
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9035
9088
  }
9036
- return api.DELETE(`entity/${entityId}/ucs`, reqParams);
9089
+ yield api.DELETE(`entity/${entityId}/ucs`, reqParams);
9090
+ InvalidateCoordsCache(api, entityId);
9037
9091
  });
9038
9092
  }
9039
9093
  EntityCoords.UnlinkCoords = UnlinkCoords;
@@ -9048,9 +9102,36 @@
9048
9102
  * @returns
9049
9103
  */
9050
9104
  function GetCacheKey(entityId) {
9051
- return exports.Api.ECacheKey.EntityCoords + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + entityId;
9105
+ const isList = Array.isArray(entityId);
9106
+ const id = isList ? entityId.join(",") : entityId;
9107
+ return exports.Api.ECacheKey.EntityCoords + exports.Api.ECacheKey.Entity + (isList ? exports.Api.ECacheKey.ListId : exports.Api.ECacheKey.Id) + id;
9052
9108
  }
9053
9109
  EntityCoords.GetCacheKey = GetCacheKey;
9110
+ /**
9111
+ * Invalidates all cached coords that involve the given Entity ID.
9112
+ *
9113
+ * Example:
9114
+ * ```
9115
+ * const api: BruceApi.Api = ...;
9116
+ * InvalidateCoordsCache(api, "123");
9117
+ * ```
9118
+ * @param api
9119
+ * @param entityId Single Entity whose cached coords should be invalidated.
9120
+ */
9121
+ function InvalidateCoordsCache(api, entityId) {
9122
+ // Remove the exact single-entity cache entry.
9123
+ api.Cache.Remove(GetCacheKey(entityId));
9124
+ // Remove any multi-Entity cache entries whose ID list includes this Entity.
9125
+ const multiPrefix = exports.Api.ECacheKey.EntityCoords + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.ListId;
9126
+ api.Cache.RemoveBy(key => {
9127
+ const k = String(key);
9128
+ if (!k.startsWith(multiPrefix)) {
9129
+ return false;
9130
+ }
9131
+ return k.slice(multiPrefix.length).split(",").includes(entityId);
9132
+ });
9133
+ }
9134
+ EntityCoords.InvalidateCoordsCache = InvalidateCoordsCache;
9054
9135
  })(exports.EntityCoords || (exports.EntityCoords = {}));
9055
9136
 
9056
9137
  (function (EntityTableView) {
@@ -18175,7 +18256,7 @@
18175
18256
  })(exports.ChangeSet || (exports.ChangeSet = {}));
18176
18257
 
18177
18258
  // This is updated with the package.json version on build.
18178
- const VERSION = "7.1.41";
18259
+ const VERSION = "7.1.43";
18179
18260
 
18180
18261
  exports.VERSION = VERSION;
18181
18262
  exports.AbstractApi = AbstractApi;