bruce-models 5.9.5 → 5.9.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.
@@ -1734,21 +1734,26 @@
1734
1734
  */
1735
1735
  function Get(params) {
1736
1736
  return __awaiter(this, void 0, void 0, function* () {
1737
- let { api, assemblyId, req: reqParams } = params;
1737
+ let { api, assemblyId, req: reqParams, expand } = params;
1738
1738
  if (!api) {
1739
1739
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1740
1740
  }
1741
+ if (expand == null) {
1742
+ expand = true;
1743
+ }
1741
1744
  if (!assemblyId) {
1742
1745
  throw ("Assembly ID is required.");
1743
1746
  }
1744
- const key = GetCacheKey(assemblyId);
1747
+ const key = GetCacheKey(assemblyId, expand);
1745
1748
  const cache = api.GetCacheItem(key, reqParams);
1746
1749
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
1747
1750
  return cache.data;
1748
1751
  }
1749
1752
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1750
1753
  try {
1751
- const data = yield api.GET(`v3/assembly/${assemblyId}`, exports.Api.PrepReqParams(reqParams));
1754
+ let url = `v3/assembly/${assemblyId}`;
1755
+ url += "?Expand=" + (expand ? "true" : "false");
1756
+ const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
1752
1757
  res({
1753
1758
  assembly: data
1754
1759
  });
@@ -1835,7 +1840,7 @@
1835
1840
  }
1836
1841
  const url = `v3/assembly/${data.ID}`;
1837
1842
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
1838
- api.Cache.Remove(GetCacheKey(data.ID));
1843
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Assembly + exports.Api.ECacheKey.Id + data.ID);
1839
1844
  return {
1840
1845
  assembly: res
1841
1846
  };
@@ -1856,7 +1861,7 @@
1856
1861
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1857
1862
  }
1858
1863
  yield api.DELETE(`v3/assembly/${assemblyId}`, exports.Api.PrepReqParams(reqParams));
1859
- api.Cache.Remove(GetCacheKey(assemblyId));
1864
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Assembly + exports.Api.ECacheKey.Id + assemblyId);
1860
1865
  });
1861
1866
  }
1862
1867
  Assembly.Delete = Delete;
@@ -1912,8 +1917,8 @@
1912
1917
  * @param assemblyId
1913
1918
  * @returns
1914
1919
  */
1915
- function GetCacheKey(assemblyId) {
1916
- return `${exports.Api.ECacheKey.Assembly}${exports.Api.ECacheKey.Id}${assemblyId}`;
1920
+ function GetCacheKey(assemblyId, expand) {
1921
+ return `${exports.Api.ECacheKey.Assembly}${exports.Api.ECacheKey.Id}${assemblyId}${String(Boolean(expand))}`;
1917
1922
  }
1918
1923
  Assembly.GetCacheKey = GetCacheKey;
1919
1924
  })(exports.Assembly || (exports.Assembly = {}));
@@ -4027,7 +4032,7 @@
4027
4032
  OrderBy: filter.orderBy,
4028
4033
  Filter: requestFilter,
4029
4034
  LODType: filter.lodCategoryId,
4030
- BruceEntityType: filter.entityTypeId,
4035
+ BruceEntityType: (!filter.entityTypeId ? null : filter.entityTypeId),
4031
4036
  PageIndex: filter.pageIndex,
4032
4037
  PageSize: filter.pageSize,
4033
4038
  historicKey: historicKey,
@@ -4079,7 +4084,7 @@
4079
4084
  urlParams.set("LODType", body.LODType);
4080
4085
  }
4081
4086
  if (body.BruceEntityType) {
4082
- urlParams.set("BruceEntityType", body.BruceEntityType);
4087
+ urlParams.set("BruceEntityType", typeof body.BruceEntityType == "string" ? body.BruceEntityType : body.BruceEntityType.join(","));
4083
4088
  }
4084
4089
  if (body.PageIndex) {
4085
4090
  urlParams.set("PageIndex", String(body.PageIndex));
@@ -4178,7 +4183,7 @@
4178
4183
  expandLocation,
4179
4184
  expandImports,
4180
4185
  expandSources,
4181
- entityTypeId: filter.entityTypeId,
4186
+ entityTypeId: typeof filter.entityTypeId == "string" ? filter.entityTypeId : filter.entityTypeId.join(","),
4182
4187
  historicFrom: historicFrom,
4183
4188
  historicKey: historicKey,
4184
4189
  historicTo: historicTo,
@@ -4197,12 +4202,40 @@
4197
4202
  nextPage = data.NextPage;
4198
4203
  nextPageUrl = data.NextPageURL;
4199
4204
  }
4205
+ // Callback to get the next page.
4206
+ let getNextPage;
4207
+ if (nextPage) {
4208
+ getNextPage = () => __awaiter(this, void 0, void 0, function* () {
4209
+ let urlStr = null;
4210
+ if (nextPageUrl.startsWith("http")) {
4211
+ urlStr = nextPageUrl;
4212
+ }
4213
+ else {
4214
+ urlStr = api.ConstructUrl({
4215
+ cdn: false,
4216
+ url: nextPageUrl
4217
+ });
4218
+ }
4219
+ const data = yield api.get(urlStr, exports.Api.PrepReqParams(reqParams));
4220
+ // Update URL so we can re-use the same function instance.
4221
+ nextPageUrl = data.NextPageURL;
4222
+ return {
4223
+ entities: data.Items,
4224
+ totalCount: data.TotalCount,
4225
+ imports: data.Imports,
4226
+ nextPage: data.NextPage,
4227
+ nextPageUrl: data.NextPageURL,
4228
+ getNextPage: nextPageUrl ? getNextPage : null
4229
+ };
4230
+ });
4231
+ }
4200
4232
  return {
4201
4233
  entities,
4202
4234
  totalCount,
4203
4235
  imports,
4204
4236
  nextPage,
4205
- nextPageUrl
4237
+ nextPageUrl,
4238
+ getNextPage
4206
4239
  };
4207
4240
  });
4208
4241
  }
@@ -15307,7 +15340,7 @@
15307
15340
  })(exports.Scenario || (exports.Scenario = {}));
15308
15341
 
15309
15342
  // This is updated with the package.json version on build.
15310
- const VERSION = "5.9.5";
15343
+ const VERSION = "5.9.7";
15311
15344
 
15312
15345
  exports.VERSION = VERSION;
15313
15346
  exports.AbstractApi = AbstractApi;