bruce-models 5.9.2 → 5.9.3

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,192 @@
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
+ url += "?" + urlParams.toString();
1794
+ const data = yield api.GET(url, exports.Api.PrepReqParams(reqParams));
1795
+ const result = {};
1796
+ result.assemblies = data.Items ? data.Items : [];
1797
+ if (data.TotalCount != null) {
1798
+ result.totalCount = data.TotalCount;
1799
+ }
1800
+ if (data.NextPage != null) {
1801
+ result.nextPage = data.NextPage;
1802
+ }
1803
+ if (data.NextPageURL != null) {
1804
+ result.nextPageUrl = data.NextPageURL;
1805
+ }
1806
+ res(result);
1807
+ }
1808
+ catch (e) {
1809
+ rej(e);
1810
+ }
1811
+ }));
1812
+ return req;
1813
+ });
1814
+ }
1815
+ Assembly.GetList = GetList;
1816
+ /**
1817
+ * Creates or updates an assembly record.
1818
+ * @param params
1819
+ * @returns
1820
+ */
1821
+ function Update(params) {
1822
+ return __awaiter(this, void 0, void 0, function* () {
1823
+ let { api, assembly: data, req: reqParams } = params;
1824
+ if (!api) {
1825
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1826
+ }
1827
+ if (!data.ID) {
1828
+ data.ID = 0;
1829
+ }
1830
+ const url = `v3/assembly/${data.ID}`;
1831
+ const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
1832
+ api.Cache.Remove(GetCacheKey(data.ID));
1833
+ return {
1834
+ assembly: res
1835
+ };
1836
+ });
1837
+ }
1838
+ Assembly.Update = Update;
1839
+ /**
1840
+ * Deletes an assembly record.
1841
+ * @param params
1842
+ */
1843
+ function Delete(params) {
1844
+ return __awaiter(this, void 0, void 0, function* () {
1845
+ let { api, assemblyId, req: reqParams } = params;
1846
+ if (!assemblyId) {
1847
+ throw ("Assembly ID is required.");
1848
+ }
1849
+ if (!api) {
1850
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1851
+ }
1852
+ yield api.DELETE(`v3/assembly/${assemblyId}`, exports.Api.PrepReqParams(reqParams));
1853
+ api.Cache.Remove(GetCacheKey(assemblyId));
1854
+ });
1855
+ }
1856
+ Assembly.Delete = Delete;
1857
+ /**
1858
+ * Deletes a list of assembly records based on specified conditions.
1859
+ * @param params
1860
+ */
1861
+ function DeleteList(params) {
1862
+ return __awaiter(this, void 0, void 0, function* () {
1863
+ let { api, req: reqParams } = params;
1864
+ if (!api) {
1865
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1866
+ }
1867
+ let url = "v3/assemblies";
1868
+ const urlParams = new URLSearchParams();
1869
+ if (params.invalidRootIds) {
1870
+ urlParams.append("InvalidRootEntityID", "true");
1871
+ }
1872
+ url += "?" + urlParams.toString();
1873
+ yield api.DELETE(url, exports.Api.PrepReqParams(reqParams));
1874
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Assembly);
1875
+ });
1876
+ }
1877
+ Assembly.DeleteList = DeleteList;
1878
+ /**
1879
+ * Runs a job to locate existing assemblies by searching for root Entity IDs.
1880
+ * Each unregistered root Entity ID will be used to create a new assembly.
1881
+ *
1882
+ * WARNING: on completion, you should kill cache.
1883
+ * Eg: api.Cache.RemoveByStartsWith(Api.ECacheKey.Assembly);
1884
+ * @param params
1885
+ */
1886
+ function SyncWithRootEntityIDs(params) {
1887
+ return __awaiter(this, void 0, void 0, function* () {
1888
+ if (!params) {
1889
+ params = {};
1890
+ }
1891
+ let { api, req: reqParams } = params;
1892
+ if (!api) {
1893
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
1894
+ }
1895
+ return yield api.POST("v3/assembly/resyncrootentitiestoassemblies", {}, exports.Api.PrepReqParams(reqParams));
1896
+ });
1897
+ }
1898
+ Assembly.SyncWithRootEntityIDs = SyncWithRootEntityIDs;
1899
+ /**
1900
+ * Returns cache identifier for an assembly by ID.
1901
+ * Example: {
1902
+ * const api: BruceApi.Api = ...;
1903
+ * const key = GetCacheKey(5);
1904
+ * api.Cache.Remove(key);
1905
+ * }
1906
+ * @param assemblyId
1907
+ * @returns
1908
+ */
1909
+ function GetCacheKey(assemblyId) {
1910
+ return `${exports.Api.ECacheKey.Assembly}${exports.Api.ECacheKey.Id}${assemblyId}`;
1911
+ }
1912
+ Assembly.GetCacheKey = GetCacheKey;
1913
+ })(exports.Assembly || (exports.Assembly = {}));
1914
+
1728
1915
  (function (AnnDocument) {
1729
1916
  /**
1730
1917
  * The types of supported annotated documents.
@@ -15114,7 +15301,7 @@
15114
15301
  })(exports.Scenario || (exports.Scenario = {}));
15115
15302
 
15116
15303
  // This is updated with the package.json version on build.
15117
- const VERSION = "5.9.2";
15304
+ const VERSION = "5.9.3";
15118
15305
 
15119
15306
  exports.VERSION = VERSION;
15120
15307
  exports.AbstractApi = AbstractApi;