@nsshunt/stsfhirclient 1.0.7 → 1.0.8

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.
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("node:https"), require("axios"), require("@nsshunt/stsutils"), require("@nsshunt/stsobservability"), require("@nsshunt/stsconfig")) : typeof define === "function" && define.amd ? define(["exports", "node:https", "axios", "@nsshunt/stsutils", "@nsshunt/stsobservability", "@nsshunt/stsconfig"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nsshunt/stsfhirclient"] = {}, global.https, global.axios, global.stsutils, global.stsobservability, global.stsconfig));
3
- })(this, function(exports2, https, axios, stsutils, stsobservability, stsconfig) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("node:https"), require("axios"), require("@nsshunt/stsutils"), require("@nsshunt/stsobservability")) : typeof define === "function" && define.amd ? define(["exports", "node:https", "axios", "@nsshunt/stsutils", "@nsshunt/stsobservability"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nsshunt/stsfhirclient"] = {}, global.https, global.axios, global.stsutils, global.stsobservability));
3
+ })(this, function(exports2, https, axios, stsutils, stsobservability) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __typeError = (msg) => {
6
6
  throw TypeError(msg);
@@ -12,7 +12,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
12
12
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
13
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
14
14
 
15
- var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
15
+ var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
16
16
  var IFhirPersistenceType = /* @__PURE__ */ ((IFhirPersistenceType2) => {
17
17
  IFhirPersistenceType2["postgresResources"] = "postgresResources";
18
18
  IFhirPersistenceType2["postgresResourcesEntities"] = "postgresResourcesEntities";
@@ -1542,6 +1542,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1542
1542
  StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
1543
1543
  })(StatusCodes || (StatusCodes = {}));
1544
1544
  class FhirClient {
1545
+ // Default value
1545
1546
  constructor(options) {
1546
1547
  __privateAdd(this, _options);
1547
1548
  __privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
@@ -1554,6 +1555,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1554
1555
  StatusCodes.NOT_FOUND,
1555
1556
  StatusCodes.CONFLICT
1556
1557
  ]);
1558
+ __privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
1557
1559
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1558
1560
  __privateAdd(this, _LogDebugMessage, (message) => {
1559
1561
  __privateGet(this, _options).logger.debug(message);
@@ -1564,14 +1566,18 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1564
1566
  });
1565
1567
  __privateAdd(this, _GetHttpsAgent, () => {
1566
1568
  if (__privateGet(this, _httpsAgent) === null) {
1567
- __privateSet(this, _httpsAgent, new https.Agent({
1568
- keepAlive: stsconfig.goptions.keepAlive,
1569
- maxSockets: stsconfig.goptions.maxSockets,
1570
- maxTotalSockets: stsconfig.goptions.maxTotalSockets,
1571
- maxFreeSockets: stsconfig.goptions.maxFreeSockets,
1572
- timeout: stsconfig.goptions.timeout,
1573
- rejectUnauthorized: false
1574
- }));
1569
+ if (__privateGet(this, _options).agentOptions) {
1570
+ __privateSet(this, _httpsAgent, new https.Agent({
1571
+ keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
1572
+ maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
1573
+ maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
1574
+ maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
1575
+ timeout: __privateGet(this, _options).agentOptions.timeout,
1576
+ rejectUnauthorized: __privateGet(this, _options).agentOptions.rejectUnauthorized
1577
+ }));
1578
+ } else {
1579
+ __privateSet(this, _httpsAgent, new https.Agent());
1580
+ }
1575
1581
  }
1576
1582
  return __privateGet(this, _httpsAgent);
1577
1583
  });
@@ -1727,7 +1733,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1727
1733
  }
1728
1734
  });
1729
1735
  __publicField(this, "GetResource", async (resource, id, filters, errorCb) => {
1730
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${id}`;
1736
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
1731
1737
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
1732
1738
  if (response) {
1733
1739
  return response.data;
@@ -1736,7 +1742,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1736
1742
  }
1737
1743
  });
1738
1744
  __publicField(this, "GetResources", async (resource, filters, errorCb) => {
1739
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1745
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1740
1746
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
1741
1747
  if (response) {
1742
1748
  return response.data;
@@ -1745,7 +1751,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1745
1751
  }
1746
1752
  });
1747
1753
  __publicField(this, "CreateResource", async (resource, domainResource, errorCb) => {
1748
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1754
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1749
1755
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "post", domainResource, null, errorCb);
1750
1756
  if (response) {
1751
1757
  if (response.status === StatusCodes.CREATED) {
@@ -1759,7 +1765,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1759
1765
  }
1760
1766
  });
1761
1767
  __publicField(this, "UpdateResource", async (resource, domainResource, errorCb) => {
1762
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
1768
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
1763
1769
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResource, null, errorCb);
1764
1770
  if (response) {
1765
1771
  return response.data;
@@ -1768,7 +1774,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1768
1774
  }
1769
1775
  });
1770
1776
  __publicField(this, "UpdateResources", async (resource, domainResources, errorCb) => {
1771
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1777
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1772
1778
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResources, null, errorCb);
1773
1779
  if (response) {
1774
1780
  return response.data;
@@ -1777,7 +1783,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1777
1783
  }
1778
1784
  });
1779
1785
  __publicField(this, "PatchResource", async (resource, domainResource, errorCb) => {
1780
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
1786
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
1781
1787
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResource, null, errorCb);
1782
1788
  if (response) {
1783
1789
  return response.data;
@@ -1786,7 +1792,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1786
1792
  }
1787
1793
  });
1788
1794
  __publicField(this, "PatchResources", async (resource, domainResources, errorCb) => {
1789
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1795
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1790
1796
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResources, null, errorCb);
1791
1797
  if (response) {
1792
1798
  return response.data;
@@ -1795,7 +1801,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1795
1801
  }
1796
1802
  });
1797
1803
  __publicField(this, "DeleteResource", async (resource, id, errorCb) => {
1798
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${id}`;
1804
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
1799
1805
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", null, null, errorCb);
1800
1806
  if (response) {
1801
1807
  return response.data;
@@ -1804,7 +1810,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1804
1810
  }
1805
1811
  });
1806
1812
  __publicField(this, "DeleteResources", async (resource, domainResources, errorCb) => {
1807
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1813
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1808
1814
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", domainResources, null, errorCb);
1809
1815
  if (response) {
1810
1816
  return response.data;
@@ -1813,7 +1819,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1813
1819
  }
1814
1820
  });
1815
1821
  __publicField(this, "GetLatency", async () => {
1816
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/latency`;
1822
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
1817
1823
  try {
1818
1824
  const headers = {
1819
1825
  "Content-Type": "application/json"
@@ -1833,6 +1839,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1833
1839
  }
1834
1840
  });
1835
1841
  __privateSet(this, _options, options);
1842
+ if (__privateGet(this, _options).stsfhirapiroot !== void 0) {
1843
+ __privateSet(this, _stsfhirapiroot, __privateGet(this, _options).stsfhirapiroot);
1844
+ }
1836
1845
  }
1837
1846
  get options() {
1838
1847
  return __privateGet(this, _options);
@@ -1845,6 +1854,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1845
1854
  _maxRetries = new WeakMap();
1846
1855
  _sleepDuration = new WeakMap();
1847
1856
  _NoRetryStatusCodes = new WeakMap();
1857
+ _stsfhirapiroot = new WeakMap();
1848
1858
  _LogDebugMessage = new WeakMap();
1849
1859
  _LogErrorMessage = new WeakMap();
1850
1860
  _GetHttpsAgent = new WeakMap();