bruce-models 4.8.1 → 4.8.2

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.
@@ -2594,21 +2594,24 @@ var EntityType;
2594
2594
  */
2595
2595
  function ReIndex(params) {
2596
2596
  return __awaiter(this, void 0, void 0, function* () {
2597
- let { api, entityTypeId: typeId, req } = params;
2598
- if (!typeId) {
2599
- throw ("Type ID is required.");
2600
- }
2597
+ let { api, entityTypeId: typeId, req, dataTransformId, reSaveAll } = params;
2601
2598
  if (!api) {
2602
2599
  api = ENVIRONMENT.Api().GetBruceApi();
2603
2600
  }
2604
2601
  const urlParams = new URLSearchParams();
2605
- if (params.dataTransformId) {
2606
- urlParams.append("dataTransformID", String(params.dataTransformId));
2602
+ if (dataTransformId) {
2603
+ urlParams.append("dataTransformID", String(dataTransformId));
2607
2604
  }
2608
- const url = `entitytype/${typeId}/reindex?${urlParams.toString()}`;
2605
+ if (reSaveAll) {
2606
+ urlParams.append("reSaveAll", "true");
2607
+ }
2608
+ let url = typeId ? `entityType/${typeId}/reindex` : "entities/reindex";
2609
+ url += "?" + urlParams.toString();
2609
2610
  req = Api.PrepReqParams(req);
2610
- const pa = yield api.POST(url, {}, req);
2611
- return pa;
2611
+ const res = yield api.POST(url, {}, req);
2612
+ return {
2613
+ pendingActionId: res.PendingActionID
2614
+ };
2612
2615
  });
2613
2616
  }
2614
2617
  EntityType.ReIndex = ReIndex;
@@ -10784,7 +10787,7 @@ var PendingAction;
10784
10787
  */
10785
10788
  function OnCompletion(params) {
10786
10789
  return __awaiter(this, void 0, void 0, function* () {
10787
- let { api, actionId, req: reqParams, interval: intMs, isDisposed } = params;
10790
+ let { api, actionId, req: reqParams, interval: intMs, isDisposed, onMessage } = params;
10788
10791
  if (!actionId) {
10789
10792
  throw ("Action ID is required.");
10790
10793
  }
@@ -10794,10 +10797,43 @@ var PendingAction;
10794
10797
  if (!intMs || intMs <= 0) {
10795
10798
  intMs = 3000;
10796
10799
  }
10800
+ // Map of found messages.
10801
+ const returnedMsgs = new Map();
10802
+ const returnedMsgsArr = [];
10797
10803
  const res = yield new Promise((res, rej) => {
10804
+ let msgInterval = null;
10805
+ if (onMessage != null) {
10806
+ msgInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
10807
+ try {
10808
+ const { messages } = yield GetMessages({
10809
+ api,
10810
+ actionId,
10811
+ order: Api.ESortOrder.Desc,
10812
+ startIndex: 0,
10813
+ amount: 5
10814
+ });
10815
+ for (let i = 0; i < messages.length; i++) {
10816
+ const message = messages[i];
10817
+ // If this is a new message we'll notify the callback.
10818
+ // We'll also add it to the map so we don't notify it again, and to return it later.
10819
+ if (!returnedMsgs.has(message.ID)) {
10820
+ returnedMsgs.set(message.ID, true);
10821
+ returnedMsgsArr.push(message);
10822
+ onMessage(message);
10823
+ }
10824
+ }
10825
+ }
10826
+ catch (e) {
10827
+ clearInterval(msgInterval);
10828
+ }
10829
+ }), 1000);
10830
+ }
10798
10831
  let interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
10799
10832
  if (isDisposed && isDisposed()) {
10800
10833
  clearInterval(interval);
10834
+ if (msgInterval) {
10835
+ clearInterval(msgInterval);
10836
+ }
10801
10837
  res(null);
10802
10838
  }
10803
10839
  try {
@@ -10808,16 +10844,41 @@ var PendingAction;
10808
10844
  });
10809
10845
  if (action.Status !== EStatus.InProgress) {
10810
10846
  clearInterval(interval);
10847
+ if (msgInterval) {
10848
+ clearInterval(msgInterval);
10849
+ }
10811
10850
  res(action);
10812
10851
  }
10813
10852
  }
10814
10853
  catch (e) {
10854
+ clearInterval(interval);
10855
+ if (msgInterval) {
10856
+ clearInterval(msgInterval);
10857
+ }
10815
10858
  rej(e);
10816
10859
  }
10817
10860
  }), intMs);
10818
10861
  });
10862
+ // Gather latest 30 messages.
10863
+ if (!isDisposed || !isDisposed()) {
10864
+ const { messages } = yield GetMessages({
10865
+ api,
10866
+ actionId,
10867
+ order: Api.ESortOrder.Desc,
10868
+ startIndex: 0,
10869
+ amount: 30
10870
+ });
10871
+ for (let i = 0; i < messages.length; i++) {
10872
+ const message = messages[i];
10873
+ if (!returnedMsgs.has(message.ID)) {
10874
+ returnedMsgs.set(message.ID, true);
10875
+ returnedMsgsArr.push(message);
10876
+ }
10877
+ }
10878
+ }
10819
10879
  return {
10820
- action: res
10880
+ action: res,
10881
+ messages: returnedMsgsArr
10821
10882
  };
10822
10883
  });
10823
10884
  }
@@ -14258,7 +14319,7 @@ var DataSource;
14258
14319
  })(DataSource || (DataSource = {}));
14259
14320
 
14260
14321
  // This is updated with the package.json version on build.
14261
- const VERSION = "4.8.1";
14322
+ const VERSION = "4.8.2";
14262
14323
 
14263
14324
  export { VERSION, 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, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
14264
14325
  //# sourceMappingURL=bruce-models.es5.js.map