bruce-models 6.0.8 → 6.1.0

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.
@@ -1780,55 +1780,89 @@
1780
1780
  * @returns
1781
1781
  */
1782
1782
  function GetList(params) {
1783
+ var _a;
1783
1784
  return __awaiter(this, void 0, void 0, function* () {
1784
1785
  let { api, req: reqParams } = params;
1785
1786
  if (!api) {
1786
1787
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1787
1788
  }
1788
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1789
- try {
1790
- let url = "v3/assemblies";
1791
- const urlParams = new URLSearchParams();
1792
- if (params.pageSize != null) {
1793
- urlParams.append("PageSize", String(params.pageSize));
1794
- }
1795
- if (params.pageIndex != null) {
1796
- urlParams.append("PageIndex", String(params.pageIndex));
1797
- }
1798
- if (params.parentId) {
1799
- urlParams.append("ParentID", String(params.parentId));
1800
- }
1801
- if (params.search) {
1802
- urlParams.append("Search", params.search);
1803
- }
1804
- if (params.withTilesets != null) {
1805
- urlParams.append("WithTilesets", String(params.withTilesets));
1806
- }
1807
- if (params.ids != null) {
1808
- for (let i = 0; i < params.ids.length; i++) {
1809
- urlParams.append("ID", String(params.ids[i]));
1789
+ // Separate code for IDs to avoid overloading URL.
1790
+ // If we're searching for IDs, we'll batch in 50 at a time then return the total.
1791
+ if (((_a = params.ids) === null || _a === void 0 ? void 0 : _a.length) && params.ids.length > 50) {
1792
+ const assemblies = [];
1793
+ let ids = [...params.ids];
1794
+ while (ids.length > 0) {
1795
+ const batch = ids.splice(0, 50);
1796
+ const result = yield GetList({
1797
+ api,
1798
+ req: reqParams,
1799
+ pageSize: batch.length,
1800
+ pageIndex: 0,
1801
+ ids: batch,
1802
+ parentId: params.parentId,
1803
+ search: params.search,
1804
+ withTilesets: params.withTilesets
1805
+ });
1806
+ assemblies.push(...result.assemblies);
1807
+ }
1808
+ const result = {};
1809
+ result.assemblies = assemblies;
1810
+ result.totalCount = assemblies.length;
1811
+ result.nextPage = false;
1812
+ return result;
1813
+ }
1814
+ else {
1815
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1816
+ try {
1817
+ let url = "v3/assemblies";
1818
+ const urlParams = new URLSearchParams();
1819
+ if (params.pageSize != null) {
1820
+ urlParams.append("PageSize", String(params.pageSize));
1810
1821
  }
1822
+ if (params.pageIndex != null) {
1823
+ urlParams.append("PageIndex", String(params.pageIndex));
1824
+ }
1825
+ if (params.parentId) {
1826
+ urlParams.append("ParentID", String(params.parentId));
1827
+ }
1828
+ if (params.search) {
1829
+ urlParams.append("Search", params.search);
1830
+ }
1831
+ if (params.withTilesets != null) {
1832
+ urlParams.append("WithTilesets", String(params.withTilesets));
1833
+ }
1834
+ if (params.ids != null) {
1835
+ for (let i = 0; i < params.ids.length; i++) {
1836
+ urlParams.append("ID", String(params.ids[i]));
1837
+ }
1838
+ if (params.pageIndex != null) {
1839
+ urlParams.append("PageIndex", String(0));
1840
+ }
1841
+ if (params.pageSize != null) {
1842
+ urlParams.append("PageSize", String(params.ids.length));
1843
+ }
1844
+ }
1845
+ url += "?" + urlParams.toString();
1846
+ const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
1847
+ const result = {};
1848
+ result.assemblies = data.Items ? data.Items : [];
1849
+ if (data.TotalCount != null) {
1850
+ result.totalCount = data.TotalCount;
1851
+ }
1852
+ if (data.NextPage != null) {
1853
+ result.nextPage = data.NextPage;
1854
+ }
1855
+ if (data.NextPageURL != null) {
1856
+ result.nextPageUrl = data.NextPageURL;
1857
+ }
1858
+ res(result);
1811
1859
  }
1812
- url += "?" + urlParams.toString();
1813
- const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
1814
- const result = {};
1815
- result.assemblies = data.Items ? data.Items : [];
1816
- if (data.TotalCount != null) {
1817
- result.totalCount = data.TotalCount;
1818
- }
1819
- if (data.NextPage != null) {
1820
- result.nextPage = data.NextPage;
1821
- }
1822
- if (data.NextPageURL != null) {
1823
- result.nextPageUrl = data.NextPageURL;
1860
+ catch (e) {
1861
+ rej(e);
1824
1862
  }
1825
- res(result);
1826
- }
1827
- catch (e) {
1828
- rej(e);
1829
- }
1830
- }));
1831
- return req;
1863
+ }));
1864
+ return req;
1865
+ }
1832
1866
  });
1833
1867
  }
1834
1868
  Assembly.GetList = GetList;
@@ -11222,6 +11256,52 @@
11222
11256
  });
11223
11257
  }
11224
11258
  PendingAction.Get = Get;
11259
+ /**
11260
+ * Returns a list of pending action records by their IDs.
11261
+ * @param params
11262
+ */
11263
+ function GetList(params) {
11264
+ var _a;
11265
+ return __awaiter(this, void 0, void 0, function* () {
11266
+ let { api, ids, reqParams } = params;
11267
+ if (!ids || ids.length === 0) {
11268
+ throw ("IDs are required.");
11269
+ }
11270
+ if (!api) {
11271
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
11272
+ }
11273
+ // Separate code for IDs to avoid overloading URL.
11274
+ // If we're searching for IDs, we'll batch in 50 at a time then return the total.
11275
+ if (((_a = params.ids) === null || _a === void 0 ? void 0 : _a.length) && params.ids.length > 50) {
11276
+ const actions = [];
11277
+ let ids = [...params.ids];
11278
+ while (ids.length > 0) {
11279
+ const batch = ids.splice(0, 50);
11280
+ const result = yield GetList({
11281
+ ids: batch,
11282
+ api,
11283
+ reqParams
11284
+ });
11285
+ actions.push(...result.actions);
11286
+ }
11287
+ const result = {};
11288
+ result.actions = actions;
11289
+ return result;
11290
+ }
11291
+ else {
11292
+ const urlParams = new URLSearchParams();
11293
+ urlParams.append("IDs", ids.join(","));
11294
+ urlParams.append("PageSize", ids.length.toString());
11295
+ urlParams.append("PageIndex", "0");
11296
+ const url = `pendingActions?${urlParams.toString()}`;
11297
+ const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
11298
+ return {
11299
+ actions: data.Items
11300
+ };
11301
+ }
11302
+ });
11303
+ }
11304
+ PendingAction.GetList = GetList;
11225
11305
  /**
11226
11306
  * Returns a list of pending action records.
11227
11307
  * @param params
@@ -15429,7 +15509,7 @@
15429
15509
  })(exports.Scenario || (exports.Scenario = {}));
15430
15510
 
15431
15511
  // This is updated with the package.json version on build.
15432
- const VERSION = "6.0.8";
15512
+ const VERSION = "6.1.0";
15433
15513
 
15434
15514
  exports.VERSION = VERSION;
15435
15515
  exports.AbstractApi = AbstractApi;