bruce-models 2.7.5 → 2.7.7

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.
@@ -54,6 +54,7 @@ var Api;
54
54
  ECacheKey["LodCategory"] = "lodcategory";
55
55
  ECacheKey["Style"] = "style";
56
56
  ECacheKey["PublishTileset"] = "publishtileset";
57
+ ECacheKey["TilesetAccess"] = "tilesetaccess";
57
58
  ECacheKey["User"] = "user";
58
59
  ECacheKey["UserSettings"] = "usersettings";
59
60
  ECacheKey["UserEmail"] = "useremail";
@@ -4796,14 +4797,26 @@ var CustomFormContent;
4796
4797
  (function (CustomFormContent) {
4797
4798
  let ECellType;
4798
4799
  (function (ECellType) {
4800
+ // Description-like text box that the user types in.
4799
4801
  ECellType[ECellType["StaticText"] = 0] = "StaticText";
4802
+ // Label + Value pair of an entity attribute.
4800
4803
  ECellType[ECellType["DataValue"] = 1] = "DataValue";
4804
+ // Static picture.
4801
4805
  ECellType[ECellType["StaticPicture"] = 2] = "StaticPicture";
4806
+ // Sub-section of the form. Contains other sections.
4802
4807
  ECellType[ECellType["SubSection"] = 3] = "SubSection";
4808
+ // Button that opens another form (or info view).
4803
4809
  ECellType[ECellType["ButtonMore"] = 4] = "ButtonMore";
4810
+ // Entity gallery.
4804
4811
  ECellType[ECellType["EntityPhoto"] = 5] = "EntityPhoto";
4812
+ // Embedded media frame. Eg: youtube video.
4805
4813
  ECellType[ECellType["EmbeddedMedia"] = 6] = "EmbeddedMedia";
4814
+ // Deprecated
4806
4815
  ECellType[ECellType["Chart"] = 7] = "Chart";
4816
+ // Similar to DataValue, except it populates a description-like text-box.
4817
+ ECellType[ECellType["EntityText"] = 8] = "EntityText";
4818
+ // Icon and optional action associated with it.
4819
+ ECellType[ECellType["Icon"] = 9] = "Icon";
4807
4820
  })(ECellType = CustomFormContent.ECellType || (CustomFormContent.ECellType = {}));
4808
4821
  let EFlowDirection;
4809
4822
  (function (EFlowDirection) {
@@ -9253,6 +9266,10 @@ var Tileset;
9253
9266
  return Api.ECacheKey.PublishTileset + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + tilesetId;
9254
9267
  }
9255
9268
  Publish.GetCacheKey = GetCacheKey;
9269
+ function GetAccessAllowedCacheKey(tilesetId, sourceAccountId, forAccountId) {
9270
+ return Api.ECacheKey.PublishTileset + Api.ECacheKey.TilesetAccess + Api.ECacheKey.Id + tilesetId + Api.ECacheKey.Id + sourceAccountId + Api.ECacheKey.Id + forAccountId;
9271
+ }
9272
+ Publish.GetAccessAllowedCacheKey = GetAccessAllowedCacheKey;
9256
9273
  function Update(params) {
9257
9274
  return __awaiter(this, void 0, void 0, function* () {
9258
9275
  let { api, published: data, req: reqParams } = params;
@@ -9271,8 +9288,9 @@ var Tileset;
9271
9288
  };
9272
9289
  data.ID = res.ID;
9273
9290
  yield api.POST(`tileset/${data.ID}/enableForAccounts`, req, reqParams);
9274
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9275
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9291
+ yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9292
+ yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9293
+ yield api.Cache.RemoveByStartsWith(Api.ECacheKey.PublishTileset + Api.ECacheKey.TilesetAccess);
9276
9294
  return {
9277
9295
  published: data
9278
9296
  };
@@ -9345,6 +9363,59 @@ var Tileset;
9345
9363
  });
9346
9364
  }
9347
9365
  Publish.GetList = GetList;
9366
+ /**
9367
+ * Returns if a given tileset is allowed to be loaded for a given account.
9368
+ * @param params
9369
+ */
9370
+ function IsAccessAllowed(params) {
9371
+ return __awaiter(this, void 0, void 0, function* () {
9372
+ let { tilesetId, sourceAccountId, api, forAccountId, req } = params;
9373
+ if (!forAccountId) {
9374
+ forAccountId = ENVIRONMENT.PARAMS.accountId;
9375
+ }
9376
+ // Null source account id means it's a tileset from within the same account.
9377
+ // We also don't want to bother looking for records if we're loading in our own account.
9378
+ if (forAccountId == sourceAccountId || !sourceAccountId) {
9379
+ return true;
9380
+ }
9381
+ if (!api) {
9382
+ api = ENVIRONMENT.Api().GetGlobalApi();
9383
+ }
9384
+ req = Api.PrepReqParams(req);
9385
+ const key = GetAccessAllowedCacheKey(tilesetId, sourceAccountId, forAccountId);
9386
+ const cacheData = yield api.GetCacheItem(key, req);
9387
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
9388
+ return cacheData.data;
9389
+ }
9390
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
9391
+ var _a;
9392
+ try {
9393
+ // We try find the published record for the tileset.
9394
+ // If it doesn't exist, then it's not published.
9395
+ const { published } = yield GetList({
9396
+ accountId: sourceAccountId,
9397
+ api: api,
9398
+ });
9399
+ const tileset = published.find(x => x["Tileset.ID"] == tilesetId && x["PublishedBy.ClientAccount.ID"] == sourceAccountId);
9400
+ if (!tileset) {
9401
+ res(false);
9402
+ return;
9403
+ }
9404
+ res(tileset.IsPublic || (((_a = tileset["EnabledFor.ClientAccount.ID"]) === null || _a === void 0 ? void 0 : _a.length) && tileset["EnabledFor.ClientAccount.ID"].includes(forAccountId)));
9405
+ }
9406
+ catch (e) {
9407
+ rej(e);
9408
+ }
9409
+ }));
9410
+ yield api.SetCacheItem({
9411
+ key: key,
9412
+ value: prom,
9413
+ req: req
9414
+ });
9415
+ return prom;
9416
+ });
9417
+ }
9418
+ Publish.IsAccessAllowed = IsAccessAllowed;
9348
9419
  })(Publish = Tileset.Publish || (Tileset.Publish = {}));
9349
9420
  let Settings;
9350
9421
  (function (Settings) {
@@ -11940,7 +12011,7 @@ var DataSource;
11940
12011
  DataSource.GetList = GetList;
11941
12012
  })(DataSource || (DataSource = {}));
11942
12013
 
11943
- const VERSION$1 = "2.7.5";
12014
+ const VERSION$1 = "2.7.7";
11944
12015
 
11945
12016
  export { VERSION$1 as VERSION, AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
11946
12017
  //# sourceMappingURL=bruce-models.es5.js.map