bruce-models 5.9.2 → 5.9.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.
@@ -40,6 +40,7 @@
40
40
  (function (ECacheKey) {
41
41
  ECacheKey["Id"] = ":";
42
42
  ECacheKey["ListId"] = "::";
43
+ ECacheKey["Assembly"] = "assembly";
43
44
  ECacheKey["Entity"] = "entity";
44
45
  ECacheKey["EntityType"] = "entitytype";
45
46
  ECacheKey["ProjectView"] = "projectview";
@@ -1725,6 +1726,198 @@
1725
1726
  ENVIRONMENT.Reset = Reset;
1726
1727
  })(exports.ENVIRONMENT || (exports.ENVIRONMENT = {}));
1727
1728
 
1729
+ (function (Assembly) {
1730
+ /**
1731
+ * Returns an assembly record by ID.
1732
+ * @param params
1733
+ * @returns
1734
+ */
1735
+ function Get(params) {
1736
+ return __awaiter(this, void 0, void 0, function* () {
1737
+ let { api, assemblyId, req: reqParams } = params;
1738
+ if (!api) {
1739
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1740
+ }
1741
+ if (!assemblyId) {
1742
+ throw ("Assembly ID is required.");
1743
+ }
1744
+ const key = GetCacheKey(assemblyId);
1745
+ const cache = api.GetCacheItem(key, reqParams);
1746
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
1747
+ return cache.data;
1748
+ }
1749
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1750
+ try {
1751
+ const data = yield api.GET(`v3/assembly/${assemblyId}`, exports.Api.PrepReqParams(reqParams));
1752
+ res({
1753
+ assembly: data
1754
+ });
1755
+ }
1756
+ catch (e) {
1757
+ rej(e);
1758
+ }
1759
+ }));
1760
+ api.SetCacheItem({
1761
+ key,
1762
+ value: prom,
1763
+ req: reqParams
1764
+ });
1765
+ return prom;
1766
+ });
1767
+ }
1768
+ Assembly.Get = Get;
1769
+ /**
1770
+ * Gets a list of assembly records.
1771
+ * @param params
1772
+ * @returns
1773
+ */
1774
+ function GetList(params) {
1775
+ return __awaiter(this, void 0, void 0, function* () {
1776
+ let { api, req: reqParams } = params;
1777
+ if (!api) {
1778
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1779
+ }
1780
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
1781
+ try {
1782
+ let url = "v3/assemblies";
1783
+ const urlParams = new URLSearchParams();
1784
+ if (params.pageSize != null) {
1785
+ urlParams.append("PageSize", String(params.pageSize));
1786
+ }
1787
+ if (params.pageIndex != null) {
1788
+ urlParams.append("PageIndex", String(params.pageIndex));
1789
+ }
1790
+ if (params.parentId) {
1791
+ urlParams.append("ParentID", String(params.parentId));
1792
+ }
1793
+ if (params.search) {
1794
+ urlParams.append("Search", params.search);
1795
+ }
1796
+ if (params.withTilesets != null) {
1797
+ urlParams.append("WithTilesets", String(params.withTilesets));
1798
+ }
1799
+ url += "?" + urlParams.toString();
1800
+ const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
1801
+ const result = {};
1802
+ result.assemblies = data.Items ? data.Items : [];
1803
+ if (data.TotalCount != null) {
1804
+ result.totalCount = data.TotalCount;
1805
+ }
1806
+ if (data.NextPage != null) {
1807
+ result.nextPage = data.NextPage;
1808
+ }
1809
+ if (data.NextPageURL != null) {
1810
+ result.nextPageUrl = data.NextPageURL;
1811
+ }
1812
+ res(result);
1813
+ }
1814
+ catch (e) {
1815
+ rej(e);
1816
+ }
1817
+ }));
1818
+ return req;
1819
+ });
1820
+ }
1821
+ Assembly.GetList = GetList;
1822
+ /**
1823
+ * Creates or updates an assembly record.
1824
+ * @param params
1825
+ * @returns
1826
+ */
1827
+ function Update(params) {
1828
+ return __awaiter(this, void 0, void 0, function* () {
1829
+ let { api, assembly: data, req: reqParams } = params;
1830
+ if (!api) {
1831
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1832
+ }
1833
+ if (!data.ID) {
1834
+ data.ID = 0;
1835
+ }
1836
+ const url = `v3/assembly/${data.ID}`;
1837
+ const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
1838
+ api.Cache.Remove(GetCacheKey(data.ID));
1839
+ return {
1840
+ assembly: res
1841
+ };
1842
+ });
1843
+ }
1844
+ Assembly.Update = Update;
1845
+ /**
1846
+ * Deletes an assembly record.
1847
+ * @param params
1848
+ */
1849
+ function Delete(params) {
1850
+ return __awaiter(this, void 0, void 0, function* () {
1851
+ let { api, assemblyId, req: reqParams } = params;
1852
+ if (!assemblyId) {
1853
+ throw ("Assembly ID is required.");
1854
+ }
1855
+ if (!api) {
1856
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1857
+ }
1858
+ yield api.DELETE(`v3/assembly/${assemblyId}`, exports.Api.PrepReqParams(reqParams));
1859
+ api.Cache.Remove(GetCacheKey(assemblyId));
1860
+ });
1861
+ }
1862
+ Assembly.Delete = Delete;
1863
+ /**
1864
+ * Deletes a list of assembly records based on specified conditions.
1865
+ * @param params
1866
+ */
1867
+ function DeleteList(params) {
1868
+ return __awaiter(this, void 0, void 0, function* () {
1869
+ let { api, req: reqParams } = params;
1870
+ if (!api) {
1871
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1872
+ }
1873
+ let url = "v3/assemblies";
1874
+ const urlParams = new URLSearchParams();
1875
+ if (params.invalidRootIds) {
1876
+ urlParams.append("InvalidRootEntityID", "true");
1877
+ }
1878
+ url += "?" + urlParams.toString();
1879
+ yield api.DELETE(url, exports.Api.PrepReqParams(reqParams));
1880
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Assembly);
1881
+ });
1882
+ }
1883
+ Assembly.DeleteList = DeleteList;
1884
+ /**
1885
+ * Runs a job to locate existing assemblies by searching for root Entity IDs.
1886
+ * Each unregistered root Entity ID will be used to create a new assembly.
1887
+ *
1888
+ * WARNING: on completion, you should kill cache.
1889
+ * Eg: api.Cache.RemoveByStartsWith(Api.ECacheKey.Assembly);
1890
+ * @param params
1891
+ */
1892
+ function SyncWithRootEntityIDs(params) {
1893
+ return __awaiter(this, void 0, void 0, function* () {
1894
+ if (!params) {
1895
+ params = {};
1896
+ }
1897
+ let { api, req: reqParams } = params;
1898
+ if (!api) {
1899
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1900
+ }
1901
+ return yield api.POST("v3/assembly/resyncrootentitiestoassemblies", {}, exports.Api.PrepReqParams(reqParams));
1902
+ });
1903
+ }
1904
+ Assembly.SyncWithRootEntityIDs = SyncWithRootEntityIDs;
1905
+ /**
1906
+ * Returns cache identifier for an assembly by ID.
1907
+ * Example: {
1908
+ * const api: BruceApi.Api = ...;
1909
+ * const key = GetCacheKey(5);
1910
+ * api.Cache.Remove(key);
1911
+ * }
1912
+ * @param assemblyId
1913
+ * @returns
1914
+ */
1915
+ function GetCacheKey(assemblyId) {
1916
+ return `${exports.Api.ECacheKey.Assembly}${exports.Api.ECacheKey.Id}${assemblyId}`;
1917
+ }
1918
+ Assembly.GetCacheKey = GetCacheKey;
1919
+ })(exports.Assembly || (exports.Assembly = {}));
1920
+
1728
1921
  (function (AnnDocument) {
1729
1922
  /**
1730
1923
  * The types of supported annotated documents.
@@ -15114,7 +15307,7 @@
15114
15307
  })(exports.Scenario || (exports.Scenario = {}));
15115
15308
 
15116
15309
  // This is updated with the package.json version on build.
15117
- const VERSION = "5.9.2";
15310
+ const VERSION = "5.9.4";
15118
15311
 
15119
15312
  exports.VERSION = VERSION;
15120
15313
  exports.AbstractApi = AbstractApi;