bruce-models 4.1.3 → 4.1.4

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.
@@ -8385,7 +8385,7 @@
8385
8385
  */
8386
8386
  function IsAccessAllowed(params) {
8387
8387
  return __awaiter(this, void 0, void 0, function* () {
8388
- let { tilesetId, sourceAccountId, api, forAccountId, req } = params;
8388
+ let { tilesetId, sourceAccountId, getters, forAccountId, req } = params;
8389
8389
  if (!forAccountId) {
8390
8390
  forAccountId = exports.ENVIRONMENT.PARAMS.accountId;
8391
8391
  }
@@ -8394,31 +8394,50 @@
8394
8394
  if (forAccountId == sourceAccountId || !sourceAccountId) {
8395
8395
  return true;
8396
8396
  }
8397
- if (!api) {
8398
- api = exports.ENVIRONMENT.Api().GetGlobalApi();
8397
+ if (!getters) {
8398
+ getters = exports.ENVIRONMENT.Api();
8399
8399
  }
8400
8400
  req = exports.Api.PrepReqParams(req);
8401
+ const globalApi = getters.GetGlobalApi();
8401
8402
  const key = GetAccessAllowedCacheKey(tilesetId, sourceAccountId, forAccountId);
8402
- const cacheData = yield api.GetCacheItem(key, req);
8403
+ const cacheData = globalApi.GetCacheItem(key, req);
8403
8404
  if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
8404
8405
  return cacheData.data;
8405
8406
  }
8406
8407
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8408
+ var _a;
8407
8409
  try {
8408
8410
  // We try find the published record for the tileset.
8409
8411
  // If it doesn't exist, then it's not published.
8410
8412
  const { published } = yield GetList({
8411
8413
  accountId: forAccountId,
8412
- api: api,
8414
+ api: globalApi,
8413
8415
  });
8414
8416
  const tileset = published.find(x => x["Tileset.ID"] == tilesetId && x["PublishedBy.ClientAccount.ID"] == sourceAccountId);
8415
- res(tileset != null);
8417
+ const allowed = tileset != null;
8418
+ if (allowed) {
8419
+ res(true);
8420
+ }
8421
+ // If not allowed we'll check if this is a CC3D tileset and if it's set as the selected "free" one.
8422
+ // This is a placeholder feature until a marketplace system is made.
8423
+ if (String(sourceAccountId).toLowerCase().trim() == "cc3d") {
8424
+ const settings = (yield exports.Account.GetAppSettings({
8425
+ accountId: forAccountId,
8426
+ appId: exports.Account.EAppId.Navigator,
8427
+ api: getters.GetGuardianApi()
8428
+ })).settings;
8429
+ const cc3dTilesetId = (_a = settings === null || settings === void 0 ? void 0 : settings.published) === null || _a === void 0 ? void 0 : _a.freeCC3dTilesetId;
8430
+ if (cc3dTilesetId == tilesetId) {
8431
+ res(true);
8432
+ }
8433
+ }
8434
+ res(false);
8416
8435
  }
8417
8436
  catch (e) {
8418
8437
  rej(e);
8419
8438
  }
8420
8439
  }));
8421
- yield api.SetCacheItem({
8440
+ globalApi.SetCacheItem({
8422
8441
  key: key,
8423
8442
  value: prom,
8424
8443
  req: req
@@ -11665,7 +11684,7 @@
11665
11684
  })(exports.DataSource || (exports.DataSource = {}));
11666
11685
 
11667
11686
  // This is updated with the package.json version on build.
11668
- const VERSION = "4.1.3";
11687
+ const VERSION = "4.1.4";
11669
11688
 
11670
11689
  exports.VERSION = VERSION;
11671
11690
  exports.AbstractApi = AbstractApi;