@nsshunt/stsfhirclient 1.0.7 → 1.0.9

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")) : typeof define === "function" && define.amd ? define(["exports", "node:https", "axios", "@nsshunt/stsutils"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nsshunt/stsfhirclient"] = {}, global.https, global.axios, global.stsutils));
3
+ })(this, function(exports2, https, axios, stsutils) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __typeError = (msg) => {
6
6
  throw TypeError(msg);
@@ -12,14 +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;
16
- var IFhirPersistenceType = /* @__PURE__ */ ((IFhirPersistenceType2) => {
17
- IFhirPersistenceType2["postgresResources"] = "postgresResources";
18
- IFhirPersistenceType2["postgresResourcesEntities"] = "postgresResourcesEntities";
19
- IFhirPersistenceType2["redisJson"] = "redisJson";
20
- IFhirPersistenceType2["ioredisJson"] = "ioredisJson";
21
- return IFhirPersistenceType2;
22
- })(IFhirPersistenceType || {});
15
+ var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
23
16
  var byteToHex = [];
24
17
  for (var i = 0; i < 256; ++i) {
25
18
  byteToHex.push((i + 256).toString(16).slice(1));
@@ -1542,6 +1535,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1542
1535
  StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
1543
1536
  })(StatusCodes || (StatusCodes = {}));
1544
1537
  class FhirClient {
1538
+ // Default value
1545
1539
  constructor(options) {
1546
1540
  __privateAdd(this, _options);
1547
1541
  __privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
@@ -1554,6 +1548,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1554
1548
  StatusCodes.NOT_FOUND,
1555
1549
  StatusCodes.CONFLICT
1556
1550
  ]);
1551
+ __privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
1557
1552
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1558
1553
  __privateAdd(this, _LogDebugMessage, (message) => {
1559
1554
  __privateGet(this, _options).logger.debug(message);
@@ -1564,14 +1559,18 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1564
1559
  });
1565
1560
  __privateAdd(this, _GetHttpsAgent, () => {
1566
1561
  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
- }));
1562
+ if (__privateGet(this, _options).agentOptions) {
1563
+ __privateSet(this, _httpsAgent, new https.Agent({
1564
+ keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
1565
+ maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
1566
+ maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
1567
+ maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
1568
+ timeout: __privateGet(this, _options).agentOptions.timeout,
1569
+ rejectUnauthorized: __privateGet(this, _options).agentOptions.rejectUnauthorized
1570
+ }));
1571
+ } else {
1572
+ __privateSet(this, _httpsAgent, new https.Agent());
1573
+ }
1575
1574
  }
1576
1575
  return __privateGet(this, _httpsAgent);
1577
1576
  });
@@ -1625,11 +1624,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1625
1624
  if (statusCode === StatusCodes.UNAUTHORIZED) {
1626
1625
  console.error(chalk$1.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
1627
1626
  __privateGet(this, _options).ResetAccessToken();
1628
- if (__privateGet(this, _options).publishInstrumentController) {
1629
- __privateGet(this, _options).publishInstrumentController.UpdateInstrument(stsobservability.Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, {
1630
- Inc: 1
1631
- });
1632
- }
1633
1627
  if (__privateGet(this, _options).clientTelemetryEvents) {
1634
1628
  __privateGet(this, _options).clientTelemetryEvents.AuthenticationErrorInc();
1635
1629
  }
@@ -1657,11 +1651,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1657
1651
  console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
1658
1652
  await stsutils.Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
1659
1653
  __privateGet(this, _invokeMethods)[id].retries++;
1660
- if (__privateGet(this, _options).publishInstrumentController) {
1661
- __privateGet(this, _options).publishInstrumentController.UpdateInstrument(stsobservability.Gauge.RETRY_COUNT_GAUGE, {
1662
- Inc: 1
1663
- });
1664
- }
1665
1654
  if (__privateGet(this, _options).clientTelemetryEvents) {
1666
1655
  __privateGet(this, _options).clientTelemetryEvents.RetryInc();
1667
1656
  }
@@ -1727,7 +1716,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1727
1716
  }
1728
1717
  });
1729
1718
  __publicField(this, "GetResource", async (resource, id, filters, errorCb) => {
1730
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${id}`;
1719
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
1731
1720
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
1732
1721
  if (response) {
1733
1722
  return response.data;
@@ -1736,7 +1725,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1736
1725
  }
1737
1726
  });
1738
1727
  __publicField(this, "GetResources", async (resource, filters, errorCb) => {
1739
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1728
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1740
1729
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
1741
1730
  if (response) {
1742
1731
  return response.data;
@@ -1745,7 +1734,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1745
1734
  }
1746
1735
  });
1747
1736
  __publicField(this, "CreateResource", async (resource, domainResource, errorCb) => {
1748
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1737
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1749
1738
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "post", domainResource, null, errorCb);
1750
1739
  if (response) {
1751
1740
  if (response.status === StatusCodes.CREATED) {
@@ -1759,7 +1748,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1759
1748
  }
1760
1749
  });
1761
1750
  __publicField(this, "UpdateResource", async (resource, domainResource, errorCb) => {
1762
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
1751
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
1763
1752
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResource, null, errorCb);
1764
1753
  if (response) {
1765
1754
  return response.data;
@@ -1768,7 +1757,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1768
1757
  }
1769
1758
  });
1770
1759
  __publicField(this, "UpdateResources", async (resource, domainResources, errorCb) => {
1771
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1760
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1772
1761
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResources, null, errorCb);
1773
1762
  if (response) {
1774
1763
  return response.data;
@@ -1777,7 +1766,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1777
1766
  }
1778
1767
  });
1779
1768
  __publicField(this, "PatchResource", async (resource, domainResource, errorCb) => {
1780
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
1769
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
1781
1770
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResource, null, errorCb);
1782
1771
  if (response) {
1783
1772
  return response.data;
@@ -1786,7 +1775,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1786
1775
  }
1787
1776
  });
1788
1777
  __publicField(this, "PatchResources", async (resource, domainResources, errorCb) => {
1789
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1778
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1790
1779
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResources, null, errorCb);
1791
1780
  if (response) {
1792
1781
  return response.data;
@@ -1795,7 +1784,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1795
1784
  }
1796
1785
  });
1797
1786
  __publicField(this, "DeleteResource", async (resource, id, errorCb) => {
1798
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}/${id}`;
1787
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
1799
1788
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", null, null, errorCb);
1800
1789
  if (response) {
1801
1790
  return response.data;
@@ -1804,7 +1793,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1804
1793
  }
1805
1794
  });
1806
1795
  __publicField(this, "DeleteResources", async (resource, domainResources, errorCb) => {
1807
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/${resource}`;
1796
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
1808
1797
  const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", domainResources, null, errorCb);
1809
1798
  if (response) {
1810
1799
  return response.data;
@@ -1813,7 +1802,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1813
1802
  }
1814
1803
  });
1815
1804
  __publicField(this, "GetLatency", async () => {
1816
- const url = `${__privateGet(this, _options).fhirEndpoint}${stsconfig.goptions.stsfhirapiroot}/latency`;
1805
+ const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
1817
1806
  try {
1818
1807
  const headers = {
1819
1808
  "Content-Type": "application/json"
@@ -1833,6 +1822,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1833
1822
  }
1834
1823
  });
1835
1824
  __privateSet(this, _options, options);
1825
+ if (__privateGet(this, _options).stsfhirapiroot !== void 0) {
1826
+ __privateSet(this, _stsfhirapiroot, __privateGet(this, _options).stsfhirapiroot);
1827
+ }
1836
1828
  }
1837
1829
  get options() {
1838
1830
  return __privateGet(this, _options);
@@ -1845,6 +1837,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1845
1837
  _maxRetries = new WeakMap();
1846
1838
  _sleepDuration = new WeakMap();
1847
1839
  _NoRetryStatusCodes = new WeakMap();
1840
+ _stsfhirapiroot = new WeakMap();
1848
1841
  _LogDebugMessage = new WeakMap();
1849
1842
  _LogErrorMessage = new WeakMap();
1850
1843
  _GetHttpsAgent = new WeakMap();
@@ -1853,7 +1846,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1853
1846
  _TestMode = new WeakMap();
1854
1847
  ___InvokeResourceAPI = new WeakMap();
1855
1848
  exports2.FhirClient = FhirClient;
1856
- exports2.IFhirPersistenceType = IFhirPersistenceType;
1857
1849
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
1858
1850
  });
1859
1851
  //# sourceMappingURL=stsfhirclient.umd.js.map