bruce-models 2.7.6 → 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.
@@ -59,6 +59,7 @@
59
59
  ECacheKey["LodCategory"] = "lodcategory";
60
60
  ECacheKey["Style"] = "style";
61
61
  ECacheKey["PublishTileset"] = "publishtileset";
62
+ ECacheKey["TilesetAccess"] = "tilesetaccess";
62
63
  ECacheKey["User"] = "user";
63
64
  ECacheKey["UserSettings"] = "usersettings";
64
65
  ECacheKey["UserEmail"] = "useremail";
@@ -9106,6 +9107,10 @@
9106
9107
  return exports.Api.ECacheKey.PublishTileset + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Id + tilesetId;
9107
9108
  }
9108
9109
  Publish.GetCacheKey = GetCacheKey;
9110
+ function GetAccessAllowedCacheKey(tilesetId, sourceAccountId, forAccountId) {
9111
+ return exports.Api.ECacheKey.PublishTileset + exports.Api.ECacheKey.TilesetAccess + exports.Api.ECacheKey.Id + tilesetId + exports.Api.ECacheKey.Id + sourceAccountId + exports.Api.ECacheKey.Id + forAccountId;
9112
+ }
9113
+ Publish.GetAccessAllowedCacheKey = GetAccessAllowedCacheKey;
9109
9114
  function Update(params) {
9110
9115
  return __awaiter(this, void 0, void 0, function* () {
9111
9116
  let { api, published: data, req: reqParams } = params;
@@ -9124,8 +9129,9 @@
9124
9129
  };
9125
9130
  data.ID = res.ID;
9126
9131
  yield api.POST(`tileset/${data.ID}/enableForAccounts`, req, reqParams);
9127
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9128
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9132
+ yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9133
+ yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9134
+ yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.PublishTileset + exports.Api.ECacheKey.TilesetAccess);
9129
9135
  return {
9130
9136
  published: data
9131
9137
  };
@@ -9198,6 +9204,59 @@
9198
9204
  });
9199
9205
  }
9200
9206
  Publish.GetList = GetList;
9207
+ /**
9208
+ * Returns if a given tileset is allowed to be loaded for a given account.
9209
+ * @param params
9210
+ */
9211
+ function IsAccessAllowed(params) {
9212
+ return __awaiter(this, void 0, void 0, function* () {
9213
+ let { tilesetId, sourceAccountId, api, forAccountId, req } = params;
9214
+ if (!forAccountId) {
9215
+ forAccountId = exports.ENVIRONMENT.PARAMS.accountId;
9216
+ }
9217
+ // Null source account id means it's a tileset from within the same account.
9218
+ // We also don't want to bother looking for records if we're loading in our own account.
9219
+ if (forAccountId == sourceAccountId || !sourceAccountId) {
9220
+ return true;
9221
+ }
9222
+ if (!api) {
9223
+ api = exports.ENVIRONMENT.Api().GetGlobalApi();
9224
+ }
9225
+ req = exports.Api.PrepReqParams(req);
9226
+ const key = GetAccessAllowedCacheKey(tilesetId, sourceAccountId, forAccountId);
9227
+ const cacheData = yield api.GetCacheItem(key, req);
9228
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
9229
+ return cacheData.data;
9230
+ }
9231
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
9232
+ var _a;
9233
+ try {
9234
+ // We try find the published record for the tileset.
9235
+ // If it doesn't exist, then it's not published.
9236
+ const { published } = yield GetList({
9237
+ accountId: sourceAccountId,
9238
+ api: api,
9239
+ });
9240
+ const tileset = published.find(x => x["Tileset.ID"] == tilesetId && x["PublishedBy.ClientAccount.ID"] == sourceAccountId);
9241
+ if (!tileset) {
9242
+ res(false);
9243
+ return;
9244
+ }
9245
+ res(tileset.IsPublic || (((_a = tileset["EnabledFor.ClientAccount.ID"]) === null || _a === void 0 ? void 0 : _a.length) && tileset["EnabledFor.ClientAccount.ID"].includes(forAccountId)));
9246
+ }
9247
+ catch (e) {
9248
+ rej(e);
9249
+ }
9250
+ }));
9251
+ yield api.SetCacheItem({
9252
+ key: key,
9253
+ value: prom,
9254
+ req: req
9255
+ });
9256
+ return prom;
9257
+ });
9258
+ }
9259
+ Publish.IsAccessAllowed = IsAccessAllowed;
9201
9260
  })(Publish = Tileset.Publish || (Tileset.Publish = {}));
9202
9261
  let Settings;
9203
9262
  (function (Settings) {
@@ -11717,7 +11776,7 @@
11717
11776
  DataSource.GetList = GetList;
11718
11777
  })(exports.DataSource || (exports.DataSource = {}));
11719
11778
 
11720
- const VERSION$1 = "2.7.6";
11779
+ const VERSION$1 = "2.7.7";
11721
11780
 
11722
11781
  exports.VERSION = VERSION$1;
11723
11782
  exports.AbstractApi = AbstractApi;