@nsshunt/stsfhirclient 1.0.19 → 1.0.20
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.
|
@@ -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 _options2, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot,
|
|
15
|
+
var _options2, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _agentManager2, _LogDebugMessage, _LogErrorMessage, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
16
16
|
var byteToHex = [];
|
|
17
17
|
for (var i = 0; i < 256; ++i) {
|
|
18
18
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -1921,7 +1921,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
1921
1921
|
return __privateGet2(obj, member, getter);
|
|
1922
1922
|
}
|
|
1923
1923
|
});
|
|
1924
|
-
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
|
|
1924
|
+
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
1925
1925
|
var ansiStyles$1 = { exports: {} };
|
|
1926
1926
|
var colorName;
|
|
1927
1927
|
var hasRequiredColorName;
|
|
@@ -3562,10 +3562,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3562
3562
|
__privateAdd2(this, _agentResetInterval, null);
|
|
3563
3563
|
__privateAdd2(this, _requestCount, 0);
|
|
3564
3564
|
__privateAdd2(this, _SetupResetInterval, () => {
|
|
3565
|
-
|
|
3566
|
-
this
|
|
3567
|
-
|
|
3568
|
-
|
|
3565
|
+
if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
|
|
3566
|
+
__privateSet2(this, _agentResetInterval, setTimeout(() => {
|
|
3567
|
+
this.ResetAgent();
|
|
3568
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3569
|
+
}, __privateGet2(this, _options).agentResetInterval).unref());
|
|
3570
|
+
}
|
|
3569
3571
|
});
|
|
3570
3572
|
__privateAdd2(this, _GetAgentOptions, (https2) => {
|
|
3571
3573
|
let options;
|
|
@@ -3601,6 +3603,22 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3601
3603
|
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3602
3604
|
}
|
|
3603
3605
|
}
|
|
3606
|
+
get agentResetInterval() {
|
|
3607
|
+
return __privateGet2(this, _options).agentResetInterval;
|
|
3608
|
+
}
|
|
3609
|
+
set agentResetInterval(val) {
|
|
3610
|
+
if (__privateGet2(this, _agentResetInterval)) {
|
|
3611
|
+
clearTimeout(__privateGet2(this, _agentResetInterval));
|
|
3612
|
+
}
|
|
3613
|
+
__privateGet2(this, _options).agentResetInterval = val;
|
|
3614
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3615
|
+
}
|
|
3616
|
+
get agentResetCount() {
|
|
3617
|
+
return __privateGet2(this, _options).agentResetCount;
|
|
3618
|
+
}
|
|
3619
|
+
set agentResetCount(val) {
|
|
3620
|
+
__privateGet2(this, _options).agentResetCount = val;
|
|
3621
|
+
}
|
|
3604
3622
|
IncRequestCount() {
|
|
3605
3623
|
__privateWrapper(this, _requestCount)._++;
|
|
3606
3624
|
if (__privateGet2(this, _options).agentResetCount) {
|
|
@@ -3673,6 +3691,86 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3673
3691
|
_requestCount = /* @__PURE__ */ new WeakMap();
|
|
3674
3692
|
_SetupResetInterval = /* @__PURE__ */ new WeakMap();
|
|
3675
3693
|
_GetAgentOptions = /* @__PURE__ */ new WeakMap();
|
|
3694
|
+
class STSAxiosConfig {
|
|
3695
|
+
constructor(url, method, headers, timeout) {
|
|
3696
|
+
__privateAdd2(this, _url);
|
|
3697
|
+
__privateAdd2(this, _method);
|
|
3698
|
+
__privateAdd2(this, _headers);
|
|
3699
|
+
__privateAdd2(this, _data);
|
|
3700
|
+
__privateAdd2(this, _agentManager);
|
|
3701
|
+
__privateAdd2(this, _timeout);
|
|
3702
|
+
__privateAdd2(this, _withCredentials);
|
|
3703
|
+
__privateSet2(this, _url, url);
|
|
3704
|
+
__privateSet2(this, _method, method);
|
|
3705
|
+
if (headers !== void 0) {
|
|
3706
|
+
__privateSet2(this, _headers, headers);
|
|
3707
|
+
}
|
|
3708
|
+
if (timeout !== void 0) {
|
|
3709
|
+
__privateSet2(this, _timeout, timeout);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3713
|
+
withData(data) {
|
|
3714
|
+
__privateSet2(this, _data, data);
|
|
3715
|
+
return this;
|
|
3716
|
+
}
|
|
3717
|
+
// 'Content-Type': 'application/json'
|
|
3718
|
+
withHeaders(headers) {
|
|
3719
|
+
__privateSet2(this, _headers, headers);
|
|
3720
|
+
return this;
|
|
3721
|
+
}
|
|
3722
|
+
withDefaultHeaders() {
|
|
3723
|
+
__privateSet2(this, _headers, {
|
|
3724
|
+
"Content-Type": "application/json"
|
|
3725
|
+
});
|
|
3726
|
+
return this;
|
|
3727
|
+
}
|
|
3728
|
+
withCredentials() {
|
|
3729
|
+
__privateSet2(this, _withCredentials, true);
|
|
3730
|
+
return this;
|
|
3731
|
+
}
|
|
3732
|
+
withTimeout(timeout) {
|
|
3733
|
+
__privateSet2(this, _timeout, timeout);
|
|
3734
|
+
return this;
|
|
3735
|
+
}
|
|
3736
|
+
withAgentManager(agentManager) {
|
|
3737
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
3738
|
+
return this;
|
|
3739
|
+
}
|
|
3740
|
+
get config() {
|
|
3741
|
+
const retVal = {
|
|
3742
|
+
url: __privateGet2(this, _url),
|
|
3743
|
+
method: __privateGet2(this, _method)
|
|
3744
|
+
};
|
|
3745
|
+
if (__privateGet2(this, _headers)) {
|
|
3746
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
3747
|
+
}
|
|
3748
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
3749
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
3750
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3751
|
+
} else {
|
|
3752
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
3756
|
+
retVal.data = __privateGet2(this, _data);
|
|
3757
|
+
}
|
|
3758
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
3759
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
3760
|
+
}
|
|
3761
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
3762
|
+
retVal.withCredentials = true;
|
|
3763
|
+
}
|
|
3764
|
+
return retVal;
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
3768
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
3769
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
3770
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
3771
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
3772
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
3773
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
3676
3774
|
class FhirClient {
|
|
3677
3775
|
constructor(options) {
|
|
3678
3776
|
__privateAdd(this, _options2);
|
|
@@ -3687,7 +3785,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3687
3785
|
]);
|
|
3688
3786
|
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
3689
3787
|
// Default value
|
|
3690
|
-
__privateAdd(this,
|
|
3788
|
+
__privateAdd(this, _agentManager2, null);
|
|
3691
3789
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3692
3790
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
3693
3791
|
__privateGet(this, _options2).logger.debug(message);
|
|
@@ -3750,9 +3848,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3750
3848
|
__privateGet(this, _options2).clientTelemetryEvents.AuthenticationErrorInc();
|
|
3751
3849
|
}
|
|
3752
3850
|
}
|
|
3753
|
-
if (isNode && __privateGet(this,
|
|
3851
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3754
3852
|
console.error(chalk$2.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
3755
|
-
__privateGet(this,
|
|
3853
|
+
__privateGet(this, _agentManager2).ResetAgent();
|
|
3756
3854
|
}
|
|
3757
3855
|
performRetry = true;
|
|
3758
3856
|
}
|
|
@@ -3811,30 +3909,15 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3811
3909
|
}
|
|
3812
3910
|
}
|
|
3813
3911
|
const accessToken = await __privateGet(this, _options2).GetAccessToken();
|
|
3814
|
-
const
|
|
3912
|
+
const requestConfig = new STSAxiosConfig(url, httpVerb).withHeaders({
|
|
3815
3913
|
"Content-Type": "application/json",
|
|
3816
3914
|
"Authorization": `Bearer ${accessToken}`,
|
|
3817
3915
|
"x-sts_user_id": __privateGet(this, _DUMMY_USER)
|
|
3818
|
-
};
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
method: httpVerb,
|
|
3822
|
-
headers
|
|
3823
|
-
};
|
|
3824
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
3825
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
3826
|
-
requestConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3827
|
-
} else {
|
|
3828
|
-
requestConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3829
|
-
}
|
|
3830
|
-
}
|
|
3831
|
-
if (filters) {
|
|
3832
|
-
requestConfig.data = filters;
|
|
3833
|
-
} else if (domainResource) {
|
|
3834
|
-
requestConfig.data = domainResource;
|
|
3916
|
+
}).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
3917
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3918
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
3835
3919
|
}
|
|
3836
|
-
|
|
3837
|
-
return retVal;
|
|
3920
|
+
return await axios(requestConfig.config);
|
|
3838
3921
|
} catch (error) {
|
|
3839
3922
|
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
3840
3923
|
errorCb(responseCode, error);
|
|
@@ -3930,23 +4013,13 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3930
4013
|
__publicField(this, "GetLatency", async () => {
|
|
3931
4014
|
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
|
|
3932
4015
|
try {
|
|
3933
|
-
const
|
|
4016
|
+
const requestConfig = new STSAxiosConfig(url, "get", {
|
|
3934
4017
|
"Content-Type": "application/json"
|
|
3935
|
-
};
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
method: "get",
|
|
3939
|
-
headers
|
|
3940
|
-
};
|
|
3941
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
3942
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
3943
|
-
requestConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3944
|
-
} else {
|
|
3945
|
-
requestConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3946
|
-
}
|
|
4018
|
+
});
|
|
4019
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
4020
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
3947
4021
|
}
|
|
3948
|
-
|
|
3949
|
-
return retVal;
|
|
4022
|
+
return await axios(requestConfig.config);
|
|
3950
4023
|
} catch (error) {
|
|
3951
4024
|
__privateGet(this, _HandleError).call(this, error);
|
|
3952
4025
|
}
|
|
@@ -3957,11 +4030,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3957
4030
|
}
|
|
3958
4031
|
if (isNode) {
|
|
3959
4032
|
if (__privateGet(this, _options2).agentOptions) {
|
|
3960
|
-
__privateSet(this,
|
|
4033
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
3961
4034
|
agentOptions: __privateGet(this, _options2).agentOptions
|
|
3962
4035
|
}));
|
|
3963
4036
|
} else {
|
|
3964
|
-
__privateSet(this,
|
|
4037
|
+
__privateSet(this, _agentManager2, new AgentManager({}));
|
|
3965
4038
|
}
|
|
3966
4039
|
}
|
|
3967
4040
|
}
|
|
@@ -3976,7 +4049,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3976
4049
|
_sleepDuration = new WeakMap();
|
|
3977
4050
|
_NoRetryStatusCodes = new WeakMap();
|
|
3978
4051
|
_stsfhirapiroot = new WeakMap();
|
|
3979
|
-
|
|
4052
|
+
_agentManager2 = new WeakMap();
|
|
3980
4053
|
_LogDebugMessage = new WeakMap();
|
|
3981
4054
|
_LogErrorMessage = new WeakMap();
|
|
3982
4055
|
_HandleError = new WeakMap();
|