bruce-models 1.7.5 → 1.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.
@@ -820,14 +820,14 @@
820
820
  Account.Create = Create;
821
821
  function GetDbRegions(params) {
822
822
  return __awaiter(this, void 0, void 0, function* () {
823
- const { api, req: reqParams } = params;
823
+ const { api, req: reqParams, key } = params;
824
824
  const cacheData = api.GetCacheItem(GetDbRegionListCacheKey(), reqParams);
825
825
  if (cacheData) {
826
826
  return cacheData;
827
827
  }
828
828
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
829
829
  try {
830
- const data = yield api.GET("config/regions", exports.Api.PrepReqParams(reqParams));
830
+ const data = yield api.GET(`config/regions${key ? "?Key=" + key : ""}`, exports.Api.PrepReqParams(reqParams));
831
831
  res(data);
832
832
  }
833
833
  catch (e) {
@@ -1108,29 +1108,31 @@
1108
1108
  throw ("Specified Environment is not valid. SuppliedEnv=" + env);
1109
1109
  }
1110
1110
  this.baseUrl = url;
1111
- if (cam && loadRegionalUrl) {
1112
- // Attempt to load an account specific base url.
1113
- // This could be one with a region specific endpoint.
1114
- try {
1115
- const settings = (yield exports.Account.GetAppSettings({
1116
- api: cam,
1117
- accountId: this.accountId,
1118
- appId: exports.Account.EAppId.BruceApi
1119
- })).settings;
1120
- if (this.loadCancelled) {
1121
- console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1122
- return;
1123
- }
1124
- let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1125
- if (typeof endpoint == "string") {
1126
- if (!endpoint.endsWith("/")) {
1127
- endpoint += "/";
1111
+ if (cam) {
1112
+ if (loadRegionalUrl) {
1113
+ // Attempt to load an account specific base url.
1114
+ // This could be one with a region specific endpoint.
1115
+ try {
1116
+ const settings = (yield exports.Account.GetAppSettings({
1117
+ api: cam,
1118
+ accountId: this.accountId,
1119
+ appId: exports.Account.EAppId.BruceApi
1120
+ })).settings;
1121
+ if (this.loadCancelled) {
1122
+ console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1123
+ return;
1124
+ }
1125
+ let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1126
+ if (typeof endpoint == "string") {
1127
+ if (!endpoint.endsWith("/")) {
1128
+ endpoint += "/";
1129
+ }
1130
+ this.baseUrl = endpoint;
1128
1131
  }
1129
- this.baseUrl = endpoint;
1130
1132
  }
1131
- }
1132
- catch (e) {
1133
- console.error(e);
1133
+ catch (e) {
1134
+ console.error(e);
1135
+ }
1134
1136
  }
1135
1137
  }
1136
1138
  try {
@@ -1849,7 +1851,7 @@
1849
1851
  Entity.CalculateName = CalculateName;
1850
1852
  function GetList(params) {
1851
1853
  return __awaiter(this, void 0, void 0, function* () {
1852
- const { api, filter, req: reqParams } = params;
1854
+ const { api, filter, req: reqParams, viaCdn, viaCdnCacheToken } = params;
1853
1855
  let requestFilter = {};
1854
1856
  if (filter.entityTypeConditions) {
1855
1857
  requestFilter = Object.assign({}, filter.entityTypeConditions);
@@ -1878,17 +1880,50 @@
1878
1880
  PageIndex: filter.pageIndex,
1879
1881
  PageSize: filter.pageSize
1880
1882
  };
1881
- const data = yield api.POST("entities", body, exports.Api.PrepReqParams(reqParams));
1882
- const entities = data.Items;
1883
- for (let i = 0; i < entities.length; i++) {
1884
- const entity = entities[i];
1885
- const id = entity.Bruce.ID;
1886
- api.Cache.Set(GetCacheKey(id), {
1887
- entity: entity
1888
- }, exports.Api.DEFAULT_CACHE_DURATION);
1883
+ let entities = [];
1884
+ if (viaCdn && api.EntityCdnUrl) {
1885
+ const url = new URL(api.EntityCdnUrl);
1886
+ const urlParams = new URLSearchParams(url.search);
1887
+ urlParams.set("cacheToken", String(viaCdnCacheToken ? viaCdnCacheToken : 0));
1888
+ if (body.SortOrder) {
1889
+ urlParams.set("SortOrder", body.SortOrder);
1890
+ }
1891
+ if (body.OrderBy) {
1892
+ urlParams.set("OrderBy", body.OrderBy);
1893
+ }
1894
+ if (body.Filter) {
1895
+ urlParams.set("Filter", JSON.stringify(body.Filter));
1896
+ }
1897
+ if (body.LODType) {
1898
+ urlParams.set("LODType", body.LODType);
1899
+ }
1900
+ if (body.BruceEntityType) {
1901
+ urlParams.set("BruceEntityType", body.BruceEntityType);
1902
+ }
1903
+ if (body.PageIndex) {
1904
+ urlParams.set("PageIndex", String(body.PageIndex));
1905
+ }
1906
+ if (body.PageSize) {
1907
+ urlParams.set("PageSize", String(body.PageSize));
1908
+ }
1909
+ const urlStr = url.toString() + "?" + urlParams.toString();
1910
+ const data = yield api.get(urlStr, exports.Api.PrepReqParams(reqParams));
1911
+ entities = data.Items;
1912
+ }
1913
+ else {
1914
+ const data = yield api.POST("entities", body, exports.Api.PrepReqParams(reqParams));
1915
+ entities = data.Items;
1916
+ // Only caching when non-CDN.
1917
+ for (let i = 0; i < entities.length; i++) {
1918
+ const entity = entities[i];
1919
+ const id = entity.Bruce.ID;
1920
+ api.Cache.Set(GetCacheKey(id), {
1921
+ entity: entity
1922
+ }, exports.Api.DEFAULT_CACHE_DURATION);
1923
+ }
1889
1924
  }
1890
1925
  return {
1891
- entities: entities
1926
+ entities
1892
1927
  };
1893
1928
  });
1894
1929
  }
@@ -3998,7 +4033,7 @@
3998
4033
  EStatus["Loading"] = "LOADING";
3999
4034
  })(EStatus = EntityFilterGetter.EStatus || (EntityFilterGetter.EStatus = {}));
4000
4035
  class Getter {
4001
- constructor(api, viewPort, typeId, batchSize, attrFilter) {
4036
+ constructor(api, viewPort, typeId, batchSize, attrFilter, viaCdn) {
4002
4037
  this.onUpdate = null;
4003
4038
  this.LastStateUpdates = {};
4004
4039
  this.onStateUpdate = null;
@@ -4014,7 +4049,8 @@
4014
4049
  this.viewCenter = null;
4015
4050
  this.api = api;
4016
4051
  this.typeId = typeId;
4017
- this.batchSize = batchSize;
4052
+ this.viaCdn = Boolean(viaCdn);
4053
+ this.batchSize = isNaN(batchSize) ? 300 : batchSize;
4018
4054
  this.viewPort = viewPort;
4019
4055
  this.attrFilter = attrFilter;
4020
4056
  this.updateBounds();
@@ -4191,7 +4227,8 @@
4191
4227
  bounds: curCell.GetBounds(),
4192
4228
  sortOrder: exports.Api.ESortOrder.Asc,
4193
4229
  entityTypeConditions: this.attrFilter
4194
- }
4230
+ },
4231
+ viaCdn: this.viaCdn
4195
4232
  });
4196
4233
  const integrity = this.getIntegrityId();
4197
4234
  if (loopIntegrity == integrity && entities) {