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