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.
@@ -831,14 +831,14 @@ var Account;
831
831
  Account.Create = Create;
832
832
  function GetDbRegions(params) {
833
833
  return __awaiter(this, void 0, void 0, function* () {
834
- const { api, req: reqParams } = params;
834
+ const { api, req: reqParams, key } = params;
835
835
  const cacheData = api.GetCacheItem(GetDbRegionListCacheKey(), reqParams);
836
836
  if (cacheData) {
837
837
  return cacheData;
838
838
  }
839
839
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
840
840
  try {
841
- const data = yield api.GET("config/regions", Api.PrepReqParams(reqParams));
841
+ const data = yield api.GET(`config/regions${key ? "?Key=" + key : ""}`, Api.PrepReqParams(reqParams));
842
842
  res(data);
843
843
  }
844
844
  catch (e) {
@@ -1126,29 +1126,31 @@ var BruceApi;
1126
1126
  throw ("Specified Environment is not valid. SuppliedEnv=" + env);
1127
1127
  }
1128
1128
  this.baseUrl = url;
1129
- if (cam && loadRegionalUrl) {
1130
- // Attempt to load an account specific base url.
1131
- // This could be one with a region specific endpoint.
1132
- try {
1133
- const settings = (yield Account.GetAppSettings({
1134
- api: cam,
1135
- accountId: this.accountId,
1136
- appId: Account.EAppId.BruceApi
1137
- })).settings;
1138
- if (this.loadCancelled) {
1139
- console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1140
- return;
1141
- }
1142
- let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1143
- if (typeof endpoint == "string") {
1144
- if (!endpoint.endsWith("/")) {
1145
- endpoint += "/";
1129
+ if (cam) {
1130
+ if (loadRegionalUrl) {
1131
+ // Attempt to load an account specific base url.
1132
+ // This could be one with a region specific endpoint.
1133
+ try {
1134
+ const settings = (yield Account.GetAppSettings({
1135
+ api: cam,
1136
+ accountId: this.accountId,
1137
+ appId: Account.EAppId.BruceApi
1138
+ })).settings;
1139
+ if (this.loadCancelled) {
1140
+ console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1141
+ return;
1142
+ }
1143
+ let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1144
+ if (typeof endpoint == "string") {
1145
+ if (!endpoint.endsWith("/")) {
1146
+ endpoint += "/";
1147
+ }
1148
+ this.baseUrl = endpoint;
1146
1149
  }
1147
- this.baseUrl = endpoint;
1148
1150
  }
1149
- }
1150
- catch (e) {
1151
- console.error(e);
1151
+ catch (e) {
1152
+ console.error(e);
1153
+ }
1152
1154
  }
1153
1155
  }
1154
1156
  try {
@@ -1878,7 +1880,7 @@ var Entity;
1878
1880
  Entity.CalculateName = CalculateName;
1879
1881
  function GetList(params) {
1880
1882
  return __awaiter(this, void 0, void 0, function* () {
1881
- const { api, filter, req: reqParams } = params;
1883
+ const { api, filter, req: reqParams, viaCdn, viaCdnCacheToken } = params;
1882
1884
  let requestFilter = {};
1883
1885
  if (filter.entityTypeConditions) {
1884
1886
  requestFilter = Object.assign({}, filter.entityTypeConditions);
@@ -1907,17 +1909,50 @@ var Entity;
1907
1909
  PageIndex: filter.pageIndex,
1908
1910
  PageSize: filter.pageSize
1909
1911
  };
1910
- const data = yield api.POST("entities", body, Api.PrepReqParams(reqParams));
1911
- const entities = data.Items;
1912
- for (let i = 0; i < entities.length; i++) {
1913
- const entity = entities[i];
1914
- const id = entity.Bruce.ID;
1915
- api.Cache.Set(GetCacheKey(id), {
1916
- entity: entity
1917
- }, Api.DEFAULT_CACHE_DURATION);
1912
+ let entities = [];
1913
+ if (viaCdn && api.EntityCdnUrl) {
1914
+ const url = new URL(api.EntityCdnUrl);
1915
+ const urlParams = new URLSearchParams(url.search);
1916
+ urlParams.set("cacheToken", String(viaCdnCacheToken ? viaCdnCacheToken : 0));
1917
+ if (body.SortOrder) {
1918
+ urlParams.set("SortOrder", body.SortOrder);
1919
+ }
1920
+ if (body.OrderBy) {
1921
+ urlParams.set("OrderBy", body.OrderBy);
1922
+ }
1923
+ if (body.Filter) {
1924
+ urlParams.set("Filter", JSON.stringify(body.Filter));
1925
+ }
1926
+ if (body.LODType) {
1927
+ urlParams.set("LODType", body.LODType);
1928
+ }
1929
+ if (body.BruceEntityType) {
1930
+ urlParams.set("BruceEntityType", body.BruceEntityType);
1931
+ }
1932
+ if (body.PageIndex) {
1933
+ urlParams.set("PageIndex", String(body.PageIndex));
1934
+ }
1935
+ if (body.PageSize) {
1936
+ urlParams.set("PageSize", String(body.PageSize));
1937
+ }
1938
+ const urlStr = url.toString() + "?" + urlParams.toString();
1939
+ const data = yield api.get(urlStr, Api.PrepReqParams(reqParams));
1940
+ entities = data.Items;
1941
+ }
1942
+ else {
1943
+ const data = yield api.POST("entities", body, Api.PrepReqParams(reqParams));
1944
+ entities = data.Items;
1945
+ // Only caching when non-CDN.
1946
+ for (let i = 0; i < entities.length; i++) {
1947
+ const entity = entities[i];
1948
+ const id = entity.Bruce.ID;
1949
+ api.Cache.Set(GetCacheKey(id), {
1950
+ entity: entity
1951
+ }, Api.DEFAULT_CACHE_DURATION);
1952
+ }
1918
1953
  }
1919
1954
  return {
1920
- entities: entities
1955
+ entities
1921
1956
  };
1922
1957
  });
1923
1958
  }
@@ -4110,7 +4145,7 @@ var EntityFilterGetter;
4110
4145
  EStatus["Loading"] = "LOADING";
4111
4146
  })(EStatus = EntityFilterGetter.EStatus || (EntityFilterGetter.EStatus = {}));
4112
4147
  class Getter {
4113
- constructor(api, viewPort, typeId, batchSize, attrFilter) {
4148
+ constructor(api, viewPort, typeId, batchSize, attrFilter, viaCdn) {
4114
4149
  this.onUpdate = null;
4115
4150
  this.LastStateUpdates = {};
4116
4151
  this.onStateUpdate = null;
@@ -4126,7 +4161,8 @@ var EntityFilterGetter;
4126
4161
  this.viewCenter = null;
4127
4162
  this.api = api;
4128
4163
  this.typeId = typeId;
4129
- this.batchSize = batchSize;
4164
+ this.viaCdn = Boolean(viaCdn);
4165
+ this.batchSize = isNaN(batchSize) ? 300 : batchSize;
4130
4166
  this.viewPort = viewPort;
4131
4167
  this.attrFilter = attrFilter;
4132
4168
  this.updateBounds();
@@ -4303,7 +4339,8 @@ var EntityFilterGetter;
4303
4339
  bounds: curCell.GetBounds(),
4304
4340
  sortOrder: Api.ESortOrder.Asc,
4305
4341
  entityTypeConditions: this.attrFilter
4306
- }
4342
+ },
4343
+ viaCdn: this.viaCdn
4307
4344
  });
4308
4345
  const integrity = this.getIntegrityId();
4309
4346
  if (loopIntegrity == integrity && entities) {