bruce-models 4.8.0 → 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;
@@ -10758,6 +10761,128 @@ var PendingAction;
10758
10761
  });
10759
10762
  }
10760
10763
  PendingAction.Cancel = Cancel;
10764
+ /**
10765
+ * Resolves when the Pending Action is no longer running.
10766
+ * @param params
10767
+ *
10768
+ * @example
10769
+ * try {
10770
+ * const { action } = await PendingAction.OnCompletion({ actionId: 123 });
10771
+ * }
10772
+ * catch (e) {
10773
+ * // Threw because the action failed to be found.
10774
+ * // Most likely scenarios are invalid actionId or server connection issues.
10775
+ * // If it's related to server connection issues then wait a bit and relaunch.
10776
+ * }
10777
+ *
10778
+ * // Here is how you can stop the loop on early disposal.
10779
+ * let disposed = false;
10780
+ * const { action } = await PendingAction.OnCompletion({
10781
+ * actionId: 123,
10782
+ * isDisposed: () => {
10783
+ * return disposed;
10784
+ * }
10785
+ * });
10786
+ * // Action will resolve as null if it was disposed early.
10787
+ */
10788
+ function OnCompletion(params) {
10789
+ return __awaiter(this, void 0, void 0, function* () {
10790
+ let { api, actionId, req: reqParams, interval: intMs, isDisposed, onMessage } = params;
10791
+ if (!actionId) {
10792
+ throw ("Action ID is required.");
10793
+ }
10794
+ if (!api) {
10795
+ api = ENVIRONMENT.Api().GetBruceApi();
10796
+ }
10797
+ if (!intMs || intMs <= 0) {
10798
+ intMs = 3000;
10799
+ }
10800
+ // Map of found messages.
10801
+ const returnedMsgs = new Map();
10802
+ const returnedMsgsArr = [];
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
+ }
10831
+ let interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
10832
+ if (isDisposed && isDisposed()) {
10833
+ clearInterval(interval);
10834
+ if (msgInterval) {
10835
+ clearInterval(msgInterval);
10836
+ }
10837
+ res(null);
10838
+ }
10839
+ try {
10840
+ const { action } = yield Get({
10841
+ api,
10842
+ actionId,
10843
+ req: reqParams
10844
+ });
10845
+ if (action.Status !== EStatus.InProgress) {
10846
+ clearInterval(interval);
10847
+ if (msgInterval) {
10848
+ clearInterval(msgInterval);
10849
+ }
10850
+ res(action);
10851
+ }
10852
+ }
10853
+ catch (e) {
10854
+ clearInterval(interval);
10855
+ if (msgInterval) {
10856
+ clearInterval(msgInterval);
10857
+ }
10858
+ rej(e);
10859
+ }
10860
+ }), intMs);
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
+ }
10879
+ return {
10880
+ action: res,
10881
+ messages: returnedMsgsArr
10882
+ };
10883
+ });
10884
+ }
10885
+ PendingAction.OnCompletion = OnCompletion;
10761
10886
  })(PendingAction || (PendingAction = {}));
10762
10887
 
10763
10888
  // Some dead accounts that we don't want to show in the UI.
@@ -14194,7 +14319,7 @@ var DataSource;
14194
14319
  })(DataSource || (DataSource = {}));
14195
14320
 
14196
14321
  // This is updated with the package.json version on build.
14197
- const VERSION = "4.8.0";
14322
+ const VERSION = "4.8.2";
14198
14323
 
14199
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 };
14200
14325
  //# sourceMappingURL=bruce-models.es5.js.map